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