ofpath: Handle disk devices with no sd node
authorBrian King <brking@linux.vnet.ibm.com>
Tue, 23 Aug 2011 04:45:30 +0000 (04:45 +0000)
committerTony Breeds <tony@bakeyournoodle.com>
Tue, 18 Oct 2011 04:38:10 +0000 (15:38 +1100)
Some storage boxes report a direct access device at LUN 31
which does not actually result in an sd device being attached.
Skip over these devices when parsing /proc/scsi/scsi.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
ybin/ofpath

index a487149416a07d59bf7a492d88646898adddd336..4892d8c755717a8a55f75e9ec246fcd22d36fffc 100755 (executable)
@@ -285,17 +285,20 @@ scsiinfo()
        [ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: DEVHOST=$DEVHOST"
 
        if [ "$DEVTYPE" = "Direct-Access" ] || [ "$DEVTYPE" = "Direct-Access-RBC" ] ; then
-           DEVCOUNT="$(($DEVCOUNT + 1))"
-           [ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: DEVCOUNT=$DEVCOUNT"
-           if [ "$SUBDEV" = "$DEVCOUNT" ] ; then
-               DEVICE_HOST=$DEVHOST
-               DEVICE_BUS=$DEVBUS
-               DEVICE_ID=$DEVID
-               DEVICE_LUN=$DEVLUN
-               [ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: DEVICE_HOST=$DEVICE_HOST"
-               break
-           fi
-       fi
+           ls /sys/bus/scsi/devices/$DEVHOST:$DEVBUS:$DEVID:$DEVLUN/scsi_disk* > /dev/null 2>&1
+           if [ $? -eq 0 ] ; then
+                DEVCOUNT="$(($DEVCOUNT + 1))"
+                [ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: DEVCOUNT=$DEVCOUNT"
+                if [ "$SUBDEV" = "$DEVCOUNT" ] ; then
+                        DEVICE_HOST=$DEVHOST
+                        DEVICE_BUS=$DEVBUS
+                        DEVICE_ID=$DEVID
+                        DEVICE_LUN=$DEVLUN
+                        [ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: DEVICE_HOST=$DEVICE_HOST"
+                        break
+                fi
+            fi
+        fi
     done
 
     ## figure out what the scsi driver is, it is /proc/scsi/dirname.