diff --git a/rescan-scsi-bus.sh b/rescan-scsi-bus.sh index 9f4e1f2..41442f0 100644 --- a/rescan-scsi-bus.sh +++ b/rescan-scsi-bus.sh @@ -188,7 +188,7 @@ testonline () # echo -e "\e[A\e[A\e[A${yellow}Test existence of $SGDEV = $RC ${norm} \n\n\n" if test $RC = 1; then return $RC; fi # OK, device online, compare INQUIRY string - INQ=`sg_inq -36 /dev/$SGDEV` + INQ=`sg_inq $sg_len_arg /dev/$SGDEV` IVEND=`echo "$INQ" | grep 'Vendor identification:' | sed 's/^[^:]*: \(.*\)$/\1/'` IPROD=`echo "$INQ" | grep 'Product identification:' | sed 's/^[^:]*: \(.*\)$/\1/'` IPREV=`echo "$INQ" | grep 'Product revision level:' | sed 's/^[^:]*: \(.*\)$/\1/'` @@ -205,12 +205,12 @@ testonline () TMPSTR=`echo "$SCSISTR" | grep 'Vendor:'` if [ "$TMPSTR" != "$STR" ]; then echo -e "\e[A\e[A\e[A\e[A${red}$SGDEV changed: ${bold}\nfrom:${SCSISTR#* } \nto: $STR ${norm}\n\n\n" - return 1 + return 0 fi TMPSTR=`echo "$SCSISTR" | sed -n 's/.*Type: *\(.*\) *ANSI.*/\1/p'` if [ $TMPSTR != $TYPE ] ; then echo -e "\e[A\e[A\e[A\e[A${red}$SGDEV changed: ${bold}\nfrom:${TMPSTR} \nto: $TYPE ${norm}\n\n\n" - return 1 + return 0 fi return $RC } @@ -297,7 +297,8 @@ dolunscan() # Device exists: Test whether it's still online # (testonline returns 1 if it's gone or has changed) testonline - if test $? = 1 -o ! -z "$forceremove"; then + RC=$? + if test $RC = 1 -o ! -z "$forceremove"; then echo -en "\r\e[A\e[A\e[A${red}REM: " echo "$SCSISTR" | head -n1 echo -e "${norm}\e[B\e[B" @@ -311,6 +312,11 @@ dolunscan() echo "scsi add-single-device $devnr" > /proc/scsi/scsi fi fi + if test $RC = 0 ; then + if test -e /sys/class/scsi_device/${host}:${channel}:${id}:${lun}/device; then + echo 1 > /sys/class/scsi_device/${host}:${channel}:${id}:${lun}/device/rescan + fi + fi printf "\r\x1b[A\x1b[A\x1b[A${yellow}OLD: $norm" testexist if test -z "$SCSISTR"; then @@ -374,10 +380,7 @@ doreportlun() oldsearch="$lunsearch" for tmplun in $lunsearch; do if test $tmplun -eq $lun ; then - # Optimization: don't scan lun 0 again - if [ $lun -ne 0 ]; then - dolunscan - fi + dolunscan else newsearch="$newsearch $tmplun" fi @@ -471,11 +474,19 @@ fi # Make sure sg is there modprobe sg >/dev/null 2>&1 +sg_version=$(sg_inq -V 2>&1 | cut -d " " -f 3) +sg_version=${sg_version##0.} +if [ "$sg_version" -lt 70 ] ; then + sg_len_arg="-36" +else + sg_len_arg="--len=36" +fi + # defaults unsetcolor lunsearch="" idsearch=`seq 0 7` -channelsearch="0" +channelsearch="" remove= forceremove= optscan=1 diff --git a/sg3_utils.changes b/sg3_utils.changes index 44972a5..4660c70 100644 --- a/sg3_utils.changes +++ b/sg3_utils.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Wed Jul 16 09:55:33 CEST 2008 - hare@suse.de + +- Use correct length parameter for sg_inq (bnc#363438) + ------------------------------------------------------------------- Fri May 23 10:22:31 CEST 2008 - hare@suse.de diff --git a/sg3_utils.spec b/sg3_utils.spec index b49ef49..f7bb22e 100644 --- a/sg3_utils.spec +++ b/sg3_utils.spec @@ -20,7 +20,7 @@ Provides: scsi Obsoletes: scsi <= 1.7_2.38_1.25_0.19_1.02_0.93 AutoReqProv: on Version: 1.25 -Release: 9 +Release: 16 Summary: A collection of tools that send SCSI commands to devices Source: http://sg.torque.net/sg/p/sg3_utils-%{sgver}.tar.bz2 Source2: http://www.garloff.de/kurt/linux/rescan-scsi-bus.sh @@ -210,6 +210,8 @@ test ! -z "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != "/" && rm -rf $RPM_BUILD_ROO rm -rf $RPM_BUILD_DIR/sg3_utils-%{sgver} %changelog +* Wed Jul 16 2008 hare@suse.de +- Use correct length parameter for sg_inq (bnc#363438) * Fri May 23 2008 hare@suse.de - Use 'Provides' to clean update dependency * Fri May 09 2008 schwab@suse.de