1/* $NetBSD: menus.pm,v 1.3 2020/01/09 13:22:30 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/* arg is a struct part_entry* */ 36menu pmdiskentry, x=50, y=5, exit, default exit; 37 display action { pmdiskentry_enable(menu, arg); }; 38 option MSG_edit_parts, exit, action { pm_edit_partitions(arg); }; 39 option MSG_switch_parts, exit, action { 40 struct pm_devs *my_pm = pm_from_pe(arg); 41 const char *err; 42 43 if (!convert_scheme(my_pm, false, &err)) 44 err_msg_win(err); 45 else 46 pm_partusage(my_pm, -1, 1); 47 }; 48 option MSG_fmtasraid, exit, action 49 { 50 pm_whole_disk(arg, SY_NEWRAID); 51 }; 52 option MSG_fmtaslvm, exit, action 53 { 54 part_id new_part; 55 56 new_part = pm_whole_disk(arg, SY_NEWLVM); 57 if (new_part != NO_PART) 58 pm_set_lvmpv(pm_from_pe(arg), new_part, true); 59 }; 60 option MSG_encrypt, exit, action 61 { 62 part_id new_part; 63 new_part = pm_whole_disk(arg, SY_NEWCGD); 64 if (new_part != NO_PART) 65 pm_cgd_edit_new(pm_from_pe(arg), new_part); 66 }; 67 option MSG_erase, next menu shred_modes; 68 option MSG_undo, exit, action { 69 /* label_read(); */ pm->unsaved = 0; 70 pm_partusage(pm, -1, 1); 71 }; 72 option MSG_unconfig, exit, action { 73 if (pm_unconfigure(pm) == 0) 74 pm_partusage(pm, -1, 1); 75 }; 76 77/* arg is a struct part_entry* */ 78menu pmpartentry, x=50, y=5, exit, default exit; 79 option MSG_edit, exit, action 80 { 81 struct part_entry *cur_pe = arg; 82 pm->unsaved = 1; 83 pm_editpart(cur_pe->id); 84 pm_partusage(pm, cur_pe->id, 1); 85 }; 86 option MSG_fmtasraid, exit, action { 87 if (pm->no_part) { 88 hit_enter_to_continue(NULL, MSG_notsupported); 89 return -1; 90 } 91 struct part_entry *cur_pe = arg; 92 pm->unsaved = 1; 93 pm_partusage(pm, cur_pe->id, 1); 94 pm_setfstype(pm, cur_pe->id, FS_RAID, 0); 95 }; 96 option MSG_fmtaslvm, exit, action { 97 if (pm->no_part) { 98 hit_enter_to_continue(NULL, MSG_notsupported); 99 return -1; 100 } 101 struct part_entry *cur_pe = arg; 102 pm->unsaved = 1; 103 pm_partusage(pm, cur_pe->id, 1); 104 pm_setfstype(pm, cur_pe->id, FS_BSDFFS, 2); 105 pm_set_lvmpv(pm, cur_pe->id, true); 106 }; 107 option MSG_encrypt, exit, action { 108 if (pm->no_part) { 109 hit_enter_to_continue(NULL, MSG_notsupported); 110 return -1; 111 } 112 struct part_entry *cur_pe = arg; 113 pm->unsaved = 1; 114 pm_partusage(pm, cur_pe->id, 1); 115 pm_setfstype(pm, cur_pe->id, FS_CGD, 0); 116 pm_cgd_edit_old(cur_pe); 117 }; 118 option MSG_erase, next menu shred_modes; 119 option MSG_doumount, exit, action { 120 struct part_entry *cur_pe = arg; 121 pm_umount(pm, cur_pe->id); 122 }; 123 option MSG_Delete_partition, exit, action { 124 struct part_entry *cur_pe = arg; 125 pm->unsaved = 1; 126 pm_partusage(pm, cur_pe->id, 1); 127 if (pm->no_part) 128 pm_unconfigure(pm); 129 else 130 pm_setfstype(pm, cur_pe->id, FS_UNUSED, 0); 131 }; 132 133/* arg is a struct part_entry* */ 134menu shred_modes, x=50, y=5, exit, default exit; 135 option MSG_fillzeros, exit, 136 action { pm_shred(arg, SHRED_ZEROS); }; 137 option MSG_fillrandom, exit, 138 action { pm_shred(arg, SHRED_RANDOM); }; 139 140/* arg is a int pointer for the requested raid level */ 141menu raidlevel; 142 option MSG_raid0, exit, action { *(int *)arg = 0; }; 143 option MSG_raid1, exit, action { *(int *)arg = 1; }; 144 option MSG_raid4, exit, action { *(int *)arg = 4; }; 145 option MSG_raid5, exit, action { *(int *)arg = 5; }; 146 147/* arg is a const char ** set to the selected encryption type */ 148menu cgd_enctype; 149 option "aes-xts", exit, action { *(const char**)arg = "aes-xts"; }; 150 option "aes-cbc", exit, action { *(const char**)arg = "aes-cbc"; }; 151 option "3des-cbc", exit, action { *(const char**)arg = "3des-cbc"; }; 152 option "blowfish-cbc", exit, action 153 { *(const char**)arg = "blowfish-cbc"; }; 154 155/* arg is a const char ** set to the requested iv type */ 156menu cgd_ivtype; 157 option "encblkno1", exit, action { *(const char**)arg = "encblkno1"; }; 158 option "encblkno8", exit, action { *(const char**)arg = "encblkno8"; }; 159 160/* arg is const char ** set to the key gen type */ 161menu cgd_keygentype; 162 option "pkcs5_pbkdf2/sha1", exit, action 163 { *(const char**)arg = "pkcs5_pbkdf2/sha1"; }; 164 option "pkcs5_pbkdf2", exit, action 165 { *(const char**)arg = "pkcs5_pbkdf2"; }; 166 option "storedkey", exit, action 167 { *(const char**)arg = "storedkey"; }; 168 option "randomkey", exit, action 169 { *(const char**)arg = "randomkey"; }; 170 option "urandomkey", exit, action 171 { *(const char**)arg = "urandomkey"; }; 172 option "shell_cmd", exit, action 173 { *(const char**)arg = "shell_cmd"; }; 174 175/* art is a const char ** set to the requested verification type */ 176menu cgd_verifytype; 177 option "none", exit, action { *(const char**)arg = "none"; }; 178 option "disklabel", exit, action { *(const char**)arg = "disklabel"; }; 179 option "MBR", exit, action { *(const char**)arg = "mbr"; }; 180 option "GPT", exit, action { *(const char**)arg = "gpt"; }; 181 option "ffs", exit, action { *(const char**)arg = "ffs"; }; 182 option "re-enter", exit, action { *(const char**)arg = "re-enter"; }; 183