Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst On architectures that usually do MBR/diskla...



details:   https://anonhg.NetBSD.org/src/rev/1710cede75c5
branches:  trunk
changeset: 964732:1710cede75c5
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Aug 14 13:02:23 2019 +0000

description:
On architectures that usually do MBR/disklabel, nevertheless deal with
pure/plain disklabel disks, and explicitly offer this as partitioning
option when bootability is not a concern.

diffstat:

 usr.sbin/sysinst/disklabel.c  |   7 ++++---
 usr.sbin/sysinst/gpt.c        |   7 ++++---
 usr.sbin/sysinst/mbr.c        |  10 ++++++----
 usr.sbin/sysinst/msg.mi.de    |   7 ++++++-
 usr.sbin/sysinst/msg.mi.en    |   7 ++++++-
 usr.sbin/sysinst/msg.mi.es    |   7 ++++++-
 usr.sbin/sysinst/msg.mi.fr    |   7 ++++++-
 usr.sbin/sysinst/msg.mi.pl    |   7 ++++++-
 usr.sbin/sysinst/partitions.c |  35 +++++++++++++++++++++++++++++++----
 usr.sbin/sysinst/partitions.h |   5 +++--
 10 files changed, 78 insertions(+), 21 deletions(-)

diffs (288 lines):

diff -r 0948404165ac -r 1710cede75c5 usr.sbin/sysinst/disklabel.c
--- a/usr.sbin/sysinst/disklabel.c      Wed Aug 14 12:55:35 2019 +0000
+++ b/usr.sbin/sysinst/disklabel.c      Wed Aug 14 13:02:23 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disklabel.c,v 1.11 2019/08/07 10:08:04 martin Exp $    */
+/*     $NetBSD: disklabel.c,v 1.12 2019/08/14 13:02:23 martin Exp $    */
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -164,7 +164,8 @@
 }
 
 static struct disk_partitions *
-disklabel_parts_read(const char *disk, daddr_t start, daddr_t len)
+disklabel_parts_read(const char *disk, daddr_t start, daddr_t len,
+    const struct disk_partitioning_scheme *scheme)
 {
        int fd;
        char diskpath[MAXPATHLEN];
@@ -214,7 +215,7 @@
 
        if (len > disklabel_parts.size_limit)
                len = disklabel_parts.size_limit;
-       parts->dp.pscheme = &disklabel_parts;
+       parts->dp.pscheme = scheme;
        parts->dp.disk = disk;
        parts->dp.disk_start = start;
        parts->dp.disk_size = parts->dp.free_space = len;
diff -r 0948404165ac -r 1710cede75c5 usr.sbin/sysinst/gpt.c
--- a/usr.sbin/sysinst/gpt.c    Wed Aug 14 12:55:35 2019 +0000
+++ b/usr.sbin/sysinst/gpt.c    Wed Aug 14 13:02:23 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gpt.c,v 1.9 2019/08/07 10:08:04 martin Exp $   */
+/*     $NetBSD: gpt.c,v 1.10 2019/08/14 13:02:23 martin Exp $  */
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -249,7 +249,8 @@
 }
 
 static struct disk_partitions *
-gpt_read_from_disk(const char *dev, daddr_t start, daddr_t len)
+gpt_read_from_disk(const char *dev, daddr_t start, daddr_t len,
+    const struct disk_partitioning_scheme *scheme)
 {
        char diskpath[MAXPATHLEN];
        int fd;
@@ -362,7 +363,7 @@
                return NULL;
        }
 
-       parts->dp.pscheme = &gpt_parts;
+       parts->dp.pscheme = scheme;
        parts->dp.disk = dev;
        parts->dp.disk_start = start;
        parts->dp.disk_size = disk_size;
