xref: /titanic_51/usr/src/cmd/format/init_menus.c (revision af007057247046b266b7b580708a7c33f76a97e4)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 /*
29  * This file contains the declarations of menus for the program.  To add
30  * a new command/menu, simply add it to the appropriate table and define
31  * the function that executes it.
32  */
33 #include <sys/isa_defs.h>
34 #include "global.h"
35 #include "menu.h"
36 #include "menu_partition.h"
37 #include "menu_command.h"
38 #include "menu_analyze.h"
39 #include "menu_defect.h"
40 #include "add_definition.h"
41 #include "menu_scsi.h"
42 #include "menu_developer.h"
43 #include "menu_cache.h"
44 
45 #include "menu_fdisk.h"
46 
47 
48 /*
49  * This declaration is for the command menu.  It is the menu first
50  * encountered upon entering the program.
51  */
52 struct	menu_item menu_command[] = {
53 	{ "disk       - select a disk",
54 		c_disk, true },
55 
56 	{ "type       - select (define) a disk type",
57 		c_type, true },
58 
59 	{ "partition  - select (define) a partition table",
60 		c_partition, true },
61 
62 	{ "current    - describe the current disk",
63 		c_current, true },
64 
65 	{ "format     - format and analyze the disk",
66 		c_format, true },
67 
68 	{ "fdisk      - run the fdisk program",
69 		c_fdisk, support_fdisk_on_sparc },
70 
71 	{ "repair     - repair a defective sector",
72 		c_repair, true },
73 
74 	{ "show       - translate a disk address",
75 		c_show,	 not_scsi },
76 
77 	{ "label      - write label to the disk",
78 		c_label, true },
79 
80 	{ "analyze    - surface analysis",
81 		c_analyze, true },
82 
83 	{ "defect     - defect list management",
84 		c_defect, true },
85 
86 	{ "backup     - search for backup labels",
87 		c_backup, true },
88 
89 	{ "verify     - read and display labels",
90 		c_verify, true },
91 
92 	{ "save       - save new disk/partition definitions",
93 		add_definition, not_efi },
94 
95 	{ "inquiry    - show vendor, product and revision",
96 		c_inquiry, scsi },
97 
98 	{ "scsi       - independent SCSI mode selects",
99 		c_scsi, scsi_expert },
100 
101 	{ "cache      - enable, disable or query SCSI disk cache",
102 		c_cache, scsi_expert },
103 
104 	{ "volname    - set 8-character volume name",
105 		c_volname, true },
106 
107 	{ "developer  - dump developer things",
108 		c_developer, developer },
109 
110 	{ "!<cmd>     - execute <cmd>, then return",
111 		execute_shell, true},
112 
113 	{ NULL }
114 };
115 
116 
117 /*
118  * This declaration is for the partition menu.  It is used to create
119  * and maintain partition tables.
120  */
121 struct	menu_item menu_partition[] = {
122 	{ "0      - change `0' partition",
123 		p_apart, true },
124 	{ "1      - change `1' partition",
125 		p_bpart, true },
126 	{ "2      - change `2' partition",
127 		p_cpart, true },
128 	{ "3      - change `3' partition",
129 		p_dpart, true },
130 	{ "4      - change `4' partition",
131 		p_epart, true },
132 	{ "5      - change `5' partition",
133 		p_fpart, true },
134 	{ "6      - change `6' partition",
135 		p_gpart, true },
136 	{ "7      - change `7' partition",
137 		p_hpart, disp_expert_change_expert_efi },
138 	{ "8      - change '8' partition",
139 		p_ipart, disp_all_change_expert_efi },
140 #if defined(i386)
141 	{ "9      - change `9' partition",
142 		p_jpart, expert },
143 #endif
144 	{ "expand - expand label to use whole disk",
145 		p_expand, disp_expand_efi },
146 	{ "select - select a predefined table",
147 		p_select, true },
148 	{ "modify - modify a predefined partition table",
149 		p_modify, true },
150 	{ "name   - name the current table",
151 		p_name, true },
152 	{ "print  - display the current table",
153 		p_print, true },
154 	{ "label  - write partition map and label to the disk",
155 		c_label, true },
156 	{ "!<cmd> - execute <cmd>, then return",
157 		execute_shell, true},
158 
159 	{ NULL }
160 };
161 
162 
163 
164 /*
165  * This declaration is for the analysis menu.  It is used to set up
166  * and execute surface analysis of a disk.
167  */
168 struct menu_item menu_analyze[] = {
169 	{ "read     - read only test   (doesn't harm SunOS)",
170 		a_read,	 true },
171 	{ "refresh  - read then write  (doesn't harm data)",
172 		a_refresh, true },
173 	{ "test     - pattern testing  (doesn't harm data)",
174 		a_test,	 true },
175 	{ "write    - write then read      (corrupts data)",
176 		a_write, true },
177 	{ "compare  - write, read, compare (corrupts data)",
178 		a_compare, true },
179 	{ "purge    - write, read, write   (corrupts data)",
180 		a_purge, true },
181 	{ "verify   - write entire disk, then verify (corrupts data)",
182 		a_verify, true },
183 	{ "print    - display data buffer",
184 		a_print, true },
185 	{ "setup    - set analysis parameters",
186 		a_setup, true },
187 	{ "config   - show analysis parameters",
188 		a_config, true },
189 	{ "!<cmd>   - execute <cmd> , then return",
190 		execute_shell, true},
191 	{ NULL }
192 };
193 
194 
195 
196 /*
197  * This declaration is for the defect menu.  It is used to manipulate
198  * the defect list for a disk.
199  */
200 struct menu_item menu_defect[] = {
201 	{ "restore  - set working list = current list",
202 		d_restore, not_embedded_scsi },
203 	{ "original - extract manufacturer's list from disk",
204 		d_original, not_embedded_scsi },
205 	{ "extract  - extract working list from disk",
206 		d_extract, not_embedded_scsi },
207 	{ "primary  - extract manufacturer's defect list",
208 		d_primary, embedded_scsi },
209 	{ "grown    - extract the grown defects list",
210 		d_grown, embedded_scsi },
211 	{ "both     - extract both primary and grown defects lists",
212 		d_both, embedded_scsi },
213 	{ "add      - add defects to working list",
214 		d_add,	 not_embedded_scsi },
215 	{ "delete   - delete a defect from working list",
216 		d_delete, not_embedded_scsi },
217 	{ "print    - display defect list",
218 		d_print, embedded_scsi },
219 	{ "dump     - dump defect list to file",
220 		d_dump,	 embedded_scsi },
221 	{ "print    - display working list",
222 		d_print, not_embedded_scsi },
223 	{ "dump     - dump working list to file",
224 		d_dump,	 not_embedded_scsi },
225 	{ "load     - load working list from file",
226 		d_load,	 not_embedded_scsi },
227 	{ "commit   - set current list = working list",
228 		d_commit, not_embedded_scsi },
229 	{ "create   - recreates maufacturer's defect list on disk",
230 		d_create, not_embedded_scsi },
231 	{ "!<cmd>   - execute <cmd>, then return",
232 		execute_shell, true},
233 
234 	{ NULL }
235 };
236 
237 /*
238  * This declaration is for the developer menu.
239  */
240 struct menu_item menu_developer[] = {
241 	{ "dump_disk  - dump disk entries",
242 		dv_disk, true },
243 	{ "dump_cont  - dump controller entries",
244 		dv_cont, true },
245 	{ "dump_c_chain - dump controller chain entries",
246 		dv_cont_chain, true },
247 	{ "dev_params - dump device parameters",
248 		dv_params, true },
249 	{ "!<cmd>     - execute <cmd>, then return",
250 		execute_shell, true},
251 	{ NULL }
252 };
253 
254 /*
255  * This declaration is for the cache menu.
256  */
257 struct menu_item menu_cache[] = {
258 	{ "write_cache - display or modify write cache settings",
259 		ca_write_cache, scsi_expert },
260 	{ "read_cache  - display or modify read cache settings",
261 		ca_read_cache,  scsi_expert },
262 	{ "!<cmd>      - execute <cmd>, then return",
263 		execute_shell, true},
264 	{ NULL }
265 };
266 
267 /*
268  * This declaration is for the write_cache menu.
269  */
270 struct menu_item menu_write_cache[] = {
271 	{ "display     - display current setting of write cache",
272 		ca_write_display, scsi_expert },
273 	{ "enable      - enable write cache",
274 		ca_write_enable,  scsi_expert },
275 	{ "disable     - disable write cache",
276 		ca_write_disable, scsi_expert },
277 	{ "!<cmd>      - execute <cmd>, then return",
278 		execute_shell, true},
279 	{ NULL }
280 };
281 
282 /*
283  * This declaration is for the read_cache menu.
284  */
285 struct menu_item menu_read_cache[] = {
286 	{ "display     - display current setting of read cache",
287 		ca_read_display, scsi_expert },
288 	{ "enable      - enable read cache",
289 		ca_read_enable,  scsi_expert },
290 	{ "disable     - disable read cache",
291 		ca_read_disable, scsi_expert },
292 	{ "!<cmd>      - execute <cmd>, then return",
293 		execute_shell, true},
294 	{ NULL }
295 };
296