Module Name:    src
Committed By:   jakllsch
Date:           Wed Jan 26 20:59:49 UTC 2011

Modified Files:
        src/sys/arch/i386/stand/lib: biosdisk.c

Log Message:
Attempt to correct two regressions.
 - avoid Virtualbox's BIOS panicing on 64-bit LBAs
 - MBR-without-disklabel was ignored


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/i386/stand/lib/biosdisk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/i386/stand/lib/biosdisk.c
diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.36 src/sys/arch/i386/stand/lib/biosdisk.c:1.37
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.36	Wed Jan  5 22:06:59 2011
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Wed Jan 26 20:59:48 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.36 2011/01/05 22:06:59 jakllsch Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.37 2011/01/26 20:59:48 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -310,6 +310,10 @@
 	daddr_t gptsector[2];
 	int i, error;
 
+	if (d->ll.type != BIOSDISK_TYPE_HD)
+		/* No GPT on floppy and CD */
+		return -1;
+
 	gptsector[0] = GPT_HDR_BLKNO;
 	if (set_geometry(&d->ll, &ed) == 0 && d->ll.flags & BIOSDISK_INT13EXT) {
 		gptsector[1] = ed.totsec - 1;
@@ -345,11 +349,28 @@
 #endif	/* !NO_GPT */
 
 #ifndef NO_DISKLABEL
+static void
+ingest_label(struct biosdisk *d, struct disklabel *lp)
+{
+	int part;
+
+	memset(d->part, 0, sizeof(d->part));
+
+	for (part = 0; part < lp->d_npartitions; part++) {
+		if (lp->d_partitions[part].p_size == 0)
+			continue;
+		if (lp->d_partitions[part].p_fstype == FS_UNUSED)
+			continue;
+		d->part[part].fstype = lp->d_partitions[part].p_fstype;
+		d->part[part].offset = lp->d_partitions[part].p_offset;
+		d->part[part].size = lp->d_partitions[part].p_size;
+	}
+}
+	
 static int
 check_label(struct biosdisk *d, daddr_t sector)
 {
 	struct disklabel *lp;
-	int part;
 
 	/* find partition in NetBSD disklabel */
 	if (readsects(&d->ll, sector + LABELSECTOR, 1, d->buf, 0)) {
@@ -366,18 +387,7 @@
 		return -1;
 	}
 
-	memset(d->part, 0, sizeof(d->part));
-	for (part = 0; part < lp->d_npartitions; part++) {
-		if (lp->d_partitions[part].p_size == 0)
-			continue;
-		if (lp->d_partitions[part].p_fstype == FS_UNUSED)
-			continue;
-		d->part[part].fstype = lp->d_partitions[part].p_fstype;
-		d->part[part].offset = lp->d_partitions[part].p_offset;
-		d->part[part].size = lp->d_partitions[part].p_size;
-	}
-	
-	d->boff = sector;
+	ingest_label(d, lp);
 
 #ifdef _STANDALONE
 	bi_disk.labelsector = d->boff + LABELSECTOR;
@@ -499,7 +509,7 @@
 	 */
 	/* XXX fill it to make checksum match kernel one */
 	dflt_lbl.d_checksum = dkcksum(&dflt_lbl);
-	memcpy(d->buf, &dflt_lbl, sizeof(dflt_lbl));
+	ingest_label(d, &dflt_lbl);
 	return 0;
 }
 #endif /* NO_DISKLABEL */

Reply via email to