X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Fsysfs%2Fmount.c;h=1fe30ee7b1b42b48ee51bad256f9399b4e701c62;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=823813ce03e0b323bbff9f583e9ba412cdf03df8;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c index 823813ce0..1fe30ee7b 100644 --- a/fs/sysfs/mount.c +++ b/fs/sysfs/mount.c @@ -14,12 +14,20 @@ struct vfsmount *sysfs_mount; struct super_block * sysfs_sb = NULL; +kmem_cache_t *sysfs_dir_cachep; static struct super_operations sysfs_ops = { .statfs = simple_statfs, .drop_inode = generic_delete_inode, }; +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_element = NULL, + .s_type = SYSFS_ROOT, +}; + static int sysfs_fill_super(struct super_block *sb, void *data, int silent) { struct inode *inode; @@ -29,12 +37,13 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent) sb->s_blocksize_bits = PAGE_CACHE_SHIFT; sb->s_magic = SYSFS_SUPER_MAGIC; sb->s_op = &sysfs_ops; + sb->s_time_gran = 1; sysfs_sb = sb; inode = sysfs_new_inode(S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO); if (inode) { - inode->i_op = &simple_dir_inode_operations; - inode->i_fop = &simple_dir_operations; + inode->i_op = &sysfs_dir_inode_operations; + inode->i_fop = &sysfs_dir_operations; /* directory inodes start off with i_nlink == 2 (for "." entry) */ inode->i_nlink++; } else { @@ -48,6 +57,7 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent) iput(inode); return -ENOMEM; } + root->d_fsdata = &sysfs_root; sb->s_root = root; return 0; } @@ -66,7 +76,13 @@ static struct file_system_type sysfs_fs_type = { int __init sysfs_init(void) { - int err; + int err = -ENOMEM; + + sysfs_dir_cachep = kmem_cache_create("sysfs_dir_cache", + sizeof(struct sysfs_dirent), + 0, 0, NULL, NULL); + if (!sysfs_dir_cachep) + goto out; err = register_filesystem(&sysfs_fs_type); if (!err) { @@ -75,7 +91,13 @@ int __init sysfs_init(void) printk(KERN_ERR "sysfs: could not mount!\n"); err = PTR_ERR(sysfs_mount); sysfs_mount = NULL; + goto out_err; } - } + } else + goto out_err; +out: return err; +out_err: + kmem_cache_destroy(sysfs_dir_cachep); + goto out; }