Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst Remove more pm->ptstart abuse - calculate v...



details:   https://anonhg.NetBSD.org/src/rev/e0887fe1fae1
branches:  trunk
changeset: 940585:e0887fe1fae1
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Oct 10 19:42:19 2020 +0000

description:
Remove more pm->ptstart abuse - calculate values localy where needed
instead.

diffstat:

 usr.sbin/sysinst/arch/i386/md.c |  28 ++++++++++++++++++----------
 usr.sbin/sysinst/label.c        |  24 +++---------------------
 usr.sbin/sysinst/part_edit.c    |  29 +++++------------------------
 3 files changed, 26 insertions(+), 55 deletions(-)

diffs (232 lines):

diff -r 283fff984c4b -r e0887fe1fae1 usr.sbin/sysinst/arch/i386/md.c
--- a/usr.sbin/sysinst/arch/i386/md.c   Sat Oct 10 19:25:19 2020 +0000
+++ b/usr.sbin/sysinst/arch/i386/md.c   Sat Oct 10 19:42:19 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.c,v 1.30 2020/02/06 10:47:33 martin Exp $ */
+/*     $NetBSD: md.c,v 1.31 2020/10/10 19:42:19 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -65,7 +65,7 @@
 /* prototypes */
 
 static bool get_bios_info(const char*, struct disk_partitions*, int*, int*, int*);
-static int mbr_root_above_chs(void);
+static int mbr_root_above_chs(daddr_t);
 static int md_read_bootcode(const char *, struct mbr_sector *);
 static unsigned int get_bootmodel(void);
 
@@ -462,6 +462,7 @@
        mbr_info_t *ext;
        struct mbr_partition *p;
        const char *bootcode;
+       daddr_t inst_start, inst_size;
        int i, names, fl, ofl;
 #define        ACTIVE_FOUND    0x0100
 #define        NETBSD_ACTIVE   0x0200
@@ -469,8 +470,15 @@
 #define        ACTIVE_NAMED    0x0800
 
        root_limit = 0;
+       if (parts->pscheme->guess_install_target == NULL ||
+           !parts->pscheme->guess_install_target(parts, &inst_start,
+           &inst_size)) {
+               inst_start = parts->disk_start;
+               inst_size = parts->disk_size;
+       }
+
        if (biosdisk != NULL && (biosdisk->bi_flags & BIFLAG_EXTINT13) == 0) {
-               if (mbr_root_above_chs()) {
+               if (mbr_root_above_chs(inst_start)) {
                        if (quiet)
                                return 0;
                        msg_display(MSG_partabovechs);
@@ -487,7 +495,7 @@
        }
 
        /*
-        * Ensure the install partition (at sector pm->ptstart) and the active
+        * Ensure the install partition (at sector inst_start) and the active
         * partition are bootable.
         * Determine whether the bootselect code is needed.
         * Note that MBR_BS_NEWMBR is always set, so we ignore it!
@@ -499,14 +507,14 @@
                for (i = 0; i < MBR_PART_COUNT; p++, i++) {
                        if (p->mbrp_flag == MBR_PFLAG_ACTIVE) {
                                fl |= ACTIVE_FOUND;
-                           if (ext->sector + p->mbrp_start == pm->ptstart)
+                           if (ext->sector + p->mbrp_start == inst_start)
                                fl |= NETBSD_ACTIVE;
                        }
                        if (ext->mbrb.mbrbs_nametab[i][0] == 0) {
                                /* No bootmenu label... */
                                if (ext->sector == 0)
                                        continue;
-                               if (ext->sector + p->mbrp_start == pm->ptstart)
+                               if (ext->sector + p->mbrp_start == inst_start)
                                        /*
                                         * Have installed into an extended ptn
                                         * force name & bootsel...
@@ -517,7 +525,7 @@
                        /* Partition has a bootmenu label... */
                        if (ext->sector != 0)
                                fl |= MBR_BS_EXTLBA;
-                       if (ext->sector + p->mbrp_start == pm->ptstart)
+                       if (ext->sector + p->mbrp_start == inst_start)
                                fl |= NETBSD_NAMED;
                        else if (p->mbrp_flag == MBR_PFLAG_ACTIVE)
                                fl |= ACTIVE_NAMED;
@@ -571,7 +579,7 @@
                /* Check there is some bootcode at all... */
                if (mbri->mbr.mbr_magic != htole16(MBR_MAGIC) ||
                    mbri->mbr.mbr_jmpboot[0] == 0 ||
-                   mbr_root_above_chs())
+                   mbr_root_above_chs(inst_start))
                        /* Existing won't do, force update */
                        fl |= MBR_BS_NEWMBR;
        }
@@ -709,9 +717,9 @@
 }
 
 static int
-mbr_root_above_chs(void)
+mbr_root_above_chs(daddr_t ptstart)
 {
-       return pm->ptstart + (daddr_t)DEFROOTSIZE * (daddr_t)(MEG / 512)
+       return ptstart + (daddr_t)DEFROOTSIZE * (daddr_t)(MEG / 512)
            >= pm->max_chs;
 }
 
