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

Re: yaboot with updated e2fsprogs



Hi Richard!

On 9/9/20 5:38 AM, Richard Allen wrote:
> I'm unsure if this is helpful for anyone, but I started hacking
> on yaboot a few days ago for GCC10 and better ext4 support.
> This boots my PowerMacG5, but I have yet to try booting a
> 64-bit ext4 /boot partition - the updated e2fsprogs should
> support it though. It's still a little kludgy, but it's here:

I just remembered that the Yaboot package in Debian actually contains a couple
of patches which should be upstreamed.

I have not checked whether all of those patches are still relevant, so I'm just
attaching all of them. They have been extracted from the source package in [1].

Could you have a look and apply them keeping the original author information
intact if there is any?

Thanks,
Adrian

> [1] http://snapshot.debian.org/package/yaboot/1.3.17-4/

-- 
 .''`.  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
--- /dev/null
+++ b/man/yaboot.de.8
@@ -0,0 +1,145 @@
+.\" Hey Emacs! This file is -*- nroff -*- source.
+.\"
+.\" Translated into german by Helge Kreutzmann <kreutzm@itp.uni-hannover.de>
+.hw Kenn-zeichen
+.TH YABOOT 8 "21 Juli 2004" "GNU/Linux PowerPC" "Systemverwalters Handbuch"
+.SH NAME
+.B yaboot
+\- PowerMac OpenFirmware Urlader (Boot-Lader)
+.SH ZUSAMMENFASSUNG
+.B Yaboot
+ist ein ELF-Binärprogramm für OpenFirmware, das den Linux Kernel
+urlädt (bootet).
+.SH BESCHREIBUNG
+Diese Handbuchseite beschreibt den \fByaboot\fR OpenFirmware Urlader.
+
+.B yaboot
+ist \fIkein\fR Linux- oder MacOS-Programm.  Der Versuch, \fByaboot\fR
+von einer Linux-Shell aus auszuführen wird nur in einem 
+Segmentierungsfehler enden.  \fByaboot\fR ist nur dazu gedacht, von
+OpenFirmware ausgeführt zu werden.
+
+.B yaboot
+wird von OpenFirmware in der folgenden Weise ausgeführt:
+.I boot hd:2,yaboot
+wobei \fIhd:\fR der OpenFirmware-Pfad für die Festplatte und \fI2\fR die
+Nummer der Partition, auf der sich \fByaboot\fR befindet, ist.  In diesem
+Beispiel ist der Festplattenpfad tatsächlich ein OpenFirmware-Alias der auf
+allen NewWorld-PowerMacs verfügbar ist.  Normalerweise zeigt er auf die
+interne ATA-Festplatte. Falls Sie eine SCSI-Festplatte haben, dann würden Sie
+\fByaboot\fR mit folgendem Befehl ausführen:
+.I boot /pci@80000000/pci-bridge@d/ADPT,2930CU@2/@1:2,yaboot
+Dieser Pfad hängt von der Art Ihres SCSI-Adapters ab. Für eine
+detailiertere Erklärung der [widerlichen] OpenFirmware-Pfade lesen
+Sie bitte \fBbootstrap\fR(8). Auf IBM-Hardware wird \fByaboot\fR
+direkt in die rohe, d.h. ohne mit Dateisystem versehene, Partition
+kopiert. OpenFirmware booted direkt von einer bootbar markierten 
+Type 0x41 PReP-Boot-Partition die \fByaboot\fR enthalten muß.
+Auf IBM-Hardware wird die Konfigurationsdatei direkt aus dem
+Wurzeldateisystem gelesen. Auf PowerMac-Hardware muß diese auf der
+\fBbootstrap\fR(8)-Partition vorhanden sein, aber
+.BR ybin (8)
+kümmert sich darum.
+
+Glücklicherweise müssen Sie normalerweise \fByaboot\fR nicht von
+Hand ausführen. Falls Sie Ihre Platte mit einer \fBbootstrap\fR(8)-Partition
+angelegt und \fBybin\fR(8) zur Installation von \fByaboot\fR verwendet
+haben, dann müssen Sie \fByaboot\fR  nicht selbst aufrufen. (Falls dies
+nicht funktioniert, dann können Sie auch die \fIboot-device\fR-Variable
+in der OpenFirmware setzen, um automatisch zu booten, lesen Sie hierzu
+\fBbootstrap\fR(8).)
+
+Sobald \fByaboot\fR von der OpenFirmware ausgeführt wurde, zeigt er eine
+\fIboot:\fR-Eingabeaufforderung an, an der Sie einen Namen für ein
+in der \fByaboot.conf\fR(5) definiertes Kernel-Image eingeben können. Falls in der
+\fByaboot.conf\fR(5) kein Kernel-Image definiert ist, können Sie immer
+noch ein beliebieges Image durch Angabe seines absoluten Open Firmware-Pfads
+booten, ähnlich zu den obigen Kommandos um \fByaboot\fR selbst auszuführen.
+Lassen Sie einfach das \fIboot\fR-Kommando fort und geben Sie nur den
+Pfadnamen ein. (Siehe auch unter BEISPIELE)
+
+Wenn Sie ein Image booten (entweder über ein vordefinierten Namen oder
+über einen absoluten Pfad) werden alle Argumente an das Image weitergereicht.
+Zum Beispiel:
+.I boot: linux root=/dev/hda3
+Hier werden die Argumente \fIroot=/dev/hda3\fR an den Kernel weitergereicht.
+
+.B yaboot
+sollte bevorzugt auf einer dedizierten  \fBbootstrap\fR(8)-Partition 
+(vom Typ Apple_Bootstrap auf PowerMacs, Typ 0x41 PReP-Boot auf
+IBM-Hardware) installiert werden. Dies erlaubt die Modifikation der
+Partition derart, daß OpenFirmware \fByaboot\fR oder ein Boot-Menü
+automatisch in einer Standard-OF-Konfiguration lädt. Falls \fByaboot\fR
+nicht auf einer \fBbootstrap\fR(8)-Partition installiert werden kann, 
+kann es stattdessen in der Wurzel der MacOS-Boot-Partition installiert
+werden. \fByaboot\fR sollte allerdings nicht in einem Unterverzeichnis
+des MacOS-Dateisystems installiert werden, da dies weniger zuverlässig
+und schwieriger von OpenFirmware aus ausführbar ist. Lesen Sie die
+\fBybin\fR(8)-Handbuchseite für weitere Details zur Installation von 
+\fByaboot\fR  (\fBybin\fR(8) ist ein Werkzeug um \fByaboot\fR unter
+minimaler Schwierigkeit zu installieren)
+
+Die \fByaboot.conf\fR(5)-Datei muß neben dem \fByaboot\fR-Programm auf
+der \fBbootstrap\fR(8)-Partition liegen.  \fBybin\fR(8) kümmert sich darum.
+
+OpenFirmware kann durch gleichzeitiges Drücken der \fIcommand, option,
+o, f\fR-Tasten sofort nach dem Einschalten erreicht werden.
+
+Die Einstellungen von OpenFirmware können durch das gleichzeitige Drücken
+der \fIcommand, option, p, r\fR-Tasten während eines Kaltstarts auf die
+Standardwerte zurückgesetzt werden.
+
+Fall Sie G4-Hardware besitzen, dann könnte Ihre OpenFirmware bereits
+über ein eingebautes graphische Bootauswahlmenü verfügen. Dieses 
+Auswahlmenü kann über das Drücken der \fIoption\fR-Taste während
+des Bootens der Maschine erreicht werden. Sie sollten einen Bildschirm
+mit Knöpfen für jede bootbare Partition sehen. Die derzeitige Version
+(in \fBybin\fR(8) 0.13 enthalten) von ofboot enthält ein Kennzeichen-Icon,
+der Knopf mit dem Pinguin-Icon steht für Ihre
+\fBbootstrap\fR(8)-Partition. Vielen Dank an Nicholas Humfrey für die
+Erstellung des Kennzeichen-Icons.
+
+Die \fBbootstrap\fR(8)-Partition braucht und 
+.B sollte nicht
+irgendwo in Ihrem Dateisystem, insbesondere in /boot, eingehängt werden. \fBYaboot\fR ist
+in der Lage, Kernel von der mit ext2 formatierten Wurzelpartition zu laden, deshalb sollten
+die Kernel auch dort vorgehalten werden.
+.SH BEISPIELE
+\fByaboot\fR von der internen ATA-Platte, Partition 2 booten:
+
+.I boot hd:2,yaboot 
+
+\fByaboot\fR von Partition 2 von einer SCSI-Platte mit ID 2 an einem
+Adaptec 2930 SCSI-Adapter booten (dies ist auf einem blauen G3, Revision 1,
+und kann auf anderen Modellen variieren):
+
+.I boot /pci@80000000/pci-bridge@d/ADPT,2930CU@2/@2:2,yaboot
+
+Ein Kernel-Image auf Partition 3 der internen ATA-Platte booten
+(von \fByaboot's\fR \fIboot:\fR-Eingabeaufforderung):
+
+.I hd:3,/boot/vmlinux
+
+Ein Kernel-Image auf Partition 3 der SCSI-Platte mit ID 2 an einem
+Adaptec 2930 SCSI-Adapter booten
+(von \fByaboot's\fR \fIboot:\fR-Eingabeaufforderung):
+
+.I /pci@80000000/pci-bridge@d/ADPT,2930CU@2/@2:3,/vmlinux
+.SH DATEIEN
+.nf
+/etc/yaboot.conf \- Urlader (Boot-Lader) Konfigurationsdatei
+.fi
+.SH FEHLER
+OpenFirmware
+.SH AUTOREN
+Diese Handbuchseite wurde von Ethan Benson <erbenson@alaska.net> geschrieben.
+.P
+.B yaboot
+wurde von Benjamin Herrenschmidt <benh@kernel.crashing.org> geschrieben.
+.SH "FEHLER BERICHTEN"
+Fehler in \fByaboot\fR sollten (auf englisch) an Ethan Benson <erbenson@alaska.net>
+berichtet werden.
+.SH "SIEHE AUCH"
+.BR bootstrap (8),
+.BR yaboot.conf (5),
+.BR ybin (8).
--- a/second/fs_xfs.c
+++ b/second/fs_xfs.c
@@ -661,8 +661,6 @@
 
 	startpos = xfs_file->pos;
 	endpos = xfs_file->pos + len;
-	if (endpos > xfs_file->len)
-		endpos = xfs_file->len;
 	endofprev = (xfs_fileoff_t)-1;
 	init_extents ();
 	while (len > 0 && (xad = next_extent ())) {
Description: correct ofpath discovery on newer kernels
Author: Milan Kupcevic <milan@physics.harvard.edu>
Bug-Debian: http://bugs.debian.org/784387
Forwarded: no
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/ybin/ofpath
+++ b/ybin/ofpath
@@ -220,7 +220,10 @@
     IEEE1394_ID=`cat /sys/block/$DEVNODE/device/ieee1394_id 2>/dev/null`
     IEEE1394_ID=${IEEE1394_ID%%:*}
 
-    PLUG_ID=$(ls -dv $SYS_PATH/host* 2>/dev/null | grep -n "/host$HOST_ID$")
+    PLUG_ID=$(ls -dv $SYS_PATH/*/host* 2>/dev/null | grep -n "/host$HOST_ID$")
+    [ -z "$PLUG_ID" ] && {
+      PLUG_ID=$(ls -dv $SYS_PATH/host* 2>/dev/null | grep -n "/host$HOST_ID$")
+    }
     PLUG_ID=$((${PLUG_ID%%:*}-1))
 
     PART=${PARTITION:+:$PARTITION}
Description: let it probe for other filesystems
 Not having a partition does not constitute a bad device.
Author: Milan Kupcevic <milan@debian.org>
Bug-Debian: http://bugs.debian.org/819549
Forwarded: no
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/second/fs_swap.c
+++ b/second/fs_swap.c
@@ -60,8 +60,8 @@
      DEBUG_OPEN;
 
      if (file->device_kind != FILE_DEVICE_BLOCK || part == NULL) {
-	  DEBUG_LEAVE(FILE_ERR_BADDEV);
-	  return FILE_ERR_BADDEV;
+          DEBUG_LEAVE(FILE_ERR_BAD_FSYS);
+          return FILE_ERR_BAD_FSYS;
      }
 
      /* We assume that device is "short" and is correctly NULL terminsated */
--- a/Makefile
+++ b/Makefile
@@ -39,7 +39,7 @@
 YBCFLAGS += -DTEXTADDR=$(TEXTADDR) -DDEBUG=$(DEBUG)
 YBCFLAGS += -DMALLOCADDR=$(MALLOCADDR) -DMALLOCSIZE=$(MALLOCSIZE)
 YBCFLAGS += -DKERNELADDR=$(KERNELADDR)
-YBCFLAGS += -Werror -fdiagnostics-show-option
+YBCFLAGS += -fgnu89-inline -fno-builtin-malloc
 YBCFLAGS += -I ./include
 YBCFLAGS += -fno-strict-aliasing
 
@@ -69,11 +69,15 @@
 
 # Libraries
 #
-LLIBS = -lext2fs
+LLIBS = -lext2fs -lcom_err \
+        `$(CC) -m32 -print-file-name=libpthread.a`
 
 # For compiling userland utils
 #
-UCFLAGS = -Os $(CFLAGS) -Wall -I/usr/include
+UCFLAGS = -Os -g $(CFLAGS) -Wall -I/usr/include
+UCFLAGS += -fstack-protector-strong
+UCFLAGS += -D_FORTIFY_SOURCE=2
+UCFLAGS += -Wl,-z,relro
 UCFLAGS += -Werror -fdiagnostics-show-option
 
 # For compiling build-tools that run on the host.
@@ -181,7 +185,7 @@
 	strip util/addnote
 	strip --remove-section=.comment --remove-section=.note util/addnote
 
-install: all strip
+install: all 
 	install -d -o root -g root -m 0755 ${ROOT}/etc/
 	install -d -o root -g root -m 0755 ${ROOT}/${PREFIX}/sbin/
 	install -d -o root -g root -m 0755 ${ROOT}/${PREFIX}/lib
Description: support cell platform
Origin: other, https://launchpad.net/ubuntu/+source/yaboot
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/ybin/ofpath
+++ b/ybin/ofpath
@@ -906,6 +906,8 @@
     SUBARCH=Maple
 elif (cat /proc/cpuinfo 2>/dev/null | grep ^machine | grep -q 'CHRP Pegasos') ; then
     SUBARCH=Pegasos
+elif (cat /proc/cpuinfo 2>/dev/null | grep ^platform | grep -q 'Cell') ; then
+    SUBARCH=Cell
 else
     echo 1>&2 "$PRG: This machine is not yet supported"
     exit 1
@@ -929,7 +931,7 @@
 ## use appropriate search for right sub arch.
 case "$SUBARCH" in
     # Pegasos OF seems to be NewWorld-ish enough to cope with this.
-    NewWorld|Pegasos)
+    NewWorld|Pegasos|Cell)
 	newworld || exit 1
 	;;
     OldWorld)
--- a/ybin/ybin
+++ b/ybin/ybin
@@ -79,6 +79,8 @@
     fstype=raw
 elif (cat /proc/cpuinfo 2> /dev/null | grep ^platform | grep -q 'Maple') ; then
     fstype=raw
+elif (cat /proc/cpuinfo 2> /dev/null | grep ^platform | grep -q 'Cell') ; then
+    fstype=raw
 else
     fstype=hfs
 fi
@@ -518,6 +520,8 @@
 	ADDNOTE=yes
     elif (cat /proc/cpuinfo 2> /dev/null | grep ^platform | grep -q 'Maple') ; then
 	true
+    elif (cat /proc/cpuinfo 2> /dev/null | grep ^platform | grep -q 'Cell') ; then
+	nonvram=1
     else
 	#echo 1>&2 "$PRG: Warning: Unknown archetecture, $boot may not be bootable on this machine"
 	[ "$nonvram" = 0 ] && echo 1>&2 "$PRG: Warning: Unknown architecture, nvram will not be updated"
--- a/first/ofboot
+++ b/first/ofboot
@@ -336,7 +336,7 @@
 $BGCOLOR to background-color
 \" \"(0C)\" .printf
 
-\" First Stage GNU/Linux Bootstrap\"(0d 0a)\" .printf
+\" First Stage Debian GNU/Linux Bootstrap\"(0d 0a)\" .printf
 \"  \"(0d 0a)\" .printf
 $MENUOPTS
 \"  \"(0d 0a)\" .printf
--- a/COPYING
+++ b/COPYING
@@ -2,7 +2,7 @@
 		       Version 2, June 1991
 
  Copyright (C) 1989, 1991 Free Software Foundation, Inc.
-     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+     51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  Everyone is permitted to copy and distribute verbatim copies
  of this license document, but changing it is not allowed.
 
Description: Get scsi, sata, and firewire drive info from sysfs 
 as legacy /proc/scsi interface does not exist anymore.
 Added support for pata-macio on 2011-08-04.
Last-Update: 2011-08-04
Bug-Debian: http://bugs.debian.org/608384
Bug-Debian: http://bugs.debian.org/572869
Bug-Debian: http://bugs.debian.org/377097
Bug-Debian: http://bugs.debian.org/342833
Bug-Debian: http://bugs.debian.org/289201
Author: Milan Kupcevic <milan@physics.harvard.edu>
Forwarded: http://patchwork.ozlabs.org/patch/108566/
--- a/ybin/ofpath
+++ b/ybin/ofpath
@@ -3,6 +3,9 @@
 ###############################################################################
 ##
 ## ofpath: determine OpenFirmware path from unix device node
+##
+## Copyright (C) 2010, 2011 Milan Kupcevic
+##
 ## Copyright (C) 2000, 2001, 2002, 2003 Ethan Benson
 ##
 ## Portions based on show_of_path.sh:
@@ -27,7 +30,7 @@
 
 PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"
 PRG="${0##*/}"
-VERSION=1.0.7
+VERSION=1.0.7+debian2
 DEBUG=0
 export LC_COLLATE=C
 
@@ -36,9 +39,10 @@
 {
 echo \
 "$PRG $VERSION
-Written by Ethan Benson
+Written by Ethan Benson, portions rewritten by Milan Kupcevic
 Portions based on show_of_path.sh written by Olaf Hering
 
+Copyright (C) 2010, 2011 Milan Kupcevic
 Copyright (C) 2000, 2001, 2002, 2003 Ethan Benson
 Portions Copyright (C) 2000 Olaf Hering
 This is free software; see the source for copying conditions.  There is NO
@@ -181,158 +185,125 @@
     return 0
 }
 
+# read OpenFirmware device path from its corresponding devspec
+find_of_path()
+{
+  [ -z "$1" ] && return
+  [ -f "$1/devspec" ] && {
+    OF_PATH="`cat $1/devspec`"
+    SYS_PATH="$1"
+    return
+  }
+  find_of_path "${1%/*}"
+}
+
 ## this finds information we need on both newworld and oldworld macs.
 ## mainly what scsi host a disk is attached to.
 scsiinfo()
 {
-    ## see if system has scsi at all
-    if [ ! -f /proc/scsi/scsi ] ; then
-	local kver="$(uname -r)"
-	case "$kver" in
-	    2.5.*|2.6.*)
-		if [ -d /sys/bus/scsi/devices -a \
-		    -n "$(ls /sys/bus/scsi/devices 2>/dev/null)" ] ; then
-		    echo 1>&2 "$PRG: /proc/scsi/scsi does not exist"
-		    echo 1>&2 "$PRG: Make sure you compiled your kernel with CONFIG_SCSI_PROC_FS=y"
-		    return 1
-		fi
-		;;
-	esac
-	echo 1>&2 "$PRG: /dev/$DEVNODE: Device not configured"
-	return 1
-    fi
-
-    ## first we have to figure out the SCSI ID, have to do that
-    ## anyway [to] find the attached scsi disks = "Direct-Access" and
-    ## stop at sda=1 sdb=2 or whatever count in 3 lines steps
-
-    ## get last letter of device node, ie sda -> a
-    SUBNODE=${DEVNODE##*sd}
-
-    ## turn SUBNODE above into a number starting at 1, ie a -> 1
-    SUBDEV="$(smalltr $SUBNODE)"
-    [ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: SUBNODE=$SUBNODE SUBDEV=$SUBDEV"
-
-    DEVCOUNT=0
-
-    ## copy scsi file into a variable removing "Attached Devices"
-    ## which is the first line. this avoids a lot of
-    ## [incmopatible] crap later, and improves readability.
-
-    ## find number of lines once and recycle that number, to save
-    ## some time (linecount is a bit slow). subtract one line
-    ## to scrap Attached Devices:
-
-    SCSILINES="$(($(linecount /proc/scsi/scsi) - 1))"
-
-    if [ "$SUBDEV" -gt "$(cat /proc/scsi/scsi | grep Direct-Access | linecount)" ] ; then
-	echo 1>&2 "$PRG: /dev/$DEVNODE: Device not configured"
-	return 1
-    fi
-
-    PROCSCSI="$(cat /proc/scsi/scsi | tail -n $SCSILINES)"
-
-    for i in $(smallseq $(($SCSILINES / 3))) ; do
-
-	## put every scsi device into one single line
-	DEVINFO="$(echo "$PROCSCSI" | head -n $(($i * 3)) | tail -n 3)"
-	[ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: DEVINFO=$DEVINFO"
-
-	## cut the type field, expect "Direct-Access" later.
-	DEVTYPE="$(v=$(echo ${DEVINFO##*Type: }) ; echo ${v%% *})"
-	[ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: DEVTYPE=$DEVTYPE"
-
-	## get the device id.
-	DEVID="$(v=$(echo ${DEVINFO##*Id: }) ; n=$(echo ${v%% *}) ; echo ${n#*0})"
-	[ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: DEVID=$DEVID"
-
-	## get the scsi host id.
-	DEVHOST="$(v=$(echo ${DEVINFO##*Host: scsi}) ; echo ${v%% *})"
-	[ "$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_ID=$DEVID
-		[ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: DEVICE_HOST=$DEVICE_HOST"
-		break
-	    fi
-	fi
-    done
-
-    ## 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%%/*})"
-    [ "$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%%:*})"
-    [ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: SCSI_HOSTNUMBER=$SCSI_HOSTNUMBER"
+  SYS_DEVICE="`readlink -f /sys/block/$DEVNODE/device`"
 
+  [ -e "$SYS_DEVICE" ] && {
+ 
+    SCSI_DEVICE=${SYS_DEVICE##*/}
+    HOST_ID=${SCSI_DEVICE%%:*}
+    BUS_ID=`T=${SCSI_DEVICE#*:}; echo ${T%%:*}`
+    DEVICE_ID=`T=${SCSI_DEVICE#*:*:}; echo ${T%%:*}`
+    LUN_ID=${SCSI_DEVICE##*:}
+
+    OF_PATH=;find_of_path "$SYS_DEVICE"
+
+    SCSI_DRIVER=`cat /sys/class/scsi_host/host$HOST_ID/proc_name 2>/dev/null`
+
+    SCSI_NAME=`cat /proc/device-tree$OF_PATH/name 2>/dev/null`
+
+    IEEE1394_ID=`cat /sys/block/$DEVNODE/device/ieee1394_id 2>/dev/null`
+    IEEE1394_ID=${IEEE1394_ID%%:*}
+
+    PLUG_ID=$(ls -dv $SYS_PATH/host* 2>/dev/null | grep -n "/host$HOST_ID$")
+    PLUG_ID=$((${PLUG_ID%%:*}-1))
+
+    PART=${PARTITION:+:$PARTITION}
+
+    [ "$LUN_ID" != "0" ] && LUNX=`printf ",%x" $LUN_ID`
+
+    [ "$DEBUG" = "1" ] && {
+      echo SYS_DEVICE=$SYS_DEVICE
+      echo SCSI_DEVICE=$SCSI_DEVICE
+      echo HOST_ID=$HOST_ID
+      echo BUS_ID=$BUS_ID
+      echo DEVICE_ID=$DEVICE_ID
+      echo LUN_ID=$LUN_ID
+      echo PLUG_ID=$PLUG_ID
+      echo IEEE1394_ID=$IEEE1394_ID
+      echo SCSI_NAME=$SCSI_NAME
+      echo SCSI_DRIVER=$SCSI_DRIVER
+      echo SYS_PATH=$SYS_PATH
+      echo OF_PATH=$OF_PATH
+      echo PART=$PART
+      echo LUNX=$LUNX
+    }
+ 
+    SCSI_DRIVER=${SCSI_DRIVER:?}
+ 
+    [ -z "$OF_PATH" ] && {
+      echo 1>&2 "Cannot find $DEVNODE among OpenFirmware registered devices"
+ 
+      exit 1
+    }
+ 
     return 0
+  }
+ 
+  echo 1>&2 "Link /sys/block/$DEVNODE/device does not exist"
+ 
+  exit 1
 }
 