diff -r 0948404165ac -r 1710cede75c5 usr.sbin/sysinst/mbr.c
--- a/usr.sbin/sysinst/mbr.c    Wed Aug 14 12:55:35 2019 +0000
+++ b/usr.sbin/sysinst/mbr.c    Wed Aug 14 13:02:23 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mbr.c,v 1.19 2019/07/26 08:18:47 martin Exp $ */
+/*     $NetBSD: mbr.c,v 1.20 2019/08/14 13:02:23 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -880,7 +880,8 @@
 }
 
 static struct disk_partitions *
-mbr_read_from_disk(const char *disk, daddr_t start, daddr_t len)
+mbr_read_from_disk(const char *disk, daddr_t start, daddr_t len,
+    const struct disk_partitioning_scheme *scheme)
 {
        struct mbr_disk_partitions *parts;
 
@@ -892,7 +893,7 @@
        if (!parts)
                return NULL;
 
-       parts->dp.pscheme = &mbr_parts;
+       parts->dp.pscheme = scheme;
        parts->dp.disk = disk;
        if (len >= mbr_parts.size_limit)
                len = mbr_parts.size_limit;
@@ -1629,7 +1630,8 @@
 
                if (!force_empty)
                        myparts->dlabel = disklabel_parts.read_from_disk(
-                           myparts->dp.disk, part.start, part.size);
+                           myparts->dp.disk, part.start, part.size,
+                           &disklabel_parts);
 
                if (myparts->dlabel == NULL && part.size > 0) {
                        /* we just created the outer partitions? */
