summaryrefslogtreecommitdiff
path: root/scripts/common
diff options
context:
space:
mode:
authorSerge Schneider <serge@raspberrypi.com>2022-11-11 08:58:33 +0000
committerSerge Schneider <serge@raspberrypi.com>2022-11-11 08:58:33 +0000
commit366bc2c8f34e71507d9c6293cfbda27081a5ee7b (patch)
tree5a1034e71ce5255e5ff64645db46ef5c48be518f /scripts/common
parentbd2cf0e0e4bac19f6966bc9ffaaca3e5044c5de3 (diff)
parent1d13a292a79f151b06ff84823b9e41781120ce6f (diff)
Merge branch 'master' into arm64
Diffstat (limited to 'scripts/common')
-rw-r--r--scripts/common20
1 files changed, 8 insertions, 12 deletions
diff --git a/scripts/common b/scripts/common
index 42e4f8a..1bb68a2 100644
--- a/scripts/common
+++ b/scripts/common
@@ -58,19 +58,15 @@ export -f unmount
unmount_image(){
sync
sleep 1
- local LOOP_DEVICES
- LOOP_DEVICES=$(losetup --list | grep "$(basename "${1}")" | cut -f1 -d' ')
- for LOOP_DEV in ${LOOP_DEVICES}; do
- if [ -n "${LOOP_DEV}" ]; then
- local MOUNTED_DIR
- MOUNTED_DIR=$(mount | grep "$(basename "${LOOP_DEV}")" | head -n 1 | cut -f 3 -d ' ')
- if [ -n "${MOUNTED_DIR}" ] && [ "${MOUNTED_DIR}" != "/" ]; then
- unmount "$(dirname "${MOUNTED_DIR}")"
+ LOOP_DEVICE=$(losetup --list | grep "$1" | cut -f1 -d' ')
+ if [ -n "$LOOP_DEVICE" ]; then
+ for part in "$LOOP_DEVICE"p*; do
+ if DIR=$(findmnt -n -o target -S "$part"); then
+ unmount "$DIR"
fi
- sleep 1
- losetup -d "${LOOP_DEV}"
- fi
- done
+ done
+ losetup -d "$LOOP_DEVICE"
+ fi
}
export -f unmount_image