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 setting up a "use whole disk" single o...



details:   https://anonhg.NetBSD.org/src/rev/811867861acd
branches:  trunk
changeset: 452018:811867861acd
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Jun 15 08:20:33 2019 +0000

description:
When setting up a "use whole disk" single outer partition, force an
empty set of inner partitions immediately,

This avoids reading old (stale) partitions (e.g. disklabel that
survived cleaning and re-creating the MBR with the MBR NetBSD partition
starting at the same offset) later.

diffstat:

 usr.sbin/sysinst/bsddisklabel.c |   4 ++--
 usr.sbin/sysinst/disks.c        |   6 +++---
 usr.sbin/sysinst/install.c      |   4 ++--
 usr.sbin/sysinst/mbr.c          |  12 ++++++++----
 usr.sbin/sysinst/part_edit.c    |   7 ++++++-
 usr.sbin/sysinst/partitions.h   |  10 ++++++++--
 usr.sbin/sysinst/target.c       |   6 +++---
 7 files changed, 32 insertions(+), 17 deletions(-)

diffs (178 lines):

diff -r 612b9746df96 -r 811867861acd usr.sbin/sysinst/bsddisklabel.c
--- a/usr.sbin/sysinst/bsddisklabel.c   Sat Jun 15 07:57:38 2019 +0000
+++ b/usr.sbin/sysinst/bsddisklabel.c   Sat Jun 15 08:20:33 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bsddisklabel.c,v 1.11 2019/06/13 12:44:20 martin Exp $ */
+/*     $NetBSD: bsddisklabel.c,v 1.12 2019/06/15 08:20:33 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1458,7 +1458,7 @@
        if (pscheme->secondary_partitions) {
                struct disk_partitions *p;
 
-               p = pscheme->secondary_partitions(parts, pm->ptstart);
+               p = pscheme->secondary_partitions(parts, pm->ptstart, false);
                if (p) {
                        parts = p;
                        pscheme = parts->pscheme;
diff -r 612b9746df96 -r 811867861acd usr.sbin/sysinst/disks.c
--- a/usr.sbin/sysinst/disks.c  Sat Jun 15 07:57:38 2019 +0000
+++ b/usr.sbin/sysinst/disks.c  Sat Jun 15 08:20:33 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disks.c,v 1.31 2019/06/13 19:13:05 martin Exp $ */
+/*     $NetBSD: disks.c,v 1.32 2019/06/15 08:20:33 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -777,7 +777,7 @@
                                struct disk_partitions *sec_part =
                                        old_parts->pscheme->
                                            secondary_partitions(
-                                           old_parts, oinfo.start);
+                                           old_parts, oinfo.start, false);
                                if (sec_part)
                                        convert_copy(sec_part, new_parts);
                        }
@@ -946,7 +946,7 @@
                        if (pm->parts->pscheme->secondary_partitions) {
                                const struct disk_partitions *sparts =
                                    pm->parts->pscheme->secondary_partitions(
-                                   pm->parts, pm->ptstart);
+                                   pm->parts, pm->ptstart, false);
                                if (sparts != NULL)
                                        dump_parts(sparts);
                        }
diff -r 612b9746df96 -r 811867861acd usr.sbin/sysinst/install.c
--- a/usr.sbin/sysinst/install.c        Sat Jun 15 07:57:38 2019 +0000
+++ b/usr.sbin/sysinst/install.c        Sat Jun 15 08:20:33 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: install.c,v 1.6 2019/06/12 06:20:17 martin Exp $       */
+/*     $NetBSD: install.c,v 1.7 2019/06/15 08:20:33 martin Exp $       */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -185,7 +185,7 @@
                        if (parts->pscheme->secondary_scheme != NULL &&
                            parts->pscheme->secondary_partitions != NULL) {
                                parts = parts->pscheme->secondary_partitions(
-                                   parts, pm->ptstart);
+                                   parts, pm->ptstart, false);
                                if (parts == NULL)
                                        parts = pm->parts;
                        }
