Merge pull request #25188 from armills/nuke-graph-directory

nuke-graph-directory.sh: Improve subvolume search
This commit is contained in:
Tõnis Tiigi 2016-08-16 09:47:33 -07:00 committed by GitHub
commit 8f8bb8ad4c

View file

@ -51,13 +51,10 @@ done
# now, let's go destroy individual btrfs subvolumes, if any exist
if command -v btrfs > /dev/null 2>&1; then
root="$(df "$dir" | awk 'NR>1 { print $NF }')"
root="${root%/}" # if root is "/", we want it to become ""
for subvol in $(btrfs subvolume list -o "$root/" 2>/dev/null | awk -F' path ' '{ print $2 }' | sort -r); do
subvolDir="$root/$subvol"
if dir_in_dir "$subvolDir" "$dir"; then
( set -x; btrfs subvolume delete "$subvolDir" )
fi
# Find btrfs subvolumes under $dir checking for inode 256
# Source: http://stackoverflow.com/a/32865333
for subvol in $(find "$dir" -type d -inum 256 | sort -r); do
( set -x; btrfs subvolume delete "$subvol" )
done
fi