diff options
Diffstat (limited to 'fs/sysfs/mount.c')
-rw-r--r-- | fs/sysfs/mount.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c index 00ab9125d398..402cc356203c 100644 --- a/fs/sysfs/mount.c +++ b/fs/sysfs/mount.c | |||
@@ -19,28 +19,18 @@ struct vfsmount *sysfs_mount; | |||
19 | struct super_block * sysfs_sb = NULL; | 19 | struct super_block * sysfs_sb = NULL; |
20 | struct kmem_cache *sysfs_dir_cachep; | 20 | struct kmem_cache *sysfs_dir_cachep; |
21 | 21 | ||
22 | static void sysfs_clear_inode(struct inode *inode); | ||
23 | |||
24 | static const struct super_operations sysfs_ops = { | 22 | static const struct super_operations sysfs_ops = { |
25 | .statfs = simple_statfs, | 23 | .statfs = simple_statfs, |
26 | .drop_inode = sysfs_delete_inode, | 24 | .drop_inode = sysfs_delete_inode, |
27 | .clear_inode = sysfs_clear_inode, | ||
28 | }; | 25 | }; |
29 | 26 | ||
30 | static struct sysfs_dirent sysfs_root = { | 27 | struct sysfs_dirent sysfs_root = { |
31 | .s_sibling = LIST_HEAD_INIT(sysfs_root.s_sibling), | 28 | .s_count = ATOMIC_INIT(1), |
32 | .s_children = LIST_HEAD_INIT(sysfs_root.s_children), | 29 | .s_flags = SYSFS_ROOT, |
33 | .s_element = NULL, | 30 | .s_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO, |
34 | .s_type = SYSFS_ROOT, | ||
35 | .s_iattr = NULL, | ||
36 | .s_ino = 1, | 31 | .s_ino = 1, |
37 | }; | 32 | }; |
38 | 33 | ||
39 | static void sysfs_clear_inode(struct inode *inode) | ||
40 | { | ||
41 | kfree(inode->i_private); | ||
42 | } | ||
43 | |||
44 | static int sysfs_fill_super(struct super_block *sb, void *data, int silent) | 34 | static int sysfs_fill_super(struct super_block *sb, void *data, int silent) |
45 | { | 35 | { |
46 | struct inode *inode; | 36 | struct inode *inode; |
@@ -53,24 +43,26 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent) | |||
53 | sb->s_time_gran = 1; | 43 | sb->s_time_gran = 1; |
54 | sysfs_sb = sb; | 44 | sysfs_sb = sb; |
55 | 45 | ||
56 | inode = sysfs_new_inode(S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO, | 46 | inode = new_inode(sysfs_sb); |
57 | &sysfs_root); | 47 | if (!inode) { |
58 | if (inode) { | ||
59 | inode->i_op = &sysfs_dir_inode_operations; | ||
60 | inode->i_fop = &sysfs_dir_operations; | ||
61 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ | ||
62 | inc_nlink(inode); | ||
63 | } else { | ||
64 | pr_debug("sysfs: could not get root inode\n"); | 48 | pr_debug("sysfs: could not get root inode\n"); |
65 | return -ENOMEM; | 49 | return -ENOMEM; |
66 | } | 50 | } |
67 | 51 | ||
52 | sysfs_init_inode(&sysfs_root, inode); | ||
53 | |||
54 | inode->i_op = &sysfs_dir_inode_operations; | ||
55 | inode->i_fop = &sysfs_dir_operations; | ||
56 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ | ||
57 | inc_nlink(inode); | ||
58 | |||
68 | root = d_alloc_root(inode); | 59 | root = d_alloc_root(inode); |
69 | if (!root) { | 60 | if (!root) { |
70 | pr_debug("%s: could not get root dentry!\n",__FUNCTION__); | 61 | pr_debug("%s: could not get root dentry!\n",__FUNCTION__); |
71 | iput(inode); | 62 | iput(inode); |
72 | return -ENOMEM; | 63 | return -ENOMEM; |
73 | } | 64 | } |
65 | sysfs_root.s_dentry = root; | ||
74 | root->d_fsdata = &sysfs_root; | 66 | root->d_fsdata = &sysfs_root; |
75 | sb->s_root = root; | 67 | sb->s_root = root; |
76 | return 0; | 68 | return 0; |