mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
lstape: fix to prefer sysfs to find lin_tape device name for SCSI device
This should be more stable than parsing the IBM lin_tape proc-fs output. If sysfs is not available or provides no match, fall back to proc-fs. An alternative to "ls -1d ... | head -n1" would have been to use "shopt -s extglob; ls -d $SCSI_DEV/lin_tape/$DEV_NAME+([0-9])" but I did not want to have to rely on extglob potentially influencing other old code of lstape. Signed-off-by: Steffen Maier <maier@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:
committed by
Jan Höppner
parent
ef4dc7a45b
commit
cdc787db1b
17
zconf/lstape
17
zconf/lstape
@@ -291,6 +291,23 @@ function SysfsCreateListSCSI()
|
||||
if [ "$CHG_IDX" != "" ]; then
|
||||
TAPE_DEV=$CHG_IDX
|
||||
fi
|
||||
elif [ "$(echo "$SCSI_LIST"|grep lin_tape)" != "" ]; then
|
||||
# bash glob sorts so IBMtape0 comes before IBMtape0n
|
||||
local IBM_PATH=$(
|
||||
ls -1d $SCSI_DEV/lin_tape/$DEV_NAME[0-9]* |
|
||||
head -n 1)
|
||||
if [ -d "$IBM_PATH" ]; then
|
||||
IBM_IDX=${IBM_PATH##*/}
|
||||
else
|
||||
# deprecated sysfs layout
|
||||
IBM_IDX=$(
|
||||
echo "$SCSI_LIST" |
|
||||
awk -F: '/lin_tape\:'"$DEV_NAME"'[0-9]+$/{print $NF}'
|
||||
)
|
||||
fi
|
||||
if [ "$IBM_IDX" != "" ]; then
|
||||
TAPE_DEV=$IBM_IDX
|
||||
fi
|
||||
elif [ -r /proc/scsi/$DEV_NAME ]; then
|
||||
IBM_IDX=$(
|
||||
grep -wF "$SCSI_ID" /proc/scsi/$DEV_NAME |
|
||||
|
||||
Reference in New Issue
Block a user