diff -r 283fff984c4b -r e0887fe1fae1 usr.sbin/sysinst/label.c
--- a/usr.sbin/sysinst/label.c  Sat Oct 10 19:25:19 2020 +0000
+++ b/usr.sbin/sysinst/label.c  Sat Oct 10 19:42:19 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: label.c,v 1.27 2020/10/09 18:33:00 martin Exp $        */
+/*     $NetBSD: label.c,v 1.28 2020/10/10 19:42:19 martin Exp $        */
 
 /*
  * Copyright 1997 Jonathan Stone
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: label.c,v 1.27 2020/10/09 18:33:00 martin Exp $");
+__RCSID("$NetBSD: label.c,v 1.28 2020/10/10 19:42:19 martin Exp $");
 #endif
 
 #include <sys/types.h>
@@ -187,11 +187,10 @@
        struct part_usage_info *wanted;
        struct disk_partitions *parts;
        size_t i, num_root;
-       daddr_t first_bsdstart, first_bsdsize, inst_start, inst_size;
+       daddr_t first_bsdstart, inst_start;
        int rv;
 
        first_bsdstart = inst_start = -1;
-       first_bsdsize = inst_size = 0;
        num_root = 0;
        parts = pset->parts;
        for (i = 0; i < pset->num; i++) {
@@ -209,12 +208,10 @@
  
                if (first_bsdstart <= 0) {
                        first_bsdstart = wanted->cur_start;
-                       first_bsdsize = wanted->size;
                }
                if (inst_start < 0 &&
                    (wanted->cur_flags & PTI_INSTALL_TARGET)) {
                        inst_start = wanted->cur_start;
-                       inst_size = wanted->size;
                }
        }
 
@@ -233,21 +230,6 @@
                        return rv;
        }
 
-       if (pm->ptstart == 0) {
-               if (inst_start > 0) {
-                       pm->ptstart = inst_start;
-                       pm->ptsize = inst_size;
-               } else if (first_bsdstart > 0) {
-                       pm->ptstart = first_bsdstart;
-                       pm->ptsize = first_bsdsize;
-               } else if (parts->pscheme->guess_install_target &&
-                          parts->pscheme->guess_install_target(
-                          parts, &inst_start, &inst_size)) {
-                       pm->ptstart = inst_start;
-                       pm->ptsize = inst_size;
-               }
-       }
-
        /* Check for overlaps */
        if (checkoverlap(parts) != 0) {
                rv = ask_reedit(parts);
diff -r 283fff984c4b -r e0887fe1fae1 usr.sbin/sysinst/part_edit.c
--- a/usr.sbin/sysinst/part_edit.c      Sat Oct 10 19:25:19 2020 +0000
+++ b/usr.sbin/sysinst/part_edit.c      Sat Oct 10 19:42:19 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: part_edit.c,v 1.20 2020/10/10 18:48:32 martin Exp $ */
+/*     $NetBSD: part_edit.c,v 1.21 2020/10/10 19:42:19 martin Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -1093,10 +1093,10 @@
 {
        part_id i;
        int num_bsdparts;
-       daddr_t first_bsdstart, first_bsdsize, inst_start, inst_size;
+       daddr_t first_bsdstart, inst_start, inst_size;
 
        first_bsdstart = inst_start = -1;
-       first_bsdsize = inst_size = 0;
+       inst_size = 0;
        num_bsdparts = 0;
        for (i = 0; i < parts->num_part; i++) {
                struct disk_part_info info;
@@ -1110,7 +1110,6 @@
 
                if (first_bsdstart < 0) {
                        first_bsdstart = info.start;
-                       first_bsdsize = info.size;
                }
                if (inst_start<  0 && (info.flags & PTI_INSTALL_TARGET)) {
                        inst_start = info.start;
@@ -1122,12 +1121,9 @@
            (num_bsdparts > 1 && inst_start < 0)) {
                if (quiet && num_bsdparts == 0)
                        return 0;
-               if (quiet && parts->pscheme->guess_install_target &&
-                   parts->pscheme->guess_install_target(parts,
+               if (!quiet || parts->pscheme->guess_install_target == NULL ||
+                   !parts->pscheme->guess_install_target(parts,
                    &inst_start, &inst_size)) {
-                       pm->ptstart = inst_start;
-                       pm->ptsize = inst_size;
-               } else {
                        if (num_bsdparts == 0)
                                msg_display_subst(MSG_nobsdpart, 2,
                                    msg_string(parts->pscheme->name),
@@ -1141,21 +1137,6 @@
                }
        }
 
-       if (pm->ptstart == 0) {
-               if (inst_start > 0) {
-                       pm->ptstart = inst_start;
-                       pm->ptsize = inst_size;
-               } else if (first_bsdstart > 0) {
-                       pm->ptstart = first_bsdstart;
-                       pm->ptsize = first_bsdsize;
-               } else if (parts->pscheme->guess_install_target &&
-                          parts->pscheme->guess_install_target(
-                          parts, &inst_start, &inst_size)) {
-                       pm->ptstart = inst_start;
-                       pm->ptsize = inst_size;
-               }
-       }
-
        /*
         * post_edit_verify returns:
         *  0 -> abort



Home | Main Index | Thread Index | Old Index