Home | History | Annotate | Line # | Download | only in sysinst
menus.pm revision 1.1
      1 /*	$NetBSD: menus.pm,v 1.1 2018/09/20 12:27:42 rin Exp $	*/
      2 /*	NetBSD: menus.mi,v 1.14 2018/09/11 08:05:18 martin Exp 		*/
      3 
      4 /*-
      5  * Copyright (c) 2003 The NetBSD Foundation, Inc.
      6  * All rights reserved.
      7  *
      8  * This code is derived from software contributed to The NetBSD Foundation
      9  * by David Laight.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30  * POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 /* Menu system definitions -- extended partitioning */
     34 
     35 menu pmdiskentry, x=50, y=5, exit, default exit;
     36 	option MSG_editbsdpart, exit, action { pm_make_bsd_partitions(pm); };
     37 	option MSG_editmbr,		exit, action { md_get_info();
     38 											md_pre_disklabel();
     39 											memset(&pm->bsdlabel, 0, sizeof pm->bsdlabel);};
     40 	option MSG_switchgpt,	exit, action { if (pm_gpt_convert(pm) == 0)
     41 												pm_partusage(pm, -1, 1); };
     42 	option MSG_renamedisk,	exit, action { pm->unsaved = 1; pm_rename(pm); };
     43 	option MSG_fmtasraid,	exit, action { pm->unsaved = 1;
     44 											pm_partusage(pm, -1, 1);
     45 											layoutkind = LY_NEWRAID;
     46 											md_make_bsd_partitions();};
     47 	option MSG_fmtaslvm,	exit, action { pm->unsaved = 1;
     48 											pm_partusage(pm, -1, 1);
     49 											layoutkind = LY_NEWLVM;
     50 											md_make_bsd_partitions(); };
     51 	option MSG_encrypt,		exit, action { pm->unsaved = 1;
     52 											pm_partusage(pm, -1, 1);
     53 											layoutkind = LY_NEWCGD;
     54 											md_make_bsd_partitions();
     55 											pm_cgd_edit(0, &(part_entry_t)
     56 												{.dev_ptr = pm, .dev_num = PART_E}
     57 											); };
     58 	option MSG_setbootable,	exit, action { pm->unsaved = 1;
     59 											pm->bootable = !pm->bootable; };
     60 	option MSG_erase,		next menu shred_modes;
     61 	option MSG_undo,		exit, action { label_read(); pm->unsaved = 0;
     62 											pm_partusage(pm, -1, 1); };
     63 	option MSG_unconfig,	exit, action { if (pm_unconfigure(pm) == 0)
     64 												pm_partusage(pm, -1, 1); };
     65 
     66 menu pmpartentry, x=50, y=5, exit, default exit;
     67 	option MSG_edit,		exit, action { 
     68 									pm->unsaved = 1;
     69 									int tpfs = pm->bsdlabel[*(int*)arg].pi_fstype;
     70 									int tplvm = pm->bsdlabel[*(int*)arg].lvmpv;
     71 									pm_editpart(*(int*)arg);
     72 									if (tpfs != pm->bsdlabel[*(int*)arg].pi_fstype ||
     73 										tplvm != pm->bsdlabel[*(int*)arg].lvmpv)
     74 										/* Oops, partition type changed */
     75 										pm_partusage(pm, *(int*)arg, 1);
     76 								};
     77 	option MSG_fmtasraid,	exit, action {
     78 									if (pm->gpt || pm->isspecial) {
     79 										process_menu(MENU_ok, __UNCONST(MSG_notsupported));
     80 										return -1;
     81 									}
     82 									pm->unsaved = 1;
     83 									pm_partusage(pm, *(int*)arg, 1);
     84 									pm_setfstype(pm, *(int*)arg, FS_RAID);
     85 								};
     86 	option MSG_fmtaslvm,	exit, action {
     87 									if (pm->gpt || pm->isspecial) {
     88 										process_menu(MENU_ok, __UNCONST(MSG_notsupported));
     89 										return -1;
     90 									}
     91 									pm->unsaved = 1;
     92 									pm_partusage(pm, *(int*)arg, 1);
     93 									pm_setfstype(pm, *(int*)arg, FS_BSDFFS);
     94 								    pm->bsdlabel[*(int*)arg].lvmpv = 1;
     95 								};
     96 	option MSG_encrypt,		exit, action {
     97 									if (pm->gpt || pm->isspecial) {
     98 										process_menu(MENU_ok, __UNCONST(MSG_notsupported));
     99 										return -1;
    100 									}
    101 									pm->unsaved = 1;
    102 									pm_partusage(pm, *(int*)arg, 1);
    103 									pm_setfstype(pm, *(int*)arg, FS_CGD);
    104 									pm_cgd_edit(0,
    105 										&(part_entry_t){.dev_ptr = pm,
    106 														.dev_num = *(int*)arg});
    107 								};
    108 	option MSG_erase,		next menu shred_modes;
    109 	option MSG_doumount,	exit, action { pm_umount(pm, *(int*)arg); };
    110 	option MSG_Delete_partition,	exit, action {
    111 									pm->unsaved = 1;
    112 									pm_partusage(pm, *(int*)arg, 1);
    113 									if (pm->isspecial)
    114 										pm_unconfigure(pm);
    115 									else
    116 										pm->bsdlabel[*(int*)arg].pi_fstype = FS_UNUSED;
    117 									};
    118 
    119 menu pmgptentry, x=50, y=8, exit, default exit;
    120 	option MSG_editbsdpart, exit, action { pm_make_bsd_partitions(pm); };
    121 	option MSG_switchmbr,	exit, action { if (pm_gpt_convert(pm) == 0)
    122 												pm_partusage(pm, -1, 1); };
    123 	option MSG_setbootable,	exit, action { pm->unsaved = 1;
    124 												pm->bootable = !pm->bootable; };
    125 	option MSG_erase,		next menu shred_modes;
    126 	option MSG_undo,		exit, action { label_read(); pm->unsaved = 0;
    127 											pm_partusage(pm, -1, 1); };
    128 	option MSG_unconfig,	exit, action { if (pm_unconfigure(pm) == 0)
    129 												pm_partusage(pm, -1, 1); };
    130 
    131 menu shred_modes, x=50, y=5, exit, default exit;
    132 	option MSG_fillzeros,	exit,
    133 							action { pm_shred(pm, *(int*)arg, SHRED_ZEROS); };
    134 	option MSG_fillrandom,	exit,
    135 							action { pm_shred(pm, *(int*)arg, SHRED_RANDOM); };
    136 	option MSG_fillcrypto,	exit,
    137 							action { pm_shred(pm, *(int*)arg, SHRED_CRYPTO); };
    138 
    139 menu raidlevel;
    140 	option MSG_raid0, exit, action { *(int *)arg = 0; };
    141 	option MSG_raid1, exit, action { *(int *)arg = 1; };
    142 	option MSG_raid4, exit, action { *(int *)arg = 4; };
    143 	option MSG_raid5, exit, action { *(int *)arg = 5; };
    144 
    145 menu cgd_enctype;
    146 	option "aes-xts",			exit, action { *(const char**)arg = "aes-xts"; };
    147 	option "aes-cbc",			exit, action { *(const char**)arg = "aes-cbc"; };
    148 	option "3des-cbc",			exit, action { *(const char**)arg = "3des-cbc"; };
    149 	option "blowfish-cbc",		exit, action { *(const char**)arg = "blowfish-cbc"; };
    150 
    151 menu cgd_ivtype;
    152 	option "encblkno1",			exit, action { *(const char**)arg = "encblkno1"; };
    153 	option "encblkno8",			exit, action { *(const char**)arg = "encblkno8"; };
    154 
    155 menu cgd_keygentype;
    156 	option "pkcs5_pbkdf2/sha1",	exit, action { *(const char**)arg = "pkcs5_pbkdf2/sha1"; };
    157 	option "pkcs5_pbkdf2",		exit, action { *(const char**)arg = "pkcs5_pbkdf2"; };
    158 	option "storedkey",			exit, action { *(const char**)arg = "storedkey"; };
    159 	option "randomkey",			exit, action { *(const char**)arg = "randomkey"; };
    160 	option "urandomkey",		exit, action { *(const char**)arg = "urandomkey"; };
    161 	option "shell_cmd",			exit, action { *(const char**)arg = "shell_cmd"; };
    162 
    163 menu cgd_verifytype;
    164 	option "none",				exit, action { *(const char**)arg = "none"; };
    165 	option "disklabel",			exit, action { *(const char**)arg = "disklabel"; };
    166 	option "ffs",				exit, action { *(const char**)arg = "ffs"; };
    167 	option "re-enter",			exit, action { *(const char**)arg = "re-enter"; };
    168