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

Re: Disk unit mixup for bootdev in i386/dkcsum.c::dkcsumattach() - BUG & FIX



Would it not be better to just store a copy of the original value
of bootdev and use that?  Perhaps something like this.

 - todd

Index: sys/arch/i386/i386/dkcsum.c
===================================================================
RCS file: /home/cvs/openbsd/src/sys/arch/i386/i386/dkcsum.c,v
retrieving revision 1.11
diff -u -r1.11 dkcsum.c
--- sys/arch/i386/i386/dkcsum.c	3 Jun 2003 20:31:07 -0000	1.11
+++ sys/arch/i386/i386/dkcsum.c	14 Jun 2004 22:08:35 -0000
@@ -58,7 +58,7 @@
 	struct device *dv;
 	struct buf *bp;
 	struct bdevsw *bdsw;
-	dev_t dev;
+	dev_t dev, obootdev = bootdev;
 	int error;
 	u_int32_t csum;
 	bios_diskinfo_t *bdi, *hit;
@@ -168,15 +168,15 @@
 		 * backwards compatible, but sd* and wd* should be phased-
 		 * out in the bootblocks.
 		 */
-		if (B_UNIT(bootdev) == (hit->bios_number & 0x7F)) {
+		if (B_UNIT(obootdev) == (hit->bios_number & 0x7F)) {
 			int type, ctrl, adap, part, unit;
 
 			/* Translate to MAKEBOOTDEV() style */
 			type = major(bp->b_dev);
-			adap = B_ADAPTOR(bootdev);
-			ctrl = B_CONTROLLER(bootdev);
+			adap = B_ADAPTOR(obootdev);
+			ctrl = B_CONTROLLER(obootdev);
 			unit = DISKUNIT(bp->b_dev);
-			part = B_PARTITION(bootdev);
+			part = B_PARTITION(obootdev);
 
 			bootdev = MAKEBOOTDEV(type, ctrl, adap, unit, part);
 		}