+ide_ofpath()
+{
+ local OF1275IDE=/proc/ide/pmac
+
+ if [ ! -f "$OF1275IDE" ] ; then
+ case "$(cat /proc/device-tree/model)" in
+ "PowerMac3,6")
+ local CDROM="$(grep "^drive name:" /proc/sys/dev/cdrom/info 2> /dev/null | grep $DEVNODE)"
+ if [ -z "$CDROM" ] ; then
+ echo "ultra2:$PARTITION"
+ else
+ echo "cd:$PARTITION"
+ fi
+ ;;
+ *)
+ if [ ! -L "/proc/ide/$DEVNODE" ] ; then
+ echo "$PRG: /dev/$DEVNODE: Device not configured"
+ return 1
+ fi
+ local CDROM="$(grep "^drive name:" /proc/sys/dev/cdrom/info 2> /dev/null | grep $DEVNODE)"
+ if [ -z "$CDROM" ] ; then
+ if [ "$DEVNODE" = hda ] ; then
+ echo "hd:$PARTITION"
+ else
+ echo "ultra1:$PARTITION"
+ fi
+ else
+ echo "cd:$PARTITION"
+ fi
+ ;;
+ esac
+ else
+ if [ ! -L "/proc/ide/$DEVNODE" ] ; then
+ echo 2>&1 "$PRG: /dev/$DEVNODE: Device not configured"
+ return 1
+ fi
+
+ local IDEBUS="$(v=`readlink /proc/ide/$DEVNODE` ; echo ${v%%/*} )"
+ [ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: IDEBUS=$IDEBUS"
+ local NUMBUSSES="$(($(linecount $OF1275IDE) / 5))"
+ [ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: NUMBUSSES=$NUMBUSSES"
+ if [ "$((${IDEBUS##ide} + 1))" -gt "$NUMBUSSES" ] ; then
+ echo 1>&2 "$PRG: /dev/$DEVNODE is not supported"
+ return 1
+ fi
+ local IDEDEV="$(head -n $((5 * $((${IDEBUS##ide} + 1)))) $OF1275IDE | tail -n 5)"
+ [ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: IDEDEV=$IDEDEV"
+ if [ "$(echo "$IDEDEV" | head -n 1)" != "$IDEBUS" ] ; then
+ echo "$PRG: /dev/$DEVNODE: is not supported"
+ return 1
+ fi
+ local DEVSPEC="$(v=`echo "$IDEDEV" | grep devspec` ; echo ${v##*:})"
+ [ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: DEVSPEC=$DEVSPEC"
+ case "$DEVNODE" in
+ hda|hdc|hde|hdg)
+ echo "${DEVSPEC}/disk@0:$PARTITION"
+ return 0
+ ;;
+ hdb|hdd|hdf|hdh)
+ echo "${DEVSPEC}/disk@1:$PARTITION"
+ return 0
+ ;;
+ *)
+ echo 1>&2 "$PRG: /dev/$DEVNODE is not supported"
+ return 1
+ ;;
+ esac
+ fi
+}
+