Subject: patch to disklabel
To: None <port-i386@sun-lamp.cs.berkeley.edu>
From: Torsten Duwe (Emacs) <duwe@immd4.informatik.uni-erlangen.de>
List: port-i386
Date: 06/13/1994 23:06:12
Here the long-promised patch to disklabel that makes it more verbose about
what's wrong with a partition table and clearer about what it's going to do
about it. It should be a big help to first-time installers who have no chance
to read the source. In particular, it is difficult to tell the installation
script the proper "start"-value (sector/cylinder/head - which is the first ?
0 or 1 ?) . Now disklabel tells you what you typed and what it expected.

--- disklabel.c.orig	Mon Jun 13 20:09:01 1994
+++ disklabel.c	Mon Jun 13 22:37:37 1994
@@ -364,6 +364,7 @@
 	int flag;
 #ifdef i386
 	off_t lbl_off; struct partition *pp = &lp->d_partitions[2];
+	char errmsg[100];
 #endif
 
 	lp->d_magic = DISKMAGIC;
@@ -382,21 +383,32 @@
 		 * otherwise we reject the request as meaningless. -wfj
 		 */
 
-		if (dosdp && dosdp->dp_typ == DOSPTYP_386BSD && pp->p_size &&
-			dosdp->dp_start == pp->p_offset) {
+		if (dosdp) {
+			if (dosdp->dp_typ != DOSPTYP_386BSD) {
+				sprintf(errmsg, "No primary partition of type NetBSD (0x%X)\n", DOSPTYP_386BSD);
+			} else if (pp->p_size < 2) {
+				sprintf(errmsg, "NetBSD partition size (%d) too small\n", pp->p_size);
+			} else if (dosdp->dp_start != pp->p_offset) {
+				sprintf(errmsg, "NetBSD partition start mismatch (%d != %d)\n",
+						 pp->p_offset, dosdp->dp_start);
+			} else
+				*errmsg = 0;
+		}
+		if (dosdp && *errmsg == 0) {
 			lbl_off = pp->p_offset;
 		} else {
 			if (dosdp) {
 				int c;
 
-				printf("overwriting disk with DOS partition table? (n): ");
+				printf(errmsg);
+				printf("[D]elete partition table or e[X]it (D/X) [x]: ");
 				fflush(stdout);
 				c = getchar();
 				if (c != EOF && c != '\n')
 					while (getchar() != '\n')
 						;
-				if  (c != 'y' && c != 'Y')
-					exit(0);
+				if  (c != 'd' && c != 'D')
+					exit(ENOSPC);
 			}
 			lbl_off = 0;
 		}

------------------------------------------------------------------------------