summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2005-04-27 03:06:24 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2005-04-27 03:06:24 +0000
commit2b82973704bdb769f353df1214ec812a2a63132b (patch)
tree8ed8ae763a190cf0ed6c1fb74c0716b56dc801c5
parent25d30a4da626a704307059e4df5bb5a1238e9ba8 (diff)
if SystemPartition contains a cdrom boot specifier, whack the
OSLoadPartition variable to point to partition 0 of the same unit.
-rw-r--r--sys/arch/sgi/stand/boot/Makefile4
-rw-r--r--sys/arch/sgi/stand/boot/boot.c37
-rw-r--r--sys/arch/sgi/stand/boot/strstr.c55
3 files changed, 84 insertions, 12 deletions
diff --git a/sys/arch/sgi/stand/boot/Makefile b/sys/arch/sgi/stand/boot/Makefile
index 8a49c65a215..a700082f7c7 100644
--- a/sys/arch/sgi/stand/boot/Makefile
+++ b/sys/arch/sgi/stand/boot/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.3 2004/09/16 18:54:48 pefo Exp $
+# $OpenBSD: Makefile,v 1.4 2005/04/27 03:06:22 deraadt Exp $
PROG= boot
@@ -14,7 +14,7 @@ AFLAGS+= ${SAABI}
LDFLAGS+= ${SALDFLAGS} -T ${.CURDIR}/ld.script -e __start
-SRCS= start.S boot.c filesystem.c conf.c diskio.c arcbios.c
+SRCS= start.S boot.c filesystem.c conf.c diskio.c arcbios.c strstr.c
CLEANFILES+= machine mips64
diff --git a/sys/arch/sgi/stand/boot/boot.c b/sys/arch/sgi/stand/boot/boot.c
index 2ed257f7246..388777c6c06 100644
--- a/sys/arch/sgi/stand/boot/boot.c
+++ b/sys/arch/sgi/stand/boot/boot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: boot.c,v 1.4 2005/04/27 03:03:38 deraadt Exp $ */
+/* $OpenBSD: boot.c,v 1.5 2005/04/27 03:06:23 deraadt Exp $ */
/*
* Copyright (c) 2004 Opsycon AB, www.opsycon.se.
@@ -94,10 +94,9 @@ main(argc, argv)
} else
strlcpy("invalid argument setup", line, sizeof(line));
- printf("\nOpenBSD/sgi Arcbios boot\n");
-
for (entry = 0; entry < argc; entry++)
printf("arg %d: %s\n", entry, argv[entry]);
+ printf("\nOpenBSD/sgi Arcbios boot\n");
printf("Boot: %s\n", line);
@@ -115,31 +114,49 @@ main(argc, argv)
void
dobootopts(int argc, char **argv)
{
+ char *SystemPartition = NULL;
char *cp;
int i;
- /* XXX Should this be done differently, eg env vs. args? */
for (i = 1; i < argc; i++) {
cp = argv[i];
if (cp == NULL)
continue;
-
if (strncmp(cp, "OSLoadOptions=", 14) == 0) {
if (strcmp(&cp[14], "auto") == 0)
- bootauto = AUTO_YES;
+ bootauto = AUTO_YES;
else if (strcmp(&cp[14], "single") == 0)
- bootauto = AUTO_NO;
+ bootauto = AUTO_NO;
else if (strcmp(&cp[14], "debug") == 0)
- bootauto = AUTO_DEBUG;
- }
- else if (strncmp(cp, "OSLoadPartition=", 16) == 0)
+ bootauto = AUTO_DEBUG;
+ } else if (strncmp(cp, "OSLoadPartition=", 16) == 0)
OSLoadPartition = &cp[16];
else if (strncmp(cp, "OSLoadFilename=", 15) == 0)
OSLoadFilename = &cp[15];
+ else if (strncmp(cp, "SystemPartition=", 16) == 0)
+ SystemPartition = &cp[16];
}
/* If "OSLoadOptions=" is missing, see if any arg was given */
if (bootauto == AUTO_NONE && *argv[1] == '/')
OSLoadFilename = argv[1];
+
+ if (SystemPartition) {
+ printf("SystemPartition %s\n", SystemPartition);
+ if (strstr(SystemPartition, ")cdrom(")) {
+ static char syspart[64];
+ char *p;
+
+ strlcpy(syspart, SystemPartition, sizeof syspart);
+ p = strstr(syspart, "partition(");
+ if (p) {
+ p += strlen("partition(");
+ if (*p == '8')
+ *p = '0';
+ }
+ OSLoadPartition = syspart;
+ printf("new OSLoadPartition=%s\n", OSLoadPartition);
+ }
+ }
}
/*
diff --git a/sys/arch/sgi/stand/boot/strstr.c b/sys/arch/sgi/stand/boot/strstr.c
new file mode 100644
index 00000000000..a920ce9d27e
--- /dev/null
+++ b/sys/arch/sgi/stand/boot/strstr.c
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+
+/*
+ * Find the first occurrence of find in s.
+ */
+char *
+strstr(const char *s, const char *find)
+{
+ char c, sc;
+ size_t len;
+
+ if ((c = *find++) != 0) {
+ len = strlen(find);
+ do {
+ do {
+ if ((sc = *s++) == 0)
+ return (NULL);
+ } while (sc != c);
+ } while (strncmp(s, find, len) != 0);
+ s--;
+ }
+ return ((char *)s);
+}