diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2011-11-19 16:11:56 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2011-11-19 16:11:56 +0000 |
commit | e61e6055eae259677c9446ff06f748dd406122bc (patch) | |
tree | 4ea332eff1c29678c5445bc21acb42663c1d972a /sys/arch | |
parent | 6320d2d8f2c06f6d6a676b12676605c069cebd26 (diff) |
Rewrite the parsing of arguments given to the ofwboot and restore the
possibility to boot a kernel from an HFS partition when there is no
OpenBSD partition on the disk.
Problem reported by cbsoleil at gmail.com and analysed by otto@.
Tested by otto@, krw@ and drahn@
ok krw@, drahn@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/macppc/stand/conf.c | 4 | ||||
-rw-r--r-- | sys/arch/macppc/stand/ofdev.c | 49 |
2 files changed, 27 insertions, 26 deletions
diff --git a/sys/arch/macppc/stand/conf.c b/sys/arch/macppc/stand/conf.c index 3dbaca81506..82365eedd83 100644 --- a/sys/arch/macppc/stand/conf.c +++ b/sys/arch/macppc/stand/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.3 2008/06/13 00:31:09 krw Exp $ */ +/* $OpenBSD: conf.c,v 1.4 2011/11/19 16:11:55 mpi Exp $ */ /* * Copyright (c) 2007 Dale Rahn <drahn@openbsd.org> * @@ -21,7 +21,7 @@ #include <lib/libsa/stand.h> -const char version[] = "1.1"; +const char version[] = "1.2"; int debug = 0; void ofc_probe(struct consdev *); diff --git a/sys/arch/macppc/stand/ofdev.c b/sys/arch/macppc/stand/ofdev.c index d8c992cf3fe..321a8f25a01 100644 --- a/sys/arch/macppc/stand/ofdev.c +++ b/sys/arch/macppc/stand/ofdev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofdev.c,v 1.18 2011/04/10 09:58:19 miod Exp $ */ +/* $OpenBSD: ofdev.c,v 1.19 2011/11/19 16:11:55 mpi Exp $ */ /* $NetBSD: ofdev.c,v 1.1 1997/04/16 20:29:20 thorpej Exp $ */ /* @@ -49,25 +49,39 @@ 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, 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 (*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 +158,6 @@ static struct of_dev ofdev = { -1, }; -char opened_name[256]; - static u_long get_long(p) const void *p; @@ -280,7 +292,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 +305,8 @@ devopen(struct open_file *of, const char *name, char **file) return EPERM; strlcpy(fname, name, sizeof fname); - cp = filename(fname); - if (cp == NULL) + if (parsename(fname, 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; |