Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/mfasheh...
[powerpc.git] / fs / hostfs / hostfs_kern.c
index 1e6fc37..9baf697 100644 (file)
@@ -47,13 +47,13 @@ struct dentry_operations hostfs_dentry_ops = {
 };
 
 /* Changed in hostfs_args before the kernel starts running */
-static char *root_ino = "/";
+static char *root_ino = "";
 static int append = 0;
 
 #define HOSTFS_SUPER_MAGIC 0x00c0ffee
 
-static struct inode_operations hostfs_iops;
-static struct inode_operations hostfs_dir_iops;
+static const struct inode_operations hostfs_iops;
+static const struct inode_operations hostfs_dir_iops;
 static const struct address_space_operations hostfs_link_aops;
 
 #ifndef MODULE
@@ -309,7 +309,7 @@ static void hostfs_read_inode(struct inode *inode)
        read_inode(inode);
 }
 
-static struct super_operations hostfs_sbops = {
+static const struct super_operations hostfs_sbops = {
        .alloc_inode    = hostfs_alloc_inode,
        .drop_inode     = generic_delete_inode,
        .delete_inode   = hostfs_delete_inode,
@@ -755,7 +755,7 @@ int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
                goto out_put;
 
        init_special_inode(inode, mode, dev);
-       err = do_mknod(name, mode, dev);
+       err = do_mknod(name, mode, MAJOR(dev), MINOR(dev));
        if(err)
                goto out_free;
 
@@ -880,7 +880,7 @@ int hostfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
        return(0);
 }
 
-static struct inode_operations hostfs_iops = {
+static const struct inode_operations hostfs_iops = {
        .create         = hostfs_create,
        .link           = hostfs_link,
        .unlink         = hostfs_unlink,
@@ -894,7 +894,7 @@ static struct inode_operations hostfs_iops = {
        .getattr        = hostfs_getattr,
 };
 
-static struct inode_operations hostfs_dir_iops = {
+static const struct inode_operations hostfs_dir_iops = {
        .create         = hostfs_create,
        .lookup         = hostfs_lookup,
        .link           = hostfs_link,
@@ -947,15 +947,17 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
        sb->s_magic = HOSTFS_SUPER_MAGIC;
        sb->s_op = &hostfs_sbops;
 
-       if((data == NULL) || (*data == '\0'))
-               data = root_ino;
+       /* NULL is printed as <NULL> by sprintf: avoid that. */
+       if (data == NULL)
+               data = "";
 
        err = -ENOMEM;
-       name = kmalloc(strlen(data) + 1, GFP_KERNEL);
+       name = kmalloc(strlen(root_ino) + 1
+                       + strlen(data) + 1, GFP_KERNEL);
        if(name == NULL)
                goto out;
 
-       strcpy(name, data);
+       sprintf(name, "%s/%s", root_ino, data);
 
        root_inode = iget(sb, 0);
        if(root_inode == NULL)
@@ -966,6 +968,9 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
                goto out_put;
 
        HOSTFS_I(root_inode)->host_filename = name;
+       /* Avoid that in the error path, iput(root_inode) frees again name through
+        * hostfs_destroy_inode! */
+       name = NULL;
 
        err = -ENOMEM;
        sb->s_root = d_alloc_root(root_inode);
@@ -977,7 +982,7 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
                 /* No iput in this case because the dput does that for us */
                 dput(sb->s_root);
                 sb->s_root = NULL;
-               goto out_free;
+               goto out;
         }
 
        return(0);