[PATCH 12/15] sysfs: make sysfs_root a regular directory dirent

!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 - 3:05 am

sysfs_root is different from a regular directory dirent in that it's
of type SYSFS_ROOT and doesn't have a name.  These differences aren't
used by anybody and only adds to complexity.  Make sysfs_root a
regular directory dirent.

Signed-off-by: Tejun Heo <htejun@gmail.com>
---
 fs/sysfs/inode.c |    5 -----
 fs/sysfs/mount.c |    3 ++-
 fs/sysfs/sysfs.h |    9 ++++-----
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index b6ac4e6..c40fb9f 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -157,11 +157,6 @@ static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)
 
 	/* initialize inode according to type */
 	switch (sysfs_type(sd)) {
-	case SYSFS_ROOT:
-		inode->i_op = &sysfs_dir_inode_operations;
-		inode->i_fop = &sysfs_dir_operations;
-		inc_nlink(inode); /* directory, account for "." */
-		break;
 	case SYSFS_DIR:
 		inode->i_op = &sysfs_dir_inode_operations;
 		inode->i_fop = &sysfs_dir_operations;
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 28bf359..465902c 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -24,8 +24,9 @@ static const struct super_operations sysfs_ops = {
 };
 
 struct sysfs_dirent sysfs_root = {
+	.s_name		= "",
 	.s_count	= ATOMIC_INIT(1),
-	.s_flags	= SYSFS_ROOT,
+	.s_flags	= SYSFS_DIR,
 	.s_mode		= S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
 	.s_ino		= 1,
 };
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 2a68bfa..60405a6 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -48,11 +48,10 @@ struct sysfs_dirent {
 #define SD_DEACTIVATED_BIAS		INT_MIN
 
 #define SYSFS_TYPE_MASK			0x00ff
-#define SYSFS_ROOT			0x0001
-#define SYSFS_DIR			0x0002
-#define SYSFS_KOBJ_ATTR			0x0004
-#define SYSFS_KOBJ_BIN_ATTR		0x0008
-#define SYSFS_KOBJ_LINK			0x0020
+#define SYSFS_DIR			0x0001
+#define SYSFS_KOBJ_ATTR			0x0002
+#define SYSFS_KOBJ_BIN_ATTR		0x0004
+#define SYSFS_KOBJ_LINK			0x0008
 #define SYSFS_COPY_NAME			(SYSFS_DIR | SYSFS_KOBJ_LINK)
 
 #define SYSFS_FLAG_MASK			~SYSFS_TYPE_MASK
-- 
1.5.0.3


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

Messages in current thread:
[PATCHSET 1/4] sysfs: misc updates, Tejun Heo, (Thu Sep 20, 3:05 am)
Re: [PATCHSET 1/4] sysfs: misc updates, Cornelia Huck, (Wed Sep 26, 7:04 am)
Re: [PATCHSET 1/4] sysfs: misc updates, Greg KH, (Wed Sep 26, 11:19 am)
[PATCH 12/15] sysfs: make sysfs_root a regular directory dir..., Tejun Heo, (Thu Sep 20, 3:05 am)
[PATCH 14/15] sysfs: implement sysfs_open_dirent, Tejun Heo, (Thu Sep 20, 3:05 am)
[PATCH 10/15] sysfs: make s_elem an anonymous union, Tejun Heo, (Thu Sep 20, 3:05 am)
[PATCH 05/15] sysfs: kill sysfs_update_file(), Tejun Heo, (Thu Sep 20, 3:05 am)
[PATCH 04/15] sysfs: clean up header files, Tejun Heo, (Thu Sep 20, 3:05 am)
[PATCH 01/15] sysfs: kill SYSFS_FLAG_REMOVED, Tejun Heo, (Thu Sep 20, 3:05 am)
Re: [PATCH 01/15] sysfs: kill SYSFS_FLAG_REMOVED, Greg KH, (Tue Sep 25, 5:32 pm)