aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/lib_nbd_img_handling
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-08-05 14:38:19 +0200
committerSven Gothel <[email protected]>2021-08-05 14:38:19 +0200
commite13a48f92c1a5eaeee3d80e35ec7e3afe0290651 (patch)
treeab6810d8099540152002fde6a9beb1cf69d3af38 /scripts/lib_nbd_img_handling
parent4feb56bf3b3fb646da43128ab14947b9c0f3fe95 (diff)
scripts/lib_nbd_img_handling (imagetool.sh): lib_umount*: If 'nbd_dev' unknown, still perform umount operation and only skip 'lib_disconnect_blkdev'
Diffstat (limited to 'scripts/lib_nbd_img_handling')
-rw-r--r--scripts/lib_nbd_img_handling20
1 files changed, 11 insertions, 9 deletions
diff --git a/scripts/lib_nbd_img_handling b/scripts/lib_nbd_img_handling
index 77046ba..ebbabf9 100644
--- a/scripts/lib_nbd_img_handling
+++ b/scripts/lib_nbd_img_handling
@@ -1,5 +1,7 @@
#!/bin/bash
+# set -x
+
#
# NBD and Image stateless reusable functions
#
@@ -222,16 +224,13 @@ lib_find_nbd() {
# Input {1}: mountpoint
# Input {2}: nbd device basename
lib_umount_image2() {
- if [ -z "${1}" ] ; then
+ local mnt_dir=${1}
+ local nbd_dev=${2}
+
+ if [ -z "${mnt_dir}" ] ; then
lib_echo_err "lib_umount_image2: mountpoint not given. Exit."
exit 1;
fi
- if [ -z "${2}" ] ; then
- lib_echo_err "lib_umount_image2: nbd device basename not given. Exit."
- exit 1;
- fi
- local mnt_dir=${1}
- local nbd_dev=${2}
sync
while mount | grep -q "${mnt_dir}"; do
@@ -243,6 +242,10 @@ lib_umount_image2() {
done
done
done
+ if [ -z "${nbd_dev}" ] ; then
+ lib_echo_err "lib_umount_image2: nbd device basename not given. Exit."
+ exit 1;
+ fi
lib_disconnect_blkdev "${nbd_dev}"
}
export -f lib_umount_image2
@@ -257,8 +260,7 @@ lib_umount_image1() {
local mnt_dir=${1}
local nbd_dev=$(lib_find_nbd "${mnt_dir}")
if [ -z "${nbd_dev}" ] ; then
- lib_echo_err "lib_umount_image: nbd device basename not found via mountpoint ${mnt_dir}. Exit."
- exit 1;
+ lib_echo_err "lib_umount_image: nbd device basename not found via mountpoint ${mnt_dir}. Continuing."
fi
lib_umount_image2 "${mnt_dir}" "${nbd_dev}"
}