From 544d2e84ac7e66a548e3dc6640e46bac9350b77b Mon Sep 17 00:00:00 2001 From: Antynea Date: Fri, 24 Sep 2021 12:12:43 +0200 Subject: [PATCH] Adds security if a false positive is detected * Adds security if a false positive is detected: * if the command "grep -qs "$gbgmp" /proc/mounts;" returns a false positive. "rm -d" will return an error if the directory is not empty. --- 41_snapshots-btrfs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index 6e31973..f58f8f2 100755 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -155,7 +155,11 @@ if [[ -d "$gbgmp" ]]; then printf " Success\n" >&2; fi done - [[ "$wait" != true ]] && rm -r "$gbgmp" # If mount point is empty or unmounted, delete residual folder. + if [[ "$wait" != true ]]; then + if ! rm -d "$gbgmp" >/dev/null 2>&1; then + printf "Unable to delete %s: Device or ressource is busy" "$gbgmp" >&2; + fi + fi fi }