sysfs: Pass super_block to sysfs_get_inode
[safe/jmp/linux-2.6] / fs / sysfs / mount.c
index c76c540..89db07e 100644 (file)
 #include <linux/mount.h>
 #include <linux/pagemap.h>
 #include <linux/init.h>
+#include <linux/module.h>
+#include <linux/magic.h>
 
 #include "sysfs.h"
 
-/* Random magic number */
-#define SYSFS_MAGIC 0x62656572
 
 static struct vfsmount *sysfs_mount;
 struct super_block * sysfs_sb = NULL;
@@ -29,6 +29,7 @@ struct kmem_cache *sysfs_dir_cachep;
 static const struct super_operations sysfs_ops = {
        .statfs         = simple_statfs,
        .drop_inode     = generic_delete_inode,
+       .delete_inode   = sysfs_delete_inode,
 };
 
 struct sysfs_dirent sysfs_root = {
@@ -52,7 +53,9 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
        sysfs_sb = sb;
 
        /* get root inode, initialize and unlock it */
-       inode = sysfs_get_inode(&sysfs_root);
+       mutex_lock(&sysfs_mutex);
+       inode = sysfs_get_inode(sb, &sysfs_root);
+       mutex_unlock(&sysfs_mutex);
        if (!inode) {
                pr_debug("sysfs: could not get root inode\n");
                return -ENOMEM;
@@ -61,7 +64,7 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
        /* instantiate and link root dentry */
        root = d_alloc_root(inode);
        if (!root) {
-               pr_debug("%s: could not get root dentry!\n",__FUNCTION__);
+               pr_debug("%s: could not get root dentry!\n",__func__);
                iput(inode);
                return -ENOMEM;
        }
@@ -92,6 +95,10 @@ int __init sysfs_init(void)
        if (!sysfs_dir_cachep)
                goto out;
 
+       err = sysfs_inode_init();
+       if (err)
+               goto out_err;
+
        err = register_filesystem(&sysfs_fs_type);
        if (!err) {
                sysfs_mount = kern_mount(&sysfs_fs_type);
@@ -111,3 +118,17 @@ out_err:
        sysfs_dir_cachep = NULL;
        goto out;
 }
+
+#undef sysfs_get
+struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd)
+{
+       return __sysfs_get(sd);
+}
+EXPORT_SYMBOL_GPL(sysfs_get);
+
+#undef sysfs_put
+void sysfs_put(struct sysfs_dirent *sd)
+{
+       __sysfs_put(sd);
+}
+EXPORT_SYMBOL_GPL(sysfs_put);