Commit 81d44ed1 authored by Al Viro's avatar Al Viro

configfs: don't bother with checks for mkdir/rmdir/unlink/symlink in root

just give root directory separate inode_operations without all those
methods...
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 8fc3dc5a
...@@ -89,6 +89,7 @@ extern const struct file_operations configfs_dir_operations; ...@@ -89,6 +89,7 @@ extern const struct file_operations configfs_dir_operations;
extern const struct file_operations configfs_file_operations; extern const struct file_operations configfs_file_operations;
extern const struct file_operations bin_fops; extern const struct file_operations bin_fops;
extern const struct inode_operations configfs_dir_inode_operations; extern const struct inode_operations configfs_dir_inode_operations;
extern const struct inode_operations configfs_root_inode_operations;
extern const struct inode_operations configfs_symlink_inode_operations; extern const struct inode_operations configfs_symlink_inode_operations;
extern const struct dentry_operations configfs_dentry_ops; extern const struct dentry_operations configfs_dentry_ops;
......
...@@ -1183,11 +1183,6 @@ static int configfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode ...@@ -1183,11 +1183,6 @@ static int configfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
struct module *subsys_owner = NULL, *new_item_owner = NULL; struct module *subsys_owner = NULL, *new_item_owner = NULL;
char *name; char *name;
if (dentry->d_parent == configfs_sb->s_root) {
ret = -EPERM;
goto out;
}
sd = dentry->d_parent->d_fsdata; sd = dentry->d_parent->d_fsdata;
/* /*
...@@ -1359,9 +1354,6 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -1359,9 +1354,6 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry)
struct module *subsys_owner = NULL, *dead_item_owner = NULL; struct module *subsys_owner = NULL, *dead_item_owner = NULL;
int ret; int ret;
if (dentry->d_parent == configfs_sb->s_root)
return -EPERM;
sd = dentry->d_fsdata; sd = dentry->d_fsdata;
if (sd->s_type & CONFIGFS_USET_DEFAULT) if (sd->s_type & CONFIGFS_USET_DEFAULT)
return -EPERM; return -EPERM;
...@@ -1459,6 +1451,11 @@ const struct inode_operations configfs_dir_inode_operations = { ...@@ -1459,6 +1451,11 @@ const struct inode_operations configfs_dir_inode_operations = {
.setattr = configfs_setattr, .setattr = configfs_setattr,
}; };
const struct inode_operations configfs_root_inode_operations = {
.lookup = configfs_lookup,
.setattr = configfs_setattr,
};
#if 0 #if 0
int configfs_rename_dir(struct config_item * item, const char *new_name) int configfs_rename_dir(struct config_item * item, const char *new_name)
{ {
......
...@@ -82,7 +82,7 @@ static int configfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -82,7 +82,7 @@ static int configfs_fill_super(struct super_block *sb, void *data, int silent)
inode = configfs_new_inode(S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO, inode = configfs_new_inode(S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
&configfs_root); &configfs_root);
if (inode) { if (inode) {
inode->i_op = &configfs_dir_inode_operations; inode->i_op = &configfs_root_inode_operations;
inode->i_fop = &configfs_dir_operations; inode->i_fop = &configfs_dir_operations;
/* directory inodes start off with i_nlink == 2 (for "." entry) */ /* directory inodes start off with i_nlink == 2 (for "." entry) */
inc_nlink(inode); inc_nlink(inode);
......
...@@ -141,10 +141,6 @@ int configfs_symlink(struct inode *dir, struct dentry *dentry, const char *symna ...@@ -141,10 +141,6 @@ int configfs_symlink(struct inode *dir, struct dentry *dentry, const char *symna
struct config_item *target_item = NULL; struct config_item *target_item = NULL;
struct config_item_type *type; struct config_item_type *type;
ret = -EPERM; /* What lack-of-symlink returns */
if (dentry->d_parent == configfs_sb->s_root)
goto out;
sd = dentry->d_parent->d_fsdata; sd = dentry->d_parent->d_fsdata;
/* /*
* Fake invisibility if dir belongs to a group/default groups hierarchy * Fake invisibility if dir belongs to a group/default groups hierarchy
...@@ -198,8 +194,6 @@ int configfs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -198,8 +194,6 @@ int configfs_unlink(struct inode *dir, struct dentry *dentry)
if (!(sd->s_type & CONFIGFS_ITEM_LINK)) if (!(sd->s_type & CONFIGFS_ITEM_LINK))
goto out; goto out;
BUG_ON(dentry->d_parent == configfs_sb->s_root);
sl = sd->s_element; sl = sd->s_element;
parent_item = configfs_get_config_item(dentry->d_parent); parent_item = configfs_get_config_item(dentry->d_parent);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment