Module Name: src
Committed By: martin
Date: Sun Dec 28 12:05:27 UTC 2014
Modified Files:
src/usr.sbin/sysinst: disks.c
Log Message:
We can not rely on the existence of the "gpt" binary on install media -
make installation work without it (and without strange errors) again.
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/sysinst/disks.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/sysinst/disks.c
diff -u src/usr.sbin/sysinst/disks.c:1.5 src/usr.sbin/sysinst/disks.c:1.6
--- src/usr.sbin/sysinst/disks.c:1.5 Tue Aug 19 13:26:27 2014
+++ src/usr.sbin/sysinst/disks.c Sun Dec 28 12:05:27 2014
@@ -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 @@ static int foundsysvbfs(struct data *, s
#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 @@ find_disks(const char *doingwhat)
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 @@ incoregpt(pm_devs_t *pm_cur, partinfo *l
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);
}