From 398cb1dc4f11a237b2533834bd7941cbe28ae3df Mon Sep 17 00:00:00 2001 From: Brett Milford Date: Thu, 8 Apr 2021 11:57:15 +1000 Subject: [PATCH 1/2] 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 --- contrib/nuke-graph-directory.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/contrib/nuke-graph-directory.sh b/contrib/nuke-graph-directory.sh index 3a1b5713d2..4b8581ecec 100755 --- a/contrib/nuke-graph-directory.sh +++ b/contrib/nuke-graph-directory.sh @@ -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 From a0d1a1f78c7b1a35b474ae9aec33e0220ab5168b Mon Sep 17 00:00:00 2001 From: Brett Milford Date: Fri, 9 Apr 2021 10:03:13 +1000 Subject: [PATCH 2/2] Update contrib/nuke-graph-directory.sh Signed-off-by: Brett Milford --- contrib/nuke-graph-directory.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/contrib/nuke-graph-directory.sh b/contrib/nuke-graph-directory.sh index 4b8581ecec..c0f807cd71 100755 --- a/contrib/nuke-graph-directory.sh +++ b/contrib/nuke-graph-directory.sh @@ -60,13 +60,11 @@ if command -v btrfs > /dev/null 2>&1; then # 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 - if [ "$dir" != "$subvol" ]; then - if [ "$(stat -f --format=%T $subvol)" == "btrfs" ]; then - ( - set -x - btrfs subvolume delete "$subvol" - ) - fi + if [ "$dir" != "$subvol" ] && subvolType="$(stat -f --format=%T "$subvol")" && [ "$subvolType" = "btrfs" ]; then + ( + set -x + btrfs subvolume delete "$subvol" + ) fi done fi