summaryrefslogtreecommitdiff
path: root/src/shared/btrfs-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-04-22 17:09:20 +0200
committerLennart Poettering <lennart@poettering.net>2015-04-22 17:09:20 +0200
commit3986b2581c5832a18bcd7449642a37052443e5ed (patch)
treee78d841199544fbdc4d6fe607afb22f0a998b70f /src/shared/btrfs-util.c
parentaee327b8169670986f6a48acbd5ffe1355bfcf27 (diff)
btrfs-util: support recursive removal of read-only subvolumes
When deleting a read-only subsvolume with a sub-subvolume, we need to mark it writable first, otherwise the removal will not work.
Diffstat (limited to 'src/shared/btrfs-util.c')
-rw-r--r--src/shared/btrfs-util.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/shared/btrfs-util.c b/src/shared/btrfs-util.c
index 3ed14dc0f7..49528dbf01 100644
--- a/src/shared/btrfs-util.c
+++ b/src/shared/btrfs-util.c
@@ -803,6 +803,7 @@ static int subvol_remove_children(int fd, const char *subvolume, uint64_t subvol
struct btrfs_ioctl_vol_args vol_args = {};
_cleanup_close_ int subvol_fd = -1;
struct stat st;
+ bool made_writable = false;
int r;
assert(fd >= 0);
@@ -872,6 +873,14 @@ static int subvol_remove_children(int fd, const char *subvolume, uint64_t subvol
if (ioctl(fd, BTRFS_IOC_INO_LOOKUP, &ino_args) < 0)
return -errno;
+ if (!made_writable) {
+ r = btrfs_subvol_set_read_only_fd(subvol_fd, false);
+ if (r < 0)
+ return r;
+
+ made_writable = true;
+ }
+
if (isempty(ino_args.name))
/* Subvolume is in the top-level
* directory of the subvolume. */