Module Name:    src
Committed By:   tsutsui
Date:           Tue Sep  1 13:55:26 UTC 2015

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

Log Message:
Use the default boot device if a kernel name without device is specificed.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/luna68k/stand/boot/devopen.c

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.10 src/sys/arch/luna68k/stand/boot/devopen.c:1.11
--- src/sys/arch/luna68k/stand/boot/devopen.c:1.10	Tue Sep  1 13:46:50 2015
+++ src/sys/arch/luna68k/stand/boot/devopen.c	Tue Sep  1 13:55:25 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: devopen.c,v 1.10 2015/09/01 13:46:50 tsutsui Exp $	*/
+/*	$NetBSD: devopen.c,v 1.11 2015/09/01 13:55:25 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1992 OMRON Corporation.
@@ -138,58 +138,71 @@ make_device(const char *str, int *devp, 
 	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 */
-	for (dp = devsw; dp->dv_name; dp++)
-		if (!strcmp(devname, dp->dv_name))
-			break;
-	cp++;
-	if (dp->dv_name == NULL) {
-		return -1;
-	}
-	dev = dp - devsw;
-	/* get mixed controller and unit number */
-	haveunit = false;
-	for (; *cp != ',' && *cp != ')'; cp++) {
-		if (*cp == '\0')
+		/* no device name is specified; assume default */
+		cp = str;
+		/* compare dev type name */
+		for (dp = devsw; dp->dv_name; dp++)
+			if (!strcmp(default_bootdev, dp->dv_name))
+				break;
+		if (dp->dv_name == NULL) {
 			return -1;
-		if (*cp >= '0' && *cp <= '9') {
-			unit = unit * 10 + *cp - '0';
-			haveunit = true;
 		}
-	}
-	if (unit < 0 || CTLR(unit) >= 2 || TARGET(unit) > 7) {
-#ifdef DEBUG
-		printf("%s: invalid unit number (%d)\n", __func__, unit);
-#endif
-		return -1;
-	}
-	if (!haveunit && strcmp(devname, default_bootdev) == 0)
+		dev = dp - devsw;
 		unit = default_unit;
-	/* get optional partition number */
-	if (*cp == ',')
+	} else {
+		devname[i] = '\0';
+		/* compare dev type name */
+		for (dp = devsw; dp->dv_name; dp++)
+			if (!strcmp(devname, dp->dv_name))
+				break;
 		cp++;
-
-	for (; /* *cp != ',' && */ *cp != ')'; cp++) {
-		if (*cp == '\0')
+		if (dp->dv_name == NULL) {
 			return -1;
-		if (*cp >= '0' && *cp <= '9')
-			part = part * 10 + *cp - '0';
-	}
-	if (part < 0 || part >= MAXPARTITIONS) {
+		}
+		dev = dp - devsw;
+		/* get mixed controller and unit number */
+		haveunit = false;
+		for (; *cp != ',' && *cp != ')'; cp++) {
+			if (*cp == '\0')
+				return -1;
+			if (*cp >= '0' && *cp <= '9') {
+				unit = unit * 10 + *cp - '0';
+				haveunit = true;
+			}
+		}
+		if (unit < 0 || CTLR(unit) >= 2 || TARGET(unit) > 7) {
+#ifdef DEBUG
+			printf("%s: invalid unit number (%d)\n",
+			    __func__, unit);
+#endif
+			return -1;
+		}
+		if (!haveunit && strcmp(devname, default_bootdev) == 0)
+			unit = default_unit;
+		/* 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) {
 #ifdef DEBUG
-		printf("%s: invalid partition number (%d)\n", __func__, part);
+			printf("%s: invalid partition number (%d)\n",
+			    __func__, part);
 #endif
-		return -1;
+			return -1;
+		}
+		cp++;
 	}
 	/* check out end of dev spec */
 	*devp  = dev;
 	*unitp = unit;
 	*partp = part;
 	if (fname != NULL) {
-		cp++;
 		if (*cp == '\0')
 			*fname = "netbsd";
 		else

Reply via email to