diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2010-04-18 15:09:03 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2010-04-18 15:09:03 +0000 |
commit | 17e4ae72a78d51c260502f7562f5e3e51ea465c5 (patch) | |
tree | b94de261e57a7197514664971ce3a077371b26d3 /sys/arch/aviion/stand/libsa/parse_args.c | |
parent | 62f2a437013e836bee23ffbf58501094084626f3 (diff) |
Parse commandline options in netboot, and force the onboard ethernet address
to be 00:00:00:00:00:00 if `-z' is passed; this allows netboot to work on a
machine which has lost its nvram (despite the ethernet address not being
stored in nvram at all, stupid prom can't be bothered to get it right...).
Crank netboot version.
Diffstat (limited to 'sys/arch/aviion/stand/libsa/parse_args.c')
-rw-r--r-- | sys/arch/aviion/stand/libsa/parse_args.c | 78 |
1 files changed, 62 insertions, 16 deletions
diff --git a/sys/arch/aviion/stand/libsa/parse_args.c b/sys/arch/aviion/stand/libsa/parse_args.c index efcb229ceb5..3c37072cb36 100644 --- a/sys/arch/aviion/stand/libsa/parse_args.c +++ b/sys/arch/aviion/stand/libsa/parse_args.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse_args.c,v 1.1 2006/05/16 22:48:18 miod Exp $ */ +/* $OpenBSD: parse_args.c,v 1.2 2010/04/18 15:09:00 miod Exp $ */ /*- * Copyright (c) 1995 Theo de Raadt @@ -36,14 +36,34 @@ #define KERNEL_NAME "bsd" +int boothowto = 0; + +/* skip end of token and whitespace */ +static char *stws(char *); +static char * +stws(char *p) +{ + while (*p != ' ' && *p != '\0') + p++; + + while (*p == ' ') + p++; + + return p; +} + int -parse_args(char *line, char **filep) +parse_args(char *line, char **filep, int first) { - char *name = NULL, *p; + char *s = NULL, *p; + char *name; + size_t namelen; - /* recognize the special ``halt'' keyword */ - if (strcmp(line, "halt") == 0) - return (1); + if (first == 0) { + /* recognize the special ``halt'' keyword */ + if (strcmp(line, "halt") == 0) + return (1); + } /* * The command line should be under the form @@ -62,20 +82,46 @@ parse_args(char *line, char **filep) if (*p != '\0') { for (p = line; *p != '\0' && *p != ')'; p++) ; if (*p != '\0') - name = ++p; + s = ++p; } - if (name == NULL) - name = line; + if (s == NULL) + s = line; - /* now insert a NUL before any option */ - for (p = name; *p != '\0' && *p != ' '; p++) ; - *p = '\0'; + /* figure out how long the kernel name is */ + for (p = s; *p != '\0' && *p != ' '; p++) ; + namelen = p - s; - /* no name, use the default */ - if (*name == '\0') + /* empty, use the default */ + if (namelen == 0) name = KERNEL_NAME; - + else { + name = (char *)alloc(1 + namelen); + if (name == NULL) + panic("out of memory"); + bcopy(s, name, namelen); + name[namelen] = '\0'; + } *filep = name; - return (0); + + /* + * If this commandline is the one passed by the PROM, then look + * for options specific to the standalone code. + */ + + if (first) { + p = stws(p); + while (*p != '\0') { + if (*p++ == '-') + while (*p != ' ' && *p != '\0') + switch (*p++) { + case 'z': + boothowto |= BOOT_ETHERNET_ZERO; + break; + } + p = stws(p); + } + } + + return 0; } |