Module Name:    src
Committed By:   martin
Date:           Sun Jul 21 11:56:20 UTC 2019

Modified Files:
        src/usr.sbin/sysinst: disklabel.c

Log Message:
When changing the user geometry, do not alter the disklabel internal
geometry information. On drives only capable of doing CHS addressing,
we rely on this data.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/sysinst/disklabel.c

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

Modified files:

Index: src/usr.sbin/sysinst/disklabel.c
diff -u src/usr.sbin/sysinst/disklabel.c:1.8 src/usr.sbin/sysinst/disklabel.c:1.9
--- src/usr.sbin/sysinst/disklabel.c:1.8	Sun Jul 21 11:36:34 2019
+++ src/usr.sbin/sysinst/disklabel.c	Sun Jul 21 11:56:20 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: disklabel.c,v 1.8 2019/07/21 11:36:34 martin Exp $	*/
+/*	$NetBSD: disklabel.c,v 1.9 2019/07/21 11:56:20 martin Exp $	*/
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -99,18 +99,18 @@ disklabel_change_geom(struct disk_partit
 	struct disklabel_disk_partitions *parts =
 	    (struct disklabel_disk_partitions*)arg;
 
-	disklabel_init_default_alignment(parts, nhead * nsec);
-
-	parts->l.d_ncylinders = ncyl;
-	parts->l.d_ntracks = nhead;
-	parts->l.d_nsectors = nsec;
-	parts->l.d_secsize = DEV_BSIZE;
-	parts->l.d_secpercyl = nsec * nhead;
+	assert(parts->l.d_secsize != 0);
+	assert(parts->l.d_nsectors != 0);
+	assert(parts->l.d_ntracks != 0);
+	assert(parts->l.d_ncylinders != 0);
+	assert(parts->l.d_secpercyl != 0);
 
+	disklabel_init_default_alignment(parts, nhead * nsec);
 	if (ncyl*nhead*nsec <= TINY_DISK_SIZE)
 		set_default_sizemult(1);
 	else
 		set_default_sizemult(MEG/512);
+
 	return true;
 }
 
@@ -273,6 +273,10 @@ disklabel_write_to_disk(struct disk_part
 	size_t n;
 
 	assert(parts->l.d_secsize != 0);
+	assert(parts->l.d_nsectors != 0);
+	assert(parts->l.d_ntracks != 0);
+	assert(parts->l.d_ncylinders != 0);
+	assert(parts->l.d_secpercyl != 0);
 
 	sprintf(fname, "/tmp/disklabel.%u", getpid());
 	f = fopen(fname, "w");

Reply via email to