Patches for the forthcoming 1.3.14 release

Daniel Ostrow dostrow at gentoo.org
Mon Feb 13 15:58:31 EST 2006


All:

Per Paul Nasrat's request please below a diff against the 1.3.14rc1
tarball on yaboot.ozlabs.org. This patch comprises the sum total of the
patches Gentoo applied to the 1.3.13 release.

The patches do the following:

1). Add support for disabling ssp and pie with appropriate checks.
2). Add yaboot.chrp (a copy of yaboot with addnote run over it) to the
default install.
3). Add usb-storage and sbp2 support to ofpath as well as provide a
small fix to the k2-sata portion of the script.
4). Add a dualboot option to yabootconfig to attempt to locate MacOS and
MacOS X installs.
5). I took the liberty to bump the VERSION in all the appropriate
scripts.

Thanks,

-- 
Daniel Ostrow
Gentoo Foundation Board of Trustees
Gentoo/{PPC,PPC64,DevRel}
dostrow at gentoo.org

Signed-off-by: Daniel Ostrow <dostrow at gentoo.org>

diff -Naur yaboot-1.3.14rc1.orig/Config yaboot-1.3.14rc1/Config
--- yaboot-1.3.14rc1.orig/Config	2006-02-09 21:08:33.000000000 -0500
+++ yaboot-1.3.14rc1/Config	2006-02-12 17:07:27.000000000 -0500
@@ -27,4 +27,13 @@
 
 # Local Variables:
 # mode: makefile
+
+# Check to see if pie and ssp need to be disabled.
+#
+check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
+       then echo "$(1)"; else echo "$(2)"; fi)
+
+CFLAGS     += $(call check_gcc, -fno-stack-protector)
+CFLAGS     += $(call check_gcc, -nopie)
+
 # End:
diff -Naur yaboot-1.3.14rc1.orig/lib/ssp.c yaboot-1.3.14rc1/lib/ssp.c
--- yaboot-1.3.14rc1.orig/lib/ssp.c	1969-12-31 19:00:00.000000000 -0500
+++ yaboot-1.3.14rc1/lib/ssp.c	2006-02-12 17:09:57.000000000 -0500
@@ -0,0 +1,18 @@
+unsigned long __guard = 0UL;
+static void __guard_setup (void) __attribute__ ((constructor));
+void __stack_smash_handler (char func[], int damaged
+                           __attribute__ ((unused)));
+static void
+__guard_setup (void)
+{
+  if (__guard != 0UL)
+    return;
+  __guard = 0xFF0A0D00UL;
+}
+
+void
+__stack_smash_handler (char func[], int damaged)
+{
+  return;
+}
+
diff -Naur yaboot-1.3.14rc1.orig/Makefile yaboot-1.3.14rc1/Makefile
--- yaboot-1.3.14rc1.orig/Makefile	2006-02-09 21:08:33.000000000 -0500
+++ yaboot-1.3.14rc1/Makefile	2006-02-12 17:37:38.000000000 -0500
@@ -2,7 +2,7 @@
 
 include Config
 
-VERSION = 1.3.13
+VERSION = 1.3.14
 # Debug mode (spam/verbose)
 DEBUG = 0
 # make install vars
@@ -84,7 +84,7 @@
 OBJS = second/crt0.o second/yaboot.o second/cache.o second/prom.o second/file.o \
 	second/partition.o second/fs.o second/cfg.o second/setjmp.o second/cmdline.o \
 	second/fs_of.o second/fs_ext2.o second/fs_iso.o second/iso_util.o \
-	lib/nosys.o lib/string.o lib/strtol.o lib/vsprintf.o lib/ctype.o lib/malloc.o lib/strstr.o
+	lib/nosys.o lib/string.o lib/strtol.o lib/vsprintf.o lib/ctype.o lib/malloc.o lib/strstr.o lib/ssp.o
 
 ifeq ($(USE_MD5_PASSWORDS),y)
 OBJS += second/md5.o
@@ -103,9 +103,11 @@
 
 all: yaboot addnote mkofboot
 
-yaboot: $(OBJS)
+yaboot: $(OBJS) addnote
 	$(LD) $(LFLAGS) $(OBJS) $(LLIBS) $(lgcc) -o second/$@
 	chmod -x second/yaboot
+	cp second/yaboot second/yaboot.chrp
+	util/addnote second/yaboot.chrp
 
 addnote:
 	$(CC) $(UCFLAGS) -o util/addnote util/addnote.c
@@ -185,6 +187,7 @@
 	install -d -o root -g root -m 0755 ${ROOT}/${PREFIX}/${MANDIR}/man5/
 	install -d -o root -g root -m 0755 ${ROOT}/${PREFIX}/${MANDIR}/man8/
 	install -o root -g root -m 0644 second/yaboot ${ROOT}/$(PREFIX)/lib/yaboot
+	install -o root -g root -m 0644 second/yaboot.chrp ${ROOT}/$(PREFIX)/lib/yaboot
 	install -o root -g root -m 0755 util/addnote ${ROOT}/${PREFIX}/lib/yaboot/addnote
 	install -o root -g root -m 0644 first/ofboot ${ROOT}/${PREFIX}/lib/yaboot/ofboot
 	install -o root -g root -m 0755 ybin/ofpath ${ROOT}/${PREFIX}/sbin/ofpath
