Assessing which partitions are really mounted. Made sure that a bus related reason is shown if bus was inquired. Improved hint and usage text.

This commit is contained in:
Thomas Schmitt 2019-11-30 10:18:25 +01:00
parent fe46a2d983
commit e36596b8d4

View File

@ -53,7 +53,7 @@ print_usage() {
echo "advisable device names is printed to stdout. One per line."
echo "Device names must not begin by '-' and must be single words. They must"
echo "not contain '/'. E.g. 'sdc' is valid, '/dev/sdc' is not valid."
echo "If devices names are given, then they get listed with advice shown."
echo "If device names are given, then they get listed with advice shown."
echo "If one of the given device names gets not advised, the exit value is 1."
echo
echo "Only if option -DO_WRITE is given and -list_all is not, and if exactly"
@ -225,6 +225,7 @@ list_devices() {
reasons=
good_trans=
good_fs=
bad_trans=
bad_fs=
# Unwanted device name patterns
@ -267,6 +268,7 @@ list_devices() {
tasty=y
elif test -n "$trans"
then
bad_trans="$trans"
yucky=y
if test "$transports" = "not_an_expected_name"
then
@ -279,6 +281,14 @@ list_devices() {
fi
fi
done
if test -z "$good_trans" -a -z "$bad_trans"
then
yucky=y
reasons="${reasons}no_bus_info- "
elif test -z "$bad_trans"
then
reasons="${reasons}$good_trans "
fi
# Wanted or unwanted filesystem types
fstypes=$($sudo_cmd $lsblk_cmd -n -o FSTYPE /dev/"$name")
@ -381,7 +391,7 @@ list_devices() {
else
if test -n "$show_reasons"
then
echo "$name : YES : $good_trans $reasons$descr"
echo "$name : YES : $reasons$descr"
else
echo "$name"
fi
@ -401,7 +411,18 @@ write_image() {
fi
partitions=$($lsblk_cmd -n -p -o NAME /dev/"$2" | grep -v '^'/dev/"$2"'$' \
| sed -e 's/[^a-zA-Z0-9_+@:.,/-]//g' | tr '\n\r' ' ')
echo "Would do: $sudo_cmd $umount_cmd /dev/"$2" $partitions"
mounted_devs=
for i in /dev/"$2" $partitions
do
if mount | grep '^'"$i"' ' >/dev/null
then
mounted_devs="$mounted_devs $i"
fi
done
if test -n "$mounted_devs"
then
echo "Would do: $sudo_cmd $umount_cmd $mounted_devs"
fi
if test -z "$dd_cmd"
then
@ -444,16 +465,17 @@ then
with_vendor_model=y
devs="$candidates"
list_devices >&2
echo "HINT: Re-run with one of the names {$(echo $candidates | sed -e 's/ /,/g')} as additional argument." >&2
echo "HINT: Unplug the unwanted devices from the machine,"
echo " or add the desired name out of {$(echo $candidates | sed -e 's/ /,/g')} as additional argument." >&2
exit 3
else
if test -n "$devs_named"
then
echo "NO CANDIDATE FOR TARGET DEVICE AMONG THE GIVEN NAMES !" >&2
echo "Overall available devices:"
else
echo "NO CANDIDATE FOR TARGET DEVICE FOUND !" >&2
fi
echo "Overall available devices:"
list_all=y
show_reasons=y
with_vendor_model=y