Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/evbarm/evbarm If the boot argument "root" cannot be...



details:   https://anonhg.NetBSD.org/src/rev/8dcfa6f48788
branches:  trunk
changeset: 804063:8dcfa6f48788
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sat Nov 22 11:10:22 2014 +0000

description:
If the boot argument "root" cannot be parsed as a device name, pass the
string untranslated to MI code. Due to limits in the boot argument parser
the string is terminated by whitespace.

diffstat:

 sys/arch/evbarm/evbarm/autoconf.c |  47 +++++++++++++++++++++++++++-----------
 1 files changed, 33 insertions(+), 14 deletions(-)

diffs (101 lines):

diff -r 186a2a241da0 -r 8dcfa6f48788 sys/arch/evbarm/evbarm/autoconf.c
--- a/sys/arch/evbarm/evbarm/autoconf.c Sat Nov 22 11:04:57 2014 +0000
+++ b/sys/arch/evbarm/evbarm/autoconf.c Sat Nov 22 11:10:22 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.17 2014/05/10 20:12:16 reinoud Exp $    */
+/*     $NetBSD: autoconf.c,v 1.18 2014/11/22 11:10:22 mlelstv Exp $    */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.17 2014/05/10 20:12:16 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.18 2014/11/22 11:10:22 mlelstv Exp $");
 
 #include "opt_md.h"
 
@@ -51,15 +51,15 @@
 void   (*evbarm_device_register_post_config)(device_t, void *);
 
 #ifndef MEMORY_DISK_IS_ROOT
-static void get_device(char *name);
+static int get_device(char *name, device_t *, int *);
 static void set_root_device(void);
 #endif
 
 #ifndef MEMORY_DISK_IS_ROOT
 /* Decode a device name to a major and minor number */
 
-static void
-get_device(char *name)
+static int
+get_device(char *name, device_t *dvp, int *partp)
 {
        int unit, part;
        char devname[16], *cp;
@@ -69,7 +69,7 @@
                name += 5;
 
        if (devsw_name2blk(name, devname, sizeof(devname)) == -1)
-               return;
+               return 0;
 
        name += strlen(devname);
        unit = part = 0;
@@ -78,16 +78,19 @@
        while (*cp >= '0' && *cp <= '9')
                unit = (unit * 10) + (*cp++ - '0');
        if (cp == name)
-               return;
+               return 0;
 
        if (*cp >= 'a' && *cp < ('a' + MAXPARTITIONS))
                part = *cp - 'a';
        else if (*cp != '\0' && *cp != ' ')
-               return;
+               return 0;
        if ((dv = device_find_by_driver_unit(devname, unit)) != NULL) {
-               booted_device = dv;
-               booted_partition = part;
+               *dvp = dv;
+               *partp = part;
+               return 1;
        }
+
+       return 0;
 }
 
 /* Set the rootdev variable from the root specifier in the boot args */
@@ -95,10 +98,26 @@
 static void
 set_root_device(void)
 {
-       char *ptr;
-       if (boot_args &&
-           get_bootconf_option(boot_args, "root", BOOTOPT_TYPE_STRING, &ptr))
-               get_device(ptr);
+       char *ptr, *end;
+
+       if (boot_args == NULL)
+               return;
+
+       if (!get_bootconf_option(boot_args, "root", BOOTOPT_TYPE_STRING, &ptr))
+               return;
+
+       if (get_device(ptr, &booted_device, &booted_partition))
+               return;
+
+       /* NUL-terminate string, get_bootconf_option doesn't */
+       for (end=ptr; *end != '\0'; ++end) {
+               if (*end == ' ' || *end == '\t') {
+                       *end = '\0';
+                       break;
+               }
+       }
+
+       bootspec = ptr;
 }
 #endif
 



Home | Main Index | Thread Index | Old Index