Module Name:    src
Committed By:   tsutsui
Date:           Fri Jan  3 06:15:10 UTC 2014

Modified Files:
        src/sys/arch/luna68k/stand/boot: devopen.c samachdep.h version

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/luna68k/stand/boot/devopen.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/luna68k/stand/boot/samachdep.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/luna68k/stand/boot/version

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/luna68k/stand/boot/devopen.c
diff -u src/sys/arch/luna68k/stand/boot/devopen.c:1.3 src/sys/arch/luna68k/stand/boot/devopen.c:1.4
--- src/sys/arch/luna68k/stand/boot/devopen.c:1.3	Wed Jan 16 15:46:20 2013
+++ src/sys/arch/luna68k/stand/boot/devopen.c	Fri Jan  3 06:15:10 2014
@@ -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 @@ make_device(const char *str, int *devp, 
 {
 	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 @@ make_device(const char *str, int *devp, 
 		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);
-	}
-	part = *cp - '0';
-							/* check out end of dev spec */
-	for (;;) {
-		if (*cp == ')')
-			break;
-		if (*cp++)
-			continue;
-		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';
 	}
-	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);

Index: src/sys/arch/luna68k/stand/boot/samachdep.h
diff -u src/sys/arch/luna68k/stand/boot/samachdep.h:1.11 src/sys/arch/luna68k/stand/boot/samachdep.h:1.12
--- src/sys/arch/luna68k/stand/boot/samachdep.h:1.11	Thu Jan  2 20:02:00 2014
+++ src/sys/arch/luna68k/stand/boot/samachdep.h	Fri Jan  3 06:15:10 2014
@@ -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 {

Index: src/sys/arch/luna68k/stand/boot/version
diff -u src/sys/arch/luna68k/stand/boot/version:1.6 src/sys/arch/luna68k/stand/boot/version:1.7
--- src/sys/arch/luna68k/stand/boot/version:1.6	Tue Mar  5 15:34:53 2013
+++ src/sys/arch/luna68k/stand/boot/version	Fri Jan  3 06:15:10 2014
@@ -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 @@ is taken as the current.
 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")

Reply via email to