lstape: fix SCSI HBA CCW device bus-ID e.g. for virtio-scsi-ccw

Get the SCSI HBA device bus-ID in general for HBAs on the CCW bus.

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Fedor Loshakov <loshakov@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Steffen Maier
2018-06-20 17:59:53 +02:00
committed by Jan Höppner
parent 34260f1736
commit d5291eed1c
2 changed files with 25 additions and 3 deletions

View File

@@ -223,6 +223,24 @@ function SysfsCreateListCCW() {
' | sort
}
# handle SCSI device not necessarily zfcp-attached, e.g. virtio-scsi-ccw
function SCSISearchCCWBusid()
{
local SCSI_DEV=$1
local SDEVCAN=$(readlink -e $SCSI_DEV)
while [ -n "$SDEVCAN" ]; do
# ascend to parent: strip last path part
SDEVCAN=${SDEVCAN%/*}
[ -h $SDEVCAN/subsystem ] || continue
local SUBSYSTEM=$(readlink -e $SDEVCAN/subsystem)
if [ "${SUBSYSTEM##*/}" = "ccw" ]; then
echo ${SDEVCAN##*/}
return
fi
done
echo "N/A"
}
function SysfsCreateListSCSI()
{
for SCSI_DEV in $1/bus/scsi/devices/*:*:*:*; do
@@ -335,8 +353,11 @@ function SysfsCreateListSCSI()
$STATE
if $VERBOSE; then
HBA_ID="N/A"
[ -r $SCSI_DEV/hba_id ] && HBA_ID=$(cat $SCSI_DEV/hba_id)
if [ -r $SCSI_DEV/hba_id ]; then
HBA_ID=$(cat $SCSI_DEV/hba_id)
else
HBA_ID=$(SCSISearchCCWBusid $SCSI_DEV)
fi
WWPN="N/A"
[ -r $SCSI_DEV/wwpn ] && WWPN=$(cat $SCSI_DEV/wwpn)
printf "$SCSIVFORMAT" \

View File

@@ -112,8 +112,9 @@ For SCSI devices, the --verbose option additionally displays:
.TP
.B HBA
The device bus-ID of the FCP device
or of the virtio-scsi-ccw virtual HBA
through which the tape drive is attached.
"N/A" if device is not attached through zfcp.
"N/A" if the device does not have a sysfs ancestor with subsystem ccw.
.TP
.B WWPN
The WWPN (worldwide port name) of the tape drive in the SAN.