diff options
author | Tejun Heo <htejun@gmail.com> | 2007-06-13 14:45:17 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-11 19:09:07 -0400 |
commit | fc9f54b9982e14e6dbe023425c87ffbfd6992c45 (patch) | |
tree | 61b828ac694d9e8decb02022a1056a5367bb1bef /fs/sysfs/mount.c | |
parent | 7f7cfffe60ed6271c4028ec79ae1c297b44bcb14 (diff) |
sysfs: reorganize sysfs_new_indoe() and sysfs_create()
Reorganize/clean up sysfs_new_inode() and sysfs_create().
* sysfs_init_inode() is separated out from sysfs_new_inode() and is
responsible for basic initialization.
* sysfs_instantiate() replaces the last step of sysfs_create() and is
responsible for dentry instantitaion.
* type-specific initialization is moved out to the callers.
* mode is specified only once when creating a sysfs_dirent.
* spurious list_del_init(&sd->s_sibling) dropped from create_dir()
This change is to
* prepare for inode allocation fix.
* separate alloc and init code for synchronization update.
* make dentry/inode initialization more flexible for later changes.
This patch doesn't introduce visible behavior change.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs/mount.c')
-rw-r--r-- | fs/sysfs/mount.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c index 37ff9ffc55f0..6d3a6249d21c 100644 --- a/fs/sysfs/mount.c +++ b/fs/sysfs/mount.c | |||
@@ -29,6 +29,7 @@ static struct sysfs_dirent sysfs_root = { | |||
29 | .s_sibling = LIST_HEAD_INIT(sysfs_root.s_sibling), | 29 | .s_sibling = LIST_HEAD_INIT(sysfs_root.s_sibling), |
30 | .s_children = LIST_HEAD_INIT(sysfs_root.s_children), | 30 | .s_children = LIST_HEAD_INIT(sysfs_root.s_children), |
31 | .s_type = SYSFS_ROOT, | 31 | .s_type = SYSFS_ROOT, |
32 | .s_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO, | ||
32 | .s_iattr = NULL, | 33 | .s_iattr = NULL, |
33 | .s_ino = 1, | 34 | .s_ino = 1, |
34 | }; | 35 | }; |
@@ -45,18 +46,19 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent) | |||
45 | sb->s_time_gran = 1; | 46 | sb->s_time_gran = 1; |
46 | sysfs_sb = sb; | 47 | sysfs_sb = sb; |
47 | 48 | ||
48 | inode = sysfs_new_inode(S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO, | 49 | inode = new_inode(sysfs_sb); |
49 | &sysfs_root); | 50 | if (!inode) { |
50 | if (inode) { | ||
51 | inode->i_op = &sysfs_dir_inode_operations; | ||
52 | inode->i_fop = &sysfs_dir_operations; | ||
53 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ | ||
54 | inc_nlink(inode); | ||
55 | } else { | ||
56 | pr_debug("sysfs: could not get root inode\n"); | 51 | pr_debug("sysfs: could not get root inode\n"); |
57 | return -ENOMEM; | 52 | return -ENOMEM; |
58 | } | 53 | } |
59 | 54 | ||
55 | sysfs_init_inode(&sysfs_root, inode); | ||
56 | |||
57 | inode->i_op = &sysfs_dir_inode_operations; | ||
58 | inode->i_fop = &sysfs_dir_operations; | ||
59 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ | ||
60 | inc_nlink(inode); | ||
61 | |||
60 | root = d_alloc_root(inode); | 62 | root = d_alloc_root(inode); |
61 | if (!root) { | 63 | if (!root) { |
62 | pr_debug("%s: could not get root dentry!\n",__FUNCTION__); | 64 | pr_debug("%s: could not get root dentry!\n",__FUNCTION__); |