Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst We can not rely on the existence of the "gp...



details:   https://anonhg.NetBSD.org/src/rev/d4fa4795fe77
branches:  trunk
changeset: 805301:d4fa4795fe77
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Dec 28 12:05:27 2014 +0000

description:
We can not rely on the existence of the "gpt" binary on install media -
make installation work without it (and without strange errors) again.

diffstat:

 usr.sbin/sysinst/disks.c |  28 +++++++++++++++++++++++-----
 1 files changed, 23 insertions(+), 5 deletions(-)

diffs (63 lines):

diff -r 6caf7d856fd3 -r d4fa4795fe77 usr.sbin/sysinst/disks.c
--- a/usr.sbin/sysinst/disks.c  Sun Dec 28 11:51:10 2014 +0000
+++ b/usr.sbin/sysinst/disks.c  Sun Dec 28 12:05:27 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disks.c,v 1.5 2014/08/19 13:26:27 martin Exp $ */
+/*     $NetBSD: disks.c,v 1.6 2014/12/28 12:05:27 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -106,8 +106,9 @@
 #endif
 static int fsck_preen(const char *, int, const char *);
 static void fixsb(const char *, const char *, char);
-static int is_gpt(const char *);
+static bool is_gpt(const char *);
 static int incoregpt(pm_devs_t *, partinfo *);
+static bool have_gpt_binary(void);
 
 #ifndef DISK_NAMES
 #define DISK_NAMES "wd", "sd", "ld", "raid"
@@ -576,12 +577,26 @@
        return numdisks;
 }
 
+static bool
+have_gpt_binary(void)
+{
+       static bool did_test = false;
+       static bool have_gpt;
+
+       if (!did_test) {
+               have_gpt = binary_available("gpt");
+               did_test = true;
+       }
+
+       return have_gpt;
+}
+
 void
 label_read(void)
 {
        /* Get existing/default label */
        memset(&pm->oldlabel, 0, sizeof pm->oldlabel);
-       if (! pm->gpt)
+       if (!have_gpt_binary() || !pm->gpt)
                incorelabel(pm->diskdev, pm->oldlabel);
        else
                incoregpt(pm, pm->oldlabel);
@@ -1456,9 +1471,12 @@
        return 0;
 }
 
-static int
+static bool
 is_gpt(const char *dev)
 {
-       return ! run_program(RUN_SILENT | RUN_ERROR_OK,
+       if (!have_gpt_binary())
+               return false;
+
+       return !run_program(RUN_SILENT | RUN_ERROR_OK,
                "sh -c 'gpt show %s |grep -e Pri\\ GPT\\ table'", dev);
 }



Home | Main Index | Thread Index | Old Index