xref: /illumos-gate/usr/src/cmd/format/menu.c (revision b12aaafb)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5af007057Syl  * Common Development and Distribution License (the "License").
6af007057Syl  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22af007057Syl  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
277c478bd9Sstevel@tonic-gate  * This file contains routines relating to running the menus.
287c478bd9Sstevel@tonic-gate  */
297c478bd9Sstevel@tonic-gate #include <string.h>
307c478bd9Sstevel@tonic-gate #include "global.h"
317c478bd9Sstevel@tonic-gate #include "menu.h"
327c478bd9Sstevel@tonic-gate #include "misc.h"
337c478bd9Sstevel@tonic-gate 
34*b12aaafbSToomas Soome static int	(*find_enabled_menu_item(struct menu_item *, int))(void);
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate static char	cur_title[MAXPATHLEN];
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate /*
397c478bd9Sstevel@tonic-gate  * This routine takes a menu struct and concatenates the
407c478bd9Sstevel@tonic-gate  * command names into an array of strings describing the menu.
417c478bd9Sstevel@tonic-gate  * All menus have a 'quit' command at the bottom to exit the menu.
427c478bd9Sstevel@tonic-gate  */
437c478bd9Sstevel@tonic-gate char **
create_menu_list(struct menu_item * menu)44*b12aaafbSToomas Soome create_menu_list(struct menu_item *menu)
457c478bd9Sstevel@tonic-gate {
46*b12aaafbSToomas Soome 	struct menu_item *mptr;
47*b12aaafbSToomas Soome 	char	**cpptr;
48*b12aaafbSToomas Soome 	char	**list;
497c478bd9Sstevel@tonic-gate 	int		nitems;
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate 	/*
527c478bd9Sstevel@tonic-gate 	 * A minimum list consists of the quit command, followed
537c478bd9Sstevel@tonic-gate 	 * by a terminating null.
547c478bd9Sstevel@tonic-gate 	 */
557c478bd9Sstevel@tonic-gate 	nitems = 2;
567c478bd9Sstevel@tonic-gate 	/*
577c478bd9Sstevel@tonic-gate 	 * Count the number of active commands in the menu and allocate
587c478bd9Sstevel@tonic-gate 	 * space for the array of pointers.
597c478bd9Sstevel@tonic-gate 	 */
607c478bd9Sstevel@tonic-gate 	for (mptr = menu; mptr->menu_cmd != NULL; mptr++) {
617c478bd9Sstevel@tonic-gate 		if ((*mptr->menu_state)())
627c478bd9Sstevel@tonic-gate 			nitems++;
637c478bd9Sstevel@tonic-gate 	}
647c478bd9Sstevel@tonic-gate 	list = (char **)zalloc(nitems * sizeof (char *));
657c478bd9Sstevel@tonic-gate 	cpptr = list;
667c478bd9Sstevel@tonic-gate 	/*
677c478bd9Sstevel@tonic-gate 	 * Fill in the array with the names of the menu commands.
687c478bd9Sstevel@tonic-gate 	 */
697c478bd9Sstevel@tonic-gate 	for (mptr = menu; mptr->menu_cmd != NULL; mptr++) {
707c478bd9Sstevel@tonic-gate 		if ((*mptr->menu_state)()) {
717c478bd9Sstevel@tonic-gate 			*cpptr++ = mptr->menu_cmd;
727c478bd9Sstevel@tonic-gate 		}
737c478bd9Sstevel@tonic-gate 	}
747c478bd9Sstevel@tonic-gate 	/*
757c478bd9Sstevel@tonic-gate 	 * Add the 'quit' command to the end.
767c478bd9Sstevel@tonic-gate 	 */
777c478bd9Sstevel@tonic-gate 	*cpptr = "quit";
787c478bd9Sstevel@tonic-gate 	return (list);
797c478bd9Sstevel@tonic-gate }
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate /*
827c478bd9Sstevel@tonic-gate  * This routine takes a menu list created by the above routine and
837c478bd9Sstevel@tonic-gate  * prints it nicely on the screen.
847c478bd9Sstevel@tonic-gate  */
857c478bd9Sstevel@tonic-gate void
display_menu_list(char ** list)86*b12aaafbSToomas Soome display_menu_list(char **list)
877c478bd9Sstevel@tonic-gate {
88*b12aaafbSToomas Soome 	char **str;
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate 	for (str = list; *str != NULL; str++)
917c478bd9Sstevel@tonic-gate 		fmt_print("        %s\n", *str);
927c478bd9Sstevel@tonic-gate }
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate  * Find the "i"th enabled menu in a menu list.  This depends
967c478bd9Sstevel@tonic-gate  * on menu_state() returning the same status as when the
977c478bd9Sstevel@tonic-gate  * original list of enabled commands was constructed.
987c478bd9Sstevel@tonic-gate  */
997c478bd9Sstevel@tonic-gate static int (*
find_enabled_menu_item(struct menu_item * menu,int item)100*b12aaafbSToomas Soome find_enabled_menu_item(struct menu_item *menu, int item))(void)
1017c478bd9Sstevel@tonic-gate {
1027c478bd9Sstevel@tonic-gate 	struct menu_item	*mp;
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate 	for (mp = menu; mp->menu_cmd != NULL; mp++) {
1057c478bd9Sstevel@tonic-gate 		if ((*mp->menu_state)()) {
1067c478bd9Sstevel@tonic-gate 			if (item-- == 0) {
1077c478bd9Sstevel@tonic-gate 				return (mp->menu_func);
1087c478bd9Sstevel@tonic-gate 			}
1097c478bd9Sstevel@tonic-gate 		}
1107c478bd9Sstevel@tonic-gate 	}
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate 	return (NULL);
1137c478bd9Sstevel@tonic-gate }
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate /*
1167c478bd9Sstevel@tonic-gate  * This routine 'runs' a menu.  It repeatedly requests a command and
1177c478bd9Sstevel@tonic-gate  * executes the command chosen.  It exits when the 'quit' command is
1187c478bd9Sstevel@tonic-gate  * executed.
1197c478bd9Sstevel@tonic-gate  */
1207c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1217c478bd9Sstevel@tonic-gate void
run_menu(struct menu_item * menu,char * title,char * prompt,int display_flag)122*b12aaafbSToomas Soome run_menu(struct menu_item *menu, char *title, char *prompt, int display_flag)
1237c478bd9Sstevel@tonic-gate {
1247c478bd9Sstevel@tonic-gate 	char		**list;
1257c478bd9Sstevel@tonic-gate 	int		i;
1267c478bd9Sstevel@tonic-gate 	struct		env env;
1277c478bd9Sstevel@tonic-gate 	u_ioparam_t	ioparam;
1287c478bd9Sstevel@tonic-gate 	int		(*f)();
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate 	/*
1327c478bd9Sstevel@tonic-gate 	 * Create the menu list and display it.
1337c478bd9Sstevel@tonic-gate 	 */
1347c478bd9Sstevel@tonic-gate 	list = create_menu_list(menu);
1357c478bd9Sstevel@tonic-gate 	(void) strcpy(cur_title, title);
1367c478bd9Sstevel@tonic-gate 	fmt_print("\n\n%s MENU:\n", title);
1377c478bd9Sstevel@tonic-gate 	display_menu_list(list);
1387c478bd9Sstevel@tonic-gate 	/*
1397c478bd9Sstevel@tonic-gate 	 * Save the environment so a ctrl-C out of a command lands here.
1407c478bd9Sstevel@tonic-gate 	 */
1417c478bd9Sstevel@tonic-gate 	saveenv(env);
1427c478bd9Sstevel@tonic-gate 	for (;;) {
1437c478bd9Sstevel@tonic-gate 		/*
1447c478bd9Sstevel@tonic-gate 		 * Ask the user which command they want to run.
1457c478bd9Sstevel@tonic-gate 		 */
1467c478bd9Sstevel@tonic-gate 		ioparam.io_charlist = list;
147*b12aaafbSToomas Soome 		i = input(FIO_MSTR, prompt, '>', &ioparam, NULL, CMD_INPUT);
1487c478bd9Sstevel@tonic-gate 		/*
1497c478bd9Sstevel@tonic-gate 		 * If they choose 'quit', the party's over.
1507c478bd9Sstevel@tonic-gate 		 */
1517c478bd9Sstevel@tonic-gate 		if ((f = find_enabled_menu_item(menu, i)) == NULL)
1527c478bd9Sstevel@tonic-gate 			break;
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate 		/*
1557c478bd9Sstevel@tonic-gate 		 * Mark the saved environment active so the user can now
1567c478bd9Sstevel@tonic-gate 		 * do a ctrl-C to get out of the command.
1577c478bd9Sstevel@tonic-gate 		 */
1587c478bd9Sstevel@tonic-gate 		useenv();
1597c478bd9Sstevel@tonic-gate 		/*
1607c478bd9Sstevel@tonic-gate 		 * Run the command.  If it returns an error and we are
1617c478bd9Sstevel@tonic-gate 		 * running out of a command file, the party's really over.
1627c478bd9Sstevel@tonic-gate 		 */
1637c478bd9Sstevel@tonic-gate 		if ((*f)() && option_f)
1647c478bd9Sstevel@tonic-gate 			fullabort();
1657c478bd9Sstevel@tonic-gate 		/*
1667c478bd9Sstevel@tonic-gate 		 * Mark the saved environment inactive so ctrl-C doesn't
1677c478bd9Sstevel@tonic-gate 		 * work at the menu itself.
1687c478bd9Sstevel@tonic-gate 		 */
1697c478bd9Sstevel@tonic-gate 		unuseenv();
1707c478bd9Sstevel@tonic-gate 		/*
1717c478bd9Sstevel@tonic-gate 		 * Since menu items are dynamic, some commands
1727c478bd9Sstevel@tonic-gate 		 * cause changes to occur.  Destroy the old menu,
1737c478bd9Sstevel@tonic-gate 		 * and rebuild it, so we're always up-to-date.
1747c478bd9Sstevel@tonic-gate 		 */
1757c478bd9Sstevel@tonic-gate 		destroy_data((char *)list);
1767c478bd9Sstevel@tonic-gate 		list = create_menu_list(menu);
1777c478bd9Sstevel@tonic-gate 		/*
1787c478bd9Sstevel@tonic-gate 		 * Redisplay menu, if we're returning to this one.
1797c478bd9Sstevel@tonic-gate 		 */
1807c478bd9Sstevel@tonic-gate 		if (cur_menu != last_menu) {
1817c478bd9Sstevel@tonic-gate 			last_menu = cur_menu;
1827c478bd9Sstevel@tonic-gate 			(void) strcpy(cur_title, title);
1837c478bd9Sstevel@tonic-gate 			fmt_print("\n\n%s MENU:\n", title);
1847c478bd9Sstevel@tonic-gate 			display_menu_list(list);
1857c478bd9Sstevel@tonic-gate 		}
1867c478bd9Sstevel@tonic-gate 	}
1877c478bd9Sstevel@tonic-gate 	/*
1887c478bd9Sstevel@tonic-gate 	 * Clean up the environment stack and throw away the menu list.
1897c478bd9Sstevel@tonic-gate 	 */
1907c478bd9Sstevel@tonic-gate 	clearenv();
1917c478bd9Sstevel@tonic-gate 	destroy_data((char *)list);
1927c478bd9Sstevel@tonic-gate }
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate /*
1957c478bd9Sstevel@tonic-gate  * re-display the screen after exiting from shell escape
1967c478bd9Sstevel@tonic-gate  *
1977c478bd9Sstevel@tonic-gate  */
1987c478bd9Sstevel@tonic-gate void
redisplay_menu_list(char ** list)199*b12aaafbSToomas Soome redisplay_menu_list(char **list)
2007c478bd9Sstevel@tonic-gate {
2017c478bd9Sstevel@tonic-gate 	fmt_print("\n\n%s MENU:\n", cur_title);
2027c478bd9Sstevel@tonic-gate 	display_menu_list(list);
2037c478bd9Sstevel@tonic-gate }
2047c478bd9Sstevel@tonic-gate 
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate /*
2077c478bd9Sstevel@tonic-gate  * Glue to always return true.  Used for menu items which
2087c478bd9Sstevel@tonic-gate  * are always enabled.
2097c478bd9Sstevel@tonic-gate  */
2107c478bd9Sstevel@tonic-gate int
211*b12aaafbSToomas Soome true(void)
2127c478bd9Sstevel@tonic-gate {
2137c478bd9Sstevel@tonic-gate 	return (1);
2147c478bd9Sstevel@tonic-gate }
2157c478bd9Sstevel@tonic-gate 
2167c478bd9Sstevel@tonic-gate /*
2177c478bd9Sstevel@tonic-gate  * Note: The following functions are used to enable the inclusion
2187c478bd9Sstevel@tonic-gate  * of device specific options (see init_menus.c). But when we are
2197c478bd9Sstevel@tonic-gate  * running non interactively with commands taken from a script file,
2207c478bd9Sstevel@tonic-gate  * current disk (cur_disk, cur_type, cur_ctype) may not be defined.
2217c478bd9Sstevel@tonic-gate  * They get defined when the script selects a disk using "disk" option
2227c478bd9Sstevel@tonic-gate  * in the main menu. However, in the normal interactive mode, the disk
2237c478bd9Sstevel@tonic-gate  * selection happens before entering the main menu.
2247c478bd9Sstevel@tonic-gate  */
2257c478bd9Sstevel@tonic-gate /*
2267c478bd9Sstevel@tonic-gate  * Return true for menu items enabled only for embedded SCSI controllers
2277c478bd9Sstevel@tonic-gate  */
2287c478bd9Sstevel@tonic-gate int
embedded_scsi(void)229*b12aaafbSToomas Soome embedded_scsi(void)
2307c478bd9Sstevel@tonic-gate {
2317c478bd9Sstevel@tonic-gate 	if (cur_ctype == NULL && option_f)
2327c478bd9Sstevel@tonic-gate 		return (0);
2337c478bd9Sstevel@tonic-gate 	return (EMBEDDED_SCSI);
2347c478bd9Sstevel@tonic-gate }
2357c478bd9Sstevel@tonic-gate 
2367c478bd9Sstevel@tonic-gate /*
2377c478bd9Sstevel@tonic-gate  * Return false for menu items disabled only for embedded SCSI controllers
2387c478bd9Sstevel@tonic-gate  */
2397c478bd9Sstevel@tonic-gate int
not_embedded_scsi(void)240*b12aaafbSToomas Soome not_embedded_scsi(void)
2417c478bd9Sstevel@tonic-gate {
2427c478bd9Sstevel@tonic-gate 	if (cur_ctype == NULL && option_f)
2437c478bd9Sstevel@tonic-gate 		return (0);
2447c478bd9Sstevel@tonic-gate 	return (!EMBEDDED_SCSI);
2457c478bd9Sstevel@tonic-gate }
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate /*
2487c478bd9Sstevel@tonic-gate  * Return false for menu items disabled for scsi controllers
2497c478bd9Sstevel@tonic-gate  */
2507c478bd9Sstevel@tonic-gate int
not_scsi(void)251*b12aaafbSToomas Soome not_scsi(void)
2527c478bd9Sstevel@tonic-gate {
2537c478bd9Sstevel@tonic-gate 	if (cur_ctype == NULL && option_f)
2547c478bd9Sstevel@tonic-gate 		return (0);
2557c478bd9Sstevel@tonic-gate 	return (!SCSI);
2567c478bd9Sstevel@tonic-gate }
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate /*
2597c478bd9Sstevel@tonic-gate  * Return false for menu items disabled for efi labels
2607c478bd9Sstevel@tonic-gate  */
2617c478bd9Sstevel@tonic-gate int
not_efi(void)262*b12aaafbSToomas Soome not_efi(void)
2637c478bd9Sstevel@tonic-gate {
2647c478bd9Sstevel@tonic-gate 	if ((cur_disk == NULL) && option_f)
2657c478bd9Sstevel@tonic-gate 		return (0);
2667c478bd9Sstevel@tonic-gate 	if (cur_disk->label_type == L_TYPE_EFI)
2677c478bd9Sstevel@tonic-gate 		return (0);
2687c478bd9Sstevel@tonic-gate 	return (1);
2697c478bd9Sstevel@tonic-gate }
2707c478bd9Sstevel@tonic-gate 
2717c478bd9Sstevel@tonic-gate int
disp_expert_change_expert_efi(void)272*b12aaafbSToomas Soome disp_expert_change_expert_efi(void)
2737c478bd9Sstevel@tonic-gate {
2747c478bd9Sstevel@tonic-gate 	if ((cur_disk == NULL) && option_f)
2757c478bd9Sstevel@tonic-gate 		return (0);
2767c478bd9Sstevel@tonic-gate 	if ((cur_disk->label_type == L_TYPE_EFI) && expert_mode)
2777c478bd9Sstevel@tonic-gate 		return (1);
2787c478bd9Sstevel@tonic-gate 	if (cur_disk->label_type != L_TYPE_EFI)
2797c478bd9Sstevel@tonic-gate 		return (1);
2807c478bd9Sstevel@tonic-gate 	return (0);
2817c478bd9Sstevel@tonic-gate }
2827c478bd9Sstevel@tonic-gate 
283af007057Syl int
disp_expand_efi(void)284*b12aaafbSToomas Soome disp_expand_efi(void)
285af007057Syl {
286af007057Syl 	if ((cur_disk == NULL) && option_f)
287af007057Syl 		return (0);
288af007057Syl 	if (cur_disk->label_type != L_TYPE_EFI)
289af007057Syl 		return (0);
290af007057Syl 	if (cur_parts == NULL)
291af007057Syl 		return (0);
292af007057Syl 	return (1);
293af007057Syl }
294af007057Syl 
2957c478bd9Sstevel@tonic-gate int
disp_all_change_expert_efi(void)296*b12aaafbSToomas Soome disp_all_change_expert_efi(void)
2977c478bd9Sstevel@tonic-gate {
2987c478bd9Sstevel@tonic-gate 	if ((cur_disk == NULL) && option_f)
2997c478bd9Sstevel@tonic-gate 		return (0);
3007c478bd9Sstevel@tonic-gate 	if ((cur_disk->label_type != L_TYPE_EFI) || (!expert_mode))
3017c478bd9Sstevel@tonic-gate 		return (0);
3027c478bd9Sstevel@tonic-gate 	return (1);
3037c478bd9Sstevel@tonic-gate }
3047c478bd9Sstevel@tonic-gate 
3057c478bd9Sstevel@tonic-gate /*
3067c478bd9Sstevel@tonic-gate  * Return true for menu items enabled scsi controllers
3077c478bd9Sstevel@tonic-gate  */
3087c478bd9Sstevel@tonic-gate int
scsi(void)309*b12aaafbSToomas Soome scsi(void)
3107c478bd9Sstevel@tonic-gate {
3117c478bd9Sstevel@tonic-gate 	if (cur_ctype == NULL && option_f)
3127c478bd9Sstevel@tonic-gate 		return (0);
3137c478bd9Sstevel@tonic-gate 	return (SCSI);
3147c478bd9Sstevel@tonic-gate }
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate 
3177c478bd9Sstevel@tonic-gate /*
3187c478bd9Sstevel@tonic-gate  * Return true for menu items enabled if expert mode is enabled
3197c478bd9Sstevel@tonic-gate  */
3207c478bd9Sstevel@tonic-gate int
scsi_expert(void)321*b12aaafbSToomas Soome scsi_expert(void)
3227c478bd9Sstevel@tonic-gate {
3237c478bd9Sstevel@tonic-gate 	if (cur_ctype == NULL && option_f)
3247c478bd9Sstevel@tonic-gate 		return (0);
3257c478bd9Sstevel@tonic-gate 	return (SCSI && expert_mode);
3267c478bd9Sstevel@tonic-gate }
3277c478bd9Sstevel@tonic-gate 
3287c478bd9Sstevel@tonic-gate #if	defined(i386)
3297c478bd9Sstevel@tonic-gate /*
3307c478bd9Sstevel@tonic-gate  * Return true for menu items enabled if expert mode is enabled
3317c478bd9Sstevel@tonic-gate  */
3327c478bd9Sstevel@tonic-gate int
expert(void)333*b12aaafbSToomas Soome expert(void)
3347c478bd9Sstevel@tonic-gate {
3357c478bd9Sstevel@tonic-gate 	return (expert_mode);
3367c478bd9Sstevel@tonic-gate }
3377c478bd9Sstevel@tonic-gate #endif	/* defined(i386) */
3387c478bd9Sstevel@tonic-gate 
3397c478bd9Sstevel@tonic-gate /*
3407c478bd9Sstevel@tonic-gate  * Return true for menu items enabled if developer mode is enabled
3417c478bd9Sstevel@tonic-gate  */
3427c478bd9Sstevel@tonic-gate int
developer(void)343*b12aaafbSToomas Soome developer(void)
3447c478bd9Sstevel@tonic-gate {
3457c478bd9Sstevel@tonic-gate 	return (dev_expert);
3467c478bd9Sstevel@tonic-gate }
3477c478bd9Sstevel@tonic-gate 
3487c478bd9Sstevel@tonic-gate /*
3497c478bd9Sstevel@tonic-gate  * For x86, always return true for menu items enabled
3507c478bd9Sstevel@tonic-gate  *	since fdisk is already supported on these two platforms.
3517c478bd9Sstevel@tonic-gate  * For Sparc, only return true for menu items enabled
3527c478bd9Sstevel@tonic-gate  *	if a PCATA disk is selected.
3537c478bd9Sstevel@tonic-gate  */
3547c478bd9Sstevel@tonic-gate int
support_fdisk_on_sparc(void)355*b12aaafbSToomas Soome support_fdisk_on_sparc(void)
3567c478bd9Sstevel@tonic-gate {
3577c478bd9Sstevel@tonic-gate #if defined(sparc)
3587c478bd9Sstevel@tonic-gate 	/*
3597c478bd9Sstevel@tonic-gate 	 * If it's a SCSI disk then we don't support fdisk and we
3607c478bd9Sstevel@tonic-gate 	 * don't need to know the type cause we can ask the disk,
3617c478bd9Sstevel@tonic-gate 	 * therefore we return true only if we *KNOW* it's an ATA
3627c478bd9Sstevel@tonic-gate 	 * disk.
3637c478bd9Sstevel@tonic-gate 	 */
3647c478bd9Sstevel@tonic-gate 	if (cur_ctype && cur_ctype->ctype_ctype == DKC_PCMCIA_ATA) {
3657c478bd9Sstevel@tonic-gate 		return (1);
3667c478bd9Sstevel@tonic-gate 	} else {
3677c478bd9Sstevel@tonic-gate 		return (0);
3687c478bd9Sstevel@tonic-gate 	}
3697c478bd9Sstevel@tonic-gate #elif defined(i386)
3707c478bd9Sstevel@tonic-gate 	return (1);
3717c478bd9Sstevel@tonic-gate #else
3727c478bd9Sstevel@tonic-gate #error  No Platform defined
3737c478bd9Sstevel@tonic-gate #endif /* defined(sparc) */
3747c478bd9Sstevel@tonic-gate 
3757c478bd9Sstevel@tonic-gate }
376