xref: /titanic_53/usr/src/cmd/format/menu.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 1991-2003 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate /*
30*7c478bd9Sstevel@tonic-gate  * This file contains routines relating to running the menus.
31*7c478bd9Sstevel@tonic-gate  */
32*7c478bd9Sstevel@tonic-gate #include <string.h>
33*7c478bd9Sstevel@tonic-gate #include "global.h"
34*7c478bd9Sstevel@tonic-gate #include "menu.h"
35*7c478bd9Sstevel@tonic-gate #include "misc.h"
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate /* Function prototypes for ANSI C Compilers */
40*7c478bd9Sstevel@tonic-gate static int	(*find_enabled_menu_item())(struct menu_item *menu, int item);
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate #else	/* __STDC__ */
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate /* Function prototypes for non-ANSI C Compilers */
45*7c478bd9Sstevel@tonic-gate static int	(*find_enabled_menu_item())();
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate #endif	/* __STDC__ */
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate static char	cur_title[MAXPATHLEN];
50*7c478bd9Sstevel@tonic-gate 
51*7c478bd9Sstevel@tonic-gate /*
52*7c478bd9Sstevel@tonic-gate  * This routine takes a menu struct and concatenates the
53*7c478bd9Sstevel@tonic-gate  * command names into an array of strings describing the menu.
54*7c478bd9Sstevel@tonic-gate  * All menus have a 'quit' command at the bottom to exit the menu.
55*7c478bd9Sstevel@tonic-gate  */
56*7c478bd9Sstevel@tonic-gate char **
57*7c478bd9Sstevel@tonic-gate create_menu_list(menu)
58*7c478bd9Sstevel@tonic-gate 	struct	menu_item *menu;
59*7c478bd9Sstevel@tonic-gate {
60*7c478bd9Sstevel@tonic-gate 	register struct menu_item *mptr;
61*7c478bd9Sstevel@tonic-gate 	register char	**cpptr;
62*7c478bd9Sstevel@tonic-gate 	register char	**list;
63*7c478bd9Sstevel@tonic-gate 	int		nitems;
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate 	/*
66*7c478bd9Sstevel@tonic-gate 	 * A minimum list consists of the quit command, followed
67*7c478bd9Sstevel@tonic-gate 	 * by a terminating null.
68*7c478bd9Sstevel@tonic-gate 	 */
69*7c478bd9Sstevel@tonic-gate 	nitems = 2;
70*7c478bd9Sstevel@tonic-gate 	/*
71*7c478bd9Sstevel@tonic-gate 	 * Count the number of active commands in the menu and allocate
72*7c478bd9Sstevel@tonic-gate 	 * space for the array of pointers.
73*7c478bd9Sstevel@tonic-gate 	 */
74*7c478bd9Sstevel@tonic-gate 	for (mptr = menu; mptr->menu_cmd != NULL; mptr++) {
75*7c478bd9Sstevel@tonic-gate 		if ((*mptr->menu_state)())
76*7c478bd9Sstevel@tonic-gate 			nitems++;
77*7c478bd9Sstevel@tonic-gate 	}
78*7c478bd9Sstevel@tonic-gate 	list = (char **)zalloc(nitems * sizeof (char *));
79*7c478bd9Sstevel@tonic-gate 	cpptr = list;
80*7c478bd9Sstevel@tonic-gate 	/*
81*7c478bd9Sstevel@tonic-gate 	 * Fill in the array with the names of the menu commands.
82*7c478bd9Sstevel@tonic-gate 	 */
83*7c478bd9Sstevel@tonic-gate 	for (mptr = menu; mptr->menu_cmd != NULL; mptr++) {
84*7c478bd9Sstevel@tonic-gate 		if ((*mptr->menu_state)()) {
85*7c478bd9Sstevel@tonic-gate 			*cpptr++ = mptr->menu_cmd;
86*7c478bd9Sstevel@tonic-gate 		}
87*7c478bd9Sstevel@tonic-gate 	}
88*7c478bd9Sstevel@tonic-gate 	/*
89*7c478bd9Sstevel@tonic-gate 	 * Add the 'quit' command to the end.
90*7c478bd9Sstevel@tonic-gate 	 */
91*7c478bd9Sstevel@tonic-gate 	*cpptr = "quit";
92*7c478bd9Sstevel@tonic-gate 	return (list);
93*7c478bd9Sstevel@tonic-gate }
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate /*
96*7c478bd9Sstevel@tonic-gate  * This routine takes a menu list created by the above routine and
97*7c478bd9Sstevel@tonic-gate  * prints it nicely on the screen.
98*7c478bd9Sstevel@tonic-gate  */
99*7c478bd9Sstevel@tonic-gate void
100*7c478bd9Sstevel@tonic-gate display_menu_list(list)
101*7c478bd9Sstevel@tonic-gate 	char	**list;
102*7c478bd9Sstevel@tonic-gate {
103*7c478bd9Sstevel@tonic-gate 	register char **str;
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate 	for (str = list; *str != NULL; str++)
106*7c478bd9Sstevel@tonic-gate 		fmt_print("        %s\n", *str);
107*7c478bd9Sstevel@tonic-gate }
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate /*
110*7c478bd9Sstevel@tonic-gate  * Find the "i"th enabled menu in a menu list.  This depends
111*7c478bd9Sstevel@tonic-gate  * on menu_state() returning the same status as when the
112*7c478bd9Sstevel@tonic-gate  * original list of enabled commands was constructed.
113*7c478bd9Sstevel@tonic-gate  */
114*7c478bd9Sstevel@tonic-gate static int (*
115*7c478bd9Sstevel@tonic-gate find_enabled_menu_item(menu, item))()
116*7c478bd9Sstevel@tonic-gate 	struct menu_item	*menu;
117*7c478bd9Sstevel@tonic-gate 	int			item;
118*7c478bd9Sstevel@tonic-gate {
119*7c478bd9Sstevel@tonic-gate 	struct menu_item	*mp;
120*7c478bd9Sstevel@tonic-gate 
121*7c478bd9Sstevel@tonic-gate 	for (mp = menu; mp->menu_cmd != NULL; mp++) {
122*7c478bd9Sstevel@tonic-gate 		if ((*mp->menu_state)()) {
123*7c478bd9Sstevel@tonic-gate 			if (item-- == 0) {
124*7c478bd9Sstevel@tonic-gate 				return (mp->menu_func);
125*7c478bd9Sstevel@tonic-gate 			}
126*7c478bd9Sstevel@tonic-gate 		}
127*7c478bd9Sstevel@tonic-gate 	}
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate 	return (NULL);
130*7c478bd9Sstevel@tonic-gate }
131*7c478bd9Sstevel@tonic-gate 
132*7c478bd9Sstevel@tonic-gate /*
133*7c478bd9Sstevel@tonic-gate  * This routine 'runs' a menu.  It repeatedly requests a command and
134*7c478bd9Sstevel@tonic-gate  * executes the command chosen.  It exits when the 'quit' command is
135*7c478bd9Sstevel@tonic-gate  * executed.
136*7c478bd9Sstevel@tonic-gate  */
137*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
138*7c478bd9Sstevel@tonic-gate void
139*7c478bd9Sstevel@tonic-gate run_menu(menu, title, prompt, display_flag)
140*7c478bd9Sstevel@tonic-gate 	struct	menu_item *menu;
141*7c478bd9Sstevel@tonic-gate 	char	*title;
142*7c478bd9Sstevel@tonic-gate 	char	*prompt;
143*7c478bd9Sstevel@tonic-gate 	int	display_flag;
144*7c478bd9Sstevel@tonic-gate {
145*7c478bd9Sstevel@tonic-gate 	char		**list;
146*7c478bd9Sstevel@tonic-gate 	int		i;
147*7c478bd9Sstevel@tonic-gate 	struct		env env;
148*7c478bd9Sstevel@tonic-gate 	u_ioparam_t	ioparam;
149*7c478bd9Sstevel@tonic-gate 	int		(*f)();
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate 
152*7c478bd9Sstevel@tonic-gate 	/*
153*7c478bd9Sstevel@tonic-gate 	 * Create the menu list and display it.
154*7c478bd9Sstevel@tonic-gate 	 */
155*7c478bd9Sstevel@tonic-gate 	list = create_menu_list(menu);
156*7c478bd9Sstevel@tonic-gate 	(void) strcpy(cur_title, title);
157*7c478bd9Sstevel@tonic-gate 	fmt_print("\n\n%s MENU:\n", title);
158*7c478bd9Sstevel@tonic-gate 	display_menu_list(list);
159*7c478bd9Sstevel@tonic-gate 	/*
160*7c478bd9Sstevel@tonic-gate 	 * Save the environment so a ctrl-C out of a command lands here.
161*7c478bd9Sstevel@tonic-gate 	 */
162*7c478bd9Sstevel@tonic-gate 	saveenv(env);
163*7c478bd9Sstevel@tonic-gate 	for (;;) {
164*7c478bd9Sstevel@tonic-gate 		/*
165*7c478bd9Sstevel@tonic-gate 		 * Ask the user which command they want to run.
166*7c478bd9Sstevel@tonic-gate 		 */
167*7c478bd9Sstevel@tonic-gate 		ioparam.io_charlist = list;
168*7c478bd9Sstevel@tonic-gate 		i = input(FIO_MSTR, prompt, '>', &ioparam,
169*7c478bd9Sstevel@tonic-gate 		    (int *)NULL, CMD_INPUT);
170*7c478bd9Sstevel@tonic-gate 		/*
171*7c478bd9Sstevel@tonic-gate 		 * If they choose 'quit', the party's over.
172*7c478bd9Sstevel@tonic-gate 		 */
173*7c478bd9Sstevel@tonic-gate 		if ((f = find_enabled_menu_item(menu, i)) == NULL)
174*7c478bd9Sstevel@tonic-gate 			break;
175*7c478bd9Sstevel@tonic-gate 
176*7c478bd9Sstevel@tonic-gate 		/*
177*7c478bd9Sstevel@tonic-gate 		 * Mark the saved environment active so the user can now
178*7c478bd9Sstevel@tonic-gate 		 * do a ctrl-C to get out of the command.
179*7c478bd9Sstevel@tonic-gate 		 */
180*7c478bd9Sstevel@tonic-gate 		useenv();
181*7c478bd9Sstevel@tonic-gate 		/*
182*7c478bd9Sstevel@tonic-gate 		 * Run the command.  If it returns an error and we are
183*7c478bd9Sstevel@tonic-gate 		 * running out of a command file, the party's really over.
184*7c478bd9Sstevel@tonic-gate 		 */
185*7c478bd9Sstevel@tonic-gate 		if ((*f)() && option_f)
186*7c478bd9Sstevel@tonic-gate 			fullabort();
187*7c478bd9Sstevel@tonic-gate 		/*
188*7c478bd9Sstevel@tonic-gate 		 * Mark the saved environment inactive so ctrl-C doesn't
189*7c478bd9Sstevel@tonic-gate 		 * work at the menu itself.
190*7c478bd9Sstevel@tonic-gate 		 */
191*7c478bd9Sstevel@tonic-gate 		unuseenv();
192*7c478bd9Sstevel@tonic-gate 		/*
193*7c478bd9Sstevel@tonic-gate 		 * Since menu items are dynamic, some commands
194*7c478bd9Sstevel@tonic-gate 		 * cause changes to occur.  Destroy the old menu,
195*7c478bd9Sstevel@tonic-gate 		 * and rebuild it, so we're always up-to-date.
196*7c478bd9Sstevel@tonic-gate 		 */
197*7c478bd9Sstevel@tonic-gate 		destroy_data((char *)list);
198*7c478bd9Sstevel@tonic-gate 		list = create_menu_list(menu);
199*7c478bd9Sstevel@tonic-gate 		/*
200*7c478bd9Sstevel@tonic-gate 		 * Redisplay menu, if we're returning to this one.
201*7c478bd9Sstevel@tonic-gate 		 */
202*7c478bd9Sstevel@tonic-gate 		if (cur_menu != last_menu) {
203*7c478bd9Sstevel@tonic-gate 			last_menu = cur_menu;
204*7c478bd9Sstevel@tonic-gate 			(void) strcpy(cur_title, title);
205*7c478bd9Sstevel@tonic-gate 			fmt_print("\n\n%s MENU:\n", title);
206*7c478bd9Sstevel@tonic-gate 			display_menu_list(list);
207*7c478bd9Sstevel@tonic-gate 		}
208*7c478bd9Sstevel@tonic-gate 	}
209*7c478bd9Sstevel@tonic-gate 	/*
210*7c478bd9Sstevel@tonic-gate 	 * Clean up the environment stack and throw away the menu list.
211*7c478bd9Sstevel@tonic-gate 	 */
212*7c478bd9Sstevel@tonic-gate 	clearenv();
213*7c478bd9Sstevel@tonic-gate 	destroy_data((char *)list);
214*7c478bd9Sstevel@tonic-gate }
215*7c478bd9Sstevel@tonic-gate 
216*7c478bd9Sstevel@tonic-gate /*
217*7c478bd9Sstevel@tonic-gate  * re-display the screen after exiting from shell escape
218*7c478bd9Sstevel@tonic-gate  *
219*7c478bd9Sstevel@tonic-gate  */
220*7c478bd9Sstevel@tonic-gate void
221*7c478bd9Sstevel@tonic-gate redisplay_menu_list(list)
222*7c478bd9Sstevel@tonic-gate char **list;
223*7c478bd9Sstevel@tonic-gate {
224*7c478bd9Sstevel@tonic-gate 	fmt_print("\n\n%s MENU:\n", cur_title);
225*7c478bd9Sstevel@tonic-gate 	display_menu_list(list);
226*7c478bd9Sstevel@tonic-gate }
227*7c478bd9Sstevel@tonic-gate 
228*7c478bd9Sstevel@tonic-gate 
229*7c478bd9Sstevel@tonic-gate /*
230*7c478bd9Sstevel@tonic-gate  * Glue to always return true.  Used for menu items which
231*7c478bd9Sstevel@tonic-gate  * are always enabled.
232*7c478bd9Sstevel@tonic-gate  */
233*7c478bd9Sstevel@tonic-gate int
234*7c478bd9Sstevel@tonic-gate true()
235*7c478bd9Sstevel@tonic-gate {
236*7c478bd9Sstevel@tonic-gate 	return (1);
237*7c478bd9Sstevel@tonic-gate }
238*7c478bd9Sstevel@tonic-gate 
239*7c478bd9Sstevel@tonic-gate /*
240*7c478bd9Sstevel@tonic-gate  * Note: The following functions are used to enable the inclusion
241*7c478bd9Sstevel@tonic-gate  * of device specific options (see init_menus.c). But when we are
242*7c478bd9Sstevel@tonic-gate  * running non interactively with commands taken from a script file,
243*7c478bd9Sstevel@tonic-gate  * current disk (cur_disk, cur_type, cur_ctype) may not be defined.
244*7c478bd9Sstevel@tonic-gate  * They get defined when the script selects a disk using "disk" option
245*7c478bd9Sstevel@tonic-gate  * in the main menu. However, in the normal interactive mode, the disk
246*7c478bd9Sstevel@tonic-gate  * selection happens before entering the main menu.
247*7c478bd9Sstevel@tonic-gate  */
248*7c478bd9Sstevel@tonic-gate /*
249*7c478bd9Sstevel@tonic-gate  * Return true for menu items enabled only for embedded SCSI controllers
250*7c478bd9Sstevel@tonic-gate  */
251*7c478bd9Sstevel@tonic-gate int
252*7c478bd9Sstevel@tonic-gate embedded_scsi()
253*7c478bd9Sstevel@tonic-gate {
254*7c478bd9Sstevel@tonic-gate 	if (cur_ctype == NULL && option_f)
255*7c478bd9Sstevel@tonic-gate 		return (0);
256*7c478bd9Sstevel@tonic-gate 	return (EMBEDDED_SCSI);
257*7c478bd9Sstevel@tonic-gate }
258*7c478bd9Sstevel@tonic-gate 
259*7c478bd9Sstevel@tonic-gate /*
260*7c478bd9Sstevel@tonic-gate  * Return false for menu items disabled only for embedded SCSI controllers
261*7c478bd9Sstevel@tonic-gate  */
262*7c478bd9Sstevel@tonic-gate int
263*7c478bd9Sstevel@tonic-gate not_embedded_scsi()
264*7c478bd9Sstevel@tonic-gate {
265*7c478bd9Sstevel@tonic-gate 	if (cur_ctype == NULL && option_f)
266*7c478bd9Sstevel@tonic-gate 		return (0);
267*7c478bd9Sstevel@tonic-gate 	return (!EMBEDDED_SCSI);
268*7c478bd9Sstevel@tonic-gate }
269*7c478bd9Sstevel@tonic-gate 
270*7c478bd9Sstevel@tonic-gate /*
271*7c478bd9Sstevel@tonic-gate  * Return false for menu items disabled for scsi controllers
272*7c478bd9Sstevel@tonic-gate  */
273*7c478bd9Sstevel@tonic-gate int
274*7c478bd9Sstevel@tonic-gate not_scsi()
275*7c478bd9Sstevel@tonic-gate {
276*7c478bd9Sstevel@tonic-gate 	if (cur_ctype == NULL && option_f)
277*7c478bd9Sstevel@tonic-gate 		return (0);
278*7c478bd9Sstevel@tonic-gate 	return (!SCSI);
279*7c478bd9Sstevel@tonic-gate }
280*7c478bd9Sstevel@tonic-gate 
281*7c478bd9Sstevel@tonic-gate /*
282*7c478bd9Sstevel@tonic-gate  * Return false for menu items disabled for efi labels
283*7c478bd9Sstevel@tonic-gate  */
284*7c478bd9Sstevel@tonic-gate int
285*7c478bd9Sstevel@tonic-gate not_efi()
286*7c478bd9Sstevel@tonic-gate {
287*7c478bd9Sstevel@tonic-gate 	if ((cur_disk == NULL) && option_f)
288*7c478bd9Sstevel@tonic-gate 		return (0);
289*7c478bd9Sstevel@tonic-gate 	if (cur_disk->label_type == L_TYPE_EFI)
290*7c478bd9Sstevel@tonic-gate 		return (0);
291*7c478bd9Sstevel@tonic-gate 	return (1);
292*7c478bd9Sstevel@tonic-gate }
293*7c478bd9Sstevel@tonic-gate 
294*7c478bd9Sstevel@tonic-gate int
295*7c478bd9Sstevel@tonic-gate disp_expert_change_expert_efi()
296*7c478bd9Sstevel@tonic-gate {
297*7c478bd9Sstevel@tonic-gate 	if ((cur_disk == NULL) && option_f)
298*7c478bd9Sstevel@tonic-gate 		return (0);
299*7c478bd9Sstevel@tonic-gate 	if ((cur_disk->label_type == L_TYPE_EFI) && expert_mode)
300*7c478bd9Sstevel@tonic-gate 		return (1);
301*7c478bd9Sstevel@tonic-gate 	if (cur_disk->label_type != L_TYPE_EFI)
302*7c478bd9Sstevel@tonic-gate 		return (1);
303*7c478bd9Sstevel@tonic-gate 	return (0);
304*7c478bd9Sstevel@tonic-gate }
305*7c478bd9Sstevel@tonic-gate 
306*7c478bd9Sstevel@tonic-gate int
307*7c478bd9Sstevel@tonic-gate disp_all_change_expert_efi()
308*7c478bd9Sstevel@tonic-gate {
309*7c478bd9Sstevel@tonic-gate 	if ((cur_disk == NULL) && option_f)
310*7c478bd9Sstevel@tonic-gate 		return (0);
311*7c478bd9Sstevel@tonic-gate 	if ((cur_disk->label_type != L_TYPE_EFI) || (!expert_mode))
312*7c478bd9Sstevel@tonic-gate 		return (0);
313*7c478bd9Sstevel@tonic-gate 	return (1);
314*7c478bd9Sstevel@tonic-gate }
315*7c478bd9Sstevel@tonic-gate 
316*7c478bd9Sstevel@tonic-gate /*
317*7c478bd9Sstevel@tonic-gate  * Return true for menu items enabled scsi controllers
318*7c478bd9Sstevel@tonic-gate  */
319*7c478bd9Sstevel@tonic-gate int
320*7c478bd9Sstevel@tonic-gate scsi()
321*7c478bd9Sstevel@tonic-gate {
322*7c478bd9Sstevel@tonic-gate 	if (cur_ctype == NULL && option_f)
323*7c478bd9Sstevel@tonic-gate 		return (0);
324*7c478bd9Sstevel@tonic-gate 	return (SCSI);
325*7c478bd9Sstevel@tonic-gate }
326*7c478bd9Sstevel@tonic-gate 
327*7c478bd9Sstevel@tonic-gate 
328*7c478bd9Sstevel@tonic-gate /*
329*7c478bd9Sstevel@tonic-gate  * Return true for menu items enabled if expert mode is enabled
330*7c478bd9Sstevel@tonic-gate  */
331*7c478bd9Sstevel@tonic-gate int
332*7c478bd9Sstevel@tonic-gate scsi_expert()
333*7c478bd9Sstevel@tonic-gate {
334*7c478bd9Sstevel@tonic-gate 	if (cur_ctype == NULL && option_f)
335*7c478bd9Sstevel@tonic-gate 		return (0);
336*7c478bd9Sstevel@tonic-gate 	return (SCSI && expert_mode);
337*7c478bd9Sstevel@tonic-gate }
338*7c478bd9Sstevel@tonic-gate 
339*7c478bd9Sstevel@tonic-gate #if	defined(i386)
340*7c478bd9Sstevel@tonic-gate /*
341*7c478bd9Sstevel@tonic-gate  * Return true for menu items enabled if expert mode is enabled
342*7c478bd9Sstevel@tonic-gate  */
343*7c478bd9Sstevel@tonic-gate int
344*7c478bd9Sstevel@tonic-gate expert()
345*7c478bd9Sstevel@tonic-gate {
346*7c478bd9Sstevel@tonic-gate 	return (expert_mode);
347*7c478bd9Sstevel@tonic-gate }
348*7c478bd9Sstevel@tonic-gate #endif	/* defined(i386) */
349*7c478bd9Sstevel@tonic-gate 
350*7c478bd9Sstevel@tonic-gate /*
351*7c478bd9Sstevel@tonic-gate  * Return true for menu items enabled if developer mode is enabled
352*7c478bd9Sstevel@tonic-gate  */
353*7c478bd9Sstevel@tonic-gate int
354*7c478bd9Sstevel@tonic-gate developer()
355*7c478bd9Sstevel@tonic-gate {
356*7c478bd9Sstevel@tonic-gate 	return (dev_expert);
357*7c478bd9Sstevel@tonic-gate }
358*7c478bd9Sstevel@tonic-gate 
359*7c478bd9Sstevel@tonic-gate /*
360*7c478bd9Sstevel@tonic-gate  * For x86, always return true for menu items enabled
361*7c478bd9Sstevel@tonic-gate  *	since fdisk is already supported on these two platforms.
362*7c478bd9Sstevel@tonic-gate  * For Sparc, only return true for menu items enabled
363*7c478bd9Sstevel@tonic-gate  *	if a PCATA disk is selected.
364*7c478bd9Sstevel@tonic-gate  */
365*7c478bd9Sstevel@tonic-gate int
366*7c478bd9Sstevel@tonic-gate support_fdisk_on_sparc()
367*7c478bd9Sstevel@tonic-gate {
368*7c478bd9Sstevel@tonic-gate #if defined(sparc)
369*7c478bd9Sstevel@tonic-gate 	/*
370*7c478bd9Sstevel@tonic-gate 	 * If it's a SCSI disk then we don't support fdisk and we
371*7c478bd9Sstevel@tonic-gate 	 * don't need to know the type cause we can ask the disk,
372*7c478bd9Sstevel@tonic-gate 	 * therefore we return true only if we *KNOW* it's an ATA
373*7c478bd9Sstevel@tonic-gate 	 * disk.
374*7c478bd9Sstevel@tonic-gate 	 */
375*7c478bd9Sstevel@tonic-gate 	if (cur_ctype && cur_ctype->ctype_ctype == DKC_PCMCIA_ATA) {
376*7c478bd9Sstevel@tonic-gate 		return (1);
377*7c478bd9Sstevel@tonic-gate 	} else {
378*7c478bd9Sstevel@tonic-gate 		return (0);
379*7c478bd9Sstevel@tonic-gate 	}
380*7c478bd9Sstevel@tonic-gate #elif defined(i386)
381*7c478bd9Sstevel@tonic-gate 	return (1);
382*7c478bd9Sstevel@tonic-gate #else
383*7c478bd9Sstevel@tonic-gate #error  No Platform defined
384*7c478bd9Sstevel@tonic-gate #endif /* defined(sparc) */
385*7c478bd9Sstevel@tonic-gate 
386*7c478bd9Sstevel@tonic-gate }
387