Module Name:    src
Committed By:   msaitoh
Date:           Wed Oct 23 06:03:24 UTC 2019

Modified Files:
        src/usr.sbin/sysinst [netbsd-9]: disklabel.c

Log Message:
Pull up following revision(s) (requested by martin in ticket #364):
        usr.sbin/sysinst/disklabel.c: revision 1.14
When translating (internal) indices to device names, properly deal with
gaps in partition allocations (e.g. no swap partition).


To generate a diff of this commit:
cvs rdiff -u -r1.10.2.3 -r1.10.2.4 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.10.2.3 src/usr.sbin/sysinst/disklabel.c:1.10.2.4
--- src/usr.sbin/sysinst/disklabel.c:1.10.2.3	Sun Aug 18 13:22:49 2019
+++ src/usr.sbin/sysinst/disklabel.c	Wed Oct 23 06:03:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: disklabel.c,v 1.10.2.3 2019/08/18 13:22:49 msaitoh Exp $	*/
+/*	$NetBSD: disklabel.c,v 1.10.2.4 2019/10/23 06:03:24 msaitoh Exp $	*/
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -717,6 +717,8 @@ again:
 				continue;
 			if (parts->l.d_partitions[i].p_fstype == FS_UNUSED)
 				continue;
+			if (parts->l.d_partitions[i].p_size == 0)
+				continue;
 
 			s = parts->l.d_partitions[i].p_offset;
 			e = parts->l.d_partitions[i].p_size + s;
@@ -823,11 +825,17 @@ disklabel_get_part_device(const struct d
 	if (ptn >= parts->l.d_npartitions)
 		return false;
 
-	for (id = part_index = 0; id < ptn &&
-	    part_index < parts->l.d_npartitions; part_index++)
-		if (parts->l.d_partitions[part_index].p_fstype != FS_UNUSED ||
-		    parts->l.d_partitions[part_index].p_size != 0)
-			id++;
+	for (id = part_index = 0; part_index < parts->l.d_npartitions;
+	    part_index++) {
+		if (parts->l.d_partitions[part_index].p_fstype == FS_UNUSED &&
+		    parts->l.d_partitions[part_index].p_size == 0)
+			continue;
+		if (id == ptn)
+			break;
+		id++;
+		if (id > ptn)
+			return false;
+	}
 
 	if (part != 0)
 		*part = part_index;

Reply via email to