Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/luna68k/stand/boot Pull more fixes from OpenBSD/lun...



details:   https://anonhg.NetBSD.org/src/rev/613e39943f80
branches:  trunk
changeset: 325679:613e39943f80
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Fri Jan 03 06:15:10 2014 +0000

description:
Pull more fixes from OpenBSD/luna88k:

- accept empty controller and partition numbers, as well as empty filenames,
  and use defaults (0, 0 and "netbsd") instead of complaining the boot path
  is invalid
- move a macro where actually necessary

Also bump version to denote the user visible change.

diffstat:

 sys/arch/luna68k/stand/boot/devopen.c   |  54 ++++++++++++++++++--------------
 sys/arch/luna68k/stand/boot/samachdep.h |   4 +-
 sys/arch/luna68k/stand/boot/version     |   3 +-
 3 files changed, 33 insertions(+), 28 deletions(-)

diffs (140 lines):

diff -r 6fe54c1e3ca6 -r 613e39943f80 sys/arch/luna68k/stand/boot/devopen.c
--- a/sys/arch/luna68k/stand/boot/devopen.c     Fri Jan 03 03:44:41 2014 +0000
+++ b/sys/arch/luna68k/stand/boot/devopen.c     Fri Jan 03 06:15:10 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: devopen.c,v 1.3 2013/01/16 15:46:20 tsutsui Exp $      */
+/*     $NetBSD: devopen.c,v 1.4 2014/01/03 06:15:10 tsutsui Exp $      */
 
 /*
  * Copyright (c) 1992 OMRON Corporation.
@@ -74,6 +74,8 @@
 #include <luna68k/stand/boot/samachdep.h>
 #include <machine/disklabel.h>
 
+#define MAXDEVNAME     16
+
 static int make_device(const char *, int *, int *, int *, char **);
 
 int
@@ -123,21 +125,21 @@
 {
        const char *cp;
        struct devsw *dp;
-       int major, unit, part;
+       int major, unit = 0, part = 0;
        int i;
        char devname[MAXDEVNAME + 1];
 
        /*
         * parse path strings
         */
-                                                       /* find end of dev type name */
+       /* find end of dev type name */
        for (cp = str, i = 0; *cp != '\0' && *cp != '(' && i < MAXDEVNAME; i++)
                        devname[i] = *cp++;
        if (*cp != '(') {
                return (-1);
        }
        devname[i] = '\0';
-                                                       /* compare dev type name */
+       /* compare dev type name */
        for (dp = devsw; dp->dv_name; dp++)
                if (!strcmp(devname, dp->dv_name))
                        break;
@@ -146,40 +148,44 @@
                return (-1);
        }
        major = dp - devsw;
-                                                       /* get unit number */
-       unit = *cp++ - '0';
-       if (*cp >= '0' && *cp <= '9')
-               unit = unit * 10 + *cp++ - '0';
-       if (unit < 0 || unit > 63) {
+       /* get mixed controller and unit number */
+       for (; *cp != ',' && *cp != ')'; cp++) {
+               if (*cp == '\0')
+                       return -1;
+               if (*cp >= '0' && *cp <= '9')
+                       unit = unit * 10 + *cp - '0';
+       }
+       if (unit < 0 || unit >= 20 || (unit % 10) > 7) {
 #ifdef DEBUG
                printf("%s: invalid unit number (%d)\n", __func__, unit);
 #endif
                return (-1);
        }
-                                                       /* get partition offset */
-       if (*cp++ != ',') {
-               return (-1);
+       /* get optional partition number */
+       if (*cp == ',')
+               cp++;
+
+       for (; /* *cp != ',' && */ *cp != ')'; cp++) {
+               if (*cp == '\0')
+                       return -1;
+               if (*cp >= '0' && *cp <= '9')
+                       part = part * 10 + *cp - '0';
        }
-       part = *cp - '0';
-                                                       /* check out end of dev spec */
-       for (;;) {
-               if (*cp == ')')
-                       break;
-               if (*cp++)
-                       continue;
-               return (-1);
-       }
-       if (part < 0 || part > MAXPARTITIONS) {
+       if (part < 0 || part >= MAXPARTITIONS) {
 #ifdef DEBUG
                printf("%s: invalid partition number (%d)\n", __func__, part);
 #endif
                return (-1);
        }
-
+       /* check out end of dev spec */
        *devp  = major;
        *unitp = unit;
        *partp = part;
-       *fname = __UNCONST(cp + 1);
+       cp++;
+       if (*cp == '\0')
+               *fname = "netbsd";
+       else
+               *fname = __UNCONST(cp); /* XXX */
 #ifdef DEBUG
        printf("%s: major = %d, unit = %d, part = %d, fname = %s\n",
            __func__, major, unit, part, *fname);
diff -r 6fe54c1e3ca6 -r 613e39943f80 sys/arch/luna68k/stand/boot/samachdep.h
--- a/sys/arch/luna68k/stand/boot/samachdep.h   Fri Jan 03 03:44:41 2014 +0000
+++ b/sys/arch/luna68k/stand/boot/samachdep.h   Fri Jan 03 06:15:10 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: samachdep.h,v 1.11 2014/01/02 20:02:00 tsutsui Exp $   */
+/*     $NetBSD: samachdep.h,v 1.12 2014/01/03 06:15:10 tsutsui Exp $   */
 
 /*
  * Copyright (c) 1982, 1990, 1993
@@ -45,8 +45,6 @@
 #define MHZ_33         4
 #define MHZ_50         6
 
-#define MAXDEVNAME     16
-
 struct consdev;
 struct frame;
 typedef struct label_t {
diff -r 6fe54c1e3ca6 -r 613e39943f80 sys/arch/luna68k/stand/boot/version
--- a/sys/arch/luna68k/stand/boot/version       Fri Jan 03 03:44:41 2014 +0000
+++ b/sys/arch/luna68k/stand/boot/version       Fri Jan 03 06:15:10 2014 +0000
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.6 2013/03/05 15:34:53 tsutsui Exp $
+$NetBSD: version,v 1.7 2014/01/03 06:15:10 tsutsui Exp $
 
 NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE.  The format of this
 file is important - make sure the entries are appended on end, last item
@@ -10,3 +10,4 @@
 1.3:   Add UFS2 support.
 1.4:   Add support for "awaiting key" to abort autoboot and get boot menu.
 1.5:   Check netboot and set proper default boot device.
+1.6:   Accept empty unit, partition, and filename. (defaults: 0, 0, "netbsd")



Home | Main Index | Thread Index | Old Index