]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - fs/btrfs/super.c
Btrfs: make things static and include the right headers
[mirror_ubuntu-artful-kernel.git] / fs / btrfs / super.c
index 04a3bf816509d697ee8d616c6cf211689a3da43c..93a21c77064abb2642319d6cbda09cba9cc7bfc0 100644 (file)
@@ -37,6 +37,8 @@
 #include <linux/ctype.h>
 #include <linux/namei.h>
 #include <linux/miscdevice.h>
+#include <linux/version.h>
+#include "compat.h"
 #include "ctree.h"
 #include "disk-io.h"
 #include "transaction.h"
@@ -285,11 +287,11 @@ static int btrfs_parse_early_options(const char *options, int flags,
  out:
        /*
         * If no subvolume name is specified we use the default one.  Allocate
-        * a copy of the string "default" here so that code later in the
+        * a copy of the string "." here so that code later in the
         * mount path doesn't care if it's the default volume or another one.
         */
        if (!*subvol_name) {
-               *subvol_name = kstrdup("default", GFP_KERNEL);
+               *subvol_name = kstrdup(".", GFP_KERNEL);
                if (!*subvol_name)
                        return -ENOMEM;
        }
@@ -323,12 +325,12 @@ static int btrfs_fill_super(struct super_block * sb,
        }
        sb->s_fs_info = tree_root;
        disk_super = &tree_root->fs_info->super_copy;
-       inode = btrfs_iget_locked(sb, btrfs_super_root_dir(disk_super),
-                                 tree_root);
+       inode = btrfs_iget_locked(sb, BTRFS_FIRST_FREE_OBJECTID,
+                                 tree_root->fs_info->fs_root);
        bi = BTRFS_I(inode);
        bi->location.objectid = inode->i_ino;
        bi->location.offset = 0;
-       bi->root = tree_root;
+       bi->root = tree_root->fs_info->fs_root;
 
        btrfs_set_key_type(&bi->location, BTRFS_INODE_ITEM_KEY);
 
@@ -431,6 +433,11 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags,
        if (error)
                goto error_free_subvol_name;
 
+       if (!(flags & MS_RDONLY) && fs_devices->rw_devices == 0) {
+               error = -EACCES;
+               goto error_close_devices;
+       }
+
        bdev = fs_devices->latest_bdev;
        s = sget(fs_type, btrfs_test_super, set_anon_super, fs_devices);
        if (IS_ERR(s))
@@ -444,6 +451,7 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags,
                        goto error_close_devices;
                }
 
+               btrfs_close_devices(fs_devices);
        } else {
                char b[BDEVNAME_SIZE];
 
@@ -512,6 +520,9 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
                ret =  btrfs_commit_super(root);
                WARN_ON(ret);
        } else {
+               if (root->fs_info->fs_devices->rw_devices == 0)
+                       return -EACCES;
+
                if (btrfs_super_log_root(&root->fs_info->super_copy) != 0)
                        return -EINVAL;
 
@@ -636,7 +647,7 @@ static int btrfs_interface_init(void)
        return misc_register(&btrfs_misc);
 }
 
-void btrfs_interface_exit(void)
+static void btrfs_interface_exit(void)
 {
        if (misc_deregister(&btrfs_misc) < 0)
                printk("misc_deregister failed for control device");