diff options
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r-- | fs/btrfs/super.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 04a3bf816509..92393cc60d08 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, | |||
431 | if (error) | 431 | if (error) |
432 | goto error_free_subvol_name; | 432 | goto error_free_subvol_name; |
433 | 433 | ||
434 | if (!(flags & MS_RDONLY) && fs_devices->rw_devices == 0) { | ||
435 | error = -EACCES; | ||
436 | goto error_close_devices; | ||
437 | } | ||
438 | |||
434 | bdev = fs_devices->latest_bdev; | 439 | bdev = fs_devices->latest_bdev; |
435 | s = sget(fs_type, btrfs_test_super, set_anon_super, fs_devices); | 440 | s = sget(fs_type, btrfs_test_super, set_anon_super, fs_devices); |
436 | if (IS_ERR(s)) | 441 | if (IS_ERR(s)) |
@@ -444,6 +449,7 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags, | |||
444 | goto error_close_devices; | 449 | goto error_close_devices; |
445 | } | 450 | } |
446 | 451 | ||
452 | btrfs_close_devices(fs_devices); | ||
447 | } else { | 453 | } else { |
448 | char b[BDEVNAME_SIZE]; | 454 | char b[BDEVNAME_SIZE]; |
449 | 455 | ||
@@ -512,6 +518,9 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data) | |||
512 | ret = btrfs_commit_super(root); | 518 | ret = btrfs_commit_super(root); |
513 | WARN_ON(ret); | 519 | WARN_ON(ret); |
514 | } else { | 520 | } else { |
521 | if (root->fs_info->fs_devices->rw_devices == 0) | ||
522 | return -EACCES; | ||
523 | |||
515 | if (btrfs_super_log_root(&root->fs_info->super_copy) != 0) | 524 | if (btrfs_super_log_root(&root->fs_info->super_copy) != 0) |
516 | return -EINVAL; | 525 | return -EINVAL; |
517 | 526 | ||