diff -Naur yaboot-1.3.14rc1.orig/ybin/mkofboot yaboot-1.3.14rc1/ybin/mkofboot
--- yaboot-1.3.14rc1.orig/ybin/mkofboot	2006-02-09 21:08:33.000000000 -0500
+++ yaboot-1.3.14rc1/ybin/mkofboot	2006-02-12 17:36:04.000000000 -0500
@@ -29,7 +29,7 @@
 PRG="${0##*/}"
 ABSPRG="$0"
 SIGINT="$PRG: Interrupt caught ... exiting"
-VERSION=1.3.13
+VERSION=1.3.14
 DEBUG=0
 VERBOSE=0
 TMP="${TMPDIR:-/tmp}"
diff -Naur yaboot-1.3.14rc1.orig/ybin/ofpath yaboot-1.3.14rc1/ybin/ofpath
--- yaboot-1.3.14rc1.orig/ybin/ofpath	2006-02-09 21:08:33.000000000 -0500
+++ yaboot-1.3.14rc1/ybin/ofpath	2006-02-12 17:36:16.000000000 -0500
@@ -9,6 +9,9 @@
 ##
 ## Copyright (C) 2000 Olaf Hering <olh at suse.de>
 ## 
+## sbp2 support:
+## Copyright (C) 2004 Christiaan Welvaart <cjw at time4t.net>
+##
 ## This program is free software; you can redistribute it and/or
 ## modify it under the terms of the GNU General Public License
 ## as published by the Free Software Foundation; either version 2
@@ -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.8
 DEBUG=0
 export LC_COLLATE=C
 
@@ -301,7 +304,52 @@
 	    HOST_LIST="$(for i in `find /proc/device-tree -name compatible ` ; do
 			lgrep "$i" "k2-sata" ; done | sort)"
 	    DEVICE_PATH="$(printhost $SCSI_HOSTNUMBER $HOST_LIST)"
-	    echo "${DEVICE_PATH##*device-tree}/disk at 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 at 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 at 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 at 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"
diff -Naur yaboot-1.3.14rc1.orig/ybin/yabootconfig yaboot-1.3.14rc1/ybin/yabootconfig
--- yaboot-1.3.14rc1.orig/ybin/yabootconfig	2006-02-09 21:08:33.000000000 -0500
+++ yaboot-1.3.14rc1/ybin/yabootconfig	2006-02-12 17:35:50.000000000 -0500
@@ -5,6 +5,8 @@
 ## yabootconfig generates a simple /etc/yaboot.conf
 ## Copyright (C) 2001, 2002, 2003 Ethan Benson
 ##
+## Patched for dual boot - Mark Guertin <gerk at gentoo.org>
+##
 ## This program is free software; you can redistribute it and/or
 ## modify it under the terms of the GNU General Public License
 ## as published by the Free Software Foundation; either version 2
@@ -27,7 +29,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.9
 CHROOT=/
 ## $CONFIG is relative to $CHROOT
 CONFIG=etc/yaboot.conf
@@ -264,6 +266,31 @@
     return 0
 }
 
+dualboot()
+{
+    DRIVELIST=`ls -d /dev/?d?* | grep "[sh]d[abcdefghijkl]" | cut -b 6-8 | sort -u`
+
+    for i in $DRIVELIST
+    do
+        HFS=`mac-fdisk -l "/dev/$i" | grep '\<Apple_HFS\>' | grep -v "CDROM" | cut -d" " -f1`
+        for h in $HFS
+        do
+            if [ !-x `hpmount -r $h` > /dev/null 2>&1 ] ; then
+                if [ `hpls mach_kernel 2>/dev/null` ] ; then
+                    [ "$QUIET" = 0 ] && echo "Found possible OS X/Darwin partition at $h"
+                    OSX=$h
+                fi
+                if [ "`hpls "System Folder" 2>/dev/null`" ] ; then
+                    [ "$QUIET" = 0 ] && echo "Found possible Mac OS partition at $h"
+                    MACOS=$h
+                fi
+                hpumount $h > /dev/null 2>&1
+            fi
+        done
+    done
+}
+
+
 ##########
 ## Main ##
 ##########
diff -Naur yaboot-1.3.14rc1.orig/ybin/ybin yaboot-1.3.14rc1/ybin/ybin
--- yaboot-1.3.14rc1.orig/ybin/ybin	2006-02-09 21:08:33.000000000 -0500
+++ yaboot-1.3.14rc1/ybin/ybin	2006-02-12 17:36:04.000000000 -0500
@@ -29,7 +29,7 @@
 PRG="${0##*/}"
 ABSPRG="$0"
 SIGINT="$PRG: Interrupt caught ... exiting"
-VERSION=1.3.13
+VERSION=1.3.14
 DEBUG=0
 VERBOSE=0
 TMP="${TMPDIR:-/tmp}"





More information about the Yaboot-devel mailing list