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:
parent
fe46a2d983
commit
e36596b8d4
@ -53,7 +53,7 @@ print_usage() {
|
|||||||
echo "advisable device names is printed to stdout. One per line."
|
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 "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 "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 "If one of the given device names gets not advised, the exit value is 1."
|
||||||
echo
|
echo
|
||||||
echo "Only if option -DO_WRITE is given and -list_all is not, and if exactly"
|
echo "Only if option -DO_WRITE is given and -list_all is not, and if exactly"
|
||||||
@ -225,6 +225,7 @@ list_devices() {
|
|||||||
reasons=
|
reasons=
|
||||||
good_trans=
|
good_trans=
|
||||||
good_fs=
|
good_fs=
|
||||||
|
bad_trans=
|
||||||
bad_fs=
|
bad_fs=
|
||||||
|
|
||||||
# Unwanted device name patterns
|
# Unwanted device name patterns
|
||||||
@ -267,6 +268,7 @@ list_devices() {
|
|||||||
tasty=y
|
tasty=y
|
||||||
elif test -n "$trans"
|
elif test -n "$trans"
|
||||||
then
|
then
|
||||||
|
bad_trans="$trans"
|
||||||
yucky=y
|
yucky=y
|
||||||
if test "$transports" = "not_an_expected_name"
|
if test "$transports" = "not_an_expected_name"
|
||||||
then
|
then
|
||||||
@ -279,6 +281,14 @@ list_devices() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
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
|
# Wanted or unwanted filesystem types
|
||||||
fstypes=$($sudo_cmd $lsblk_cmd -n -o FSTYPE /dev/"$name")
|
fstypes=$($sudo_cmd $lsblk_cmd -n -o FSTYPE /dev/"$name")
|
||||||
@ -381,7 +391,7 @@ list_devices() {
|
|||||||
else
|
else
|
||||||
if test -n "$show_reasons"
|
if test -n "$show_reasons"
|
||||||
then
|
then
|
||||||
echo "$name : YES : $good_trans $reasons$descr"
|
echo "$name : YES : $reasons$descr"
|
||||||
else
|
else
|
||||||
echo "$name"
|
echo "$name"
|
||||||
fi
|
fi
|
||||||
@ -401,7 +411,18 @@ write_image() {
|
|||||||
fi
|
fi
|
||||||
partitions=$($lsblk_cmd -n -p -o NAME /dev/"$2" | grep -v '^'/dev/"$2"'$' \
|
partitions=$($lsblk_cmd -n -p -o NAME /dev/"$2" | grep -v '^'/dev/"$2"'$' \
|
||||||
| sed -e 's/[^a-zA-Z0-9_+@:.,/-]//g' | tr '\n\r' ' ')
|
| 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"
|
if test -z "$dd_cmd"
|
||||||
then
|
then
|
||||||
@ -444,16 +465,17 @@ then
|
|||||||
with_vendor_model=y
|
with_vendor_model=y
|
||||||
devs="$candidates"
|
devs="$candidates"
|
||||||
list_devices >&2
|
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
|
exit 3
|
||||||
else
|
else
|
||||||
if test -n "$devs_named"
|
if test -n "$devs_named"
|
||||||
then
|
then
|
||||||
echo "NO CANDIDATE FOR TARGET DEVICE AMONG THE GIVEN NAMES !" >&2
|
echo "NO CANDIDATE FOR TARGET DEVICE AMONG THE GIVEN NAMES !" >&2
|
||||||
echo "Overall available devices:"
|
|
||||||
else
|
else
|
||||||
echo "NO CANDIDATE FOR TARGET DEVICE FOUND !" >&2
|
echo "NO CANDIDATE FOR TARGET DEVICE FOUND !" >&2
|
||||||
fi
|
fi
|
||||||
|
echo "Overall available devices:"
|
||||||
list_all=y
|
list_all=y
|
||||||
show_reasons=y
|
show_reasons=y
|
||||||
with_vendor_model=y
|
with_vendor_model=y
|
||||||
|
Loading…
Reference in New Issue
Block a user