sg3_utils/9004-sg3_utils-1.42-delete-lun-rescan-scsi-bus-report-error.patch
2020-03-13 19:14:30 +08:00

53 lines
2.3 KiB
Diff

From 56fb49584c56afe1f222b3ee9fc12c7cfd079286 Mon Sep 17 00:00:00 2001
From: wubo <wubo40@huawei.com>
Date: Tue, 27 Aug 2019 14:16:48 +0800
Subject: [PATCH] rescan-scsi-bus.sh fix delete lun report error
---
scripts/rescan-scsi-bus.sh | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh
index 4b23ba4..3f18403 100755
--- a/scripts/rescan-scsi-bus.sh
+++ b/scripts/rescan-scsi-bus.sh
@@ -434,7 +434,7 @@ dolunscan()
# Well known lun transition case. Only for Direct-Access devs (type 0)
# If block directory exists && and PQUAL != 0, we unmapped lun0 and just have a well-known lun
# If block directory doesn't exist && PQUAL == 0, we mapped a real lun0
- if test $lun -eq 0 -a $IPTYPE -eq 0 ; then
+ if test x"$lun" = x0 -a x"$IPTYPE" = x0 ; then
if test $RC = 2 ; then
if test -e /sys/class/scsi_device/${host}:${channel}:${id}:${lun}/device; then
if test -d /sys/class/scsi_device/${host}:${channel}:${id}:${lun}/device/block ; then
@@ -443,7 +443,7 @@ dolunscan()
RC=0 # Set this so the system leaves the existing well known lun alone. This is a lun 0 with no block directory
fi
fi
- elif test $RC = 0 -a $IPTYPE -eq 0; then
+ elif test $RC = 0 -a x"$IPTYPE" = x0; then
if test -e /sys/class/scsi_device/${host}:${channel}:${id}:${lun}/device; then
if test ! -d /sys/class/scsi_device/${host}:${channel}:${id}:${lun}/device/block ; then
remappedlun0=1 # Transition from well-known to real lun 0
@@ -455,7 +455,7 @@ dolunscan()
# Special case: lun 0 just got added (for reportlunscan),
# so make sure we correctly treat it as new
- if test "$lun" = "0" -a "$1" = "1" -a -z "$remappedlun0"; then
+ if test x"$lun" = x"0" -a "$1" = "1" -a -z "$remappedlun0"; then
SCSISTR=""
printf "\r\e[A\e[A\e[A"
fi
@@ -478,7 +478,7 @@ dolunscan()
sleep 0.02
else
echo "scsi remove-single-device $devnr" > /proc/scsi/scsi
- if test $RC -eq 1 -o $lun -eq 0 ; then
+ if test $RC -eq 1 -o x"$lun" = x0 ; then
# Try readding, should fail if device is gone
echo "scsi add-single-device $devnr" > /proc/scsi/scsi
fi
--
1.8.3.1