aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-11-28 14:54:39 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-11-29 21:09:27 -0500
commit061447a496b915f1dc8f8c645c6825f856d2bbac (patch)
treece67f6c0ed84ab95594ae3b50fe409e80ca336cf /fs
parent9e30cc9595303b27b48be49b7bcd4d0679e34253 (diff)
sysfs, kernfs: introduce sysfs_root_sd
Currently, it's assumed that there's a single kernfs hierarchy in the system anchored at sysfs_root which is defined as a global struct. To allow other users of kernfs, this will be made dynamic. Introduce a new global variable sysfs_root_sd which points to &sysfs_root and convert all &sysfs_root users. This patch doesn't introduce any behavior difference. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/sysfs/dir.c4
-rw-r--r--fs/sysfs/mount.c8
-rw-r--r--fs/sysfs/symlink.c6
-rw-r--r--fs/sysfs/sysfs.h2
4 files changed, 11 insertions, 9 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index e5c4e7118050..2fea501889e7 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -68,7 +68,7 @@ int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
68 if (kobj->parent) 68 if (kobj->parent)
69 parent_sd = kobj->parent->sd; 69 parent_sd = kobj->parent->sd;
70 else 70 else
71 parent_sd = &sysfs_root; 71 parent_sd = sysfs_root_sd;
72 72
73 if (!parent_sd) 73 if (!parent_sd)
74 return -ENOENT; 74 return -ENOENT;
@@ -134,7 +134,7 @@ int sysfs_move_dir_ns(struct kobject *kobj, struct kobject *new_parent_kobj,
134 134
135 BUG_ON(!sd->s_parent); 135 BUG_ON(!sd->s_parent);
136 new_parent_sd = new_parent_kobj && new_parent_kobj->sd ? 136 new_parent_sd = new_parent_kobj && new_parent_kobj->sd ?
137 new_parent_kobj->sd : &sysfs_root; 137 new_parent_kobj->sd : sysfs_root_sd;
138 138
139 return kernfs_rename_ns(sd, new_parent_sd, sd->s_name, new_ns); 139 return kernfs_rename_ns(sd, new_parent_sd, sd->s_name, new_ns);
140} 140}
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 0c80f0379016..7cbd1fce2826 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -32,7 +32,7 @@ static const struct super_operations sysfs_ops = {
32 .evict_inode = sysfs_evict_inode, 32 .evict_inode = sysfs_evict_inode,
33}; 33};
34 34
35struct sysfs_dirent sysfs_root = { 35static struct sysfs_dirent sysfs_root = {
36 .s_name = "", 36 .s_name = "",
37 .s_count = ATOMIC_INIT(1), 37 .s_count = ATOMIC_INIT(1),
38 .s_flags = SYSFS_DIR, 38 .s_flags = SYSFS_DIR,
@@ -40,6 +40,8 @@ struct sysfs_dirent sysfs_root = {
40 .s_ino = 1, 40 .s_ino = 1,
41}; 41};
42 42
43struct sysfs_dirent *sysfs_root_sd = &sysfs_root;
44
43static int sysfs_fill_super(struct super_block *sb) 45static int sysfs_fill_super(struct super_block *sb)
44{ 46{
45 struct inode *inode; 47 struct inode *inode;
@@ -53,7 +55,7 @@ static int sysfs_fill_super(struct super_block *sb)
53 55
54 /* get root inode, initialize and unlock it */ 56 /* get root inode, initialize and unlock it */
55 mutex_lock(&sysfs_mutex); 57 mutex_lock(&sysfs_mutex);
56 inode = sysfs_get_inode(sb, &sysfs_root); 58 inode = sysfs_get_inode(sb, sysfs_root_sd);
57 mutex_unlock(&sysfs_mutex); 59 mutex_unlock(&sysfs_mutex);
58 if (!inode) { 60 if (!inode) {
59 pr_debug("sysfs: could not get root inode\n"); 61 pr_debug("sysfs: could not get root inode\n");
@@ -66,7 +68,7 @@ static int sysfs_fill_super(struct super_block *sb)
66 pr_debug("%s: could not get root dentry!\n", __func__); 68 pr_debug("%s: could not get root dentry!\n", __func__);
67 return -ENOMEM; 69 return -ENOMEM;
68 } 70 }
69 root->d_fsdata = &sysfs_root; 71 root->d_fsdata = sysfs_root_sd;
70 sb->s_root = root; 72 sb->s_root = root;
71 sb->s_d_op = &sysfs_dentry_ops; 73 sb->s_d_op = &sysfs_dentry_ops;
72 return 0; 74 return 0;
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index 6797c9c2e43a..62f0e014ec48 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -70,7 +70,7 @@ static int sysfs_do_create_link(struct kobject *kobj, struct kobject *target,
70 struct sysfs_dirent *parent_sd = NULL; 70 struct sysfs_dirent *parent_sd = NULL;
71 71
72 if (!kobj) 72 if (!kobj)
73 parent_sd = &sysfs_root; 73 parent_sd = sysfs_root_sd;
74 else 74 else
75 parent_sd = kobj->sd; 75 parent_sd = kobj->sd;
76 76
@@ -144,7 +144,7 @@ void sysfs_remove_link(struct kobject *kobj, const char *name)
144 struct sysfs_dirent *parent_sd = NULL; 144 struct sysfs_dirent *parent_sd = NULL;
145 145
146 if (!kobj) 146 if (!kobj)
147 parent_sd = &sysfs_root; 147 parent_sd = sysfs_root_sd;
148 else 148 else
149 parent_sd = kobj->sd; 149 parent_sd = kobj->sd;
150 150
@@ -170,7 +170,7 @@ int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *targ,
170 int result; 170 int result;
171 171
172 if (!kobj) 172 if (!kobj)
173 parent_sd = &sysfs_root; 173 parent_sd = sysfs_root_sd;
174 else 174 else
175 parent_sd = kobj->sd; 175 parent_sd = kobj->sd;
176 176
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index ce97907e2894..2b217cef90be 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -28,7 +28,7 @@ struct sysfs_super_info {
28 const void *ns; 28 const void *ns;
29}; 29};
30#define sysfs_info(SB) ((struct sysfs_super_info *)(SB->s_fs_info)) 30#define sysfs_info(SB) ((struct sysfs_super_info *)(SB->s_fs_info))
31extern struct sysfs_dirent sysfs_root; 31extern struct sysfs_dirent *sysfs_root_sd;
32extern struct kmem_cache *sysfs_dir_cachep; 32extern struct kmem_cache *sysfs_dir_cachep;
33 33
34/* 34/*