Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/archroot.sh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/archroot.sh')
-rw-r--r--lib/archroot.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/archroot.sh b/lib/archroot.sh
index 14417aa..989f1e1 100644
--- a/lib/archroot.sh
+++ b/lib/archroot.sh
@@ -20,3 +20,23 @@ check_root() {
is_btrfs() {
[[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs ]]
}
+
+##
+# usage : subvolume_delete_recursive( $path )
+#
+# Find all btrfs subvolumes under and including $path and delete them.
+##
+subvolume_delete_recursive() {
+ local subvol
+
+ is_btrfs "$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"
+ return 1
+ fi
+ done < <(find "$1" -xdev -depth -inum 256 -print0)
+
+ return 0
+}