diff -r 612b9746df96 -r 811867861acd usr.sbin/sysinst/mbr.c
--- a/usr.sbin/sysinst/mbr.c    Sat Jun 15 07:57:38 2019 +0000
+++ b/usr.sbin/sysinst/mbr.c    Sat Jun 15 08:20:33 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mbr.c,v 1.12 2019/06/15 07:57:38 martin Exp $ */
+/*     $NetBSD: mbr.c,v 1.13 2019/06/15 08:20:33 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1603,12 +1603,15 @@
 }
 
 static struct disk_partitions *
-mbr_read_disklabel(struct disk_partitions *arg, daddr_t start)
+mbr_read_disklabel(struct disk_partitions *arg, daddr_t start, bool force_empty)
 {
        struct mbr_disk_partitions *myparts =
            (struct mbr_disk_partitions*)arg;
        struct disk_part_info part;
 
+       if (force_empty && myparts->dlabel) 
+               myparts->dlabel->pscheme->delete_all_partitions(myparts->dlabel);
+
        if (myparts->dlabel == NULL) {
                /*
                 * Find the NetBSD MBR partition
@@ -1616,8 +1619,9 @@
                if (!mbr_find_netbsd(&myparts->mbr, start, &part))
                        return NULL;
 
-               myparts->dlabel = disklabel_parts.read_from_disk(
-                   myparts->dp.disk, part.start, part.size);
+               if (!force_empty)
+                       myparts->dlabel = disklabel_parts.read_from_disk(
+                           myparts->dp.disk, part.start, part.size);
 
                if (myparts->dlabel == NULL && part.size > 0) {
                        /* we just created the outer partitions? */
diff -r 612b9746df96 -r 811867861acd usr.sbin/sysinst/part_edit.c
--- a/usr.sbin/sysinst/part_edit.c      Sat Jun 15 07:57:38 2019 +0000
+++ b/usr.sbin/sysinst/part_edit.c      Sat Jun 15 08:20:33 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: part_edit.c,v 1.1 2019/06/12 06:20:18 martin Exp $ */
+/*     $NetBSD: part_edit.c,v 1.2 2019/06/15 08:20:33 martin Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -871,6 +871,11 @@
        if (!parts->pscheme->get_part_info(parts, nbsd, &info))
                return false;
 
+       if (parts->pscheme->secondary_scheme != NULL) {
+               /* force empty secondary partitions */
+               parts->pscheme->secondary_partitions(parts, info.start, true);
+       }
+
        pm->ptstart = info.start;
        pm->ptsize = info.size;
        return true;
diff -r 612b9746df96 -r 811867861acd usr.sbin/sysinst/partitions.h
--- a/usr.sbin/sysinst/partitions.h     Sat Jun 15 07:57:38 2019 +0000
+++ b/usr.sbin/sysinst/partitions.h     Sat Jun 15 08:20:33 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: partitions.h,v 1.1 2019/06/12 06:20:18 martin Exp $    */
+/*     $NetBSD: partitions.h,v 1.2 2019/06/15 08:20:33 martin Exp $    */
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -379,12 +379,18 @@
         * Schemes that NEVER use a secondary scheme set this
         * function pointer to NULL.
         *
+        * If force_empty = true, ignore all on-disk contents and just
+        * create a new disk_partitons structure for the secondary scheme
+        * (this is used after deleting all partitions and setting up
+        * things for "use whole disk").
+        *
         * The returned pointer is always owned by the primary partitions,
         * caller MUST never free it, but otherwise can manipulate it
         * arbitrarily.
         */
        struct disk_partitions *
-           (*secondary_partitions)(struct disk_partitions *, daddr_t start);
+           (*secondary_partitions)(struct disk_partitions *, daddr_t start,
+               bool force_empty);
 
        /*
         * Write the whole set (in new_state) back to disk.
diff -r 612b9746df96 -r 811867861acd usr.sbin/sysinst/target.c
--- a/usr.sbin/sysinst/target.c Sat Jun 15 07:57:38 2019 +0000
+++ b/usr.sbin/sysinst/target.c Sat Jun 15 08:20:33 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: target.c,v 1.5 2019/06/12 06:20:18 martin Exp $        */
+/*     $NetBSD: target.c,v 1.6 2019/06/15 08:20:33 martin Exp $        */
 
 /*
  * Copyright 1997 Jonathan Stone
@@ -71,7 +71,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: target.c,v 1.5 2019/06/12 06:20:18 martin Exp $");
+__RCSID("$NetBSD: target.c,v 1.6 2019/06/15 08:20:33 martin Exp $");
 #endif
 
 /*
@@ -173,7 +173,7 @@
        }
        if (pm->parts->pscheme->secondary_partitions != NULL)
                parts = pm->parts->pscheme->secondary_partitions(parts,
-                   pm->ptstart);
+                   pm->ptstart, false);
 
        for (ptn = 0; ptn < parts->num_part; ptn++) {
                if (!parts->pscheme->get_part_info(parts, ptn, &info))



Home | Main Index | Thread Index | Old Index