Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst Too much disklabel magic happening in the k...



details:   https://anonhg.NetBSD.org/src/rev/1575954b8fb2
branches:  trunk
changeset: 1006806:1575954b8fb2
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Jan 28 07:43:42 2020 +0000

description:
Too much disklabel magic happening in the kernel - to compensate force
MBR first when trying to identify the existing partitioning scheme of
a disk.

diffstat:

 usr.sbin/sysinst/partitions.c |  19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diffs (62 lines):

diff -r 7018ca829752 -r 1575954b8fb2 usr.sbin/sysinst/partitions.c
--- a/usr.sbin/sysinst/partitions.c     Tue Jan 28 07:12:08 2020 +0000
+++ b/usr.sbin/sysinst/partitions.c     Tue Jan 28 07:43:42 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: partitions.c,v 1.9 2020/01/27 21:21:22 martin Exp $    */
+/*     $NetBSD: partitions.c,v 1.10 2020/01/28 07:43:42 martin Exp $   */
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -41,6 +41,8 @@
  */
 size_t num_available_part_schemes;
 
+extern const struct disk_partitioning_scheme disklabel_parts;
+
 /*
  * Generic reader - query a disk device and read all partitions from it.
  * disk_size is in units of physical sector size, which is passe as
@@ -51,14 +53,23 @@
     bool no_mbr)
 {
        const struct disk_partitioning_scheme **ps;
+#ifdef HAVE_MBR
+       bool mbr_done = false, disklabel_done = false;
+#endif
 
        if (!available_part_schemes)
                return NULL;
 
        for (ps = available_part_schemes; *ps; ps++) {
 #ifdef HAVE_MBR
+               if (!no_mbr && (*ps) == &disklabel_parts && !mbr_done)
+                       continue;
                if (no_mbr && (*ps)->name == MSG_parttype_mbr)
                        continue;
+               if ((*ps)->name == MSG_parttype_mbr)
+                       mbr_done = true;
+               if ((*ps)->read_from_disk == disklabel_parts.read_from_disk)
+                       disklabel_done = true;
 #endif
                struct disk_partitions *parts =
                    (*ps)->read_from_disk(dev, 0, disk_size, bytes_per_sec,
@@ -66,6 +77,11 @@
                if (parts)
                        return parts;
        }
+#ifdef HAVE_MBR
+       if (!disklabel_done)
+               return disklabel_parts.read_from_disk(dev, 0, disk_size,
+                   bytes_per_sec, &disklabel_parts);
+#endif
        return NULL;
 }
 
@@ -117,7 +133,6 @@
 extern const struct disk_partitioning_scheme mbr_parts;
 #endif
 
-extern const struct disk_partitioning_scheme disklabel_parts;
 #if RAW_PART != 2
 static struct disk_partitioning_scheme only_disklabel_parts;
 



Home | Main Index | Thread Index | Old Index