Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 318848
b: refs/heads/master
c: b9ca066
h: refs/heads/master
v: v3
  • Loading branch information
Liu Bo authored and Chris Mason committed Jul 23, 2012
1 parent 3f1e945 commit 3152b74
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e54bfa31044d602a57d4e190f6d1c3763ea76bfe
refs/heads/master: b9ca0664dc806ba70587f6f3202b60dc736cd6e5
42 changes: 28 additions & 14 deletions trunk/fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1521,29 +1521,40 @@ static noinline int btrfs_ioctl_subvol_setflags(struct file *file,
u64 flags;
int ret = 0;

if (root->fs_info->sb->s_flags & MS_RDONLY)
return -EROFS;
ret = mnt_want_write_file(file);
if (ret)
goto out;

if (btrfs_ino(inode) != BTRFS_FIRST_FREE_OBJECTID)
return -EINVAL;
if (btrfs_ino(inode) != BTRFS_FIRST_FREE_OBJECTID) {
ret = -EINVAL;
goto out_drop_write;
}

if (copy_from_user(&flags, arg, sizeof(flags)))
return -EFAULT;
if (copy_from_user(&flags, arg, sizeof(flags))) {
ret = -EFAULT;
goto out_drop_write;
}

if (flags & BTRFS_SUBVOL_CREATE_ASYNC)
return -EINVAL;
if (flags & BTRFS_SUBVOL_CREATE_ASYNC) {
ret = -EINVAL;
goto out_drop_write;
}

if (flags & ~BTRFS_SUBVOL_RDONLY)
return -EOPNOTSUPP;
if (flags & ~BTRFS_SUBVOL_RDONLY) {
ret = -EOPNOTSUPP;
goto out_drop_write;
}

if (!inode_owner_or_capable(inode))
return -EACCES;
if (!inode_owner_or_capable(inode)) {
ret = -EACCES;
goto out_drop_write;
}

down_write(&root->fs_info->subvol_sem);

/* nothing to do */
if (!!(flags & BTRFS_SUBVOL_RDONLY) == btrfs_root_readonly(root))
goto out;
goto out_drop_sem;

root_flags = btrfs_root_flags(&root->root_item);
if (flags & BTRFS_SUBVOL_RDONLY)
Expand All @@ -1566,8 +1577,11 @@ static noinline int btrfs_ioctl_subvol_setflags(struct file *file,
out_reset:
if (ret)
btrfs_set_root_flags(&root->root_item, root_flags);
out:
out_drop_sem:
up_write(&root->fs_info->subvol_sem);
out_drop_write:
mnt_drop_write_file(file);
out:
return ret;
}

Expand Down

0 comments on commit 3152b74

Please sign in to comment.