Make sure unmount_image finds stale loop devices

Fixes #257 #104 #193

Instead of searching by full path, which is prone to fail, read full list and grep on filename.
This commit is contained in:
Sam Tygier 2019-02-16 12:15:25 +00:00 committed by XECDesign
parent 9d38bfac23
commit 7068086c94

View file

@ -57,7 +57,7 @@ unmount_image(){
sync sync
sleep 1 sleep 1
local LOOP_DEVICES local LOOP_DEVICES
LOOP_DEVICES=$(losetup -j "${1}" | cut -f1 -d':') LOOP_DEVICES=$(losetup --list | grep "$(basename "${1}")" | cut -f1 -d' ')
for LOOP_DEV in ${LOOP_DEVICES}; do for LOOP_DEV in ${LOOP_DEVICES}; do
if [ -n "${LOOP_DEV}" ]; then if [ -n "${LOOP_DEV}" ]; then
local MOUNTED_DIR local MOUNTED_DIR