On 05/11/11(Sat) 07:59, Otto Moerbeek wrote:
> On Sat, Nov 05, 2011 at 09:50:33AM +0900, Joel Rees wrote:
> 
> > > 
> > > Did some tests.
> > > 
> > > Results so far: booting ofwboot and kernel from HFS+ is indeed busted
> > > 
> > > 4.1 ofwboot + 5.0 bsd.rd DOES boot
> > > 
> > > 4.2 - 5.0 ofwboot do not work
> > > 
> > > Loading ofwboot itself does work, only loading the kernel fails.

diff below rewrites the parsing of the arguments taken from the Open
Firmware and fixes the issue for me, can you confirm you can boot an
OpenBSD kernel located on you HFS partition with it? 

0 > boot hd:,ofwboot bsd.rd


Even with this diff, it is not yet possible to boot an OpenBSD kernel
from a HFS partition if you already have a valid OpenBSD partition, but
I've an other diff for that.

Martin


Index: ofdev.c
===================================================================
RCS file: /cvs/src/sys/arch/macppc/stand/ofdev.c,v
retrieving revision 1.18
diff -u -p -r1.18 ofdev.c
--- ofdev.c     10 Apr 2011 09:58:19 -0000      1.18
+++ ofdev.c     11 Nov 2011 15:45:40 -0000
@@ -49,25 +49,42 @@
 
 extern char bootdev[];
 
+char opened_name[256];
+
 /*
  * this function is passed [device specifier]:[kernel]
  * however a device specifier may contain a ':'
  */
-char namebuf[256];
-static char *
-filename(char *str)
+static int
+parsename(char *str, int *ppart, char **file)
 {
        char *cp;
-       char savec;
+       int aliases;
+       size_t len;
 
        cp = strrchr(str, ':');
        if (cp == NULL)
-               return NULL;
+               return 1;
+
+       *cp++ = 0;
+
+       if ((aliases = OF_finddevice("/aliases")) == -1 ||
+           OF_getprop(aliases, str, opened_name, sizeof opened_name) < 0)
+               strlcpy(opened_name, str, sizeof opened_name);
+
+       len = strlcat(opened_name, ":", sizeof opened_name);
+       if (len >= sizeof opened_name)
+               return 1;
+
+       if (*cp != '/')
+               strlcat(opened_name, "/", sizeof opened_name);
+
+       if (strlcat(opened_name, cp, sizeof opened_name) >= sizeof opened_name)
+               return 1;
 
-       savec = *cp;
-       *cp = 0;
-       strlcpy(namebuf, cp+1, sizeof namebuf);
-       return namebuf;
+       *file = opened_name + len + 1;
+
+       return 0;
 }
 
 static int
@@ -144,8 +161,6 @@ static struct of_dev ofdev = {
        -1,
 };
 
-char opened_name[256];
-
 static u_long
 get_long(p)
        const void *p;
@@ -280,7 +295,6 @@ search_label(devp, off, buf, lp, off0)
 int
 devopen(struct open_file *of, const char *name, char **file)
 {
-       char *cp;
        char fname[256];
        char buf[DEV_BSIZE];
        struct disklabel label;
@@ -294,18 +308,8 @@ devopen(struct open_file *of, const char
                return EPERM;
 
        strlcpy(fname, name, sizeof fname);
-       cp = filename(fname);
-       if (cp == NULL)
+       if (parsename(fname, &part, file))
                return ENOENT;
-       strlcpy(buf, cp, sizeof buf);
-       strlcpy(opened_name, fname, sizeof opened_name);
-
-       strlcat(opened_name, ":", sizeof opened_name);
-       if (*buf != '/')
-               strlcat(opened_name, "/", sizeof opened_name);
-
-       strlcat(opened_name, buf, sizeof opened_name);
-       *file = opened_name + strlen(fname) + 1;
 
        if ((handle = OF_finddevice(fname)) == -1)
                return ENOENT;

Reply via email to