Fixes subvol delete on a non-btrfs volume

Inode numbers are guaranteed to be unique only within a filesystem.
As such there is an edge case where these predicates are true on a
non-btrfs filesystem.

Closes #42271

Signed-off-by: Brett Milford <brettmilford@gmail.com>
This commit is contained in:
Brett Milford 2021-04-08 11:57:15 +10:00
parent 2acab355ec
commit 398cb1dc4f

View file

@ -61,10 +61,12 @@ if command -v btrfs > /dev/null 2>&1; then
# Source: http://stackoverflow.com/a/32865333
for subvol in $(find "$dir" -type d -inum 256 | sort -r); do
if [ "$dir" != "$subvol" ]; then
(
set -x
btrfs subvolume delete "$subvol"
)
if [ "$(stat -f --format=%T $subvol)" == "btrfs" ]; then
(
set -x
btrfs subvolume delete "$subvol"
)
fi
fi
done
fi