summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlib/common-functions19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/common-functions b/lib/common-functions
index e87e6ef..17309fb 100755
--- a/lib/common-functions
+++ b/lib/common-functions
@@ -390,10 +390,25 @@ recursively_umount_and_rm() {
exit 42
fi
+ # the sh -c '...' construct branch below is borrowed from
+ # archlinux/devtools lib/archroot.sh: is_subvolume(), is_same_fs() and
+ # subvolume_delete_recursive()
+ # shellcheck disable=SC1004,SC2016
find "${dir}" \
- -xdev -depth -type d \
+ -depth \
+ -xdev \
+ -type d \
-exec 'mountpoint' '-q' '{}' ';' \
- -exec 'sudo' 'umount' '-l' '{}' ';'
+ -exec 'sudo' 'umount' '-l' '{}' ';' \
+ -prune \
+ , \
+ -inum 256 \
+ -exec sh -c '
+ [ "$(stat -f -c %T "$1")" = btrfs ] && \
+ [ "$(stat -c %d "$1")" = "$2" ]
+ ' {} "$(stat -c %d "${dir}")" \; \
+ -exec btrfs subvolume delete {} \; \
+ -prune
rm -rf --one-file-system "${dir}"
}