Subject: port-i386/36527: installboot(8) doesn't allow for the valid consdev=auto setting
To: None <port-i386-maintainer@netbsd.org, gnats-admin@netbsd.org,>
From: Greg A. Woods <woods@planix.com>
List: netbsd-bugs
Date: 06/23/2007 10:15:00
>Number: 36527
>Category: port-i386
>Synopsis: installboot(8) doesn't allow for the valid consdev=auto setting
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: port-i386-maintainer
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Jun 23 10:15:00 +0000 2007
>Originator: Greg A. Woods
>Release: netbsd-4 2007/06/21
>Organization:
Planix, Inc.; Toronto, Ontario; Canada
>Environment:
System: NetBSD 4.0_BETA2
Architecture: i386
Machine: i386
>Description:
installboot(8) doesn't allow for the valid consdev=auto setting
>How-To-Repeat:
>Fix:
Index: usr.sbin/installboot/arch/i386.c
===================================================================
RCS file: /cvs/master/m-NetBSD/main/src/usr.sbin/installboot/arch/i386.c,v
retrieving revision 1.22
diff -u -r1.22 i386.c
--- usr.sbin/installboot/arch/i386.c 18 Feb 2006 10:08:07 -0000 1.22
+++ usr.sbin/installboot/arch/i386.c 22 Jun 2007 23:13:37 -0000
@@ -60,10 +60,22 @@
#define nelem(x) (sizeof (x)/sizeof *(x))
-static const char *const console_names[] = {
- "pc", "com0", "com1", "com2", "com3",
- "com0kbd", "com1kbd", "com2kbd", "com3kbd",
- NULL };
+static const struct console_name {
+ const char *cname; /* Name of console selection */
+ const int cdev; /* value matching CONSDEV_* from sys/arch/i386/stand/lib/libi386.h */
+} console_names[] = {
+ { "pc", 0 /* CONSDEV_PC */ },
+ { "com0", 1 /* CONSDEV_COM0 */ },
+ { "com1", 2 /* CONSDEV_COM1 */ },
+ { "com2", 3 /* CONSDEV_COM2 */ },
+ { "com3", 4 /* CONSDEV_COM3 */ },
+ { "com0kbd", 5 /* CONSDEV_COM0KBD */ },
+ { "com1kbd", 6 /* CONSDEV_COM1KBD */ },
+ { "com2kbd", 7 /* CONSDEV_COM2KBD */ },
+ { "com3kbd", 8 /* CONSDEV_COM3KBD */ },
+ { "auto", -1 /* CONSDEV_AUTO */ },
+ { NULL, 0 },
+};
static int i386_setboot(ib_params *);
static int i386_editboot(ib_params *);
@@ -88,11 +100,16 @@
printf("flags %x, ", le32toh(bpp->bp_flags));
printf("speed %d, ", le32toh(bpp->bp_conspeed));
printf("ioaddr %x, ", le32toh(bpp->bp_consaddr));
- i = le32toh(bpp->bp_consdev);
- if (i < nelem(console_names) - 1)
- printf("console %s\n", console_names[i]);
- else
- printf("console %d\n", i);
+ for (i = 0; ; i++) {
+ if (console_names[i].cname == NULL) {
+ printf("console %d\n", le32toh(bpp->bp_consdev));
+ break;
+ }
+ if (console_names[i].cdev == le32toh(bpp->bp_consdev)) {
+ printf("console %s\n", console_names[i].cname);
+ break;
+ }
+ }
if (bpp->bp_keymap[0])
printf(" keymap %s\n", bpp->bp_keymap);
}
@@ -123,18 +140,18 @@
bp.bp_consaddr = htole32(params->consaddr);
if (params->flags & IB_CONSOLE) {
for (i = 0; ; i++) {
- if (console_names[i] == NULL) {
+ if (console_names[i].cname == NULL) {
warnx("invalid console name, valid names are:");
- fprintf(stderr, "\t%s", console_names[0]);
- for (i = 1; console_names[i] != NULL; i++)
- fprintf(stderr, ", %s", console_names[i]);
+ fprintf(stderr, "\t%s", console_names[0].cname);
+ for (i = 1; console_names[i].cname != NULL; i++)
+ fprintf(stderr, ", %s", console_names[i].cname);
fprintf(stderr, "\n");
return 1;
}
- if (strcmp(console_names[i], params->console) == 0)
+ if (strcmp(console_names[i].cname, params->console) == 0)
break;
}
- bp.bp_consdev = htole32(i);
+ bp.bp_consdev = htole32(console_names[i].cdev);
}
if (params->flags & IB_PASSWORD) {
if (params->password[0]) {
>Unformatted: