aboutsummaryrefslogtreecommitdiff
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r--fs/btrfs/super.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 04a3bf81650..92393cc60d0 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -431,6 +431,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 +449,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 +518,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;