[PATCH 01/22] sysfs: make sysfs_root a pointer

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <ebiederm@...>, <cornelia.huck@...>, <greg@...>, <stern@...>, <kay.sievers@...>, <linux-kernel@...>, <htejun@...>
Cc: Tejun Heo <htejun@...>
Date: Thursday, September 20, 2007 - 4:05 am

In the upcoming new sysfs interface, sysfs_root will be exported.  To
ease usage and make dummy declaration easier, make sysfs_root a
pointer.

Signed-off-by: Tejun Heo <htejun@gmail.com>
---
 fs/sysfs/dir.c     |    4 ++--
 fs/sysfs/mount.c   |    8 +++++---
 fs/sysfs/symlink.c |    2 +-
 fs/sysfs/sysfs.h   |    2 +-
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index fe8270c..ba631eb 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -651,7 +651,7 @@ int sysfs_create_dir(struct kobject * kobj)
 	if (kobj->parent)
 		parent_sd = kobj->parent->sd;
 	else
-		parent_sd = &sysfs_root;
+		parent_sd = sysfs_root;
 
 	error = create_dir(kobj, parent_sd, kobject_name(kobj), &sd);
 	if (!error)
@@ -832,7 +832,7 @@ int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj)
 
 	mutex_lock(&sysfs_rename_mutex);
 	BUG_ON(!sd->s_parent);
-	new_parent_sd = new_parent_kobj->sd ? new_parent_kobj->sd : &sysfs_root;
+	new_parent_sd = new_parent_kobj->sd ? new_parent_kobj->sd : sysfs_root;
 
 	error = 0;
 	if (sd->s_parent == new_parent_sd)
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 465902c..d00d4b9 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -23,7 +23,7 @@ static const struct super_operations sysfs_ops = {
 	.drop_inode	= generic_delete_inode,
 };
 
-struct sysfs_dirent sysfs_root = {
+static struct sysfs_dirent sysfs_root_storage = {
 	.s_name		= "",
 	.s_count	= ATOMIC_INIT(1),
 	.s_flags	= SYSFS_DIR,
@@ -31,6 +31,8 @@ struct sysfs_dirent sysfs_root = {
 	.s_ino		= 1,
 };
 
+struct sysfs_dirent * const sysfs_root = &sysfs_root_storage;
+
 static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
 {
 	struct inode *inode;
@@ -44,7 +46,7 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
 	sysfs_sb = sb;
 
 	/* get root inode, initialize and unlock it */
-	inode = sysfs_get_inode(&sysfs_root);
+	inode = sysfs_get_inode(sysfs_root);
 	if (!inode) {
 		pr_debug("sysfs: could not get root inode\n");
 		return -ENOMEM;
@@ -57,7 +59,7 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
 		iput(inode);
 		return -ENOMEM;
 	}
-	root->d_fsdata = &sysfs_root;
+	root->d_fsdata = sysfs_root;
 	sb->s_root = root;
 	return 0;
 }
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index ffa82e9..6b3358e 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -61,7 +61,7 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char
 	BUG_ON(!name);
 
 	if (!kobj)
-		parent_sd = &sysfs_root;
+		parent_sd = sysfs_root;
 	else
 		parent_sd = kobj->sd;
 
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 58f517b..9180e2c 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -78,7 +78,7 @@ struct sysfs_addrm_cxt {
 /*
  * mount.c
  */
-extern struct sysfs_dirent sysfs_root;
+extern struct sysfs_dirent * const sysfs_root;
 extern struct super_block *sysfs_sb;
 extern struct kmem_cache *sysfs_dir_cachep;
 
-- 
1.5.0.3


-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCHSET 3/4] sysfs: divorce sysfs from kobject and dri..., Eric W. Biederman, (Thu Sep 27, 3:25 pm)
Re: [PATCHSET 3/4] sysfs: divorce sysfs from kobject and dri..., Eric W. Biederman, (Wed Oct 10, 9:16 am)
Re: [PATCHSET 3/4] sysfs: divorce sysfs from kobject and dri..., Eric W. Biederman, (Tue Oct 16, 7:54 pm)
Re: [PATCHSET 3/4] sysfs: divorce sysfs from kobject and dri..., Eric W. Biederman, (Wed Oct 10, 5:16 pm)
[PATCH 21/22] sysfs: kill sysfs_hash_and_remove(), Tejun Heo, (Thu Sep 20, 4:05 am)
[PATCH 05/22] sysfs: implement sysfs_find_child(), Tejun Heo, (Thu Sep 20, 4:05 am)
[PATCH 14/22] sysfs: s/symlink/link/g, Tejun Heo, (Thu Sep 20, 4:05 am)
[PATCH 06/22] sysfs: restructure addrm helpers, Tejun Heo, (Thu Sep 20, 4:05 am)
[PATCH 01/22] sysfs: make sysfs_root a pointer, Tejun Heo, (Thu Sep 20, 4:05 am)
[PATCH 04/22] sysfs: make SYSFS_COPY_NAME a flag, Tejun Heo, (Thu Sep 20, 4:05 am)