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.
This commit is contained in:
tsutsui 2014-01-03 06:15:10 +00:00
parent 4929bf22e1
commit 86c3ed96a4
3 changed files with 33 additions and 28 deletions

View File

@ -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, int *unitp, int *partp, char **fname)
{
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, int *unitp, int *partp, char **fname)
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);

View File

@ -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 {

View File

@ -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")