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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
7f7cfffe60
commit
fc9f54b998
@@ -29,6 +29,7 @@ static struct sysfs_dirent sysfs_root = {
|
||||
.s_sibling = LIST_HEAD_INIT(sysfs_root.s_sibling),
|
||||
.s_children = LIST_HEAD_INIT(sysfs_root.s_children),
|
||||
.s_type = SYSFS_ROOT,
|
||||
.s_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
|
||||
.s_iattr = NULL,
|
||||
.s_ino = 1,
|
||||
};
|
||||
@@ -45,18 +46,19 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
|
||||
sb->s_time_gran = 1;
|
||||
sysfs_sb = sb;
|
||||
|
||||
inode = sysfs_new_inode(S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
|
||||
&sysfs_root);
|
||||
if (inode) {
|
||||
inode->i_op = &sysfs_dir_inode_operations;
|
||||
inode->i_fop = &sysfs_dir_operations;
|
||||
/* directory inodes start off with i_nlink == 2 (for "." entry) */
|
||||
inc_nlink(inode);
|
||||
} else {
|
||||
inode = new_inode(sysfs_sb);
|
||||
if (!inode) {
|
||||
pr_debug("sysfs: could not get root inode\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
sysfs_init_inode(&sysfs_root, inode);
|
||||
|
||||
inode->i_op = &sysfs_dir_inode_operations;
|
||||
inode->i_fop = &sysfs_dir_operations;
|
||||
/* directory inodes start off with i_nlink == 2 (for "." entry) */
|
||||
inc_nlink(inode);
|
||||
|
||||
root = d_alloc_root(inode);
|
||||
if (!root) {
|
||||
pr_debug("%s: could not get root dentry!\n",__FUNCTION__);
|
||||
|
Reference in New Issue
Block a user