-## generic function that can find OF device paths for scsi devices,
+## add OF device node to the host OF path,
 ## must be run after scsiinfo().
 scsi_ofpath()
 {
-    case "$SCSI_DRIVER" in
-	aic7xxx)
-	    HOST_LIST="$(for i in `find /proc/device-tree -name compatible` ; do
-			lgrep "$i" "^ADPT" "^pci900[45]" "^pciclass,01000" ; done)"
-	    DEVICE_PATH="$(printhost $SCSI_HOSTNUMBER $HOST_LIST)"
-	    echo "${DEVICE_PATH##*device-tree}/@$DEVICE_ID:$PARTITION"
-	    ;;
-	sym53c8xx)
-	    HOST_LIST="$(for i in `find /proc/device-tree -name compatible` ; do
-			lgrep "$i" "^Symbios" "^pci1000" "^pciclass,01000" ; done)"
-	    DEVICE_PATH="$(printhost $SCSI_HOSTNUMBER $HOST_LIST)"
-	    echo "${DEVICE_PATH##*device-tree}/@$DEVICE_ID:$PARTITION"
-	    ;;
-	mesh)
-	    HOST_LIST="$(for i in `find /proc/device-tree -name compatible` ; do
-			lgrep "$i" "mesh" ; done)"
-	    DEVICE_PATH="$(printhost $SCSI_HOSTNUMBER $HOST_LIST)"
-	    echo "${DEVICE_PATH##*device-tree}/@$DEVICE_ID:$PARTITION"
-	    ;;
-	ata_k2|sata_svw)
-            #Not all G5 device trees have a compatible "k2-sata" node 
-            #per channel use parent
-	    HOST_LIST="$(for i in `find /proc/device-tree -name compatible ` ; do
-			lgrep "$i" "k2-s-ata" ; done | sort)"
-	    DEVICE_PATH="$(printhost $SCSI_HOSTNUMBER $HOST_LIST)"
-	    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)
-            HOST_LIST="$(for i in `find /proc/device-tree -name name | grep usb` ; do
-                        lgrep "$i" "disk" ; done)"
-            DEVICE_PATH="$(printhost $SCSI_HOSTNUMBER $HOST_LIST)"
-            echo "${DEVICE_PATH##*device-tree}:$PARTITION"
-	    ;;
-	sbp2|"")
-            # sbp-2 driver may not have a dir in /proc/scsi
-            HOST_LIST="$(for i in `find /proc/device-tree -name name` ; do
-                        lgrep "$i" "sbp-2" ; done)"
-            if [ "$SCSI_HOSTNUMBER" = "" ] ; then
-                SCSI_HOSTNUMBER=1
-            fi
-            DEVICE_PATH="$(printhost $SCSI_HOSTNUMBER $HOST_LIST)"
-            echo "${DEVICE_PATH##*device-tree}/disk@0:$PARTITION"
-	    ;;
-	*)
-	    echo 1>&2 "$PRG: Driver: $SCSI_DRIVER is not supported"
-	    return 1
-	    ;;
+  if [ -d "/proc/device-tree$OF_PATH/sas" ] ; then
+
+    SAS_ID=$(( ($BUS_ID << 16) | ($DEVICE_ID << 8) | $LUN_ID))
+    printf "%s/sas/disk@%x%s\n" $OF_PATH $SAS_ID $LUNX$PART
+
+  elif [ -d "/proc/device-tree$OF_PATH/scsi@`printf %x $BUS_ID`" ] ; then
+
+    printf "%s/scsi@%x/@%x%s\n" $OF_PATH $BUS_ID $DEVICE_ID $LUNX$PART
+
+  else
+
+    case "$SCSI_DRIVER-$SCSI_NAME" in
+      aic7xxx-*|sym53c8xx-*|mesh-*|*-scsi)
+        printf "%s/@%x%s\n" $OF_PATH $DEVICE_ID $LUNX$PART
+        ;;
+      sata_sil-*|sata_vsc-*)
+        printf "%s/@%x%s\n" $OF_PATH $(($PLUG_ID * 2)) $PART
+        ;;
+      sata_svw-*|*-pci-ata)
+        printf "%s/@%x/@%x%s\n" $OF_PATH $PLUG_ID $DEVICE_ID $PART
+        ;;
+      pata_macio-*)
+        printf "%s/@%x%s\n" $OF_PATH $DEVICE_ID $PART
+        ;;
+      sbp2-*)
+        IEEE1394_ID=${IEEE1394_ID:?}
+        printf "%s/node@%s/sbp-2/@%x%s\n" $OF_PATH $IEEE1394_ID $DEVICE_ID $PART
+        ;;
+      ipr-obsidian)
+        printf "%s/@%x,%x%s\n" $OF_PATH $BUS_ID $DEVICE_ID $LUNX$PART
+        ;;
+      *)
+        echo 1>&2 "${PRG}: ${SCSI_NAME} (${SCSI_DRIVER}) is not supported"
+        return 1
+        ;;
     esac
