Module Name:    src
Committed By:   snj
Date:           Wed Dec 31 06:19:19 UTC 2014

Modified Files:
        src/usr.sbin/sysinst [netbsd-7]: disks.c

Log Message:
Pull up following revision(s) (requested by martin in ticket #357):
        usr.sbin/sysinst/disks.c: revision 1.6
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.4.4.1 -r1.4.4.2 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.4.4.1 src/usr.sbin/sysinst/disks.c:1.4.4.2
--- src/usr.sbin/sysinst/disks.c:1.4.4.1	Sat Aug 23 03:44:02 2014
+++ src/usr.sbin/sysinst/disks.c	Wed Dec 31 06:19:19 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: disks.c,v 1.4.4.1 2014/08/23 03:44:02 riz Exp $ */
+/*	$NetBSD: disks.c,v 1.4.4.2 2014/12/31 06:19:19 snj 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);
 }

Reply via email to