diff -r 0948404165ac -r 1710cede75c5 usr.sbin/sysinst/msg.mi.de
--- a/usr.sbin/sysinst/msg.mi.de        Wed Aug 14 12:55:35 2019 +0000
+++ b/usr.sbin/sysinst/msg.mi.de        Wed Aug 14 13:02:23 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.de,v 1.13 2019/07/23 18:13:40 martin Exp $      */
+/*     $NetBSD: msg.mi.de,v 1.14 2019/08/14 13:02:23 martin Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1263,6 +1263,11 @@
 
 message parttype_disklabel {BSD disklabel}
 message parttype_disklabel_short {disklabel}
+/*
+ * This is used on architectures with MBR above disklabel when there is
+ * no MBR on a disk.
+ */
+message parttype_only_disklabel {disklabel (nur NetBSD)}
 
 message select_part_scheme
 {Dieses Gerät wurde anscheinend noch nicht partitioniert. 
diff -r 0948404165ac -r 1710cede75c5 usr.sbin/sysinst/msg.mi.en
--- a/usr.sbin/sysinst/msg.mi.en        Wed Aug 14 12:55:35 2019 +0000
+++ b/usr.sbin/sysinst/msg.mi.en        Wed Aug 14 13:02:23 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.en,v 1.19 2019/07/23 18:13:40 martin Exp $      */
+/*     $NetBSD: msg.mi.en,v 1.20 2019/08/14 13:02:23 martin Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1192,6 +1192,11 @@
 
 message parttype_disklabel {BSD disklabel}
 message parttype_disklabel_short {disklabel}
+/*
+ * This is used on architectures with MBR above disklabel when there is
+ * no MBR on a disk.
+ */
+message parttype_only_disklabel {disklabel (NetBSD only)}
 
 message select_part_scheme
 {The disk seems not to have been partitioned before. Please select
diff -r 0948404165ac -r 1710cede75c5 usr.sbin/sysinst/msg.mi.es
--- a/usr.sbin/sysinst/msg.mi.es        Wed Aug 14 12:55:35 2019 +0000
+++ b/usr.sbin/sysinst/msg.mi.es        Wed Aug 14 13:02:23 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.es,v 1.14 2019/07/23 18:13:40 martin Exp $      */
+/*     $NetBSD: msg.mi.es,v 1.15 2019/08/14 13:02:23 martin Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1242,6 +1242,11 @@
 
 message parttype_disklabel {BSD disklabel}
 message parttype_disklabel_short {disklabel}
+/*
+ * This is used on architectures with MBR above disklabel when there is
+ * no MBR on a disk.
+ */
+message parttype_only_disklabel {disklabel (NetBSD only)}
 
 message select_part_scheme
 {The disk seems not to have been partitioned before. Please select
diff -r 0948404165ac -r 1710cede75c5 usr.sbin/sysinst/msg.mi.fr
--- a/usr.sbin/sysinst/msg.mi.fr        Wed Aug 14 12:55:35 2019 +0000
+++ b/usr.sbin/sysinst/msg.mi.fr        Wed Aug 14 13:02:23 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.fr,v 1.17 2019/07/23 18:13:40 martin Exp $      */
+/*     $NetBSD: msg.mi.fr,v 1.18 2019/08/14 13:02:23 martin Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1295,6 +1295,11 @@
 
 message parttype_disklabel {BSD disklabel}
 message parttype_disklabel_short {disklabel}
+/*
+ * This is used on architectures with MBR above disklabel when there is
+ * no MBR on a disk.
+ */
+message parttype_only_disklabel {disklabel (NetBSD only)}
 
 message select_part_scheme
 {The disk seems not to have been partitioned before. Please select
diff -r 0948404165ac -r 1710cede75c5 usr.sbin/sysinst/msg.mi.pl
--- a/usr.sbin/sysinst/msg.mi.pl        Wed Aug 14 12:55:35 2019 +0000
+++ b/usr.sbin/sysinst/msg.mi.pl        Wed Aug 14 13:02:23 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.pl,v 1.20 2019/07/23 18:13:40 martin Exp $      */
+/*     $NetBSD: msg.mi.pl,v 1.21 2019/08/14 13:02:23 martin Exp $      */
 /*     Based on english version: */
 /*     NetBSD: msg.mi.pl,v 1.36 2004/04/17 18:55:35 atatat Exp       */
 
@@ -1188,6 +1188,11 @@
 
 message parttype_disklabel {disklabel BSD}
 message parttype_disklabel_short {disklabel}
+/*
+ * This is used on architectures with MBR above disklabel when there is
+ * no MBR on a disk.
+ */
+message parttype_only_disklabel {disklabel (NetBSD only)}
 
 message select_part_scheme
 {Ten dysk nie byl wczesniej partycjonowany. Wybierz typ tablicy
diff -r 0948404165ac -r 1710cede75c5 usr.sbin/sysinst/partitions.c
--- a/usr.sbin/sysinst/partitions.c     Wed Aug 14 12:55:35 2019 +0000
+++ b/usr.sbin/sysinst/partitions.c     Wed Aug 14 13:02:23 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: partitions.c,v 1.1 2019/06/12 06:20:18 martin Exp $    */
+/*     $NetBSD: partitions.c,v 1.2 2019/08/14 13:02:23 martin Exp $    */
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
 
        for (ps = available_part_schemes; *ps; ps++) {
                struct disk_partitions *parts =
-                   (*ps)->read_from_disk(dev, 0, disk_size);
+                   (*ps)->read_from_disk(dev, 0, disk_size, *ps);
                if (parts)
                        return parts;
        }
@@ -78,8 +78,23 @@
 #ifdef HAVE_MBR
 extern const struct disk_partitioning_scheme mbr_parts;
 #endif
-#if RAW_PART == 2      /* only available as primary on some architectures */
-const struct disk_partitioning_scheme disklabel_parts;
+
+extern const struct disk_partitioning_scheme disklabel_parts;
+#if RAW_PART != 2
+static struct disk_partitioning_scheme only_disklabel_parts;
+
+/*
+ * If not overriden by MD code, we can not boot from plain
+ * disklabel disks (w/o MBR).
+ */
+static bool have_only_disklabel_boot_support(const char *disk)
+{
+#ifdef HAVE_PLAIN_DISKLABEL_BOOT
+       return HAVE_PLAIN_DISKLABEL_BOOT(disk);
+#else
+       return false;
+#endif
+}
 #endif
 
 /*
@@ -104,6 +119,9 @@
 #ifdef HAVE_MBR
                { NULL, &mbr_parts },
 #endif
+#if RAW_PART != 2      /* "whole disk NetBSD" disklabel variant */
+               { NULL, &only_disklabel_parts },
+#endif
        };
 
        size_t i, avail;
@@ -113,6 +131,15 @@
 
        check_available_binaries();
 
+#if RAW_PART != 2
+       /* generate a variant of disklabel w/o parent scheme */
+       only_disklabel_parts = disklabel_parts;
+       only_disklabel_parts.name = MSG_parttype_only_disklabel;
+       only_disklabel_parts.have_boot_support =
+           have_only_disklabel_boot_support;
+#endif
+
+
        is_available = malloc(all_cnt);
 
        for (avail = i = 0; i < all_cnt; i++) {
diff -r 0948404165ac -r 1710cede75c5 usr.sbin/sysinst/partitions.h
--- a/usr.sbin/sysinst/partitions.h     Wed Aug 14 12:55:35 2019 +0000
+++ b/usr.sbin/sysinst/partitions.h     Wed Aug 14 13:02:23 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: partitions.h,v 1.5 2019/08/07 10:08:04 martin Exp $    */
+/*     $NetBSD: partitions.h,v 1.6 2019/08/14 13:02:23 martin Exp $    */
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -413,7 +413,8 @@
         * disk.
         */
        struct disk_partitions * (*read_from_disk)(const char *,
-           daddr_t start, daddr_t len);
+           daddr_t start, daddr_t len, const struct
+           disk_partitioning_scheme *);
 
        /*
         * Set up all internal data for a new disk



Home | Main Index | Thread Index | Old Index