summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2012-10-22 11:39:53 +0000
committerJosef Bacik <josef@toxicpanda.com>2013-01-14 13:52:32 -0500
commit5c39da5b6ca23e68e7acea7f4c01470383475214 (patch)
tree3079d0eccddbdb689879eb6d71ded878806da08c /fs
parentd86e56cf7d3669dd292012ac82b986bd1573b6cc (diff)
downloadop-kernel-dev-5c39da5b6ca23e68e7acea7f4c01470383475214.zip
op-kernel-dev-5c39da5b6ca23e68e7acea7f4c01470383475214.tar.gz
Btrfs: do not delete a subvolume which is in a R/O subvolume
Step to reproduce: # mkfs.btrfs <disk> # mount <disk> <mnt> # btrfs sub create <mnt>/subv0 # btrfs sub snap <mnt> <mnt>/subv0/snap0 # change <mnt>/subv0 from R/W to R/O # btrfs sub del <mnt>/subv0/snap0 We deleted the snapshot successfully. I think we should not be able to delete the snapshot since the parent subvolume is R/O. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/ioctl.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index dd8e344..5a72896 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2095,13 +2095,13 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
err = inode_permission(inode, MAY_WRITE | MAY_EXEC);
if (err)
goto out_dput;
-
- /* check if subvolume may be deleted by a non-root user */
- err = btrfs_may_delete(dir, dentry, 1);
- if (err)
- goto out_dput;
}
+ /* check if subvolume may be deleted by a user */
+ err = btrfs_may_delete(dir, dentry, 1);
+ if (err)
+ goto out_dput;
+
if (btrfs_ino(inode) != BTRFS_FIRST_FREE_OBJECTID) {
err = -EINVAL;
goto out_dput;
OpenPOWER on IntegriCloud