Module Name: src
Committed By: martin
Date: Sat May 9 12:06:31 UTC 2015
Modified Files:
src/usr.sbin/sysinst: defs.h disks.c partman.c
Log Message:
Add a new utility function "update_wedges()", which triggers a scan
for wedges on the given disk. Call this after writing a disklabel.
This makes all auto-discovered wedges go away after we changed the
partitioning (and are not using GPT) and fixes PR 49665.
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/sysinst/defs.h
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/sysinst/disks.c
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/sysinst/partman.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/defs.h
diff -u src/usr.sbin/sysinst/defs.h:1.6 src/usr.sbin/sysinst/defs.h:1.7
--- src/usr.sbin/sysinst/defs.h:1.6 Fri Jan 2 19:43:13 2015
+++ src/usr.sbin/sysinst/defs.h Sat May 9 12:06:31 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.6 2015/01/02 19:43:13 abs Exp $ */
+/* $NetBSD: defs.h,v 1.7 2015/05/09 12:06:31 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -598,6 +598,13 @@ int pm_cgd_edit(void *, part_entry_t *);
int pm_gpt_convert(pm_devs_t *);
void pm_wedges_fill(pm_devs_t *);
void pm_make_bsd_partitions(pm_devs_t *);
+void update_wedges(const char *);
+
+/* flags whether to offer the respective options (depending on helper
+ programs available on install media */
+int have_raid, have_vnd, have_cgd, have_lvm, have_gpt, have_dk;
+/* initialize above variables */
+void check_available_binaries(void);
/* from bsddisklabel.c */
int make_bsd_partitions(void);
Index: src/usr.sbin/sysinst/disks.c
diff -u src/usr.sbin/sysinst/disks.c:1.7 src/usr.sbin/sysinst/disks.c:1.8
--- src/usr.sbin/sysinst/disks.c:1.7 Fri Jan 2 19:43:13 2015
+++ src/usr.sbin/sysinst/disks.c Sat May 9 12:06:31 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: disks.c,v 1.7 2015/01/02 19:43:13 abs Exp $ */
+/* $NetBSD: disks.c,v 1.8 2015/05/09 12:06:31 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -108,7 +108,6 @@ static int fsck_preen(const char *, int,
static void fixsb(const char *, const char *, 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"
@@ -577,26 +576,15 @@ 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)
{
+ check_available_binaries();
+
/* Get existing/default label */
memset(&pm->oldlabel, 0, sizeof pm->oldlabel);
- if (!have_gpt_binary() || !pm->gpt)
+ if (!have_gpt || !pm->gpt)
incorelabel(pm->diskdev, pm->oldlabel);
else
incoregpt(pm, pm->oldlabel);
@@ -666,14 +654,16 @@ fmt_fspart(menudesc *m, int ptn, void *a
int
write_disklabel (void)
{
+ int rv = 0;
#ifdef DISKLABEL_CMD
/* disklabel the disk */
- return run_program(RUN_DISPLAY, "%s -f /tmp/disktab %s '%s'",
+ rv = run_program(RUN_DISPLAY, "%s -f /tmp/disktab %s '%s'",
DISKLABEL_CMD, pm->diskdev, pm->bsddiskname);
-#else
- return 0;
+ if (rv == 0)
+ update_wedges(pm->diskdev);
#endif
+ return rv;
}
@@ -1481,7 +1471,9 @@ incoregpt(pm_devs_t *pm_cur, partinfo *l
static bool
is_gpt(const char *dev)
{
- if (!have_gpt_binary())
+ check_available_binaries();
+
+ if (!have_gpt)
return false;
return !run_program(RUN_SILENT | RUN_ERROR_OK,
Index: src/usr.sbin/sysinst/partman.c
diff -u src/usr.sbin/sysinst/partman.c:1.8 src/usr.sbin/sysinst/partman.c:1.9
--- src/usr.sbin/sysinst/partman.c:1.8 Fri Jan 2 19:43:13 2015
+++ src/usr.sbin/sysinst/partman.c Sat May 9 12:06:31 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: partman.c,v 1.8 2015/01/02 19:43:13 abs Exp $ */
+/* $NetBSD: partman.c,v 1.9 2015/05/09 12:06:31 martin Exp $ */
/*
* Copyright 2012 Eugene Lozovoy
@@ -46,7 +46,7 @@
/* flags whether to offer the respective options (depending on helper
programs available on install media */
-static int have_raid, have_vnd, have_cgd, have_lvm, have_gpt, have_dk;
+int have_raid, have_vnd, have_cgd, have_lvm, have_gpt, have_dk;
/* XXX: replace all MAX_* defines with vars that depend on kernel settings */
#define MAX_ENTRIES 96
@@ -2692,6 +2692,23 @@ pm_menuout(menudesc *m, void *arg)
cursel = m->cursel;
}
+/* initialize have_* variables */
+void
+check_available_binaries()
+{
+ static int did_test = false;
+
+ if (did_test) return;
+ did_test = 1;
+
+ have_raid = binary_available("raidctl");
+ have_vnd = binary_available("vnconfig");
+ have_cgd = binary_available("cgdconfig");
+ have_lvm = binary_available("lvm");
+ have_gpt = binary_available("gpt");
+ have_dk = binary_available("dkctl");
+}
+
/* Main partman function */
int
partman(void)
@@ -2702,12 +2719,7 @@ partman(void)
part_entry_t args[MAX_ENTRIES];
if (firstrun) {
- have_raid = binary_available("raidctl");
- have_vnd = binary_available("vnconfig");
- have_cgd = binary_available("cgdconfig");
- have_lvm = binary_available("lvm");
- have_gpt = binary_available("gpt");
- have_dk = binary_available("dkctl");
+ check_available_binaries();
if (!have_raid)
remove_raid_options();
@@ -2801,3 +2813,15 @@ partman(void)
/* retvalue <0 - error, retvalue ==0 - user quits, retvalue >0 - all ok */
return (args[0].retvalue >= 0)?0:-1;
}
+
+void
+update_wedges(const char *disk)
+{
+ check_available_binaries();
+
+ if (!have_dk)
+ return;
+
+ run_program(RUN_SILENT | RUN_ERROR_OK,
+ "dkctl %s makewedges", disk);
+}