Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst Fix detection of existing disklabels in the...



details:   https://anonhg.NetBSD.org/src/rev/574bc297022a
branches:  trunk
changeset: 847146:574bc297022a
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Dec 12 12:19:39 2019 +0000

description:
Fix detection of existing disklabels in the case when we only have
the disklabel partitioning scheme available.

diffstat:

 usr.sbin/sysinst/disklabel.c |  42 ++++++++++++++++++++++++++++++++----------
 1 files changed, 32 insertions(+), 10 deletions(-)

diffs (65 lines):

diff -r 472c9f185a0d -r 574bc297022a usr.sbin/sysinst/disklabel.c
--- a/usr.sbin/sysinst/disklabel.c      Thu Dec 12 12:00:06 2019 +0000
+++ b/usr.sbin/sysinst/disklabel.c      Thu Dec 12 12:19:39 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disklabel.c,v 1.18 2019/12/09 19:16:53 martin Exp $    */
+/*     $NetBSD: disklabel.c,v 1.19 2019/12/12 12:19:39 martin Exp $    */
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -170,17 +170,16 @@
        int fd;
        char diskpath[MAXPATHLEN];
        uint flags;
+       bool only_dl = only_have_disklabel();
+       bool have_raw_label = false;
 
 #ifndef DISKLABEL_NO_ONDISK_VERIFY
-       if (!only_have_disklabel()) {
-               /*
-                * If there are alternative partitioning schemes,
-                * verify we really have a disklabel.
-                */
-               if (run_program(RUN_SILENT | RUN_ERROR_OK,
-                   "disklabel -r %s", disk) != 0)
-                       return NULL;
-       }
+       /*
+        * Verify we really have a disklabel.
+        */
+       if (run_program(RUN_SILENT | RUN_ERROR_OK,
+           "disklabel -r %s", disk) == 0)
+               have_raw_label = true;
 #endif
 
        /* read partitions */
@@ -267,6 +266,29 @@
        }
        close(fd);
 
+       if (!have_raw_label && only_dl) {
+               bool found_real_part = false;
+
+               /*
+                * Check if kernel translation gave us "something" besides
+                * the raw or the whole-disk partition.
+                * If not: report missing disklabel.
+                */
+               for (int part = 0; part < parts->l.d_npartitions; part++) {
+                       if (parts->l.d_partitions[part].p_fstype == FS_UNUSED)
+                               continue;
+                       if (part == RAW_PART)
+                               continue;
+                       found_real_part = true;
+                       break;
+               }
+               if (!found_real_part) {
+                       /* no partion there yet */
+                       free(parts);
+                       return NULL;
+               }
+       }
+
        return &parts->dp;
 }
 



Home | Main Index | Thread Index | Old Index