-    return 0
+
+  fi
+
+  return 0
 }
 
 ide_ofpath()
@@ -432,11 +403,11 @@
 
 	case "$DEVNODE" in
 	    hda|hdc|hde|hdg|hdi|hdk|hdm|hdo)
-		echo "${DEVSPEC}${MASTER}:$PARTITION"
+		echo "${DEVSPEC}${MASTER}${PARTITION:+:${PARTITION}}"
 		return 0
 		;;
 	    hdb|hdd|hdf|hdh|hdj|hdl|hdn|hdp)
-		echo "${DEVSPEC}${SLAVE}:$PARTITION"
+		echo "${DEVSPEC}${SLAVE}${PARTITION:+:${PARTITION}}"
 		return 0
 		;;
 	    *)
Description: Support persistent device naming symlinks, UUID, and LABEL tags 
 in addition to openfirmware paths and aliases as traditional Unix block 
 device names are not persistent anymore.
Last-Update: 2011-08-04
Bug-Debian: http://bugs.debian.org/615602
Bug-Debian: http://bugs.debian.org/580455
Author: Milan Kupcevic <milan@physics.harvard.edu> 
Forwarded: http://patchwork.ozlabs.org/patch/108567/
--- a/ybin/yabootconfig
+++ b/ybin/yabootconfig
@@ -27,7 +27,7 @@
     PATH="${PATH}:${PATH_PREFIX}/sbin:${PATH_PREFIX}/bin:${PATH_PREFIX}/usr/sbin:${PATH_PREFIX}/usr/bin:${PATH_PREFIX}/usr/local/sbin:${PATH_PREFIX}/usr/local/bin"
 fi
 PRG="${0##*/}"
