Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst/arch/luna68k PR 55058: force the boot parti...



details:   https://anonhg.NetBSD.org/src/rev/81b5bfa32b45
branches:  trunk
changeset: 372942:81b5bfa32b45
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Jan 06 18:14:56 2023 +0000

description:
PR 55058: force the boot partition to sd0d, so our root partitions becomes
sd0a again.

diffstat:

 usr.sbin/sysinst/arch/luna68k/md.c |  55 +++++++++++++++++++++++++------------
 usr.sbin/sysinst/arch/luna68k/md.h |  14 ++++++++-
 2 files changed, 50 insertions(+), 19 deletions(-)

diffs (127 lines):

diff -r 0106cdf6aa1a -r 81b5bfa32b45 usr.sbin/sysinst/arch/luna68k/md.c
--- a/usr.sbin/sysinst/arch/luna68k/md.c        Fri Jan 06 18:13:40 2023 +0000
+++ b/usr.sbin/sysinst/arch/luna68k/md.c        Fri Jan 06 18:14:56 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.c,v 1.10 2022/01/29 16:01:19 martin Exp $   */
+/*     $NetBSD: md.c,v 1.11 2023/01/06 18:14:56 martin Exp $   */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -117,6 +117,23 @@
        return make_bsd_partitions(install);
 }
 
+static part_id
+find_boot_part(struct install_partition_desc *install)
+{
+       for (size_t i = 0; i < install->num; i++) {
+               if (install->infos[i].fs_type != PART_BOOT_TYPE)
+                       continue;
+               if (install->infos[i].fs_version != PART_BOOT_SUBT)
+                       continue;
+               if (install->infos[i].size < (PART_BOOT/512))
+                       continue;
+               if (install->infos[i].cur_start > 0)
+                       continue;
+               return i;
+       }
+       return NO_PART;
+}
+
 /*
  * any additional partition validation
  */
@@ -128,14 +145,12 @@
         * Make sure that a boot partition (old 4.3BSD UFS) is prepared
         * properly for our native bootloader.
         */
-       if (install->num < 1 || install->infos[0].fs_type != PART_BOOT_TYPE ||
-           install->infos[0].fs_version != PART_BOOT_SUBT ||
-           !(install->infos[0].instflags & PUIINST_NEWFS)) {
-               msg_display(MSG_nobootpartdisklabel);
-               process_menu(MENU_ok, NULL);
-               return false;
-       }
-       return true;
+       if (find_boot_part(install) != NO_PART)
+               return true;
+
+       msg_display(MSG_nobootpartdisklabel);
+       process_menu(MENU_ok, NULL);
+       return false;
 }
 
 /*
@@ -187,16 +202,19 @@
 md_post_newfs(struct install_partition_desc *install)
 {
        char rdisk[STRSIZE], disk[STRSIZE];
+       part_id boot_part = find_boot_part(install);
 
-       if (install->num < 1)
+       if (boot_part == NO_PART)
                return 1;
 
-       if (!install->infos[0].parts->pscheme->get_part_device(
-           install->infos[0].parts, install->infos[0].cur_part_id,
+       if (!install->infos[boot_part].parts->pscheme->get_part_device(
+           install->infos[boot_part].parts,
+           install->infos[boot_part].cur_part_id,
            rdisk, sizeof rdisk, NULL, raw_dev_name, true, true))
                return 1;
-       if (!install->infos[0].parts->pscheme->get_part_device(
-           install->infos[0].parts, install->infos[0].cur_part_id,
+       if (!install->infos[boot_part].parts->pscheme->get_part_device(
+           install->infos[boot_part].parts,
+           install->infos[boot_part].cur_part_id,
            disk, sizeof disk, NULL, plain_name, true, true))
                return 1;
 
@@ -240,12 +258,14 @@
        struct stat sb;
        bool hasboot = false;
        char disk[STRSIZE];
+       part_id boot_part = find_boot_part(install);
 
-       if (install->num < 1)
+       if (boot_part == NO_PART)
                return 0;
 
-       if (!install->infos[0].parts->pscheme->get_part_device(
-           install->infos[0].parts, install->infos[0].cur_part_id,
+       if (!install->infos[boot_part].parts->pscheme->get_part_device(
+           install->infos[boot_part].parts,
+           install->infos[boot_part].cur_part_id,
            disk, sizeof disk, NULL, plain_name, true, true))
                return 0;
 
@@ -288,4 +308,3 @@
        return true;
 }
 #endif
-
diff -r 0106cdf6aa1a -r 81b5bfa32b45 usr.sbin/sysinst/arch/luna68k/md.h
--- a/usr.sbin/sysinst/arch/luna68k/md.h        Fri Jan 06 18:13:40 2023 +0000
+++ b/usr.sbin/sysinst/arch/luna68k/md.h        Fri Jan 06 18:14:56 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.h,v 1.6 2022/06/17 16:09:47 tsutsui Exp $   */
+/*     $NetBSD: md.h,v 1.7 2023/01/06 18:14:56 martin Exp $    */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -64,3 +64,15 @@
  * the hand-edited disklabel will NOT be written by MI code.
  */
 #define DISKLABEL_CMD  "disklabel -w -r"
+
+/*
+ * Our boot partition is FFSv1, so it will be reported as PT_root
+ * and might take up disklabel slot 0 (partition 'a'), which we would
+ * like to avoid and make it use 'd' instead.
+ * Only allow PT_root partitions for slots before RAW_PART if they
+ * start past the boot partition size.
+ */
+#define        MD_DISKLABEL_PART_INDEX_CHECK(DL,NDX,INFO)      \
+       (((INFO)->nat_type->generic_ptype != PT_root)   \
+       || (NDX > RAW_PART)                             \
+       || ((INFO)->start >= (PART_BOOT/512)))



Home | Main Index | Thread Index | Old Index