--- yaboot-1.3.13.orig/ybin/ofpath 2004-11-04 21:57:17.000000000 -0500 +++ yaboot-1.3.13/ybin/ofpath 2004-11-04 22:36:41.234195024 -0500 @@ -8,6 +8,9 @@ ## Portions based on show_of_path.sh: ## ## Copyright (C) 2000 Olaf Hering +## +## sbp2 patch: +## Copyright (C) 2004 Christiaan Welvaart ## ## This program is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License @@ -301,7 +304,52 @@ HOST_LIST="$(for i in `find /proc/device-tree -name compatible` ; do lgrep "$i" "k2-s-ata" ; done)" DEVICE_PATH="$(printhost $SCSI_HOSTNUMBER $HOST_LIST)" - echo "${DEVICE_PATH##*device-tree}/k2-sata@$DEVICE_ID/disk@0:$PARTITION" + K2_DEVICE_ID=0 + while [ "$DEVICE_PATH" = "" ] ; do + SCSI_HOSTNUMBER=`expr $SCSI_HOSTNUMBER - 1` + let "K2_DEVICE_ID += 1" + DEVICE_PATH="$(printhost $SCSI_HOSTNUMBER $HOST_LIST)" + done + echo "${DEVICE_PATH##*device-tree}/k2-sata@$K2_DEVICE_ID/disk@0:$PARTITION" + ;; + usb-storage) + if [ ! -d /sys/devices ] + then + echo 1>&2 "sysfs must be mounted on /sys for usb-storage support" + return 1 + fi + local USBDEV=`readlink /sys/block/$DEVNODE/device` + local PCIADDR=`echo ${USBDEV#../../devices/} |sed -re 's#(pci[^/]*/[^/]*)/.*#\1#'` + local USBPATH=`echo ${USBDEV} |sed -re 's#.*/[0-9]*-([0-9\.]*):[0-9\.]*/host[0-9]*/[^/]*#\1#'` + local DEVSPEC=`cat /sys/devices/$PCIADDR/devspec` + local DISKPATH=`echo $USBPATH |sed -re 's#((.*\.)*)([0-9]*)$#\1disk@\3#' |sed -re 's#([0-9]*)\.#hub@\1/#'` + if [ `cat /proc/device-tree${DEVSPEC}/device_type` = ehci ] + then + local USB2PORT=`echo ${DEVSPEC} |sed -re 's#^.*,([0-9]+)#\1#'` + local USB1PORT=`echo ${DISKPATH} |sed -re 's#^[^@]+@([0-9]+).*#\1#'` + USB1PORT=`expr $USB1PORT - 1` + DISKPATH=`echo ${DISKPATH} |sed -re "s/^([^@]+)@${USB2PORT}(.*)/\1@1\2/"` + DEVSPEC=`echo ${DEVSPEC} |sed -re "s/^(.*),${USB2PORT}\$/\1,${USB1PORT}/"` + fi + echo "${DEVSPEC#,0}/${DISKPATH}:${PARTITION}" + ;; + "") + # sbp-2 driver does not have a dir in /proc/scsi + if [ -d /sys/devices ] + then + local SYSFSDEV=`readlink /sys/block/$DEVNODE/device` + local FWNODE=`echo ${SYSFSDEV} |sed -re 's#^.*/fw-host[0-9]+/([^/]+)/.*#\1#'` + local PCIADDR=`echo ${SYSFSDEV#../../devices/} |sed -re 's#(pci[^/]*/[^/]*)/.*#\1#'` + local DEVSPEC=`cat /sys/devices/$PCIADDR/devspec` + local OFNODE="${DEVSPEC}/node@${FWNODE}/sbp-2/disk@0" + if [ -f /proc/device-tree${OFNODE}/device_type ] + then + echo "${OFNODE}:${PARTITION}" + return 0 + fi + fi + echo 1>&2 "$PRG: cannot find SCSI driver for ${DEVNODE}" + return 1 ;; *) echo 1>&2 "$PRG: Driver: $SCSI_DRIVER is not supported"