mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
lstape: fix output without SCSI generic (sg)
The default bash setting have nullglob disabled so if $SCSI_DEV/scsi_generic* aka /sys/bus/scsi/devices/*:*:*:*/scsi_generic* does not match anything, it leaves the glob pattern unmodified and SG_DEV=$(basename $SG_DEV/*) results in the literal: * If $SG_INQ exists, it invoked sg_inq with more than the one allowed positional argument for a SCSI generic device node: sg_inq /dev/* Causing error messages and the usage of sg_inq to land in $TAPE_SERIAL. To not have to rely on the nullglob setting, explicitly check for the existence of $SCSI_DEV/scsi_generic before evaluating SG_DEV=$(basename $SG_DEV/*). Also handle availability of sg_inq but absence of scsi_generic individually to provide the user with a hint if only sg is missing. Suggested-by: Eric Farman <farman@linux.vnet.ibm.com> Signed-off-by: Steffen Maier <maier@linux.ibm.com> Reviewed-by: Jens Remus <jremus@linux.ibm.com> Cc: Eric Farman <farman@linux.vnet.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
cdc787db1b
commit
80e0c41b89
12
zconf/lstape
12
zconf/lstape
@@ -48,6 +48,9 @@ function PrintUsage() {
|
||||
: -v|--version
|
||||
: Display the version of the tools package and
|
||||
: the lstape command.
|
||||
:
|
||||
:$(basename $0) without the --ccw-only option causes extra SAN traffic
|
||||
:for each SCSI tape or changer device by invoking the sg_inq command.
|
||||
EOD
|
||||
}
|
||||
|
||||
@@ -249,11 +252,16 @@ function SysfsCreateListSCSI()
|
||||
if [ -h $SG_DEV ]; then
|
||||
# deprecated sysfs layout
|
||||
SG_DEV=$(echo $SG_DEV | awk -F: '{print $NF}')
|
||||
else
|
||||
elif [ -d $SCSI_DEV/scsi_generic ]; then
|
||||
SG_DEV=$(basename $SG_DEV/*)
|
||||
else
|
||||
SG_DEV=""
|
||||
fi
|
||||
|
||||
if [ "$SG_INQ" != "" ]; then
|
||||
if [ -z "$SG_DEV" ]; then
|
||||
SG_DEV="N/A"
|
||||
TAPE_SERIAL="NO/SG"
|
||||
elif [ "$SG_INQ" != "" ]; then
|
||||
TAPE_SERIAL=$(
|
||||
sg_inq /dev/$SG_DEV |
|
||||
awk '/serial/{print $NF}'
|
||||
|
||||
@@ -36,7 +36,13 @@ IBM tape driver this would be "IBMtape" or "IBMchanger". If "N/A" is shown,
|
||||
the correct driver could not be obtained.
|
||||
|
||||
The serial number of a SCSI tape can be displayed with the --verbose option. If
|
||||
there is no sg_inq command available "NO/INQ" is shown as the tape's serial.
|
||||
there is no sg_inq command available "NO/INQ" is shown as the serial number
|
||||
of the tape.
|
||||
If no SCSI generic (sg) kernel support is available, "NO/SG" is shown
|
||||
as the serial number of the tape and "N/A" for the "Generic" column.
|
||||
|
||||
The lstape command without the --ccw-only option causes extra SAN traffic
|
||||
for each SCSI tape or changer device by invoking the sg_inq command.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP 8
|
||||
|
||||
Reference in New Issue
Block a user