aboutsummaryrefslogtreecommitdiff
path: root/scripts/rescan-scsi-bus.sh
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2016-05-11 20:20:52 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2016-05-11 20:20:52 +0000
commit5f3a67ec3caf126f48263a8d392e83e7e99c8ba2 (patch)
tree7361495943e2978a8b168fd46f7ac26a3b9ec02e /scripts/rescan-scsi-bus.sh
parenteaf62d70e3afbd384d1b626979eb39b2854bfb7a (diff)
downloadsg3_utils-5f3a67ec3caf126f48263a8d392e83e7e99c8ba2.tar.gz
rescan-scsi-bus.sh + 55-scsi-sg3_id.rules: fixes from HR at Suse
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@703 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'scripts/rescan-scsi-bus.sh')
-rwxr-xr-xscripts/rescan-scsi-bus.sh46
1 files changed, 25 insertions, 21 deletions
diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh
index 80a9ae05..fad4868d 100755
--- a/scripts/rescan-scsi-bus.sh
+++ b/scripts/rescan-scsi-bus.sh
@@ -4,7 +4,7 @@
# (c) 2006--2015 Hannes Reinecke, GNU GPL v2 or later
# $Id: rescan-scsi-bus.sh,v 1.57 2012/03/31 14:08:48 garloff Exp $
-VERSION="20160228"
+VERSION="20160511"
SCAN_WILD_CARD=4294967295
setcolor ()
@@ -360,37 +360,37 @@ chanlist ()
# Returns the list of existing targets per host
idlist ()
{
- local hcil
- local target
local tmpid
local newid
-
- idsearch=$(ls /sys/class/scsi_device/ | sed -n "s/${host}:${channel}:\([0-9]*\):[0-9]*/\1/p" | uniq)
- echo "${channel} - -" > /sys/class/scsi_host/host${host}/scan
- # Rescan to check if we found new targets
- newsearch=$(ls /sys/class/scsi_device/ | sed -n "s/${host}:${channel}:\([0-9]*\):[0-9]*/\1/p" | uniq)
- for id in $newsearch ; do
- newid=$id
- for tmpid in $idsearch ; do
- if test $id -eq $tmpid ; then
- newid=
+ local oldid
+
+ oldlist=$(ls /sys/class/scsi_device/ | sed -n "s/${host}:${channel}:\([0-9]*:[0-9]*\)/\1/p" | uniq)
+ # Rescan LUN 0 to check if we found new targets
+ echo "${channel} - 0" > /sys/class/scsi_host/host${host}/scan
+ newlist=$(ls /sys/class/scsi_device/ | sed -n "s/${host}:${channel}:\([0-9]*:[0-9]*\)/\1/p" | uniq)
+ for newid in $newlist ; do
+ oldid=$newid
+ for tmpid in $oldlist ; do
+ if test $newid = $tmpid ; then
+ oldid=
break
fi
done
- if test -n "$newid" ; then
- id=$newid
- for dev in /sys/class/scsi_device/${host}:${channel}:${newid}:* ; do
- [ -d $dev ] || continue;
- hcil=${dev##*/}
- lun=${hcil##*:}
+ if test -n "$oldid" ; then
+ id=${oldid%%:*}
+ lun=${oldid##*:}
+ dev=/sys/class/scsi_device/${host}:${channel}:${id}:${lun}
+ if [ -d $dev ] ; then
+ hcil=${dev##*/}
printf "\r${green}NEW: $norm"
testexist
if test "$SCSISTR" ; then
incrfound "$hcil"
fi
- done
+ fi
fi
done
+ idsearch=$(ls /sys/class/scsi_device/ | sed -n "s/${host}:${channel}:\([0-9]*\):[0-9]*/\1/p" | uniq)
}
# Returns the list of existing LUNs from device $host $channel $id $lun
@@ -642,7 +642,11 @@ dosearch ()
fi
for channel in $channelsearch; do
if test -z "$idsearch" ; then
- idlist
+ if test -z "$lunsearch" ; then
+ idlist
+ else
+ idsearch=$(ls /sys/class/scsi_device/ | sed -n "s/${host}:${channel}:\([0-9]*\):[0-9]*/\1/p" | uniq)
+ fi
fi
for id in $idsearch; do
if test -z "$lunsearch" ; then