Subject: Re: Boot device confusion
To: matthew green <mrg@eterna.com.au>
From: Allen Briggs <briggs@netbsd.org>
List: tech-kern
Date: 06/21/2005 00:06:11
On Mon, Jun 20, 2005 at 11:03:57PM -0400, Allen Briggs wrote:
> Hmmm...  Unless we call DIOCGDEFLABEL?  That might
> work, too.  I'll try that.

OK.  Comparing the 'd_secperunit' field in the default label to that
in the actual label read from the disk does work for me.  However, it
will not work if someone has adjusted the default number of sectors.
Do folks do that?  I seem to recall doing this once upon a time for
some reason that seems obscure to me right now.

This looks like:

Index: x86_autoconf.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/x86_autoconf.c,v
retrieving revision 1.4
diff -p -u -r1.4 x86_autoconf.c
--- x86_autoconf.c	29 May 2005 21:36:40 -0000	1.4
+++ x86_autoconf.c	21 Jun 2005 04:04:36 -0000
@@ -285,7 +285,7 @@ match_bootdisk(struct device *dv, struct
 {
 	struct vnode *tmpvn;
 	int error;
-	struct disklabel label;
+	struct disklabel label, deflabel;
 	int found = 0;
 	int bmajor;
 
@@ -334,10 +334,20 @@ match_bootdisk(struct device *dv, struct
 		    dv->dv_xname, error);
 		goto closeout;
 	}
+	error = VOP_IOCTL(tmpvn, DIOCGDEFLABEL, &deflabel, FREAD, NOCRED, 0);
+	if (error) {
+		/*
+		 * XXX Can't happen -- open() would have errored out
+		 */
+		printf("findroot: can't get default label for dev %s (%d)\n",
+		    dv->dv_xname, error);
+		goto closeout;
+	}
 
 	/* Compare with our data. */
 	if (label.d_type == bid->label.type &&
 	    label.d_checksum == bid->label.checksum &&
+	    label.d_secperunit == deflabel.d_secperunit &&
 	    strncmp(label.d_packname, bid->label.packname, 16) == 0)
 	    	found = 1;

-allen

-- 
                  Use NetBSD!  http://www.NetBSD.org/