Reassured success of unmount
This commit is contained in:
@ -512,19 +512,12 @@ list_devices() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
write_image() {
|
||||
|
||||
if test -z "$umount_cmd"
|
||||
then
|
||||
echo "No executable program umount found in: $sudo_x_dir_list" >&2
|
||||
return 6
|
||||
fi
|
||||
|
||||
echo "Looking for mount points of $2:"
|
||||
partitions=$($lsblk_cmd -n -p -o NAME /dev/"$2" | grep -v '^'/dev/"$2"'$' \
|
||||
## Puts list of mounted (sub-)devices of $1 into $mounted_devs
|
||||
list_mounted_of() {
|
||||
partitions=$($lsblk_cmd -n -p -o NAME /dev/"$1" | grep -v '^'/dev/"$1"'$' \
|
||||
| sed -e 's/[^a-zA-Z0-9_+@:.,/-]//g' | tr '\n\r' ' ')
|
||||
mounted_devs=
|
||||
for i in /dev/"$2" $partitions
|
||||
for i in /dev/"$1" $partitions
|
||||
do
|
||||
# Show the found mount lines and add their device paths to list
|
||||
mount_line=$(mount | grep '^'"$i"' ')
|
||||
@ -534,6 +527,20 @@ write_image() {
|
||||
mounted_devs="$mounted_devs $i"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
## Does the work of unmounting and dd-ing
|
||||
write_image() {
|
||||
|
||||
if test -z "$umount_cmd"
|
||||
then
|
||||
echo "No executable program umount found in: $sudo_x_dir_list" >&2
|
||||
return 6
|
||||
fi
|
||||
echo "Looking for mount points of $2:"
|
||||
mounted_devs=
|
||||
list_mounted_of "$2"
|
||||
|
||||
if test -n "$dummy_force"
|
||||
then
|
||||
echo "AGAINST THE ADVICE BY THIS PROGRAM, a daring user could do:"
|
||||
@ -554,13 +561,20 @@ write_image() {
|
||||
then
|
||||
echo "Unmounted: $i"
|
||||
else
|
||||
echo "FAILURE: Non-zero exit value with: sudo_cmd $umount_cmd $i" >&2
|
||||
echo "FAILURE: Non-zero exit value with: $sudo_cmd $umount_cmd $i" >&2
|
||||
return 7
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Check again if any mount points still exist
|
||||
list_mounted_of "$2"
|
||||
if test -n "$mounted_devs" -a -z "$dummy_run"
|
||||
then
|
||||
echo "FAILURE: $sudo_cmd $umount_cmd could not remove all mounts: $mounted_devs" >&2
|
||||
return 7
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$dd_cmd"
|
||||
then
|
||||
@ -585,6 +599,8 @@ write_image() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# main()
|
||||
|
||||
reset_job
|
||||
arg_interpreter "$@"
|
||||
|
||||
|
Reference in New Issue
Block a user