提交 2a152ad3 编写于 作者: A Al Viro

make configfs_pin_fs() return root dentry on success

... and make configfs_mnt static
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 0dd6c08a
...@@ -58,7 +58,6 @@ struct configfs_dirent { ...@@ -58,7 +58,6 @@ struct configfs_dirent {
extern struct mutex configfs_symlink_mutex; extern struct mutex configfs_symlink_mutex;
extern spinlock_t configfs_dirent_lock; extern spinlock_t configfs_dirent_lock;
extern struct vfsmount * configfs_mount;
extern struct kmem_cache *configfs_dir_cachep; extern struct kmem_cache *configfs_dir_cachep;
extern int configfs_is_root(struct config_item *item); extern int configfs_is_root(struct config_item *item);
...@@ -80,7 +79,7 @@ extern const unsigned char * configfs_get_name(struct configfs_dirent *sd); ...@@ -80,7 +79,7 @@ extern const unsigned char * configfs_get_name(struct configfs_dirent *sd);
extern void configfs_drop_dentry(struct configfs_dirent *sd, struct dentry *parent); extern void configfs_drop_dentry(struct configfs_dirent *sd, struct dentry *parent);
extern int configfs_setattr(struct dentry *dentry, struct iattr *iattr); extern int configfs_setattr(struct dentry *dentry, struct iattr *iattr);
extern int configfs_pin_fs(void); extern struct dentry *configfs_pin_fs(void);
extern void configfs_release_fs(void); extern void configfs_release_fs(void);
extern struct rw_semaphore configfs_rename_sem; extern struct rw_semaphore configfs_rename_sem;
......
...@@ -1075,16 +1075,15 @@ int configfs_depend_item(struct configfs_subsystem *subsys, ...@@ -1075,16 +1075,15 @@ int configfs_depend_item(struct configfs_subsystem *subsys,
* Pin the configfs filesystem. This means we can safely access * Pin the configfs filesystem. This means we can safely access
* the root of the configfs filesystem. * the root of the configfs filesystem.
*/ */
ret = configfs_pin_fs(); root = configfs_pin_fs();
if (ret) if (IS_ERR(root))
return ret; return PTR_ERR(root);
/* /*
* Next, lock the root directory. We're going to check that the * Next, lock the root directory. We're going to check that the
* subsystem is really registered, and so we need to lock out * subsystem is really registered, and so we need to lock out
* configfs_[un]register_subsystem(). * configfs_[un]register_subsystem().
*/ */
root = configfs_mount->mnt_root;
mutex_lock(&root->d_inode->i_mutex); mutex_lock(&root->d_inode->i_mutex);
root_sd = root->d_fsdata; root_sd = root->d_fsdata;
...@@ -1673,14 +1672,13 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys) ...@@ -1673,14 +1672,13 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys)
struct dentry *root; struct dentry *root;
struct configfs_dirent *sd; struct configfs_dirent *sd;
err = configfs_pin_fs(); root = configfs_pin_fs();
if (err) if (IS_ERR(root))
return err; return PTR_ERR(root);
if (!group->cg_item.ci_name) if (!group->cg_item.ci_name)
group->cg_item.ci_name = group->cg_item.ci_namebuf; group->cg_item.ci_name = group->cg_item.ci_namebuf;
root = configfs_mount->mnt_root;
sd = root->d_fsdata; sd = root->d_fsdata;
link_group(to_config_group(sd->s_element), group); link_group(to_config_group(sd->s_element), group);
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
/* Random magic number */ /* Random magic number */
#define CONFIGFS_MAGIC 0x62656570 #define CONFIGFS_MAGIC 0x62656570
struct vfsmount * configfs_mount = NULL; static struct vfsmount *configfs_mount = NULL;
struct kmem_cache *configfs_dir_cachep; struct kmem_cache *configfs_dir_cachep;
static int configfs_mnt_count = 0; static int configfs_mnt_count = 0;
...@@ -115,10 +115,11 @@ static struct file_system_type configfs_fs_type = { ...@@ -115,10 +115,11 @@ static struct file_system_type configfs_fs_type = {
.kill_sb = kill_litter_super, .kill_sb = kill_litter_super,
}; };
int configfs_pin_fs(void) struct dentry *configfs_pin_fs(void)
{ {
return simple_pin_fs(&configfs_fs_type, &configfs_mount, int err = simple_pin_fs(&configfs_fs_type, &configfs_mount,
&configfs_mnt_count); &configfs_mnt_count);
return err ? ERR_PTR(err) : configfs_mount->mnt_root;
} }
void configfs_release_fs(void) void configfs_release_fs(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册