lib/archroot.sh: subvolume_delete_recursive: support arbitrary recursion

The `-xdev` flag to `find` makes it not recurse over subvolumes; so it only
supports recursion with depth=1.  Fix this by having the function
recursively call itself.
This commit is contained in:
Luke Shumaker 2017-05-05 18:41:01 -04:00 committed by Jan Alexander Steffens (heftig)
parent 6d1992909c
commit 31a800fd88
No known key found for this signature in database
GPG Key ID: A5E9288C4FA415FA
1 changed files with 6 additions and 3 deletions

View File

@ -52,11 +52,14 @@ subvolume_delete_recursive() {
is_subvolume "$1" || return 0
while IFS= read -d $'\0' -r subvol; do
if ! btrfs subvolume delete "$subvol" &>/dev/null; then
error "Unable to delete subvolume %s" "$subvol"
if ! subvolume_delete_recursive "$subvol"; then
return 1
fi
done < <(find "$1" -xdev -depth -inum 256 -print0)
done < <(find "$1" -mindepth 1 -xdev -depth -inum 256 -print0)
if ! btrfs subvolume delete "$1" &>/dev/null; then
error "Unable to delete subvolume %s" "$subvol"
return 1
fi
return 0
}