Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst When translating (internal) indices to devi...



details:   https://anonhg.NetBSD.org/src/rev/176860006cd0
branches:  trunk
changeset: 460399:176860006cd0
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Oct 21 16:09:59 2019 +0000

description:
When translating (internal) indices to device names, properly deal with
gaps in partition allocations (e.g. no swap partition).

diffstat:

 usr.sbin/sysinst/disklabel.c |  20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diffs (41 lines):

diff -r 6e99ddcff885 -r 176860006cd0 usr.sbin/sysinst/disklabel.c
--- a/usr.sbin/sysinst/disklabel.c      Mon Oct 21 14:23:53 2019 +0000
+++ b/usr.sbin/sysinst/disklabel.c      Mon Oct 21 16:09:59 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disklabel.c,v 1.13 2019/08/14 13:58:00 martin Exp $    */
+/*     $NetBSD: disklabel.c,v 1.14 2019/10/21 16:09:59 martin Exp $    */
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -717,6 +717,8 @@
                                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 @@
        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;



Home | Main Index | Thread Index | Old Index