tech-kern archive

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

[Patch] Bootinfo root device (x86)



Hi,

The root device passed to the kernel in the bootinfo structure is not
correctly used in x86_autoconf's findroot() function.  This results in
the kernel ignoring the given root device (and prompting for one).  The
attached patch (two versions, one for -current and one for netbsd-5)
fixes this issue.

The problem does not occur when booted (on x86) with the NetBSD boot
loader boot(8) since the latter uses other means than the bootinfo root
device to specify the root device.  However, it occurs with e.g. Grub2.

The patch accepts an incomplete boot device such as wd1 in which case it
assumes that the desired BSD partition is a.  This behavior can easily
be removed.

Grégoire
Index: x86_autoconf.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/x86_autoconf.c,v
retrieving revision 1.50
diff -u -p -r1.50 x86_autoconf.c
--- x86_autoconf.c      24 Feb 2010 22:37:55 -0000      1.50
+++ x86_autoconf.c      2 Jun 2010 15:26:00 -0000
@@ -393,18 +393,21 @@ findroot(void)
                for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST);
                     dv != NULL;
                     dv = deviter_next(&di)) {
-                       cfdata_t cd;
+                       const char *name;
                        size_t len;
 
                        if (device_class(dv) != DV_DISK)
                                continue;
 
-                       cd = device_cfdata(dv);
-                       len = strlen(cd->cf_name);
+                       name = device_xname(dv);
+                       len = strlen(name);
 
-                       if (strncmp(cd->cf_name, biv->devname, len) == 0 &&
-                           biv->devname[len] - '0' == cd->cf_unit) {
-                               handle_wedges(dv, biv->devname[len + 1] - 'a');
+                       if (strncmp(name, biv->devname, len) == 0) {
+                               /* Default to BSD partition 'a' */
+                               if (biv->devname[len] == '\0')
+                                       handle_wedges(dv, 0);
+                               else
+                                       handle_wedges(dv, biv->devname[len] - 
'a');
                                break;
                        }
                }
Index: x86_autoconf.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/x86_autoconf.c,v
retrieving revision 1.35.4.1
diff -u -p -r1.35.4.1 x86_autoconf.c
--- x86_autoconf.c      14 Feb 2010 13:35:44 -0000      1.35.4.1
+++ x86_autoconf.c      2 Jun 2010 14:53:35 -0000
@@ -324,18 +324,21 @@ findroot(void)
 
        if ((biv = lookup_bootinfo(BTINFO_ROOTDEVICE)) != NULL) {
                TAILQ_FOREACH(dv, &alldevs, dv_list) {
-                       struct cfdata *cd;
+                       const char *name;
                        size_t len;
 
                        if (device_class(dv) != DV_DISK)
                                continue;
 
-                       cd = device_cfdata(dv);
-                       len = strlen(cd->cf_name);
+                       name = device_xname(dv);
+                       len = strlen(name);
 
-                       if (strncmp(cd->cf_name, biv->devname, len) == 0 &&
-                           biv->devname[len] - '0' == cd->cf_unit) {
-                               handle_wedges(dv, biv->devname[len + 1] - 'a');
+                       if (strncmp(name, biv->devname, len) == 0) {
+                               /* Default to BSD partition 'a' */
+                               if (biv->devname[len] == '\0')
+                                       handle_wedges(dv, 0);
+                               else
+                                       handle_wedges(dv, biv->devname[len] - 
'a');
                                return;
                        }
                }


Home | Main Index | Thread Index | Old Index