Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/sysinst Remove a few menu entries if raid/lvm/cgd/g...
details: https://anonhg.NetBSD.org/src/rev/ac63f3363764
branches: trunk
changeset: 331228:ac63f3363764
user: martin <martin%NetBSD.org@localhost>
date: Wed Aug 06 10:03:49 2014 +0000
description:
Remove a few menu entries if raid/lvm/cgd/gpt are not available.
diffstat:
usr.sbin/sysinst/defs.h | 6 ++-
usr.sbin/sysinst/menus.mi | 82 ++++++++++++++++++++++++++++++++++++++++-----
usr.sbin/sysinst/partman.c | 11 +++++-
3 files changed, 88 insertions(+), 11 deletions(-)
diffs (153 lines):
diff -r 59aad707613d -r ac63f3363764 usr.sbin/sysinst/defs.h
--- a/usr.sbin/sysinst/defs.h Wed Aug 06 09:11:46 2014 +0000
+++ b/usr.sbin/sysinst/defs.h Wed Aug 06 10:03:49 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.2 2014/08/03 16:09:38 martin Exp $ */
+/* $NetBSD: defs.h,v 1.3 2014/08/06 10:03:49 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -412,6 +412,10 @@
/* needed prototypes */
void set_menu_numopts(int, int);
void remove_color_options(void);
+void remove_raid_options(void);
+void remove_lvm_options(void);
+void remove_cgd_options(void);
+void remove_gpt_options(void);
/* Machine dependent functions .... */
void md_init(void);
diff -r 59aad707613d -r ac63f3363764 usr.sbin/sysinst/menus.mi
--- a/usr.sbin/sysinst/menus.mi Wed Aug 06 09:11:46 2014 +0000
+++ b/usr.sbin/sysinst/menus.mi Wed Aug 06 10:03:49 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: menus.mi,v 1.3 2014/08/04 08:50:13 martin Exp $ */
+/* $NetBSD: menus.mi,v 1.4 2014/08/06 10:03:49 martin Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -62,19 +62,14 @@
msg_prompt_win(prompt, -1, 12, 0, 0, buf, buf, size);
}
-void
-remove_color_options()
+static void
+remove_sub_menu(int menuID)
{
- /*
- * Current terminal type does not support colors, so remove all
- * menu entries (actually that is: Utils/Color Scheme) that do not
- * make any sense in this case.
- */
for (size_t i = 0; i < DYN_MENU_START; i++) {
for (int j = 0; j < menu_def[i].numopts; j++) {
if ((menu_def[i].opts[j].opt_flags & OPT_SUB)
- && menu_def[i].opts[j].opt_menu == MENU_colors) {
+ && menu_def[i].opts[j].opt_menu == menuID) {
for (int k = j + 1; k < menu_def[i].numopts;
k++) {
@@ -89,6 +84,75 @@
}
}
+static void
+remove_menu_option(int menuID, const char *option)
+{
+
+ for (int j = 0; j < menu_def[menuID].numopts; j++) {
+ if (menu_def[menuID].opts[j].opt_name == option) {
+ for (int k = j + 1; k < menu_def[menuID].numopts;
+ k++) {
+ menu_def[menuID].opts[k-1] =
+ menu_def[menuID].opts[k];
+ }
+ menu_def[menuID].numopts--;
+ return;
+
+ }
+ }
+}
+
+void
+remove_color_options()
+{
+ /*
+ * Current terminal type does not support colors, so remove all
+ * menu entries (actually that is: Utils/Color Scheme) that do not
+ * make any sense in this case.
+ */
+ remove_sub_menu(MENU_colors);
+}
+
+void
+remove_raid_options()
+{
+ /*
+ * No raidframe available, remove the following menu entries:
+ */
+ remove_menu_option(MENU_pmdiskentry, MSG_fmtasraid);
+ remove_menu_option(MENU_pmpartentry, MSG_fmtasraid);
+}
+
+void
+remove_lvm_options()
+{
+ /*
+ * No LVM available, remove the following menu entries:
+ */
+ remove_menu_option(MENU_pmdiskentry, MSG_fmtaslvm);
+ remove_menu_option(MENU_pmpartentry, MSG_fmtaslvm);
+}
+
+void
+remove_gpt_options()
+{
+ /*
+ * No GPT available, remove the following menu entries:
+ */
+ remove_menu_option(MENU_pmdiskentry, MSG_switchgpt);
+ remove_menu_option(MENU_pmpartentry, MSG_switchgpt);
+}
+
+void
+remove_cgd_options()
+{
+ /*
+ * No CGD available, remove the following menu entries:
+ */
+ remove_menu_option(MENU_pmdiskentry, MSG_encrypt);
+ remove_menu_option(MENU_pmpartentry, MSG_encrypt);
+}
+
}
default y=12, no exit, scrollable;
diff -r 59aad707613d -r ac63f3363764 usr.sbin/sysinst/partman.c
--- a/usr.sbin/sysinst/partman.c Wed Aug 06 09:11:46 2014 +0000
+++ b/usr.sbin/sysinst/partman.c Wed Aug 06 10:03:49 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: partman.c,v 1.2 2014/08/05 08:39:39 martin Exp $ */
+/* $NetBSD: partman.c,v 1.3 2014/08/06 10:03:49 martin Exp $ */
/*
* Copyright 2012 Eugene Lozovoy
@@ -2707,6 +2707,15 @@
have_gpt = binary_available("gpt");
have_dk = binary_available("dkctl");
+ if (!have_raid)
+ remove_raid_options();
+ if (!have_lvm)
+ remove_lvm_options();
+ if (!have_gpt)
+ remove_gpt_options();
+ if (!have_cgd)
+ remove_cgd_options();
+
raids_t_info = (structinfo_t) {
.max = MAX_RAID,
.entry_size = sizeof raids[0],
Home |
Main Index |
Thread Index |
Old Index