-VERSION=1.0.8
+VERSION=1.0.8+debian2
 CHROOT=/
 ## $CONFIG is relative to $CHROOT
 CONFIG=etc/yaboot.conf
@@ -732,6 +732,27 @@
     INITRDIMGS="\tinitrd=$INITRDIMG\n\tinitrd-size=8192\n"
 fi
 
+## Get a symlink which always points to the correct block device.
+## If it does not exist, give the unix block device name back.
+devsymlink() {
+  [ "$2" != "nobyid" ] && BYID="/dev/disk/by-id/scsi* /dev/disk/by-id/*"
+  for SYMLINK in $BYID /dev/disk/by-uuid/* /dev/disk/by-label/*; do
+    [ "`readlink -f "$SYMLINK"`" = "$1" ] && {
+      echo $SYMLINK
+      return
+    }
+  done
+  echo $1
+}
+
+## Get UUID= or LABEL= for the given unix partition block device.
+## If it could not be determined, give the unix partition block device back.
+uuidlabel() {
+  echo `devsymlink "$1" nobyid` \
+  | sed -e "s,/dev/disk/by-uuid/,UUID=," \
+        -e "s,/dev/disk/by-label/,LABEL=,"
+}
+
 ## generate global section of yaboot.conf
 GLOBAL="## yaboot.conf generated by $PRG $VERSION
 ##
@@ -739,9 +760,9 @@
 ${HEADER}##
 ## For a dual-boot menu, add one or more of:
 ## bsd=/dev/hdaX, macos=/dev/hdaY, macosx=/dev/hdaZ\n
-boot=${BOOT}${DEVICE:-}
+boot=\"`devsymlink "${BOOT}"`\"${DEVICE:-}
 partition=$PARTITION
-root=$ROOT
+root=\"`uuidlabel "${ROOT}"`\"
 timeout=30
 install=${INSTALL}${OFBOOT:-}\n"
 
--- a/ybin/ybin
+++ b/ybin/ybin
@@ -1647,6 +1647,12 @@
     exit 1
 fi
 
+## also accept quoted symlink names
+for v in boot bsd macos macosx darwin ; do
+  eval $v="\`echo \$$v | tr -d '\"'\`"
+  eval [ -h \"\$$v\" ] \&\& $v="\`readlink -f \$$v\`"
+done
+
 ## if there is still no config file use the automatic generation to make a
 ## generic yaboot.conf. do this before the confcheck to avoid wierd errors.
 if [ "$bootconf" = /dev/null ] ; then
Description: correct spelling/typo
Author: Milan Kupcevic <milan@physics.harvard.edu>
Forwarded: no
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/second/prom.c
+++ b/second/prom.c
@@ -216,7 +216,7 @@
      else if (!strcmp(tmp, "network"))
 	  return FILE_DEVICE_NET;
      else {
-	  prom_printf("Unkown device type <%s>\n", tmp);
+	  prom_printf("Unknown device type <%s>\n", tmp);
 	  return FILE_ERR_BADDEV;
      }
 }
Description: Support for YDL PowerStation
Bug-Debian: http://bugs.debian.org/603894
Author: Milan Kupcevic <milan@physics.harvard.edu>
Forwarded: http://patchwork.ozlabs.org/patch/111893/
--- a/ybin/ofpath
+++ b/ybin/ofpath
@@ -30,7 +30,7 @@
 
 PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"
 PRG="${0##*/}"
