[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Invalid OpenBOOT path for a device



Control: tags -1 +patch

Attaching a patch squashing my three commits to address the issue
from my fork on Github in the mac-support tree [1].

Adrian

> [1] https://github.com/glaubitz/powerpc-utils/tree/mac-support

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
>From b5e6f5151a1720f0443af2dea5d641fe966998c6 Mon Sep 17 00:00:00 2001
From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Date: Fri, 17 Apr 2020 15:23:33 +0200
Subject: [PATCH] ofpathname: Add support for Macintosh OF paths

---
 scripts/ofpathname | 54 +++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 51 insertions(+), 3 deletions(-)

diff --git a/scripts/ofpathname b/scripts/ofpathname
index c37c6bd..7011ca5 100755
--- a/scripts/ofpathname
+++ b/scripts/ofpathname
@@ -37,6 +37,8 @@ PSERIES_PLATFORM=$(dirname $0)/pseries_platform
 PLATFORM=$(sed /proc/cpuinfo -ne "s/^machine\t*: \(.*\)/\1/p")
 case $PLATFORM in
     EFIKA5K2\ *)	PLATFORM=efika ;;
+    PowerBook*)		PLATFORM=mac ;;
+    PowerMac*)		PLATFORM=mac ;;
 esac
 
 # Usage statemnet
@@ -519,6 +521,13 @@ l2of_ide()
     if [[ -z $link ]]; then
         err $ERR_NO_SYSFS_DEVINFO
     fi
+
+    # partition number: N in sd*N
+    local devpart="${DEVICE##*[a-z]}"
+    if [[ $devpart = $DEVICE ]]; then
+        devpart='' # no partition number
+    fi
+
     cd $link
 
     # get the device number
@@ -547,7 +556,11 @@ l2of_ide()
         devno=0,0
     fi
 
-    OF_PATH=$OF_PATH/disk@$devno
+    if [ "$PLATFORM" = "mac" ] ; then
+        OF_PATH=$OF_PATH/@$devno
+    else
+        OF_PATH=$OF_PATH/disk@$devno
+    fi
 }
 
 #
@@ -584,6 +597,13 @@ l2of_vd()
     if [[ -z $OF_PATH ]]; then
         err $ERR_NO_OFPATH
     fi
+
+    # No partition specified.
+    if [[ -z $devpart ]]; then
+        return
+    fi
+
+    OF_PATH="${OF_PATH}:${devpart}"
 }
 
 #
@@ -786,6 +806,12 @@ l2of_scsi()
         err $ERR_NOT_CONFIG
     fi
 
+    # partition number: N in sd*N
+    local devpart="${DEVICE##*[a-z]}"
+    if [[ $devpart = $DEVICE ]]; then
+        devpart='' # no partition number
+    fi
+
     # follow the 'device' link
     local link=`get_link "device"`
     if [[ -z $link ]]; then
@@ -804,6 +830,7 @@ l2of_scsi()
     goto_dir $PWD "devspec"
 
     OF_PATH=`$CAT $PWD/devspec`
+    SYS_PATH=$PWD
     if [[ -z $OF_PATH ]]; then
         err $ERR_NO_OFPATH
     fi
@@ -922,12 +949,22 @@ l2of_scsi()
             fi
 	fi
     else
+
+        plug_id=$(ls -dv $SYS_PATH/*/host* 2>/dev/null | grep -n "/host$HOST$")
+        [ -z "$plug_id" ] && {
+                plug_id=$(ls -dv $SYS_PATH/host* 2>/dev/null | grep -n "/host$HOST$")
+        }
+        plug_id=$((${plug_id%%:*}-1))
+
         # make sure the "scsi" information is on the end of the path
         local scsi_name=${OF_PATH##/*/}
         scsi_name=${scsi_name%%@*}
-        if [[ $scsi_name != "scsi" ]]; then
+        if [[ $scsi_name != "scsi" && "$PLATFORM" != "mac" ]]; then
             scsi_name="scsi@$BUS"
             OF_PATH=$OF_PATH/$scsi_name
+        elif [[ $scsi_name != "scsi" && "$PLATFORM" = "mac" && $devtype != "ata" ]]; then
+            scsi_name="@$plug_id"
+            OF_PATH=$OF_PATH/$scsi_name
         fi
 
         local modalias=""
@@ -941,9 +978,20 @@ l2of_scsi()
              diskno=`get_scsi_disk_no $device_dir`
              OF_PATH=$OF_PATH/disk\@$diskno
         else
-             OF_PATH=$OF_PATH/sd@$ID,$LUN
+             if [ "$PLATFORM" = "mac" ] ; then
+                 OF_PATH=$OF_PATH/@$ID
+             else
+                 OF_PATH=$OF_PATH/sd@$ID,$LUN
+             fi
        fi
     fi
+
+    # No partition specified.
+    if [[ -z $devpart ]]; then
+        return
+    fi
+
+    OF_PATH="${OF_PATH}:${devpart}"
 }
 
 #
-- 
2.26.0


Reply to: