|
|
|
@ -650,6 +650,40 @@ xdt_list_mounted_of() {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
## Unmount xdt_mounted_devs (maybe filled by xdt_list_mounted_of)
|
|
|
|
|
xdt_unmount() {
|
|
|
|
|
if test -z "$xdt_mounted_devs"
|
|
|
|
|
then
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
for xdt_i in $xdt_mounted_devs
|
|
|
|
|
do
|
|
|
|
|
if test -n "$xdt_dummy_run"
|
|
|
|
|
then
|
|
|
|
|
echo " $xdt_sudo_cmd $xdt_umount_cmd $xdt_i"
|
|
|
|
|
elif $xdt_sudo_cmd "$xdt_umount_cmd" "$xdt_i"
|
|
|
|
|
then
|
|
|
|
|
echo "Unmounted: $xdt_i"
|
|
|
|
|
else
|
|
|
|
|
echo "FAILURE: Non-zero exit value with: $xdt_sudo_cmd $xdt_umount_cmd $xdt_i" >&2
|
|
|
|
|
return 7
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# Check again if any mount points still exist
|
|
|
|
|
if test -z "$xdt_dummy_run"
|
|
|
|
|
then
|
|
|
|
|
xdt_list_mounted_of "$2"
|
|
|
|
|
if test -n "$xdt_mounted_devs"
|
|
|
|
|
then
|
|
|
|
|
echo "FAILURE: $xdt_sudo_cmd $xdt_umount_cmd could not remove all mounts: $xdt_mounted_devs" >&2
|
|
|
|
|
return 7
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
## Does the work of unmounting and dd-ing
|
|
|
|
|
xdt_write_image() {
|
|
|
|
|
|
|
|
|
@ -670,35 +704,8 @@ xdt_write_image() {
|
|
|
|
|
then
|
|
|
|
|
echo "Would do if not -dummy:"
|
|
|
|
|
fi
|
|
|
|
|
if test -n "$xdt_mounted_devs"
|
|
|
|
|
then
|
|
|
|
|
for xdt_i in $xdt_mounted_devs
|
|
|
|
|
do
|
|
|
|
|
if test -n "$xdt_dummy_run"
|
|
|
|
|
then
|
|
|
|
|
echo " $xdt_sudo_cmd $xdt_umount_cmd $xdt_i"
|
|
|
|
|
else
|
|
|
|
|
if $xdt_sudo_cmd "$xdt_umount_cmd" "$xdt_i"
|
|
|
|
|
then
|
|
|
|
|
echo "Unmounted: $xdt_i"
|
|
|
|
|
else
|
|
|
|
|
echo "FAILURE: Non-zero exit value with: $xdt_sudo_cmd $xdt_umount_cmd $xdt_i" >&2
|
|
|
|
|
return 7
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# Check again if any mount points still exist
|
|
|
|
|
if test -z "$xdt_dummy_run"
|
|
|
|
|
then
|
|
|
|
|
xdt_list_mounted_of "$2"
|
|
|
|
|
if test -n "$xdt_mounted_devs"
|
|
|
|
|
then
|
|
|
|
|
echo "FAILURE: $xdt_sudo_cmd $xdt_umount_cmd could not remove all mounts: $xdt_mounted_devs" >&2
|
|
|
|
|
return 7
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
xdt_unmount || return "$?"
|
|
|
|
|
|
|
|
|
|
if test -z "$xdt_dd_cmd"
|
|
|
|
|
then
|
|
|
|
|