-VERSION=1.0.7+debian2
+VERSION=1.0.7+debian3
 DEBUG=0
 export LC_COLLATE=C
 
@@ -899,6 +899,8 @@
     SUBARCH=OldWorld
 elif (cat /proc/cpuinfo 2> /dev/null | grep ^machine | grep -q 'CHRP IBM') ; then
     SUBARCH=CHRP
+elif (cat /proc/cpuinfo 2> /dev/null | grep ^platform | grep -q 'Maple') ; then
+    SUBARCH=Maple
 elif (cat /proc/cpuinfo 2>/dev/null | grep ^machine | grep -q 'CHRP Pegasos') ; then
     SUBARCH=Pegasos
 else
@@ -930,7 +932,7 @@
     OldWorld)
 	oldworld || exit 1
 	;;
-    CHRP)
+    CHRP|Maple)
 	chrp || exit 1
 	;;
 esac
--- a/ybin/ybin
+++ b/ybin/ybin
@@ -77,6 +77,8 @@
     fstype=raw
 elif (cat /proc/cpuinfo 2> /dev/null | grep ^platform | grep -q 'PowerNV') ; then
     fstype=raw
+elif (cat /proc/cpuinfo 2> /dev/null | grep ^platform | grep -q 'Maple') ; then
+    fstype=raw
 else
     fstype=hfs
 fi
