summaryrefslogtreecommitdiff
path: root/sys-boot/yaboot/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /sys-boot/yaboot/files
reinit the tree, so we can have metadata
Diffstat (limited to 'sys-boot/yaboot/files')
-rw-r--r--sys-boot/yaboot/files/chrpfix.patch23
-rw-r--r--sys-boot/yaboot/files/new-ofpath143
-rw-r--r--sys-boot/yaboot/files/new-ofpath-devspec.patch28
-rw-r--r--sys-boot/yaboot/files/sysfs-ofpath.patch105
-rw-r--r--sys-boot/yaboot/files/yaboot-1.3.16-memalign.patch41
-rw-r--r--sys-boot/yaboot/files/yaboot-1.3.17-nopiessp-gcc4.patch38
-rw-r--r--sys-boot/yaboot/files/yaboot-nopiessp-gcc4.patch38
-rw-r--r--sys-boot/yaboot/files/yaboot-stubfuncs.patch231
-rw-r--r--sys-boot/yaboot/files/yabootconfig-1.3.13.patch42
9 files changed, 689 insertions, 0 deletions
diff --git a/sys-boot/yaboot/files/chrpfix.patch b/sys-boot/yaboot/files/chrpfix.patch
new file mode 100644
index 000000000000..e64369ba899a
--- /dev/null
+++ b/sys-boot/yaboot/files/chrpfix.patch
@@ -0,0 +1,23 @@
+--- Makefile.orig 2004-03-22 12:04:32.056149336 -0600
++++ Makefile 2004-03-22 12:05:51.824138328 -0600
+@@ -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 --git a/sys-boot/yaboot/files/new-ofpath b/sys-boot/yaboot/files/new-ofpath
new file mode 100644
index 000000000000..5e395b251a8e
--- /dev/null
+++ b/sys-boot/yaboot/files/new-ofpath
@@ -0,0 +1,143 @@
+#!/bin/sh
+###############################################################################
+# Determines the Open Firmware path based on the linux device name
+#
+# Joseph Jezak <josejx@gentoo.org> Copyright (C) 2010
+# Rewrite of OFPath for newer kernels/scsi configurations
+#
+# 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
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+###############################################################################
+
+### Set this to 1 to turn on debugging messages
+DEBUG=0
+
+### Find the device tree
+if [ ! -e /proc/device-tree ]; then
+ echo 1>&2 "ofpath: Cannot find the device tree!"
+ exit 1
+fi
+DEV_TREE="/proc/device-tree"
+
+### Check if sys is mounted
+if ! (grep -q '.* .* sysfs ' /proc/mounts 2> /dev/null) ; then
+ echo 1>&2 "ofpath: sysfs must be mounted for ofpath to support this system"
+ exit 1
+fi
+
+### Get the sysfs mount point
+SYS="$(m=`grep '.* .* sysfs ' /proc/mounts | head -n 1` ; echo `d=${m#* };echo ${d%% *}`)"
+if [ -z "$SYS" -o ! -d "$SYS" ] ; then
+ echo 1>&2 "ofpath: Unable to determine sysfs mountpoint"
+ exit 1
+fi
+
+
+### Get the device from the user
+### We dereference links to support devices like /dev/cdrom1
+DEVICE=$1
+if [ -z "$DEVICE" ]; then
+ echo 1>&2 "ofpath: No device specified!"
+ exit 1
+fi
+DEVICE=$(readlink -f "$DEVICE")
+DEVICE=$(basename $DEVICE)
+if [ -z "$DEVICE" ] || [ ! -e "/dev/$DEVICE" ]; then
+ echo 1>&2 "ofpath: Invalid device: /dev/$DEVICE"
+ exit 1
+fi
+[ "$DEBUG" = 1 ] && echo "Device is: $DEVICE"
+
+### Get the partition if we have it
+case ${DEVICE} in
+ sd*) PARTITION="${DEVICE#sd?}" ;;
+ ### No partition for sr/sg devices
+ sr*|sg*) PARTITION="${DEVICE#sr?}" ;;
+ hd*) PARTITION="${DEVICE#hd?}" ;;
+ *) echo "Unknown device string."; exit 1;;
+esac
+if [ ! -z "$PARTITION" ] && [ "$DEBUG" = 1 ]; then
+ echo "Partition: $PARTITION"
+fi
+
+### Get the disk device name
+DISK_NAME="${DEVICE%%${PARTITION}}"
+[ "$DEBUG" = 1 ] && echo "Disk Name: $DISK_NAME"
+
+### Find the devspec for the controller
+DEVPATH=$(cd -P "$SYS/block/${DISK_NAME}/device" && pwd)
+if [ -z "$DEVPATH" ]; then
+ echo "Unable to determine device path!"
+ exit 1
+fi
+[ "$DEBUG" = 1 ] && echo "Devpath is: $DEVPATH"
+
+### Get the OF Path of the controller
+case ${DISK_NAME} in
+ sd*|sg*|sr*) CONTROLLER_PATH=$(cat ${DEVPATH}/../../../devspec) ;;
+ hd*) CONTROLLER_PATH=$(cat ${DEVPATH}/../../devspec) ;;
+ *) CONTROLLER_PATH="" ;;
+esac
+if [ -z "$CONTROLLER_PATH" ]; then
+ echo "Unable to determine controller path!"
+ exit 1
+fi
+[ "$DEBUG" = 1 ] && echo "Controller Path is: $CONTROLLER_PATH"
+
+### Generate the disk number and partition info
+case ${DISK_NAME} in
+ sd*|sg*|sr*)
+ DISK_NO="$(cd ${DEVPATH}/../; pwd)";
+ DISK_NO="${DISK_NO##*:}";
+ ;;
+ hd*)
+ DISK_NO="$(cd ${DEVPATH}/../; pwd)";
+ DISK_NO="${DISK_NO##*ide}";
+ ;;
+ *) echo "Unsupported disk type!"; exit 1 ;;
+esac
+DISK_NO="disk@${DISK_NO}:"
+[ "$DEBUG" = 1 ] && echo "Disk Number: ${DISK_NO}"
+
+### We need to get the controller port path (if it has one)
+if [ ! -d "$DEV_TREE/$CONTROLLER_PATH/disk" ] && [ ! -d "$DEV_TREE/$CONTROLLER_PATH/$DISK_NO" ]; then
+ ### FIXME I don't know if every scsi device uses the host nomenclature
+ case ${DISK_NAME} in
+ sd*|sg*|sr*)
+ PORT="$(cd ${DEVPATH}/../../; pwd)";
+ PORT="${PORT##*host}";
+ CTL_PORT="${CONTROLLER_PATH##*/}";
+ CTL_PORT="${CTL_PORT%%-root*}";
+ PORT="$CTL_PORT@$PORT"
+ [ "$DEBUG" = 1 ] && echo "Port: $PORT"
+ ;;
+ *) echo "Unsupported disk type!"; exit 1 ;;
+ esac
+fi
+
+### Add the partition information if required
+if [ ! -z $PARTITION ]; then
+ DISK_NO="$DISK_NO$PARTITION"
+fi
+
+### Build the OF Path
+if [ -z "$PORT" ]; then
+ OFPATH="$CONTROLLER_PATH/$DISK_NO"
+else
+ OFPATH="$CONTROLLER_PATH/${PORT}/$DISK_NO"
+fi
+
+### Print out the ofpath
+echo $OFPATH
diff --git a/sys-boot/yaboot/files/new-ofpath-devspec.patch b/sys-boot/yaboot/files/new-ofpath-devspec.patch
new file mode 100644
index 000000000000..ac03c15d8dd7
--- /dev/null
+++ b/sys-boot/yaboot/files/new-ofpath-devspec.patch
@@ -0,0 +1,28 @@
+--- ybin/ofpath.bak 2012-05-09 12:24:51.709911981 -0400
++++ ybin/ofpath 2012-05-09 12:32:19.661560544 -0400
+@@ -85,11 +85,20 @@
+ [ "$DEBUG" = 1 ] && echo "Devpath is: $DEVPATH"
+
+ ### Get the OF Path of the controller
+-case ${DISK_NAME} in
+- sd*|sg*|sr*) CONTROLLER_PATH=$(cat ${DEVPATH}/../../../devspec) ;;
+- hd*) CONTROLLER_PATH=$(cat ${DEVPATH}/../../devspec) ;;
+- *) CONTROLLER_PATH="" ;;
+-esac
++if [ -e "${DEVPATH}/../../devspec" ]; then
++ ### /dev/hd*
++ CONTROLLER_PATH=$(cat ${DEVPATH}/../../devspec);
++elif [ -e "${DEVPATH}/../../../devspec" ]; then
++ ### /dev/sd* on kernel <3.3
++ CONTROLLER_PATH=$(cat ${DEVPATH}/../../../devspec);
++elif [ -e "${DEVPATH}/../../../../devspec" ]; then
++ ### /dev/sd* on kernel 3.3+
++ CONTROLLER_PATH=$(cat ${DEVPATH}/../../../../devspec);
++else
++ ### None of the above...
++ CONTROLLER_PATH="";
++fi
++
+ if [ -z "$CONTROLLER_PATH" ]; then
+ echo "Unable to determine controller path!"
+ exit 1
diff --git a/sys-boot/yaboot/files/sysfs-ofpath.patch b/sys-boot/yaboot/files/sysfs-ofpath.patch
new file mode 100644
index 000000000000..7ebc0bfac86f
--- /dev/null
+++ b/sys-boot/yaboot/files/sysfs-ofpath.patch
@@ -0,0 +1,105 @@
+--- ybin/ofpath 2008-08-03 04:00:35.000000000 -0400
++++ ybin/ofpath 2009-01-09 13:46:12.000000000 -0500
+@@ -337,15 +337,18 @@
+
+ ide_ofpath()
+ {
+- if [ ! -L "/proc/ide/$DEVNODE" ] ; then
++ if [ ! -L "/proc/ide/$DEVNODE" ] && [ ! -e "/sys/block/$DEVNODE" ] ; then
+ echo 1>&2 "$PRG: /dev/$DEVNODE: Device not configured"
+ return 1
+ fi
+
+- local IDEBUS="$(v=`readlink /proc/ide/$DEVNODE` ; echo ${v%%/*} )"
+- if [ -z "$IDEBUS" ] ; then
+- echo 1>&2 "$PRG: BUG: IDEBUS == NULL"
+- return 1
++ if [ -L "/proc/ide/$DEVNODE" ] ; then
++ local USE_OLD_PROC=1
++ local IDEBUS="$(v=`readlink /proc/ide/$DEVNODE` ; echo ${v%%/*} )"
++ if [ -z "$IDEBUS" ] ; then
++ echo 1>&2 "$PRG: BUG: IDEBUS == NULL"
++ return 1
++ fi
+ fi
+
+ case "$(uname -r)" in
+@@ -363,7 +366,8 @@
+ echo 1>&2 "$PRG: Unable to determine sysfs mountpoint"
+ return 1
+ fi
+- local OF1275IDE="${SYS}/block/${DEVNODE}/device/../../devspec"
++ local OF1275IDE=$(cd -P "${SYS}/block/${DEVNODE}/device" && pwd)
++ OF1275IDE="${OF1275IDE}/../../devspec"
+ ;;
+ *)
+ local OF1275IDE="/proc/ide/$IDEBUS/devspec"
+@@ -402,34 +406,41 @@
+ return 1
+ fi
+
+- if [ ! -f "/proc/ide/${IDEBUS}/channel" ] ; then
+- echo 1>&2 "$PRG: KERNEL BUG: /proc/ide/${IDEBUS}/channel does not exist"
+- return 1
+- fi
+-
+- case "$(cat /proc/device-tree${DEVSPEC}/device_type 2> /dev/null)" in
+- ide|ata)
+- local MASTER="/disk@0"
+- local SLAVE="/disk@1"
+- ;;
+- pci-ide|pci-ata)
+- local MASTER="/@$(cat /proc/ide/${IDEBUS}/channel)/disk@0"
+- local SLAVE="/@$(cat /proc/ide/${IDEBUS}/channel)/disk@1"
+- ;;
+- scsi) ## some lame controllers pretend they are scsi, hopefully all kludges are created equal.
+- local MASTER="/@$(($(cat /proc/ide/${IDEBUS}/channel) * 2 + 0))"
+- local SLAVE="/@$(($(cat /proc/ide/${IDEBUS}/channel) * 2 + 1))"
+- ;;
+- spi)
+- local MASTER="/disk@$(cat /proc/ide/${IDEBUS}/channel),0"
+- local SLAVE="/disk@$(cat /proc/ide/${IDEBUS}/channel),1"
+- ;;
+- *)
+- echo 1>&2 "$PRG: Unsupported IDE device type: \"$(cat /proc/device-tree${DEVSPEC}/device_type 2> /dev/null)\""
+- return 1
+- ;;
+- esac
++
++ if [ "${USE_OLD_PROC}" = "1" ] ; then
++ if [ ! -f "/proc/ide/${IDEBUS}/channel" ] ; then
++ echo 1>&2 "$PRG: KERNEL BUG: /proc/ide/${IDEBUS}/channel does not exist"
++ return 1
++ fi
+
++ case "$(cat /proc/device-tree${DEVSPEC}/device_type 2> /dev/null)" in
++ ide|ata)
++ local MASTER="/disk@0"
++ local SLAVE="/disk@1"
++ ;;
++ pci-ide|pci-ata)
++ local MASTER="/@$(cat /proc/ide/${IDEBUS}/channel)/disk@0"
++ local SLAVE="/@$(cat /proc/ide/${IDEBUS}/channel)/disk@1"
++ ;;
++ scsi) ## some lame controllers pretend they are scsi, hopefully all kludges are created equal.
++ local MASTER="/@$(($(cat /proc/ide/${IDEBUS}/channel) * 2 + 0))"
++ local SLAVE="/@$(($(cat /proc/ide/${IDEBUS}/channel) * 2 + 1))"
++ ;;
++ spi)
++ local MASTER="/disk@$(cat /proc/ide/${IDEBUS}/channel),0"
++ local SLAVE="/disk@$(cat /proc/ide/${IDEBUS}/channel),1"
++ ;;
++ *)
++ echo 1>&2 "$PRG: Unsupported IDE device type: \"$(cat /proc/device-tree${DEVSPEC}/device_type 2> /dev/null)\""
++ return 1
++ ;;
++ esac
++ else
++ ### I don't know what other disks would look like... FIXME
++ local MASTER="/disk@0"
++ local SLAVE="/disk@1"
++ fi
++
+ case "$DEVNODE" in
+ hda|hdc|hde|hdg|hdi|hdk|hdm|hdo)
+ echo "${DEVSPEC}${MASTER}:$PARTITION"
diff --git a/sys-boot/yaboot/files/yaboot-1.3.16-memalign.patch b/sys-boot/yaboot/files/yaboot-1.3.16-memalign.patch
new file mode 100644
index 000000000000..0fe4e250f292
--- /dev/null
+++ b/sys-boot/yaboot/files/yaboot-1.3.16-memalign.patch
@@ -0,0 +1,41 @@
+diff -uNr yaboot/lib/malloc.c yaboot-1.3.16//lib/malloc.c
+--- yaboot/lib/malloc.c 2010-07-09 03:18:17.000000000 +0100
++++ yaboot-1.3.16//lib/malloc.c 2011-01-23 16:57:13.000000000 +0000
+@@ -42,6 +42,37 @@
+ last_alloc = 0;
+ }
+
++static char *align_ptr_to(char *ptr, unsigned long align)
++{
++ return (char *)((((unsigned long)ptr) + (align - 1UL)) &
++ ~(align - 1UL));
++}
++
++int posix_memalign(void **memptr, unsigned long alignment, unsigned long size)
++{
++ char *caddr;
++
++ if (alignment & (alignment - 1UL))
++ return -1;
++
++ if (alignment & (sizeof(void *) - 1UL))
++ return -1;
++
++ if (size == 0)
++ {
++ *memptr = (void *)0;
++ return 0;
++ }
++
++ caddr = align_ptr_to(malloc_ptr, alignment);
++ malloc_ptr = (caddr + size);
++ last_alloc = caddr;
++ malloc_ptr = align_ptr_to(malloc_ptr, 8UL);
++
++ *memptr = caddr;
++ return 0;
++}
++
+ void *malloc (unsigned int size)
+ {
+ char *caddr;
diff --git a/sys-boot/yaboot/files/yaboot-1.3.17-nopiessp-gcc4.patch b/sys-boot/yaboot/files/yaboot-1.3.17-nopiessp-gcc4.patch
new file mode 100644
index 000000000000..1ab2a3eecc3e
--- /dev/null
+++ b/sys-boot/yaboot/files/yaboot-1.3.17-nopiessp-gcc4.patch
@@ -0,0 +1,38 @@
+disable ssp usage in yaboot itself
+
+unfortunately, since we link against external libs that themselves were built
+with ssp turned on, we have to provide stubs to keep the linking from failing
+
+--- yaboot-1.3.13/Config.gentoo
++++ yaboot-1.3.13/Config.gentoo
+@@ -0,0 +1,6 @@
++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)
++
+--- yaboot-1.3.13/Makefile
++++ yaboot-1.3.13/Makefile
+@@ -1,6 +1,7 @@
+ ## Setup
+
+ include Config
++include Config.gentoo
+
+ VERSION = 1.3.13
+ # Debug mode (spam/verbose)
+@@ -79,7 +80,7 @@ HOSTCFLAGS = -O2 $(CFLAGS) -Wall -I/usr/
+ second/fs_of.o second/fs_ext2.o second/fs_iso.o second/fs_swap.o \
+ second/iso_util.o \
+ lib/nonstd.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
+--- yaboot-1.3.14/lib/ssp.c
++++ yaboot-1.3.14/lib/ssp.c
+@@ -0,0 +1,2 @@
++void __stack_chk_fail(void) {}
++void __stack_chk_fail_local(void) {}
diff --git a/sys-boot/yaboot/files/yaboot-nopiessp-gcc4.patch b/sys-boot/yaboot/files/yaboot-nopiessp-gcc4.patch
new file mode 100644
index 000000000000..ed1755b72b33
--- /dev/null
+++ b/sys-boot/yaboot/files/yaboot-nopiessp-gcc4.patch
@@ -0,0 +1,38 @@
+disable ssp usage in yaboot itself
+
+unfortunately, since we link against external libs that themselves were built
+with ssp turned on, we have to provide stubs to keep the linking from failing
+
+--- yaboot-1.3.13/Config.gentoo
++++ yaboot-1.3.13/Config.gentoo
+@@ -0,0 +1,6 @@
++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)
++
+--- yaboot-1.3.13/Makefile
++++ yaboot-1.3.13/Makefile
+@@ -1,6 +1,7 @@
+ ## Setup
+
+ include Config
++include Config.gentoo
+
+ VERSION = 1.3.13
+ # Debug mode (spam/verbose)
+@@ -79,7 +80,7 @@ HOSTCFLAGS = -O2 $(CFLAGS) -Wall -I/usr/
+ 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
+--- yaboot-1.3.14/lib/ssp.c
++++ yaboot-1.3.14/lib/ssp.c
+@@ -0,0 +1,2 @@
++void __stack_chk_fail(void) {}
++void __stack_chk_fail_local(void) {}
diff --git a/sys-boot/yaboot/files/yaboot-stubfuncs.patch b/sys-boot/yaboot/files/yaboot-stubfuncs.patch
new file mode 100644
index 000000000000..8ae522b7d4eb
--- /dev/null
+++ b/sys-boot/yaboot/files/yaboot-stubfuncs.patch
@@ -0,0 +1,231 @@
+Stub out some functions that are not provided (and unneeded)
+
+--- lib/malloc.c
++++ lib/malloc.c
+@@ -64,6 +64,15 @@ void *malloc (unsigned int size)
+ return caddr;
+ }
+
++/* Calloc wrapper for malloc */
++void *memset(void *s, int c, size_t n);
++void *calloc(size_t nmemb, size_t size) {
++ void *caddr;
++ caddr = malloc(nmemb * size);
++ memset(caddr, 0, nmemb * size);
++ return caddr;
++}
++
+ /* Do not fall back to the malloc above as posix_memalign is needed by
+ * external libraries not yaboot */
+ int posix_memalign(void **memptr, size_t alignment, size_t size)
+--- lib/nonstd.c
++++ lib/nonstd.c
+@@ -65,3 +65,208 @@
+ {
+ return NULL;
+ }
++
++int lseek(int fd, int offset, int whence) {
++ // XXX: This whence addition seems wrong ..
++ return prom_lseek((void *)fd, whence + offset);
++}
++
++int lseek64(int fd, int64_t offset, int whence) {
++ return lseek(fd, offset, whence);
++}
++
++int open(const char *pathname, int flags) {
++ return (int) prom_open((char *)pathname);
++}
++
++int open64(const char *pathname, int flags) {
++ return open(pathname, flags);
++}
++
++// Internal glibc fortify calls.
++int __open64_2(const char *path, int flags) {
++ return open64(path, flags);
++}
++
++int read(int fd, void *buf, size_t count) {
++ return prom_read((void *)fd, buf, count);
++}
++
++int write(int fd, const void *buf, size_t count) {
++ return prom_write((void *)fd, (void *)buf, count);
++}
++
++int close(int fd) {
++ prom_close((void *)fd);
++ return 0;
++}
++
++int pread(int fd, void *buf, size_t count, int32_t offset) {
++ int curr = lseek(fd, 0, 0 /*SEEK_CUR*/);
++ lseek(fd, offset, 0 /*SEEK_SET*/);
++ int ret = read(fd, buf, count);
++ lseek(fd, curr, 0 /*SEEK_SET*/);
++ return ret;
++}
++
++int pread64(int fd, void *buf, int64_t count, int64_t offset) {
++ return pread(fd, buf, count, offset);
++}
++
++int pwrite(int fd, const void *buf, size_t count, int32_t offset) {
++ int curr = lseek(fd, 0, 0 /*SEEK_CUR*/);
++ lseek(fd, offset, 0 /*SEEK_SET*/);
++ int ret = write(fd, buf, count);
++ lseek(fd, curr, 0 /*SEEK_SET*/);
++ return ret;
++}
++
++int pwrite64(int fd, const void *buf, int64_t count, int64_t offset) {
++ return pwrite(fd, buf, count, offset);
++}
++
++// No fsync, just assume we've sync'd
++int fsync(int fd) {
++ return 0;
++}
++
++// ext2 libs only use this to turn off caches currently
++int fcntl(int fd, int cmd, ...) {
++ return 0;
++}
++
++void exit(int status) {
++ prom_exit();
++}
++
++int __printf_chk(int flag, const char *format, ...) {
++ va_list ap;
++ va_start (ap, format);
++ prom_vfprintf (prom_stdout, format, ap);
++ va_end (ap);
++
++ return 0;
++}
++
++int __sprintf_chk(char * str, int flag, size_t strlen, const char * format, ...) {
++ va_list ap;
++ va_start(ap, format);
++ // No sprintf? :(
++ va_end(ap);
++ return 0;
++
++}
++
++int __fprintf_chk(FILE *stream, int flag, const char *format, ...) {
++ va_list ap;
++ va_start (ap, format);
++ prom_vfprintf (prom_stdout, format, ap);
++ va_end (ap);
++
++ return 0;
++}
++
++void *memcpy(void *dest, const void *src, size_t n);
++void *__memcpy_chk(void *dest, const void *src, size_t n, size_t destlen) {
++ return memcpy(dest, src, n);
++}
++
++// But these are all dummy functions
++int __xstat64 (int __ver, const char *__filename, void *__stat_buf) {
++ return 0;
++}
++
++int stat64(const char *path, void *stat_buf) {
++ return 0;
++}
++
++int fstat64(int fildes, void *stat_buf) {
++ return 0;
++}
++
++int __fxstat64 (int __ver, int __filedesc, void *__stat_buf) {
++ return 0;
++}
++
++signed int random(void) {
++ return 0;
++}
++
++void srandom(unsigned int seed) {
++ return;
++}
++
++int rand(void) {
++ return 0;
++}
++
++void srand(unsigned int seed) {
++ return;
++}
++
++unsigned int sleep(unsigned int seconds) {
++ return 0;
++}
++
++int gettimeofday(void *tv, void *tz) {
++ return 0;
++}
++
++long sysconf(int name) {
++ return 0;
++}
++
++int getpagesize(void) {
++ return 0;
++}
++
++int gethostname(char *name, size_t len) {
++ return 0;
++}
++
++int getpid(void) {
++ return 0;
++}
++
++int getuid(void) {
++ return 0;
++}
++
++void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)) {
++ return;
++}
++
++int * __errno_location(void) {
++ return 0;
++}
++
++size_t fwrite(const void *ptr, size_t size, size_t nmemb, void *stream) {
++ return 0;
++}
++
++int ioctl(int d, int request, ...) {
++ return 0;
++}
++
++int fallocate(int fd, int mode, unsigned int offset, unsigned int len) {
++ return 0;
++}
++
++int uname(void *buf) {
++ return 0;
++}
++
++int setrlimit(int resource, void *rlim) {
++ return 0;
++}
++
++unsigned long long int strtoull(const char *nptr, char **endptr, int base) {
++ return 0;
++}
++
++int getrlimit(int resource, void *rlim) {
++ return 0;
++}
++
++int stderr = 0;
++int perror = 0;
diff --git a/sys-boot/yaboot/files/yabootconfig-1.3.13.patch b/sys-boot/yaboot/files/yabootconfig-1.3.13.patch
new file mode 100644
index 000000000000..4bc13eef8b18
--- /dev/null
+++ b/sys-boot/yaboot/files/yabootconfig-1.3.13.patch
@@ -0,0 +1,42 @@
+--- yaboot-1.3.13.orig/ybin/yabootconfig 2004-11-04 21:57:17.000000000 -0500
++++ yaboot-1.3.13/ybin/yabootconfig 2004-11-04 22:40:45.503060512 -0500
+@@ -5,6 +5,8 @@
+ ## yabootconfig generates a simple /etc/yaboot.conf
+ ## Copyright (C) 2001, 2002, 2003 Ethan Benson
+ ##
++## Patched for Gentoo and dual boot - Mark Guertin <gerk@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
+@@ -264,6 +266,30 @@
+ 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 ##
+ ##########