Sorry for that, but there's no time on my side to work on a complete old/new merger - and I think it doesn't make any sense this way either.
I've looked at your code and there are two little things that do not work for some drivers but are easily added without any overhead: SCSI-drivers that don't provide informations in /proc/scsi/DRIVER ... ... are not detected because the driver name is derived from the directory name ... the SCSI_HOSTNUMBER cannot be retrieved After fixing the issues from above, I added support for the "ipr" driver in the scsi driver case/esac clause. Maybe the SCSI_CHANNEL could be defined outside the sysfs based if/fi clause. There are no dependencies to external binaries. Cheers, Cajus
--- /usr/sbin/ofpath 2005-01-06 15:37:30.000000000 +0000 +++ ofpath.patched 2005-01-17 13:54:00.175072992 +0000 @@ -265,10 +265,23 @@ ## figure out what the scsi driver is, it is /proc/scsi/dirname. [ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: DEVICE_HOST=$DEVICE_HOST" SCSI_DRIVER="$(x=`ls /proc/scsi/*/$DEVICE_HOST 2>/dev/null | cat` ; y=`echo ${x##*proc/scsi/}` ; echo ${y%%/*})" + + ## if scsi driver is empty, we need to query /sys/.../proc_name + if [ -z "$SCSI_DRIVER" -a -f /sys/class/scsi_host/host$DEVICE_HOST/proc_name ]; then + SCSI_DRIVER="$(cat /sys/class/scsi_host/host$DEVICE_HOST/proc_name)" + fi [ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: SCSI_DRIVER=$SCSI_DRIVER" ## figure out which host we found. SCSI_HOSTNUMBER="$(v=`ls /proc/scsi/$SCSI_DRIVER/* 2>/dev/null | cat | grep -n "$DEVICE_HOST\>"` ; echo ${v%%:*})" + + ## if host number is empty, we need to query for sysfs informations + if [ -z "$SCSI_HOSTNUMBER" ]; then + SYSINFO=$(v=`ls -l /sys/block/${DEVNODE}/device`; echo ${v##*/}) + SCSI_CHANNEL="$(v=${SYSINFO%:*:*};echo ${v#*:})" + SCSI_HOSTNUMBER="${SYSINFO%%:*}" + [ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: SCSI_CHANNEL=$SCSI_CHANNEL" + fi [ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: SCSI_HOSTNUMBER=$SCSI_HOSTNUMBER" return 0 @@ -303,6 +316,13 @@ DEVICE_PATH="$(printhost $SCSI_HOSTNUMBER $HOST_LIST)" echo "${DEVICE_PATH##*device-tree}/[EMAIL PROTECTED]/[EMAIL PROTECTED]:$PARTITION" ;; + ipr) + HOST_LIST="$(for i in `find /proc/device-tree -name compatible` ; do + lgrep "$i" "pci1069,b166" "pciclass,01000" ; done)" + DEVICE_PATH="$(printhost 1 $HOST_LIST)" + DEVICE_TYPE="$(cat $DEVICE_PATH/[EMAIL PROTECTED]/device_type)" + echo "$DEVICE_TYPE${DEVICE_PATH##*device-tree}/[EMAIL PROTECTED]/[EMAIL PROTECTED],0:$PARTITION" + ;; *) echo 1>&2 "$PRG: Driver: $SCSI_DRIVER is not supported" return 1