@@ -514,6 +516,8 @@
 	## IBM hardware does not need nvram update AFAICT
 	nonvram=1
 	ADDNOTE=yes
+    elif (cat /proc/cpuinfo 2> /dev/null | grep ^platform | grep -q 'Maple') ; then
+	true
     else
 	#echo 1>&2 "$PRG: Warning: Unknown archetecture, $boot may not be bootable on this machine"
 	[ "$nonvram" = 0 ] && echo 1>&2 "$PRG: Warning: Unknown architecture, nvram will not be updated"
@@ -1157,6 +1161,20 @@
 	return 1
     fi
     sync ; sync
+
+    ## update the boot-device variable in OF nvram.
+    if [ "$nonvram" = 0 ] ; then
+	chrp_ofboot=${ofboot%%:*}
+	[ "$VERBOSE" = 1 ] && echo "$PRG: Updating OpenFirmware boot-device variable in nvram..."
+	[ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: boot-device=${chrp_ofboot}"
+	nvsetenv boot-device "${chrp_ofboot}"
+	if [ $? != 0 ] ; then
+	    echo 1>&2 "$PRG: An error occured while updating nvram, we'll ignore it"
+	fi
+    else
+	echo 1>&2 "$PRG: Warning: You must manually configure OpenFirmware to boot."
+    fi
+
     [ "$VERBOSE" = 1 ] && echo "$PRG: Installation successful"
     return 0
 }

Reply to: