Home | History | Annotate | Line # | Download | only in sysinst
menus.pm revision 1.2
      1 /*	$NetBSD: menus.pm,v 1.2 2019/06/12 06:20:17 martin 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
     37 				 {
     38 #ifndef NO_DISKLABEL	/* XXX ??? */
     39 					 make_bsd_partitions(NULL);
     40 #endif
     41 				  };
     42 	option MSG_editmbr,		exit, action {
     43 				md_get_info(NULL);
     44 				md_pre_disklabel(NULL, pm->parts);
     45 	};
     46 	option MSG_switchgpt,	exit, action {
     47 				const char *err;
     48 				if (!convert_scheme(pm, false, &err))
     49 					err_msg_win(err);
     50 				else
     51 					pm_partusage(pm, -1, 1);
     52 	};
     53 	option MSG_renamedisk,	exit, action {
     54 				pm->unsaved = 1; pm_rename(pm);
     55 	};
     56 	option MSG_fmtasraid,	exit, action {
     57 				pm->unsaved = 1;
     58 				pm_partusage(pm, -1, 1);
     59 				(*(enum setup_type*)arg) = SY_NEWRAID;
     60 				md_make_bsd_partitions(NULL);
     61 	};
     62 	option MSG_fmtaslvm,	exit, action {
     63 				pm->unsaved = 1;
     64 				pm_partusage(pm, -1, 1);
     65 				(*(enum setup_type*)arg) = SY_NEWLVM;
     66 				md_make_bsd_partitions(NULL);
     67 	};
     68 	option MSG_encrypt,		exit, action {
     69 				pm->unsaved = 1;
     70 				pm_partusage(pm, -1, 1);
     71 				(*(enum setup_type*)arg) = SY_NEWCGD;
     72 				md_make_bsd_partitions(NULL);
     73 				pm_cgd_edit(0, &(struct part_entry)
     74 				    {.dev_ptr = pm, .index = 0 }
     75 				    );
     76 	};
     77 	option MSG_setbootable,	exit, action {
     78 				pm->unsaved = 1;
     79 				pm->bootable = !pm->bootable;
     80 	};
     81 	option MSG_erase,		next menu shred_modes;
     82 	option MSG_undo,		exit, action {
     83 				/* label_read(); */ pm->unsaved = 0;
     84 				pm_partusage(pm, -1, 1);
     85 	};
     86 	option MSG_unconfig,	exit, action {
     87 				if (pm_unconfigure(pm) == 0)
     88 					pm_partusage(pm, -1, 1);
     89 	};
     90 
     91 menu pmpartentry, x=50, y=5, exit, default exit;
     92 	option MSG_edit,		exit, action { 
     93 									pm->unsaved = 1;
     94 									uint tpfs = 0; /*PI_FSTYPE(&pm->bsdlabel[*(int*)arg]);*/
     95 									// int tplvm = 0; /* pm->bsdlabel[*(int*)arg].lvmpv; */
     96 									pm_editpart(*(int*)arg);
     97 									if (tpfs != 0 /*PI_FSTYPE(&pm->bsdlabel[*(int*)arg]) ||
     98 										tplvm != pm->bsdlabel[*(int*)arg].lvmpv */)
     99 										/* Oops, partition type changed */
    100 										pm_partusage(pm, *(int*)arg, 1);
    101 								};
    102 	option MSG_fmtasraid,	exit, action {
    103 									if (pm->no_part) {
    104 										hit_enter_to_continue(NULL, MSG_notsupported);
    105 										return -1;
    106 									}
    107 									pm->unsaved = 1;
    108 									pm_partusage(pm, *(int*)arg, 1);
    109 									pm_setfstype(pm, (part_id)*(int*)arg, FS_RAID, 0);
    110 								};
    111 	option MSG_fmtaslvm,	exit, action {
    112 									if (pm->no_part) {
    113 										hit_enter_to_continue(NULL, MSG_notsupported);
    114 										return -1;
    115 									}
    116 									pm->unsaved = 1;
    117 									pm_partusage(pm, *(int*)arg, 1);
    118 									pm_setfstype(pm, (part_id)*(int*)arg, FS_BSDFFS, 2);
    119 									/* pm->bsdlabel[*(int*)arg].lvmpv = 1; */
    120 								};
    121 	option MSG_encrypt,		exit, action {
    122 									if (pm->no_part) {
    123 										hit_enter_to_continue(NULL, MSG_notsupported);
    124 										return -1;
    125 									}
    126 									pm->unsaved = 1;
    127 									pm_partusage(pm, *(int*)arg, 1);
    128 									pm_setfstype(pm, (part_id)*(int*)arg, FS_CGD, 0);
    129 									pm_cgd_edit(0,
    130 										&(struct part_entry){.dev_ptr = pm,
    131 											.id = *(int*)arg});
    132 								};
    133 	option MSG_erase,		next menu shred_modes;
    134 	option MSG_doumount,	exit, action { pm_umount(pm, *(int*)arg); };
    135 	option MSG_Delete_partition,	exit, action {
    136 									pm->unsaved = 1;
    137 									pm_partusage(pm, *(int*)arg, 1);
    138 									if (pm->no_part)
    139 										pm_unconfigure(pm);
    140 									else
    141 										pm_setfstype(pm, (part_id)*(int*)arg, FS_UNUSED, 0);
    142 									};
    143 
    144 menu pmgptentry, x=50, y=8, exit, default exit;
    145 	option MSG_editpart, exit, action { /* pm_make_gpt_partitions(pm); */ };
    146 	option MSG_switchmbr,	exit, action
    147 	    {
    148 		const char *err;
    149 		if (!convert_scheme(pm, false, &err))
    150 			err_msg_win(err);
    151 		else
    152 			pm_partusage(pm, -1, 1);
    153 	    };
    154 	option MSG_setbootable,	exit, action
    155 	    {
    156 		pm->unsaved = 1;
    157 		pm->bootable = !pm->bootable;
    158 	    };
    159 	option MSG_erase, next menu shred_modes;
    160 	option MSG_undo, exit, action
    161 	    {
    162 		/* label_read(); */ pm->unsaved = 0;
    163 		pm_partusage(pm, -1, 1);
    164 	    };
    165 	option MSG_unconfig, exit, action
    166 	    {
    167 		if (pm_unconfigure(pm) == 0)
    168 					pm_partusage(pm, -1, 1);
    169 	    };
    170 
    171 menu shred_modes, x=50, y=5, exit, default exit;
    172 	option MSG_fillzeros,	exit,
    173 							action { pm_shred(pm, *(int*)arg, SHRED_ZEROS); };
    174 	option MSG_fillrandom,	exit,
    175 							action { pm_shred(pm, *(int*)arg, SHRED_RANDOM); };
    176 	option MSG_fillcrypto,	exit,
    177 							action { pm_shred(pm, *(int*)arg, SHRED_CRYPTO); };
    178 
    179 menu raidlevel;
    180 	option MSG_raid0, exit, action { *(int *)arg = 0; };
    181 	option MSG_raid1, exit, action { *(int *)arg = 1; };
    182 	option MSG_raid4, exit, action { *(int *)arg = 4; };
    183 	option MSG_raid5, exit, action { *(int *)arg = 5; };
    184 
    185 menu cgd_enctype;
    186 	option "aes-xts",			exit, action { *(const char**)arg = "aes-xts"; };
    187 	option "aes-cbc",			exit, action { *(const char**)arg = "aes-cbc"; };
    188 	option "3des-cbc",			exit, action { *(const char**)arg = "3des-cbc"; };
    189 	option "blowfish-cbc",		exit, action { *(const char**)arg = "blowfish-cbc"; };
    190 
    191 menu cgd_ivtype;
    192 	option "encblkno1",			exit, action { *(const char**)arg = "encblkno1"; };
    193 	option "encblkno8",			exit, action { *(const char**)arg = "encblkno8"; };
    194 
    195 menu cgd_keygentype;
    196 	option "pkcs5_pbkdf2/sha1",	exit, action { *(const char**)arg = "pkcs5_pbkdf2/sha1"; };
    197 	option "pkcs5_pbkdf2",		exit, action { *(const char**)arg = "pkcs5_pbkdf2"; };
    198 	option "storedkey",			exit, action { *(const char**)arg = "storedkey"; };
    199 	option "randomkey",			exit, action { *(const char**)arg = "randomkey"; };
    200 	option "urandomkey",		exit, action { *(const char**)arg = "urandomkey"; };
    201 	option "shell_cmd",			exit, action { *(const char**)arg = "shell_cmd"; };
    202 
    203 menu cgd_verifytype;
    204 	option "none",				exit, action { *(const char**)arg = "none"; };
    205 	option "disklabel",			exit, action { *(const char**)arg = "disklabel"; };
    206 	option "ffs",				exit, action { *(const char**)arg = "ffs"; };
    207 	option "re-enter",			exit, action { *(const char**)arg = "re-enter"; };
    208