xref: /onnv-gate/usr/src/cmd/mpathadm/mpathadm.c (revision 10696:cd0f390dd9e2)
17836SJohn.Forte@Sun.COM /*
27836SJohn.Forte@Sun.COM  * CDDL HEADER START
37836SJohn.Forte@Sun.COM  *
47836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
57836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
67836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
77836SJohn.Forte@Sun.COM  *
87836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
107836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
117836SJohn.Forte@Sun.COM  * and limitations under the License.
127836SJohn.Forte@Sun.COM  *
137836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
147836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
167836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
177836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
187836SJohn.Forte@Sun.COM  *
197836SJohn.Forte@Sun.COM  * CDDL HEADER END
207836SJohn.Forte@Sun.COM  */
217836SJohn.Forte@Sun.COM /*
22*10696SDavid.Hollister@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237836SJohn.Forte@Sun.COM  * Use is subject to license terms.
247836SJohn.Forte@Sun.COM  */
257836SJohn.Forte@Sun.COM 
267836SJohn.Forte@Sun.COM /*
277836SJohn.Forte@Sun.COM  * mpathadm.c : MP API CLI program
287836SJohn.Forte@Sun.COM  *
297836SJohn.Forte@Sun.COM  */
307836SJohn.Forte@Sun.COM 
317836SJohn.Forte@Sun.COM #include <libintl.h>
327836SJohn.Forte@Sun.COM 
337836SJohn.Forte@Sun.COM #include <mpapi.h>
347836SJohn.Forte@Sun.COM #include "cmdparse.h"
357836SJohn.Forte@Sun.COM #include "mpathadm_text.h"
367836SJohn.Forte@Sun.COM #include "mpathadm.h"
377836SJohn.Forte@Sun.COM 
387836SJohn.Forte@Sun.COM #include <sys/types.h>
397836SJohn.Forte@Sun.COM #include <sys/stat.h>
407836SJohn.Forte@Sun.COM #include <unistd.h>
417836SJohn.Forte@Sun.COM #include <stdlib.h>
427836SJohn.Forte@Sun.COM #include <devid.h>
437836SJohn.Forte@Sun.COM #include <fcntl.h>
447836SJohn.Forte@Sun.COM 
457836SJohn.Forte@Sun.COM /* helper functions */
467836SJohn.Forte@Sun.COM static char *getExecBasename(char *);
477836SJohn.Forte@Sun.COM 
487836SJohn.Forte@Sun.COM /* object functions per subcommand */
497836SJohn.Forte@Sun.COM static int listFunc(int, char **, int, cmdOptions_t *, void *);
507836SJohn.Forte@Sun.COM static int showFunc(int, char **, int, cmdOptions_t *, void *);
517836SJohn.Forte@Sun.COM static int modifyFunc(int, char **, int, cmdOptions_t *, void *);
527836SJohn.Forte@Sun.COM static int enableFunc(int, char **, int, cmdOptions_t *, void *);
537836SJohn.Forte@Sun.COM static int disableFunc(int, char **, int, cmdOptions_t *, void *);
547836SJohn.Forte@Sun.COM static int failoverFunc(int, char **, int, cmdOptions_t *, void *);
557836SJohn.Forte@Sun.COM static int overrideFunc(int, char **, int, cmdOptions_t *, void *);
567836SJohn.Forte@Sun.COM 
577836SJohn.Forte@Sun.COM #define	VERSION_STRING_MAX_LEN	10
587836SJohn.Forte@Sun.COM 
597836SJohn.Forte@Sun.COM #define	OPTIONSTRING_NAME	"name"
607836SJohn.Forte@Sun.COM #define	OPTIONSTRING_TPNAME	"target-port name"
617836SJohn.Forte@Sun.COM #define	OPTIONSTRING_ONOFF	"on/off"
627836SJohn.Forte@Sun.COM #define	OPTIONSTRING_LBTYPE	"loadbalance type"
637836SJohn.Forte@Sun.COM #define	OPTIONSTRING_IPORT	"initiator-port name"
647836SJohn.Forte@Sun.COM #define	OPTIONSTRING_LUNIT	"logical-unit name"
657836SJohn.Forte@Sun.COM #define	OPTIONSTRING_CANCEL	"cancel"
667836SJohn.Forte@Sun.COM #define	OPTIONSTRING_VALUE	"value"
677836SJohn.Forte@Sun.COM 
687836SJohn.Forte@Sun.COM /*
697836SJohn.Forte@Sun.COM  * Version number: (copied from iscsiadm)
707836SJohn.Forte@Sun.COM  *  MAJOR - This should only change when there is an incompatible change made
717836SJohn.Forte@Sun.COM  *  to the interfaces or the output.
727836SJohn.Forte@Sun.COM  *
737836SJohn.Forte@Sun.COM  *  MINOR - This should change whenever there is a new command or new feature
747836SJohn.Forte@Sun.COM  *  with no incompatible change.
757836SJohn.Forte@Sun.COM  */
767836SJohn.Forte@Sun.COM #define	VERSION_STRING_MAJOR	    "1"
777836SJohn.Forte@Sun.COM #define	VERSION_STRING_MINOR	    "0"
787836SJohn.Forte@Sun.COM 
797836SJohn.Forte@Sun.COM 
807836SJohn.Forte@Sun.COM /* globals */
817836SJohn.Forte@Sun.COM static char *cmdName;
827836SJohn.Forte@Sun.COM 
837836SJohn.Forte@Sun.COM 
847836SJohn.Forte@Sun.COM /*
857836SJohn.Forte@Sun.COM  * ****************************************************************************
867836SJohn.Forte@Sun.COM  *
877836SJohn.Forte@Sun.COM  * getExecBasename - copied from iscsiadm code
887836SJohn.Forte@Sun.COM  *
897836SJohn.Forte@Sun.COM  * input:
907836SJohn.Forte@Sun.COM  *  execFullName - exec name of program (argv[0])
917836SJohn.Forte@Sun.COM  *
927836SJohn.Forte@Sun.COM  * Returns:
937836SJohn.Forte@Sun.COM  *  command name portion of execFullName
947836SJohn.Forte@Sun.COM  *
957836SJohn.Forte@Sun.COM  * ****************************************************************************
967836SJohn.Forte@Sun.COM  */
977836SJohn.Forte@Sun.COM static char *
getExecBasename(char * execFullname)987836SJohn.Forte@Sun.COM getExecBasename(char *execFullname)
997836SJohn.Forte@Sun.COM {
1007836SJohn.Forte@Sun.COM 	char 				*lastSlash, *execBasename;
1017836SJohn.Forte@Sun.COM 
1027836SJohn.Forte@Sun.COM 	/* guard against '/' at end of command invocation */
1037836SJohn.Forte@Sun.COM 	for (;;) {
1047836SJohn.Forte@Sun.COM 		lastSlash = strrchr(execFullname, '/');
1057836SJohn.Forte@Sun.COM 		if (lastSlash == NULL) {
1067836SJohn.Forte@Sun.COM 			execBasename = execFullname;
1077836SJohn.Forte@Sun.COM 			break;
1087836SJohn.Forte@Sun.COM 		} else {
1097836SJohn.Forte@Sun.COM 			execBasename = lastSlash + 1;
1107836SJohn.Forte@Sun.COM 			if (*execBasename == '\0') {
1117836SJohn.Forte@Sun.COM 				*lastSlash = '\0';
1127836SJohn.Forte@Sun.COM 				continue;
1137836SJohn.Forte@Sun.COM 			}
1147836SJohn.Forte@Sun.COM 			break;
1157836SJohn.Forte@Sun.COM 		}
1167836SJohn.Forte@Sun.COM 	}
1177836SJohn.Forte@Sun.COM 	return (execBasename);
1187836SJohn.Forte@Sun.COM }
1197836SJohn.Forte@Sun.COM 
1207836SJohn.Forte@Sun.COM 
1217836SJohn.Forte@Sun.COM /*
1227836SJohn.Forte@Sun.COM  * Add new options here
1237836SJohn.Forte@Sun.COM  */
1247836SJohn.Forte@Sun.COM 
1257836SJohn.Forte@Sun.COM /* tables set up based on cmdparse instructions */
1267836SJohn.Forte@Sun.COM optionTbl_t longOptions[] = {
1277836SJohn.Forte@Sun.COM 	{"inqname", required_arg, 'n', OPTIONSTRING_NAME},
1287836SJohn.Forte@Sun.COM 	{"target-port", required_arg, 't', OPTIONSTRING_TPNAME},
1297836SJohn.Forte@Sun.COM 	{"autofailback", required_arg, 'a', OPTIONSTRING_ONOFF},
1307836SJohn.Forte@Sun.COM 	{"autoprobe", required_arg, 'p', OPTIONSTRING_ONOFF},
1317836SJohn.Forte@Sun.COM 	{"loadbalance", required_arg, 'b', OPTIONSTRING_LBTYPE},
1327836SJohn.Forte@Sun.COM 	{"initiator-port", required_arg, 'i', OPTIONSTRING_IPORT},
1337836SJohn.Forte@Sun.COM 	{"logical-unit", required_arg, 'l', OPTIONSTRING_LUNIT},
1347836SJohn.Forte@Sun.COM 	{"cancel", no_arg, 'c', OPTIONSTRING_CANCEL},
1357836SJohn.Forte@Sun.COM 	{"vendor-id", required_arg, 'd', OPTIONSTRING_VALUE},
1367836SJohn.Forte@Sun.COM 	{NULL, 0, 0, 0}
1377836SJohn.Forte@Sun.COM };
1387836SJohn.Forte@Sun.COM 
1397836SJohn.Forte@Sun.COM 
1407836SJohn.Forte@Sun.COM /*
1417836SJohn.Forte@Sun.COM  * Add new subcommands here
1427836SJohn.Forte@Sun.COM  */
1437836SJohn.Forte@Sun.COM subcommand_t subcommands[] = {
1447836SJohn.Forte@Sun.COM 	{"list", LIST, listFunc},
1457836SJohn.Forte@Sun.COM 	{"show", SHOW, showFunc},
1467836SJohn.Forte@Sun.COM 	{"modify", MODIFY, modifyFunc},
1477836SJohn.Forte@Sun.COM 	{"enable", ENABLE, enableFunc},
1487836SJohn.Forte@Sun.COM 	{"disable", DISABLE, disableFunc},
1497836SJohn.Forte@Sun.COM 	{"failover", FAILOVER, failoverFunc},
1507836SJohn.Forte@Sun.COM 	{"override", OVERRIDE, overrideFunc},
1517836SJohn.Forte@Sun.COM 	{NULL, 0, NULL}
1527836SJohn.Forte@Sun.COM };
1537836SJohn.Forte@Sun.COM 
1547836SJohn.Forte@Sun.COM /*
1557836SJohn.Forte@Sun.COM  * Add objects here
1567836SJohn.Forte@Sun.COM  */
1577836SJohn.Forte@Sun.COM object_t objects[] = {
1587836SJohn.Forte@Sun.COM 	{"mpath-support", MPATH_SUPPORT},
1597836SJohn.Forte@Sun.COM 	{"logical-unit", LOGICAL_UNIT},
1607836SJohn.Forte@Sun.COM 	{"LU", LOGICAL_UNIT},
1617836SJohn.Forte@Sun.COM 	{"initiator-port", INITIATOR_PORT},
1627836SJohn.Forte@Sun.COM 	{"path", PATH},
1637836SJohn.Forte@Sun.COM 	{NULL, 0}
1647836SJohn.Forte@Sun.COM };
1657836SJohn.Forte@Sun.COM 
1667836SJohn.Forte@Sun.COM /*
1677836SJohn.Forte@Sun.COM  * Rules for subcommands and objects
1687836SJohn.Forte@Sun.COM  *
1697836SJohn.Forte@Sun.COM  * command
1707836SJohn.Forte@Sun.COM  *
1717836SJohn.Forte@Sun.COM  * reqOpCmd -> subcommands that must have an operand
1727836SJohn.Forte@Sun.COM  * optOpCmd -> subcommands that may have an operand
1737836SJohn.Forte@Sun.COM  * noOpCmd -> subcommands that will have no operand
1747836SJohn.Forte@Sun.COM  * invCmd -> subcommands that are invalid
1757836SJohn.Forte@Sun.COM  * multOpCmd -> subcommands that can accept multiple operands
1767836SJohn.Forte@Sun.COM  * operandDefinition -> Usage definition for the operand of this object
1777836SJohn.Forte@Sun.COM  */
1787836SJohn.Forte@Sun.COM objectRules_t objectRules[] = {
1797836SJohn.Forte@Sun.COM 	{MPATH_SUPPORT, SHOW|MODIFY|ADD, LIST|REMOVE, 0,
1807836SJohn.Forte@Sun.COM 	    ENABLE|DISABLE|FAILOVER|OVERRIDE, LIST|SHOW|MODIFY,
1817836SJohn.Forte@Sun.COM 	    "mpath-support name"},
1827836SJohn.Forte@Sun.COM 	{INITIATOR_PORT, SHOW, LIST, 0,
1837836SJohn.Forte@Sun.COM 	    MODIFY|ENABLE|DISABLE|FAILOVER|OVERRIDE|ADD|REMOVE, LIST|SHOW,
1847836SJohn.Forte@Sun.COM 	    "initiator-port name"},
1857836SJohn.Forte@Sun.COM 	{LOGICAL_UNIT, SHOW|MODIFY|FAILOVER, LIST, 0,
1867836SJohn.Forte@Sun.COM 	    ENABLE|DISABLE|OVERRIDE|ADD|REMOVE, LIST|SHOW|MODIFY,
1877836SJohn.Forte@Sun.COM 	    "logical-unit name"},
1887836SJohn.Forte@Sun.COM 	{PATH, 0, 0, ENABLE|DISABLE|OVERRIDE,
1897836SJohn.Forte@Sun.COM 	    SHOW|LIST|MODIFY|FAILOVER|ADD|REMOVE, 0,
1907836SJohn.Forte@Sun.COM 	    "initiator-port name"},
1917836SJohn.Forte@Sun.COM 	{0, 0, 0, 0, 0, NULL}
1927836SJohn.Forte@Sun.COM };
1937836SJohn.Forte@Sun.COM 
1947836SJohn.Forte@Sun.COM /*
1957836SJohn.Forte@Sun.COM  * list of objects, subcommands, valid short options, required flag and
1967836SJohn.Forte@Sun.COM  * exclusive option string
1977836SJohn.Forte@Sun.COM  *
1987836SJohn.Forte@Sun.COM  * If it's not here, there are no options for that object.
1997836SJohn.Forte@Sun.COM  */
2007836SJohn.Forte@Sun.COM optionRules_t optionRules[] = {
2017836SJohn.Forte@Sun.COM 	{LOGICAL_UNIT, LIST, "nt", B_FALSE, NULL},
2027836SJohn.Forte@Sun.COM 	{LOGICAL_UNIT, MODIFY, "apb", B_TRUE, NULL},
2037836SJohn.Forte@Sun.COM 	{MPATH_SUPPORT, MODIFY, "apb", B_TRUE, NULL},
2047836SJohn.Forte@Sun.COM 	{MPATH_SUPPORT, ADD, "d", B_TRUE, NULL},
2057836SJohn.Forte@Sun.COM 	{MPATH_SUPPORT, REMOVE, "d", B_TRUE, NULL},
2067836SJohn.Forte@Sun.COM 	{PATH, ENABLE, "itl", B_TRUE, NULL},
2077836SJohn.Forte@Sun.COM 	{PATH, DISABLE, "itl", B_TRUE, NULL},
2087836SJohn.Forte@Sun.COM 	{PATH, OVERRIDE, "itlc", B_TRUE, NULL},
2097836SJohn.Forte@Sun.COM 	{0, 0, 0, 0, 0}
2107836SJohn.Forte@Sun.COM };
2117836SJohn.Forte@Sun.COM 
2127836SJohn.Forte@Sun.COM 
2137836SJohn.Forte@Sun.COM /*
2147836SJohn.Forte@Sun.COM  * ****************************************************************************
2157836SJohn.Forte@Sun.COM  *
2167836SJohn.Forte@Sun.COM  * listMpathSupport - mpathadm list mpath-support
2177836SJohn.Forte@Sun.COM  *
2187836SJohn.Forte@Sun.COM  * operandLen	- number of operands user passed into the cli
2197836SJohn.Forte@Sun.COM  * operand	- pointer to operand list from user
2207836SJohn.Forte@Sun.COM  *
2217836SJohn.Forte@Sun.COM  * ****************************************************************************
2227836SJohn.Forte@Sun.COM  */
2237836SJohn.Forte@Sun.COM int
listMpathSupport(int operandLen,char * operand[])2247836SJohn.Forte@Sun.COM listMpathSupport(int operandLen, char *operand[])
2257836SJohn.Forte@Sun.COM {
2267836SJohn.Forte@Sun.COM 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
2277836SJohn.Forte@Sun.COM 	MP_PLUGIN_PROPERTIES			pluginProps;
2287836SJohn.Forte@Sun.COM 	MP_OID_LIST				*pPluginOidList;
2297836SJohn.Forte@Sun.COM 	boolean_t				shown = B_FALSE;
2307836SJohn.Forte@Sun.COM 	/* number of plugins listed */
231*10696SDavid.Hollister@Sun.COM 	int					i, op;
2327836SJohn.Forte@Sun.COM 
2337836SJohn.Forte@Sun.COM 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
2347836SJohn.Forte@Sun.COM 	    != MP_STATUS_SUCCESS) {
2357836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s: %s\n", cmdName,
2367836SJohn.Forte@Sun.COM 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
2377836SJohn.Forte@Sun.COM 		return (mpstatus);
2387836SJohn.Forte@Sun.COM 	}
2397836SJohn.Forte@Sun.COM 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
2407836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s: %s\n", cmdName,
2417836SJohn.Forte@Sun.COM 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
2427836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
2437836SJohn.Forte@Sun.COM 	}
2447836SJohn.Forte@Sun.COM 
2457836SJohn.Forte@Sun.COM 
2467836SJohn.Forte@Sun.COM 	/* loop through operands first */
2477836SJohn.Forte@Sun.COM 	for (op = 0; (op < operandLen) |
2487836SJohn.Forte@Sun.COM 	    ((0 == operandLen) && (B_FALSE == shown)); op++) {
2497836SJohn.Forte@Sun.COM 		shown = B_TRUE;
2507836SJohn.Forte@Sun.COM 		for (i = 0; i < pPluginOidList->oidCount; i++) {
2517836SJohn.Forte@Sun.COM 
2527836SJohn.Forte@Sun.COM 			(void) memset(&pluginProps, 0,
2537836SJohn.Forte@Sun.COM 			    sizeof (MP_PLUGIN_PROPERTIES));
2547836SJohn.Forte@Sun.COM 			mpstatus =
2557836SJohn.Forte@Sun.COM 			    MP_GetPluginProperties(pPluginOidList->oids[i],
2567836SJohn.Forte@Sun.COM 			    &pluginProps);
2577836SJohn.Forte@Sun.COM 			if (mpstatus != MP_STATUS_SUCCESS) {
2587836SJohn.Forte@Sun.COM 				(void) fprintf(stderr, "%s:  %s\n",
2597836SJohn.Forte@Sun.COM 				    cmdName, getTextString(ERR_NO_PROPERTIES));
2607836SJohn.Forte@Sun.COM 			} else {
2617836SJohn.Forte@Sun.COM 				if (0 == operandLen) {
2627836SJohn.Forte@Sun.COM 					/* if no operands, list them all */
2637836SJohn.Forte@Sun.COM 					(void) printf("%s  %s\n",
2647836SJohn.Forte@Sun.COM 					    getTextString(
2657836SJohn.Forte@Sun.COM 					    TEXT_LB_MPATH_SUPPORT),
2667836SJohn.Forte@Sun.COM 					    pluginProps.fileName);
2677836SJohn.Forte@Sun.COM 				} else {
2687836SJohn.Forte@Sun.COM 					/* if there is an operand... */
2697836SJohn.Forte@Sun.COM 					/* ... compare and display if match */
2707836SJohn.Forte@Sun.COM 					if (0 ==
2717836SJohn.Forte@Sun.COM 					    strcmp(operand[op],
2727836SJohn.Forte@Sun.COM 					    pluginProps.fileName)) {
2737836SJohn.Forte@Sun.COM 						(void) printf("%s  %s\n",
2747836SJohn.Forte@Sun.COM 						    getTextString(
2757836SJohn.Forte@Sun.COM 						    TEXT_LB_MPATH_SUPPORT),
2767836SJohn.Forte@Sun.COM 						    pluginProps.fileName);
2777836SJohn.Forte@Sun.COM 					} else {
278*10696SDavid.Hollister@Sun.COM 				/* begin back-up indentation */
279*10696SDavid.Hollister@Sun.COM 				/* LINTED E_SEC_PRINTF_VAR_FMT */
280*10696SDavid.Hollister@Sun.COM 				(void) fprintf(stderr, getTextString(
2817836SJohn.Forte@Sun.COM 				    ERR_CANT_FIND_MPATH_SUPPORT_WITH_NAME),
282*10696SDavid.Hollister@Sun.COM 				    operand[op]);
283*10696SDavid.Hollister@Sun.COM 				/* end back-up indentation */
2847836SJohn.Forte@Sun.COM 						(void) printf("\n");
2857836SJohn.Forte@Sun.COM 					}
2867836SJohn.Forte@Sun.COM 				}
2877836SJohn.Forte@Sun.COM 			}
2887836SJohn.Forte@Sun.COM 		}
2897836SJohn.Forte@Sun.COM 	}
2907836SJohn.Forte@Sun.COM 
2917836SJohn.Forte@Sun.COM 	return (mpstatus);
2927836SJohn.Forte@Sun.COM }
2937836SJohn.Forte@Sun.COM 
2947836SJohn.Forte@Sun.COM 
2957836SJohn.Forte@Sun.COM /*
2967836SJohn.Forte@Sun.COM  * ****************************************************************************
2977836SJohn.Forte@Sun.COM  *
2987836SJohn.Forte@Sun.COM  * showMpathSupport - mpathadm show mpath-support <mpath-support name>, ...
2997836SJohn.Forte@Sun.COM  *
3007836SJohn.Forte@Sun.COM  * operandLen	- number of operands user passed into the cli
3017836SJohn.Forte@Sun.COM  * operand	- pointer to operand list from user
3027836SJohn.Forte@Sun.COM  *
3037836SJohn.Forte@Sun.COM  * ****************************************************************************
3047836SJohn.Forte@Sun.COM  */
3057836SJohn.Forte@Sun.COM int
showMpathSupport(int operandLen,char * operand[])3067836SJohn.Forte@Sun.COM showMpathSupport(int operandLen, char *operand[])
3077836SJohn.Forte@Sun.COM {
3087836SJohn.Forte@Sun.COM 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
3097836SJohn.Forte@Sun.COM 	MP_PLUGIN_PROPERTIES			pluginProps;
3107836SJohn.Forte@Sun.COM 	MP_OID_LIST				*pPluginOidList;
3117836SJohn.Forte@Sun.COM 	MP_OID_LIST				*deviceOidListArray;
3127836SJohn.Forte@Sun.COM 	MP_DEVICE_PRODUCT_PROPERTIES		devProps;
3137836SJohn.Forte@Sun.COM 	boolean_t				bListIt = B_FALSE;
314*10696SDavid.Hollister@Sun.COM 	int					op, i, j;
3157836SJohn.Forte@Sun.COM 	MP_LOAD_BALANCE_TYPE 			lb;
3167836SJohn.Forte@Sun.COM 
3177836SJohn.Forte@Sun.COM 
3187836SJohn.Forte@Sun.COM 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList)) !=
3197836SJohn.Forte@Sun.COM 	    MP_STATUS_SUCCESS) {
3207836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s:  %s\n",
3217836SJohn.Forte@Sun.COM 		    cmdName, getTextString(ERR_NO_MPATH_SUPPORT_LIST));
3227836SJohn.Forte@Sun.COM 		return (mpstatus);
3237836SJohn.Forte@Sun.COM 	}
3247836SJohn.Forte@Sun.COM 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
3257836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s:  %s\n",
3267836SJohn.Forte@Sun.COM 		    cmdName, getTextString(ERR_NO_MPATH_SUPPORT_LIST));
3277836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
3287836SJohn.Forte@Sun.COM 	}
3297836SJohn.Forte@Sun.COM 
3307836SJohn.Forte@Sun.COM 	for (op = 0; op < operandLen; op++) {
331*10696SDavid.Hollister@Sun.COM 		bListIt = B_FALSE;
3327836SJohn.Forte@Sun.COM 
3337836SJohn.Forte@Sun.COM 		for (i = 0; i < pPluginOidList->oidCount; i++) {
3347836SJohn.Forte@Sun.COM 
3357836SJohn.Forte@Sun.COM 			(void) memset(&pluginProps, 0,
3367836SJohn.Forte@Sun.COM 			    sizeof (MP_PLUGIN_PROPERTIES));
3377836SJohn.Forte@Sun.COM 			mpstatus =
3387836SJohn.Forte@Sun.COM 			    MP_GetPluginProperties(pPluginOidList->oids[i],
3397836SJohn.Forte@Sun.COM 			    &pluginProps);
3407836SJohn.Forte@Sun.COM 			if (MP_STATUS_SUCCESS != mpstatus) {
3417836SJohn.Forte@Sun.COM 				(void) fprintf(stderr, "%s: %s\n",
3427836SJohn.Forte@Sun.COM 				    cmdName, getTextString(ERR_NO_PROPERTIES));
3437836SJohn.Forte@Sun.COM 				return (mpstatus);
3447836SJohn.Forte@Sun.COM 				}
3457836SJohn.Forte@Sun.COM 
3467836SJohn.Forte@Sun.COM 				if (0 == operandLen) {
3477836SJohn.Forte@Sun.COM 					/* if no operand, list it */
3487836SJohn.Forte@Sun.COM 					bListIt = B_TRUE;
3497836SJohn.Forte@Sun.COM 				} else {
3507836SJohn.Forte@Sun.COM 					/* ... compare and display if match */
3517836SJohn.Forte@Sun.COM 					if (0 ==
3527836SJohn.Forte@Sun.COM 					    strcmp(operand[op],
3537836SJohn.Forte@Sun.COM 					    pluginProps.fileName)) {
3547836SJohn.Forte@Sun.COM 						bListIt = B_TRUE;
3557836SJohn.Forte@Sun.COM 				}
3567836SJohn.Forte@Sun.COM 			}
3577836SJohn.Forte@Sun.COM 
3587836SJohn.Forte@Sun.COM 			if (B_TRUE != bListIt) {
3597836SJohn.Forte@Sun.COM 				break;
3607836SJohn.Forte@Sun.COM 			}
3617836SJohn.Forte@Sun.COM 
3627836SJohn.Forte@Sun.COM 			(void) printf("%s  %s\n",
3637836SJohn.Forte@Sun.COM 			    getTextString(TEXT_LB_MPATH_SUPPORT),
3647836SJohn.Forte@Sun.COM 			    pluginProps.fileName);
3657836SJohn.Forte@Sun.COM 
3667836SJohn.Forte@Sun.COM 			/* display the info for this plugin */
3677836SJohn.Forte@Sun.COM 			(void) printf("\t%s  ", getTextString(TEXT_LB_VENDOR));
3687836SJohn.Forte@Sun.COM 			displayWideArray(pluginProps.vendor,
3697836SJohn.Forte@Sun.COM 			    sizeof (pluginProps.vendor));
3707836SJohn.Forte@Sun.COM 			(void) printf("\n\t%s  ",
3717836SJohn.Forte@Sun.COM 			    getTextString(TEXT_LB_DRIVER_NAME));
3727836SJohn.Forte@Sun.COM 			displayArray(pluginProps.driverName,
3737836SJohn.Forte@Sun.COM 			    sizeof (pluginProps.driverName));
3747836SJohn.Forte@Sun.COM 			(void) printf("\n\t%s  ",
3757836SJohn.Forte@Sun.COM 			    getTextString(TEXT_LB_DEFAULT_LB));
3767836SJohn.Forte@Sun.COM 			/* don't ignore load balance type none. */
3777836SJohn.Forte@Sun.COM 			if (pluginProps.defaultloadBalanceType == 0) {
378*10696SDavid.Hollister@Sun.COM 				(void) printf("%s",
379*10696SDavid.Hollister@Sun.COM 				    getTextString(TEXT_LBTYPE_NONE));
3807836SJohn.Forte@Sun.COM 			} else {
381*10696SDavid.Hollister@Sun.COM 				displayLoadBalanceString(
382*10696SDavid.Hollister@Sun.COM 				    pluginProps.defaultloadBalanceType);
3837836SJohn.Forte@Sun.COM 			}
3847836SJohn.Forte@Sun.COM 			(void) printf("\n");
3857836SJohn.Forte@Sun.COM 
3867836SJohn.Forte@Sun.COM 
3877836SJohn.Forte@Sun.COM 			(void) printf("\t%s  \n",
3887836SJohn.Forte@Sun.COM 			    getTextString(TEXT_LB_SUPPORTED_LB));
3897836SJohn.Forte@Sun.COM 			/* check each bit, display string if found set */
3907836SJohn.Forte@Sun.COM 			if (pluginProps.supportedLoadBalanceTypes == 0) {
3917836SJohn.Forte@Sun.COM 				(void) printf("\t\t%s\n",
392*10696SDavid.Hollister@Sun.COM 				    getTextString(TEXT_LBTYPE_NONE));
3937836SJohn.Forte@Sun.COM 			} else {
394*10696SDavid.Hollister@Sun.COM 				lb = 1;
395*10696SDavid.Hollister@Sun.COM 				do {
396*10696SDavid.Hollister@Sun.COM 					if (0 != (lb & pluginProps.
397*10696SDavid.Hollister@Sun.COM 					    supportedLoadBalanceTypes)) {
398*10696SDavid.Hollister@Sun.COM 						(void) printf("\t\t");
399*10696SDavid.Hollister@Sun.COM 						displayLoadBalanceString(lb &
400*10696SDavid.Hollister@Sun.COM 						    pluginProps.
401*10696SDavid.Hollister@Sun.COM 						    supportedLoadBalanceTypes);
402*10696SDavid.Hollister@Sun.COM 						(void) printf("\n");
403*10696SDavid.Hollister@Sun.COM 					}
404*10696SDavid.Hollister@Sun.COM 					lb = lb<<1;
405*10696SDavid.Hollister@Sun.COM 				} while (lb < 0x80000000);
4067836SJohn.Forte@Sun.COM 			}
4077836SJohn.Forte@Sun.COM 
4087836SJohn.Forte@Sun.COM 			(void) printf("\t%s  %s\n",
4097836SJohn.Forte@Sun.COM 			    getTextString(TEXT_LB_ALLOWS_ACT_TPG),
4107836SJohn.Forte@Sun.COM 			    (MP_TRUE == pluginProps.canSetTPGAccess)?
4117836SJohn.Forte@Sun.COM 			    getTextString(TEXT_YES):getTextString(TEXT_NO));
4127836SJohn.Forte@Sun.COM 			(void) printf("\t%s  %s\n",
4137836SJohn.Forte@Sun.COM 			    getTextString(TEXT_LB_ALLOWS_PATH_OV),
4147836SJohn.Forte@Sun.COM 			    (MP_TRUE == pluginProps.canOverridePaths)?
4157836SJohn.Forte@Sun.COM 			    getTextString(TEXT_YES):getTextString(TEXT_NO));
4167836SJohn.Forte@Sun.COM 			(void) printf("\t%s  %d\n",
4177836SJohn.Forte@Sun.COM 			    getTextString(TEXT_LB_SUPP_AUTO_FB),
4187836SJohn.Forte@Sun.COM 			    pluginProps.autoFailbackSupport);
4197836SJohn.Forte@Sun.COM 			if ((MP_AUTOFAILBACK_SUPPORT_PLUGIN  ==
4207836SJohn.Forte@Sun.COM 			    pluginProps.autoFailbackSupport) |
4217836SJohn.Forte@Sun.COM 			    (MP_AUTOFAILBACK_SUPPORT_PLUGINANDMPLU
4227836SJohn.Forte@Sun.COM 			    == pluginProps.autoFailbackSupport)) {
4237836SJohn.Forte@Sun.COM 				(void) printf("\t%s  %s\n",
4247836SJohn.Forte@Sun.COM 				    getTextString(TEXT_LB_AUTO_FB),
4257836SJohn.Forte@Sun.COM 				    pluginProps.pluginAutoFailbackEnabled?\
4267836SJohn.Forte@Sun.COM 				    getTextString(TEXT_ON):
4277836SJohn.Forte@Sun.COM 				    getTextString(TEXT_OFF));
4287836SJohn.Forte@Sun.COM 				(void) printf("\t%s  %d/%d\n",
4297836SJohn.Forte@Sun.COM 				    getTextString(TEXT_LB_FB_POLLING_RATE),
4307836SJohn.Forte@Sun.COM 				    pluginProps.currentFailbackPollingRate,
4317836SJohn.Forte@Sun.COM 				    pluginProps.failbackPollingRateMax);
4327836SJohn.Forte@Sun.COM 			} else {
4337836SJohn.Forte@Sun.COM 				(void) printf("\t%s  %s\n",
4347836SJohn.Forte@Sun.COM 				    getTextString(TEXT_LB_AUTO_FB),
4357836SJohn.Forte@Sun.COM 				    getTextString(TEXT_NA));
4367836SJohn.Forte@Sun.COM 				(void) printf("\t%s  %s/%s\n",
4377836SJohn.Forte@Sun.COM 				    getTextString(TEXT_LB_FB_POLLING_RATE),
4387836SJohn.Forte@Sun.COM 				    getTextString(TEXT_NA),
4397836SJohn.Forte@Sun.COM 				    getTextString(TEXT_NA));
4407836SJohn.Forte@Sun.COM 			}
4417836SJohn.Forte@Sun.COM 			(void) printf("\t%s  %d\n",
4427836SJohn.Forte@Sun.COM 			    getTextString(TEXT_LB_SUPP_AUTO_P),
4437836SJohn.Forte@Sun.COM 			    pluginProps.autoProbingSupport);
4447836SJohn.Forte@Sun.COM 			if ((MP_AUTOPROBING_SUPPORT_PLUGIN  ==
4457836SJohn.Forte@Sun.COM 			    pluginProps.autoProbingSupport) |
4467836SJohn.Forte@Sun.COM 			    (MP_AUTOPROBING_SUPPORT_PLUGIN ==
4477836SJohn.Forte@Sun.COM 			    pluginProps.autoProbingSupport)) {
4487836SJohn.Forte@Sun.COM 				(void) printf("\t%s  %s\n",
4497836SJohn.Forte@Sun.COM 				    getTextString(TEXT_LB_AUTO_PROB),
4507836SJohn.Forte@Sun.COM 				    (MP_TRUE ==
4517836SJohn.Forte@Sun.COM 				    pluginProps.pluginAutoProbingEnabled)?\
4527836SJohn.Forte@Sun.COM 				    getTextString(TEXT_YES):
4537836SJohn.Forte@Sun.COM 				    getTextString(TEXT_NO));
4547836SJohn.Forte@Sun.COM 				(void) printf("\t%s  %d/%d\n",
4557836SJohn.Forte@Sun.COM 				    getTextString(TEXT_LB_PR_POLLING_RATE),
4567836SJohn.Forte@Sun.COM 				    pluginProps.currentProbingPollingRate,
4577836SJohn.Forte@Sun.COM 				    pluginProps.probingPollingRateMax);
4587836SJohn.Forte@Sun.COM 			} else {
4597836SJohn.Forte@Sun.COM 				(void) printf("\t%s  %s\n",
4607836SJohn.Forte@Sun.COM 				    getTextString(TEXT_LB_AUTO_PROB),
4617836SJohn.Forte@Sun.COM 				    getTextString(TEXT_NA));
4627836SJohn.Forte@Sun.COM 				(void) printf("\t%s  %s/%s\n",
4637836SJohn.Forte@Sun.COM 				    getTextString(TEXT_LB_PR_POLLING_RATE),
4647836SJohn.Forte@Sun.COM 				    getTextString(TEXT_NA),
4657836SJohn.Forte@Sun.COM 				    getTextString(TEXT_NA));
4667836SJohn.Forte@Sun.COM 			}
4677836SJohn.Forte@Sun.COM 
4687836SJohn.Forte@Sun.COM 
4697836SJohn.Forte@Sun.COM 			(void) printf("\t%s\n",
4707836SJohn.Forte@Sun.COM 			    getTextString(TEXT_LB_SUPP_DEVICES));
4717836SJohn.Forte@Sun.COM 
4727836SJohn.Forte@Sun.COM 
4737836SJohn.Forte@Sun.COM 			if (MP_TRUE !=
4747836SJohn.Forte@Sun.COM 			    pluginProps.onlySupportsSpecifiedProducts) {
4757836SJohn.Forte@Sun.COM 				/* LINTED E_SEC_PRINTF_VAR_FMT */
4767836SJohn.Forte@Sun.COM 				(void) printf(getTextString(TEXT_ANY_DEVICE));
4777836SJohn.Forte@Sun.COM 			} else {
4787836SJohn.Forte@Sun.COM 				/* if only supports specific products, */
4797836SJohn.Forte@Sun.COM 				/* get device product properties supported */
4807836SJohn.Forte@Sun.COM 
4817836SJohn.Forte@Sun.COM 				mpstatus = MP_GetDeviceProductOidList(\
4827836SJohn.Forte@Sun.COM 				    pPluginOidList->oids[i],
4837836SJohn.Forte@Sun.COM 				    &deviceOidListArray);
4847836SJohn.Forte@Sun.COM 				if (mpstatus != MP_STATUS_SUCCESS) {
4857836SJohn.Forte@Sun.COM 					(void) fprintf(stderr, "%s:  %s\n",
4867836SJohn.Forte@Sun.COM 					    cmdName, getTextString(
4877836SJohn.Forte@Sun.COM 					    ERR_NO_SUPP_DEVICE_INFO));
4887836SJohn.Forte@Sun.COM 					/* can't get any more info, */
4897836SJohn.Forte@Sun.COM 					/* so we're done with this one */
4907836SJohn.Forte@Sun.COM 					break;
4917836SJohn.Forte@Sun.COM 				}
4927836SJohn.Forte@Sun.COM 
4937836SJohn.Forte@Sun.COM 				for (j = 0; j < deviceOidListArray->oidCount;
4947836SJohn.Forte@Sun.COM 				    j++) {
495*10696SDavid.Hollister@Sun.COM 				/* begin backup indentation */
496*10696SDavid.Hollister@Sun.COM 				(void) memset(&devProps, 0,
497*10696SDavid.Hollister@Sun.COM 				    sizeof (MP_DEVICE_PRODUCT_PROPERTIES));
498*10696SDavid.Hollister@Sun.COM 				/* end backup indentation */
4997836SJohn.Forte@Sun.COM 					if ((mpstatus =
5007836SJohn.Forte@Sun.COM 					    MP_GetDeviceProductProperties(\
5017836SJohn.Forte@Sun.COM 					    deviceOidListArray->oids[j],
5027836SJohn.Forte@Sun.COM 					    &devProps)) == MP_STATUS_SUCCESS) {
5037836SJohn.Forte@Sun.COM 
5047836SJohn.Forte@Sun.COM 						(void) printf("\t\t%s  ",
5057836SJohn.Forte@Sun.COM 						    getTextString(
5067836SJohn.Forte@Sun.COM 						    TEXT_LB_VENDOR));
5077836SJohn.Forte@Sun.COM 						displayArray(devProps.vendor,
5087836SJohn.Forte@Sun.COM 						    sizeof (devProps.vendor));
5097836SJohn.Forte@Sun.COM 						(void) printf("\n\t\t%s  ",
5107836SJohn.Forte@Sun.COM 						    getTextString(
5117836SJohn.Forte@Sun.COM 						    TEXT_LB_PRODUCT));
5127836SJohn.Forte@Sun.COM 						displayArray(devProps.product,
5137836SJohn.Forte@Sun.COM 						    sizeof (devProps.product));
5147836SJohn.Forte@Sun.COM 						(void) printf("\n\t\t%s  ",
5157836SJohn.Forte@Sun.COM 						    getTextString(
5167836SJohn.Forte@Sun.COM 						    TEXT_LB_REVISION));
5177836SJohn.Forte@Sun.COM 						displayArray(devProps.revision,
5187836SJohn.Forte@Sun.COM 						    sizeof (devProps.revision));
5197836SJohn.Forte@Sun.COM 
5207836SJohn.Forte@Sun.COM 						(void) printf("\n\t\t%s\n",
5217836SJohn.Forte@Sun.COM 						    getTextString(
5227836SJohn.Forte@Sun.COM 						    TEXT_LB_SUPPORTED_LB));
523*10696SDavid.Hollister@Sun.COM 		/* begin back-up indentation */
524*10696SDavid.Hollister@Sun.COM 		if (devProps.supportedLoadBalanceTypes == 0) {
525*10696SDavid.Hollister@Sun.COM 			(void) printf("\t\t\t%s\n",
526*10696SDavid.Hollister@Sun.COM 			    getTextString(TEXT_LBTYPE_NONE));
527*10696SDavid.Hollister@Sun.COM 		} else {
528*10696SDavid.Hollister@Sun.COM 			lb = 1;
529*10696SDavid.Hollister@Sun.COM 			do {
5307836SJohn.Forte@Sun.COM 				if (0 != (lb &
5317836SJohn.Forte@Sun.COM 				    devProps.supportedLoadBalanceTypes)) {
5327836SJohn.Forte@Sun.COM 					(void) printf("\t\t\t");
5337836SJohn.Forte@Sun.COM 					displayLoadBalanceString(lb &
534*10696SDavid.Hollister@Sun.COM 					    devProps.supportedLoadBalanceTypes);
5357836SJohn.Forte@Sun.COM 					(void) printf("\n");
5367836SJohn.Forte@Sun.COM 				}
5377836SJohn.Forte@Sun.COM 				lb = lb<<1;
538*10696SDavid.Hollister@Sun.COM 			} while (lb < 0x80000000);
539*10696SDavid.Hollister@Sun.COM 		}
540*10696SDavid.Hollister@Sun.COM 		/* end back-up indentation */
5417836SJohn.Forte@Sun.COM 						(void) printf("\n");
5427836SJohn.Forte@Sun.COM 
5437836SJohn.Forte@Sun.COM 					} else {
5447836SJohn.Forte@Sun.COM 						(void) fprintf(stderr,
5457836SJohn.Forte@Sun.COM 						    "%s:  %s\n", cmdName,
5467836SJohn.Forte@Sun.COM 						    getTextString(
5477836SJohn.Forte@Sun.COM 						    ERR_NO_SUPP_DEVICE_INFO));
5487836SJohn.Forte@Sun.COM 					}
5497836SJohn.Forte@Sun.COM 				} /* for j */
5507836SJohn.Forte@Sun.COM 			} /* if only supports specified devices */
5517836SJohn.Forte@Sun.COM 
5527836SJohn.Forte@Sun.COM 		} /* for each plugin */
5537836SJohn.Forte@Sun.COM 
5547836SJohn.Forte@Sun.COM 		if (B_FALSE == bListIt) {
5557836SJohn.Forte@Sun.COM 			/* LINTED E_SEC_PRINTF_VAR_FMT */
5567836SJohn.Forte@Sun.COM 			(void) fprintf(stderr, getTextString(
5577836SJohn.Forte@Sun.COM 			    ERR_CANT_FIND_MPATH_SUPPORT_WITH_NAME),
5587836SJohn.Forte@Sun.COM 			    operand[op]);
5597836SJohn.Forte@Sun.COM 			(void) printf("\n");
5607836SJohn.Forte@Sun.COM 
5617836SJohn.Forte@Sun.COM 		}
5627836SJohn.Forte@Sun.COM 
5637836SJohn.Forte@Sun.COM 	} /* for each operand */
5647836SJohn.Forte@Sun.COM 
5657836SJohn.Forte@Sun.COM 
5667836SJohn.Forte@Sun.COM 	return (mpstatus);
5677836SJohn.Forte@Sun.COM }
5687836SJohn.Forte@Sun.COM 
5697836SJohn.Forte@Sun.COM 
5707836SJohn.Forte@Sun.COM /*
5717836SJohn.Forte@Sun.COM  * ****************************************************************************
5727836SJohn.Forte@Sun.COM  *
5737836SJohn.Forte@Sun.COM  * modifyMpathSupport -
5747836SJohn.Forte@Sun.COM  * 	mpathadm modify mpath-support [options] <mpath-support name>, ...
5757836SJohn.Forte@Sun.COM  *
5767836SJohn.Forte@Sun.COM  * operandLen	- number of operands user passed into the cli
5777836SJohn.Forte@Sun.COM  * operand	- pointer to operand list from user
5787836SJohn.Forte@Sun.COM  * options	- pointer to option list from user
5797836SJohn.Forte@Sun.COM  *
5807836SJohn.Forte@Sun.COM  * ****************************************************************************
5817836SJohn.Forte@Sun.COM  */
5827836SJohn.Forte@Sun.COM int
modifyMpathSupport(int operandLen,char * operand[],cmdOptions_t * options)5837836SJohn.Forte@Sun.COM modifyMpathSupport(int operandLen, char *operand[], cmdOptions_t *options)
5847836SJohn.Forte@Sun.COM {
585*10696SDavid.Hollister@Sun.COM 	MP_STATUS		mpstatus = MP_STATUS_SUCCESS;
586*10696SDavid.Hollister@Sun.COM 	MP_PLUGIN_PROPERTIES	pluginProps;
587*10696SDavid.Hollister@Sun.COM 	MP_OID_LIST		*pPluginOidList;
588*10696SDavid.Hollister@Sun.COM 	boolean_t		bFoundIt = B_FALSE;
589*10696SDavid.Hollister@Sun.COM 	MP_OID			pluginOid;
590*10696SDavid.Hollister@Sun.COM 	cmdOptions_t 		*optionList = options;
591*10696SDavid.Hollister@Sun.COM 	char			*cmdStr = getTextString(TEXT_UNKNOWN);
592*10696SDavid.Hollister@Sun.COM 	int			op, i, lbValue;
5937836SJohn.Forte@Sun.COM 
5947836SJohn.Forte@Sun.COM 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
5957836SJohn.Forte@Sun.COM 	    != MP_STATUS_SUCCESS) {
5967836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s: %s\n", cmdName,
5977836SJohn.Forte@Sun.COM 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
5987836SJohn.Forte@Sun.COM 		return (mpstatus);
5997836SJohn.Forte@Sun.COM 	}
6007836SJohn.Forte@Sun.COM 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
6017836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s: %s\n", cmdName,
6027836SJohn.Forte@Sun.COM 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
6037836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
6047836SJohn.Forte@Sun.COM 	}
6057836SJohn.Forte@Sun.COM 
6067836SJohn.Forte@Sun.COM 	for (op = 0; op < operandLen; op++) {
6077836SJohn.Forte@Sun.COM 		bFoundIt = B_FALSE;
6087836SJohn.Forte@Sun.COM 		for (i = 0;
6097836SJohn.Forte@Sun.COM 		    (i < pPluginOidList->oidCount) && (B_TRUE != bFoundIt);
6107836SJohn.Forte@Sun.COM 		    i++) {
6117836SJohn.Forte@Sun.COM 
6127836SJohn.Forte@Sun.COM 			(void) memset(&pluginProps, 0,
6137836SJohn.Forte@Sun.COM 			    sizeof (MP_PLUGIN_PROPERTIES));
6147836SJohn.Forte@Sun.COM 			if ((mpstatus =
6157836SJohn.Forte@Sun.COM 			    MP_GetPluginProperties(pPluginOidList->oids[i],
6167836SJohn.Forte@Sun.COM 			    &pluginProps)) == MP_STATUS_SUCCESS) {
6177836SJohn.Forte@Sun.COM 
6187836SJohn.Forte@Sun.COM 				if (0 == strcmp(operand[op],
6197836SJohn.Forte@Sun.COM 				    pluginProps.fileName)) {
6207836SJohn.Forte@Sun.COM 					bFoundIt = B_TRUE;
6217836SJohn.Forte@Sun.COM 					pluginOid = pPluginOidList->oids[i];
6227836SJohn.Forte@Sun.COM 				}
6237836SJohn.Forte@Sun.COM 			} else {
6247836SJohn.Forte@Sun.COM 				(void) fprintf(stderr, "%s:  %s\n",
6257836SJohn.Forte@Sun.COM 				    cmdName, getTextString(ERR_NO_PROPERTIES));
6267836SJohn.Forte@Sun.COM 			}
6277836SJohn.Forte@Sun.COM 
6287836SJohn.Forte@Sun.COM 			if (B_FALSE == bFoundIt) {
6297836SJohn.Forte@Sun.COM 				break;
6307836SJohn.Forte@Sun.COM 			}
6317836SJohn.Forte@Sun.COM 
6327836SJohn.Forte@Sun.COM /* begin back-up indentation */
6337836SJohn.Forte@Sun.COM 	/* we found the plugin oid */
6347836SJohn.Forte@Sun.COM 	/* now change the options requested */
6357836SJohn.Forte@Sun.COM 	switch (optionList->optval) {
6367836SJohn.Forte@Sun.COM 		case 'a':
6377836SJohn.Forte@Sun.COM 			/* modify autofailback */
6387836SJohn.Forte@Sun.COM 			cmdStr = getTextString(TEXT_AUTO_FAILBACK);
6397836SJohn.Forte@Sun.COM 			if (0 == strcasecmp(optionList->optarg,
6407836SJohn.Forte@Sun.COM 			    getTextString(TEXT_ON))) {
6417836SJohn.Forte@Sun.COM 				mpstatus =
6427836SJohn.Forte@Sun.COM 				    MP_EnableAutoFailback(pluginOid);
6437836SJohn.Forte@Sun.COM 			} else if (0 ==
644*10696SDavid.Hollister@Sun.COM 			    strcasecmp(optionList->optarg,
645*10696SDavid.Hollister@Sun.COM 			    getTextString(TEXT_OFF))) {
6467836SJohn.Forte@Sun.COM 				mpstatus =
6477836SJohn.Forte@Sun.COM 				    MP_DisableAutoFailback(pluginOid);
6487836SJohn.Forte@Sun.COM 			} else {
6497836SJohn.Forte@Sun.COM 				/* LINTED E_SEC_PRINTF_VAR_FMT */
6507836SJohn.Forte@Sun.COM 				(void) fprintf(stderr, getTextString(
6517836SJohn.Forte@Sun.COM 				    ERR_FAILED_TO_CHANGE_OPTION_WITH_REASON),
6527836SJohn.Forte@Sun.COM 				    cmdStr,
6537836SJohn.Forte@Sun.COM 				    getTextString(TEXT_ILLEGAL_ARGUMENT));
6547836SJohn.Forte@Sun.COM 				(void) printf("\n");
6557836SJohn.Forte@Sun.COM 				return (ERROR_CLI_FAILED);
6567836SJohn.Forte@Sun.COM 			}
6577836SJohn.Forte@Sun.COM 			break;
6587836SJohn.Forte@Sun.COM 		case 'p':
6597836SJohn.Forte@Sun.COM 			/* modify autoprobing */
6607836SJohn.Forte@Sun.COM 			cmdStr = getTextString(TEXT_AUTO_PROBING);
6617836SJohn.Forte@Sun.COM 			if (0 == strcasecmp(optionList->optarg,
6627836SJohn.Forte@Sun.COM 			    getTextString(TEXT_ON))) {
6637836SJohn.Forte@Sun.COM 				mpstatus =
6647836SJohn.Forte@Sun.COM 				    MP_EnableAutoProbing(pluginOid);
6657836SJohn.Forte@Sun.COM 			} else if (0 ==
666*10696SDavid.Hollister@Sun.COM 			    strcasecmp(optionList->optarg,
667*10696SDavid.Hollister@Sun.COM 			    getTextString(TEXT_OFF))) {
6687836SJohn.Forte@Sun.COM 				mpstatus =
6697836SJohn.Forte@Sun.COM 				    MP_DisableAutoProbing(pluginOid);
6707836SJohn.Forte@Sun.COM 			} else {
6717836SJohn.Forte@Sun.COM 				/* LINTED E_SEC_PRINTF_VAR_FMT */
6727836SJohn.Forte@Sun.COM 				(void) fprintf(stderr, getTextString(
6737836SJohn.Forte@Sun.COM 				    ERR_FAILED_TO_CHANGE_OPTION_WITH_REASON),
6747836SJohn.Forte@Sun.COM 				    cmdStr,
6757836SJohn.Forte@Sun.COM 				    getTextString(TEXT_ILLEGAL_ARGUMENT));
6767836SJohn.Forte@Sun.COM 				(void) printf("\n");
6777836SJohn.Forte@Sun.COM 				return (ERROR_CLI_FAILED);
6787836SJohn.Forte@Sun.COM 			}
6797836SJohn.Forte@Sun.COM 			break;
6807836SJohn.Forte@Sun.COM 		case 'b':
6817836SJohn.Forte@Sun.COM 			/* modify loadbalance type */
6827836SJohn.Forte@Sun.COM 			cmdStr = getTextString(TEXT_LOAD_BALANCE);
6837836SJohn.Forte@Sun.COM 			/* user of the cli sends text string, we need the int */
6847836SJohn.Forte@Sun.COM 			/* value to pass to the mpapi */
6857836SJohn.Forte@Sun.COM 			lbValue = getLbValueFromString(optionList->optarg);
6867836SJohn.Forte@Sun.COM 			mpstatus =
6877836SJohn.Forte@Sun.COM 			    MP_SetPluginLoadBalanceType(pluginOid,
6887836SJohn.Forte@Sun.COM 			    lbValue);
6897836SJohn.Forte@Sun.COM 			break;
6907836SJohn.Forte@Sun.COM 
6917836SJohn.Forte@Sun.COM 		} /* switch */
6927836SJohn.Forte@Sun.COM 		if (MP_STATUS_SUCCESS != mpstatus) {
6937836SJohn.Forte@Sun.COM 			/* LINTED E_SEC_PRINTF_VAR_FMT */
6947836SJohn.Forte@Sun.COM 			(void) fprintf(stderr,
6957836SJohn.Forte@Sun.COM 			    getTextString(
6967836SJohn.Forte@Sun.COM 			    ERR_FAILED_TO_CHANGE_OPTION_WITH_REASON),
6977836SJohn.Forte@Sun.COM 			    cmdStr, getMpStatusStr(mpstatus));
6987836SJohn.Forte@Sun.COM 			(void) printf("\n");
6997836SJohn.Forte@Sun.COM 			return (mpstatus);
7007836SJohn.Forte@Sun.COM 		}
7017836SJohn.Forte@Sun.COM /* end back-up indentation */
7027836SJohn.Forte@Sun.COM 
7037836SJohn.Forte@Sun.COM 		} /* for each plugin */
7047836SJohn.Forte@Sun.COM 
7057836SJohn.Forte@Sun.COM 		if (B_FALSE == bFoundIt) {
7067836SJohn.Forte@Sun.COM 			/* LINTED E_SEC_PRINTF_VAR_FMT */
7077836SJohn.Forte@Sun.COM 			(void) fprintf(stderr,
7087836SJohn.Forte@Sun.COM 			    getTextString(
7097836SJohn.Forte@Sun.COM 			    ERR_FAILED_TO_CHANGE_OPTION_WITH_REASON),
7107836SJohn.Forte@Sun.COM 			    cmdStr,
7117836SJohn.Forte@Sun.COM 			    getTextString(TEXT_MPATH_SUPPORT_NOT_FOUND));
7127836SJohn.Forte@Sun.COM 			(void) printf("\n");
7137836SJohn.Forte@Sun.COM 			return (ERROR_CLI_FAILED);
7147836SJohn.Forte@Sun.COM 		}
7157836SJohn.Forte@Sun.COM 
7167836SJohn.Forte@Sun.COM 	} /* for each operand */
7177836SJohn.Forte@Sun.COM 
7187836SJohn.Forte@Sun.COM 	return (mpstatus);
7197836SJohn.Forte@Sun.COM }
7207836SJohn.Forte@Sun.COM 
7217836SJohn.Forte@Sun.COM 
7227836SJohn.Forte@Sun.COM /*
7237836SJohn.Forte@Sun.COM  * ****************************************************************************
7247836SJohn.Forte@Sun.COM  *
7257836SJohn.Forte@Sun.COM  * listLogicalUnit -
7267836SJohn.Forte@Sun.COM  * 	mpathadm list {logical-unit | LU} [options] [<logical-unit name>, ...]
7277836SJohn.Forte@Sun.COM  *
7287836SJohn.Forte@Sun.COM  * operandLen	- number of operands user passed into the cli
7297836SJohn.Forte@Sun.COM  * operand	- pointer to operand list from user
7307836SJohn.Forte@Sun.COM  * options	- pointer to option list from user
7317836SJohn.Forte@Sun.COM  *
7327836SJohn.Forte@Sun.COM  * ****************************************************************************
7337836SJohn.Forte@Sun.COM  */
7347836SJohn.Forte@Sun.COM int
listLogicalUnit(int operandLen,char * operand[],cmdOptions_t * options)7357836SJohn.Forte@Sun.COM listLogicalUnit(int operandLen, char *operand[], cmdOptions_t *options)
7367836SJohn.Forte@Sun.COM {
737*10696SDavid.Hollister@Sun.COM 	MP_STATUS mpstatus = MP_STATUS_SUCCESS;
738*10696SDavid.Hollister@Sun.COM 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES luProps;
739*10696SDavid.Hollister@Sun.COM 	MP_PLUGIN_PROPERTIES pluginProps;
740*10696SDavid.Hollister@Sun.COM 	MP_TARGET_PORT_PROPERTIES tportProps;
741*10696SDavid.Hollister@Sun.COM 	MP_OID_LIST *pPluginOidList, *pLogicalUnitOidList,
742*10696SDavid.Hollister@Sun.COM 	    *pTpgOidListArray, *pTportOidListArray;
743*10696SDavid.Hollister@Sun.COM 	boolean_t bListIt = B_FALSE, bFoundOperand = B_FALSE,
744*10696SDavid.Hollister@Sun.COM 	    *bFoundOption, bContinue = B_FALSE;
745*10696SDavid.Hollister@Sun.COM 	MP_OID luOid;
746*10696SDavid.Hollister@Sun.COM 	cmdOptions_t *optionList = options;
747*10696SDavid.Hollister@Sun.COM 	int opListCount = 0, i = 0, lu = 0, tpg = 0, opoffset = 0, j = 0,
748*10696SDavid.Hollister@Sun.COM 	    opStart = 0, opEnd = 0, opIndex;
7497836SJohn.Forte@Sun.COM 
7507836SJohn.Forte@Sun.COM 	/* count number of options */
7517836SJohn.Forte@Sun.COM 	for (; optionList->optval; optionList++) {
7527836SJohn.Forte@Sun.COM 		opListCount++;
7537836SJohn.Forte@Sun.COM 	}
7547836SJohn.Forte@Sun.COM 
7557836SJohn.Forte@Sun.COM 	bFoundOption = malloc((sizeof (boolean_t)) * opListCount);
7567836SJohn.Forte@Sun.COM 	if (NULL == bFoundOption) {
7577836SJohn.Forte@Sun.COM 		(void) fprintf(stdout, "%s\n",
7587836SJohn.Forte@Sun.COM 		    getTextString(ERR_MEMORY_ALLOCATION));
7597836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
7607836SJohn.Forte@Sun.COM 	}
7617836SJohn.Forte@Sun.COM 
7627836SJohn.Forte@Sun.COM 	/* list to keep track of multiple options */
7637836SJohn.Forte@Sun.COM 	optionList = options;
7647836SJohn.Forte@Sun.COM 	for (opIndex = 0; opIndex < opListCount; opIndex++) {
7657836SJohn.Forte@Sun.COM 		bFoundOption[opIndex] = B_FALSE;
7667836SJohn.Forte@Sun.COM 	}
7677836SJohn.Forte@Sun.COM 
7687836SJohn.Forte@Sun.COM 	optionList = options;
7697836SJohn.Forte@Sun.COM 
7707836SJohn.Forte@Sun.COM 	/* if no operands or options, list everything we find */
7717836SJohn.Forte@Sun.COM 	if ((0 == operandLen) && (0 == opListCount)) {
7727836SJohn.Forte@Sun.COM 		if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
7737836SJohn.Forte@Sun.COM 		    != MP_STATUS_SUCCESS) {
7747836SJohn.Forte@Sun.COM 			(void) fprintf(stderr, "%s: %s\n", cmdName,
7757836SJohn.Forte@Sun.COM 			    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
7767836SJohn.Forte@Sun.COM 			return (mpstatus);
7777836SJohn.Forte@Sun.COM 		}
7787836SJohn.Forte@Sun.COM 		if ((NULL == pPluginOidList) ||
7797836SJohn.Forte@Sun.COM 		    (pPluginOidList->oidCount < 1)) {
7807836SJohn.Forte@Sun.COM 			(void) fprintf(stderr, "%s: %s\n", cmdName,
7817836SJohn.Forte@Sun.COM 			    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
7827836SJohn.Forte@Sun.COM 			return (ERROR_CLI_FAILED);
7837836SJohn.Forte@Sun.COM 		}
7847836SJohn.Forte@Sun.COM 
7857836SJohn.Forte@Sun.COM 		for (i = 0; i < pPluginOidList->oidCount; i++) {
7867836SJohn.Forte@Sun.COM 			/* get properties so we can list the name */
7877836SJohn.Forte@Sun.COM 			(void) memset(&pluginProps, 0,
7887836SJohn.Forte@Sun.COM 			    sizeof (MP_PLUGIN_PROPERTIES));
7897836SJohn.Forte@Sun.COM 			if ((mpstatus =
7907836SJohn.Forte@Sun.COM 			    MP_GetPluginProperties(pPluginOidList->oids[i],
7917836SJohn.Forte@Sun.COM 			    &pluginProps)) != MP_STATUS_SUCCESS) {
7927836SJohn.Forte@Sun.COM 				(void) fprintf(stderr, "%s:  %s\n",
7937836SJohn.Forte@Sun.COM 				    cmdName, getTextString(ERR_NO_PROPERTIES));
7947836SJohn.Forte@Sun.COM 				return (mpstatus);
7957836SJohn.Forte@Sun.COM 			}
7967836SJohn.Forte@Sun.COM 
7977836SJohn.Forte@Sun.COM 			/* attempt to find this logical unit */
7987836SJohn.Forte@Sun.COM 			mpstatus = MP_GetMultipathLus(pPluginOidList->oids[i],
7997836SJohn.Forte@Sun.COM 			    &pLogicalUnitOidList);
8007836SJohn.Forte@Sun.COM 			if (mpstatus != MP_STATUS_SUCCESS) {
8017836SJohn.Forte@Sun.COM 				(void) fprintf(stderr, "%s:  %s\n",
8027836SJohn.Forte@Sun.COM 				    cmdName, getTextString(ERR_NO_LU_LIST));
8037836SJohn.Forte@Sun.COM 				return (mpstatus);
8047836SJohn.Forte@Sun.COM 			}
8057836SJohn.Forte@Sun.COM 
8067836SJohn.Forte@Sun.COM 			for (lu = 0; lu < pLogicalUnitOidList->oidCount; lu++) {
807*10696SDavid.Hollister@Sun.COM 			/* begin backup indentation */
808*10696SDavid.Hollister@Sun.COM 			/* get lu properties so we can check the name */
809*10696SDavid.Hollister@Sun.COM 			(void) memset(&luProps, 0,
810*10696SDavid.Hollister@Sun.COM 			    sizeof (MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES));
811*10696SDavid.Hollister@Sun.COM 			/* end backup indentation */
8127836SJohn.Forte@Sun.COM 				mpstatus =
8137836SJohn.Forte@Sun.COM 				    MP_GetMPLogicalUnitProperties(
8147836SJohn.Forte@Sun.COM 				    pLogicalUnitOidList->oids[lu],
8157836SJohn.Forte@Sun.COM 				    &luProps);
8167836SJohn.Forte@Sun.COM 				if (mpstatus != MP_STATUS_SUCCESS) {
8177836SJohn.Forte@Sun.COM 					(void) fprintf(stderr, "%s:  %s\n",
8187836SJohn.Forte@Sun.COM 					    cmdName,
8197836SJohn.Forte@Sun.COM 					    getTextString(ERR_NO_PROPERTIES));
8207836SJohn.Forte@Sun.COM 					return (mpstatus);
8217836SJohn.Forte@Sun.COM 				}
8227836SJohn.Forte@Sun.COM 
8237836SJohn.Forte@Sun.COM 				luOid = pLogicalUnitOidList->oids[lu];
8247836SJohn.Forte@Sun.COM 				if (listIndividualLogicalUnit(luOid, luProps)
8257836SJohn.Forte@Sun.COM 				    != 0) {
8267836SJohn.Forte@Sun.COM 					return (ERROR_CLI_FAILED);
8277836SJohn.Forte@Sun.COM 				}
8287836SJohn.Forte@Sun.COM 			} /* for each LU */
8297836SJohn.Forte@Sun.COM 		} /* for each plugin */
8307836SJohn.Forte@Sun.COM 	} else { /* we have operands and/or options */
8317836SJohn.Forte@Sun.COM 
8327836SJohn.Forte@Sun.COM 		/* check if we have operands */
8337836SJohn.Forte@Sun.COM 		if (0 == operandLen) {
8347836SJohn.Forte@Sun.COM 			/* no operands */
8357836SJohn.Forte@Sun.COM 			opStart = -1;
8367836SJohn.Forte@Sun.COM 			opEnd = 0;
8377836SJohn.Forte@Sun.COM 		} else {
8387836SJohn.Forte@Sun.COM 			/* operands */
8397836SJohn.Forte@Sun.COM 			opStart = 0;
8407836SJohn.Forte@Sun.COM 			opEnd = operandLen;
8417836SJohn.Forte@Sun.COM 		}
8427836SJohn.Forte@Sun.COM 
8437836SJohn.Forte@Sun.COM 		if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
8447836SJohn.Forte@Sun.COM 		    != MP_STATUS_SUCCESS) {
8457836SJohn.Forte@Sun.COM 			(void) fprintf(stderr, "%s: %s\n", cmdName,
8467836SJohn.Forte@Sun.COM 			    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
8477836SJohn.Forte@Sun.COM 			return (mpstatus);
8487836SJohn.Forte@Sun.COM 		}
8497836SJohn.Forte@Sun.COM 		if ((NULL == pPluginOidList) ||
8507836SJohn.Forte@Sun.COM 		    (pPluginOidList->oidCount < 1)) {
8517836SJohn.Forte@Sun.COM 			(void) fprintf(stderr, "%s: %s\n", cmdName,
8527836SJohn.Forte@Sun.COM 			    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
8537836SJohn.Forte@Sun.COM 			return (ERROR_CLI_FAILED);
8547836SJohn.Forte@Sun.COM 		}
8557836SJohn.Forte@Sun.COM 
8567836SJohn.Forte@Sun.COM 		for (opoffset = opStart; opoffset < opEnd; opoffset++) {
8577836SJohn.Forte@Sun.COM 			/* loop through operands */
8587836SJohn.Forte@Sun.COM 			bFoundOperand = B_FALSE;
8597836SJohn.Forte@Sun.COM 
8607836SJohn.Forte@Sun.COM 			for (i = 0; i < pPluginOidList->oidCount; i++) {
8617836SJohn.Forte@Sun.COM 
8627836SJohn.Forte@Sun.COM 				/*
8637836SJohn.Forte@Sun.COM 				 * loop through plugin, and get properties
8647836SJohn.Forte@Sun.COM 				 * so we can list the name
8657836SJohn.Forte@Sun.COM 				 */
8667836SJohn.Forte@Sun.COM 				(void) memset(&pluginProps, 0,
8677836SJohn.Forte@Sun.COM 				    sizeof (MP_PLUGIN_PROPERTIES));
8687836SJohn.Forte@Sun.COM 				if ((mpstatus =
8697836SJohn.Forte@Sun.COM 				    MP_GetPluginProperties(
8707836SJohn.Forte@Sun.COM 				    pPluginOidList->oids[i], &pluginProps))
8717836SJohn.Forte@Sun.COM 				    != MP_STATUS_SUCCESS) {
8727836SJohn.Forte@Sun.COM 					(void) fprintf(stderr, "%s:  %s\n",
8737836SJohn.Forte@Sun.COM 					    cmdName,
8747836SJohn.Forte@Sun.COM 					    getTextString(ERR_NO_PROPERTIES));
8757836SJohn.Forte@Sun.COM 					return (mpstatus);
8767836SJohn.Forte@Sun.COM 				}
8777836SJohn.Forte@Sun.COM 
8787836SJohn.Forte@Sun.COM 				/* attempt to find this logical unit */
8797836SJohn.Forte@Sun.COM 				mpstatus =
8807836SJohn.Forte@Sun.COM 				    MP_GetMultipathLus(pPluginOidList->oids[i],
8817836SJohn.Forte@Sun.COM 				    &pLogicalUnitOidList);
8827836SJohn.Forte@Sun.COM 				if (mpstatus != MP_STATUS_SUCCESS) {
8837836SJohn.Forte@Sun.COM 					(void) fprintf(stderr, "%s:  %s\n",
8847836SJohn.Forte@Sun.COM 					    cmdName,
8857836SJohn.Forte@Sun.COM 					    getTextString(ERR_NO_LU_LIST));
8867836SJohn.Forte@Sun.COM 					return (mpstatus);
8877836SJohn.Forte@Sun.COM 				}
8887836SJohn.Forte@Sun.COM 
8897836SJohn.Forte@Sun.COM 				for (lu = 0;
8907836SJohn.Forte@Sun.COM 				    (lu < pLogicalUnitOidList->oidCount);
8917836SJohn.Forte@Sun.COM 				    lu++) {
8927836SJohn.Forte@Sun.COM 					bListIt = B_FALSE;
893*10696SDavid.Hollister@Sun.COM 			/* begin backup indentation */
894*10696SDavid.Hollister@Sun.COM 			/* get lu props & check the name */
895*10696SDavid.Hollister@Sun.COM 			(void) memset(&luProps, 0,
896*10696SDavid.Hollister@Sun.COM 			    sizeof (MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES));
897*10696SDavid.Hollister@Sun.COM 			/* end backup indentation */
8987836SJohn.Forte@Sun.COM 					mpstatus =
8997836SJohn.Forte@Sun.COM 					    MP_GetMPLogicalUnitProperties(
9007836SJohn.Forte@Sun.COM 					    pLogicalUnitOidList->oids[lu],
9017836SJohn.Forte@Sun.COM 					    &luProps);
9027836SJohn.Forte@Sun.COM 					if (mpstatus != MP_STATUS_SUCCESS) {
9037836SJohn.Forte@Sun.COM 						(void) fprintf(stderr,
9047836SJohn.Forte@Sun.COM 						    "%s:  %s\n", cmdName,
9057836SJohn.Forte@Sun.COM 						    getTextString(
9067836SJohn.Forte@Sun.COM 						    ERR_NO_PROPERTIES));
9077836SJohn.Forte@Sun.COM 						return (mpstatus);
9087836SJohn.Forte@Sun.COM 					}
9097836SJohn.Forte@Sun.COM 
9107836SJohn.Forte@Sun.COM 					/*
9117836SJohn.Forte@Sun.COM 					 * compare operand - is it a match?
9127836SJohn.Forte@Sun.COM 					 * If so, continue
9137836SJohn.Forte@Sun.COM 					 */
9147836SJohn.Forte@Sun.COM 
9157836SJohn.Forte@Sun.COM 					bContinue = B_TRUE;
9167836SJohn.Forte@Sun.COM 					if (operandLen > 0) {
9177836SJohn.Forte@Sun.COM 						bContinue =
9187836SJohn.Forte@Sun.COM 						    compareLUName(
9197836SJohn.Forte@Sun.COM 						    operand[opoffset],
9207836SJohn.Forte@Sun.COM 						    luProps.deviceFileName);
9217836SJohn.Forte@Sun.COM 					}
9227836SJohn.Forte@Sun.COM 
9237836SJohn.Forte@Sun.COM 					if (B_TRUE == bContinue) {
9247836SJohn.Forte@Sun.COM 
9257836SJohn.Forte@Sun.COM 						if (0 != opListCount) {
9267836SJohn.Forte@Sun.COM 							/* check options */
9277836SJohn.Forte@Sun.COM 
9287836SJohn.Forte@Sun.COM 
9297836SJohn.Forte@Sun.COM /* begin backup indentation */
9307836SJohn.Forte@Sun.COM optionList = options;
9317836SJohn.Forte@Sun.COM 
9327836SJohn.Forte@Sun.COM for (opIndex = 0; optionList->optval; optionList++, opIndex++) {
9337836SJohn.Forte@Sun.COM switch (optionList->optval) {
9347836SJohn.Forte@Sun.COM 	case 'n':
9357836SJohn.Forte@Sun.COM 		if (B_TRUE ==
9367836SJohn.Forte@Sun.COM 		    compareLUName(optionList->optarg, luProps.name)) {
9377836SJohn.Forte@Sun.COM 			bListIt = B_TRUE;
9387836SJohn.Forte@Sun.COM 			bFoundOperand = B_TRUE;
9397836SJohn.Forte@Sun.COM 			bFoundOption[opIndex] = B_TRUE;
9407836SJohn.Forte@Sun.COM 		}
9417836SJohn.Forte@Sun.COM 		break;
9427836SJohn.Forte@Sun.COM 	case 't':
9437836SJohn.Forte@Sun.COM 		/* get TPG list */
9447836SJohn.Forte@Sun.COM 		mpstatus =
9457836SJohn.Forte@Sun.COM 		    MP_GetAssociatedTPGOidList(pLogicalUnitOidList->oids[lu],
9467836SJohn.Forte@Sun.COM 		    &pTpgOidListArray);
9477836SJohn.Forte@Sun.COM 		if (mpstatus !=  MP_STATUS_SUCCESS) {
9487836SJohn.Forte@Sun.COM 			(void) fprintf(stderr,  "%s:  %s\n", cmdName,
9497836SJohn.Forte@Sun.COM 			    getTextString(ERR_NO_ASSOC_TPGS));
9507836SJohn.Forte@Sun.COM 			return (mpstatus);
9517836SJohn.Forte@Sun.COM 		}
9527836SJohn.Forte@Sun.COM 
9537836SJohn.Forte@Sun.COM 		/* get target ports */
9547836SJohn.Forte@Sun.COM 		for (tpg = 0;
9557836SJohn.Forte@Sun.COM 		    (NULL != pTpgOidListArray) &&
9567836SJohn.Forte@Sun.COM 		    (tpg < pTpgOidListArray->oidCount) &&
9577836SJohn.Forte@Sun.COM 		    (B_FALSE == bListIt); tpg++) {
9587836SJohn.Forte@Sun.COM 			mpstatus =
9597836SJohn.Forte@Sun.COM 			    MP_GetTargetPortOidList(pTpgOidListArray->oids[tpg],
960*10696SDavid.Hollister@Sun.COM 			    &pTportOidListArray);
9617836SJohn.Forte@Sun.COM 			if (mpstatus != MP_STATUS_SUCCESS) {
9627836SJohn.Forte@Sun.COM 				(void) fprintf(stderr, "%s:  %s\n",
9637836SJohn.Forte@Sun.COM 				    cmdName,
9647836SJohn.Forte@Sun.COM 				    getTextString(ERR_NO_ASSOC_TPORTS));
9657836SJohn.Forte@Sun.COM 				return (mpstatus);
9667836SJohn.Forte@Sun.COM 			}
9677836SJohn.Forte@Sun.COM 
9687836SJohn.Forte@Sun.COM 			/* get target port properties for the name */
9697836SJohn.Forte@Sun.COM 			for (j = 0; (NULL != pTportOidListArray) &&
9707836SJohn.Forte@Sun.COM 			    (j < pTportOidListArray->oidCount) &&
9717836SJohn.Forte@Sun.COM 			    (B_FALSE == bListIt); j++) {
9727836SJohn.Forte@Sun.COM 				(void) memset(&tportProps, 0,
9737836SJohn.Forte@Sun.COM 				    sizeof (MP_TARGET_PORT_PROPERTIES));
9747836SJohn.Forte@Sun.COM 				mpstatus =
9757836SJohn.Forte@Sun.COM 				    MP_GetTargetPortProperties(
9767836SJohn.Forte@Sun.COM 				    pTportOidListArray->oids[j], &tportProps);
9777836SJohn.Forte@Sun.COM 				if (mpstatus != MP_STATUS_SUCCESS) {
9787836SJohn.Forte@Sun.COM 					(void) fprintf(stderr, "%s:  %s\n",
9797836SJohn.Forte@Sun.COM 					    cmdName,
9807836SJohn.Forte@Sun.COM 					    getTextString(ERR_NO_PROPERTIES));
9817836SJohn.Forte@Sun.COM 					return (mpstatus);
9827836SJohn.Forte@Sun.COM 				}
9837836SJohn.Forte@Sun.COM 
9847836SJohn.Forte@Sun.COM 
9857836SJohn.Forte@Sun.COM 				/* check the name */
9867836SJohn.Forte@Sun.COM 				if (0 == strcmp(optionList->optarg,
9877836SJohn.Forte@Sun.COM 				    tportProps.portID)) {
9887836SJohn.Forte@Sun.COM 					bListIt = B_TRUE;
9897836SJohn.Forte@Sun.COM 					bFoundOperand = B_TRUE;
9907836SJohn.Forte@Sun.COM 					bFoundOption[opIndex] = B_TRUE;
9917836SJohn.Forte@Sun.COM 				}
9927836SJohn.Forte@Sun.COM 			} /* for each target port */
9937836SJohn.Forte@Sun.COM 		} /* for each tpg */
9947836SJohn.Forte@Sun.COM 	} /* end switch */
9957836SJohn.Forte@Sun.COM } /* loop through options */
9967836SJohn.Forte@Sun.COM /* end back-up indentation */
9977836SJohn.Forte@Sun.COM 
9987836SJohn.Forte@Sun.COM 						} else {
9997836SJohn.Forte@Sun.COM 							/*
10007836SJohn.Forte@Sun.COM 							 * if no options,
10017836SJohn.Forte@Sun.COM 							 * listit
10027836SJohn.Forte@Sun.COM 							 */
10037836SJohn.Forte@Sun.COM 							bListIt = B_TRUE;
10047836SJohn.Forte@Sun.COM 							bFoundOperand = B_TRUE;
10057836SJohn.Forte@Sun.COM 						}
10067836SJohn.Forte@Sun.COM 					} /* end bContinue check */
10077836SJohn.Forte@Sun.COM 
10087836SJohn.Forte@Sun.COM 		if (bListIt) {
10097836SJohn.Forte@Sun.COM 			(void) printf("%s  %s\n",
10107836SJohn.Forte@Sun.COM 			    getTextString(TEXT_LB_MPATH_SUPPORT),
10117836SJohn.Forte@Sun.COM 			    pluginProps.fileName);
10127836SJohn.Forte@Sun.COM 			luOid = pLogicalUnitOidList->oids[lu];
10137836SJohn.Forte@Sun.COM 			if (listIndividualLogicalUnit(luOid, luProps)
10147836SJohn.Forte@Sun.COM 			    != 0) {
10157836SJohn.Forte@Sun.COM 				return (ERROR_CLI_FAILED);
10167836SJohn.Forte@Sun.COM 			}
10177836SJohn.Forte@Sun.COM 
10187836SJohn.Forte@Sun.COM 		}
10197836SJohn.Forte@Sun.COM 
10207836SJohn.Forte@Sun.COM 				} /* end LU loop */
10217836SJohn.Forte@Sun.COM 			} /* end plugin loop */
10227836SJohn.Forte@Sun.COM 			if ((0 == opListCount) && (0 != operandLen)) {
10237836SJohn.Forte@Sun.COM 				if (B_FALSE == bFoundOperand) {
10247836SJohn.Forte@Sun.COM 					/* option/operand combo not found */
10257836SJohn.Forte@Sun.COM 					/* LINTED E_SEC_PRINTF_VAR_FMT */
10267836SJohn.Forte@Sun.COM 					(void) fprintf(stderr,
10277836SJohn.Forte@Sun.COM 					    getTextString(
10287836SJohn.Forte@Sun.COM 				    ERR_LU_NOT_FOUND_WITH_MISSING_LU_STR),
10297836SJohn.Forte@Sun.COM 					    operand[opoffset]);
10307836SJohn.Forte@Sun.COM 					(void) fprintf(stderr, "\n");
10317836SJohn.Forte@Sun.COM 				}
10327836SJohn.Forte@Sun.COM 			}
10337836SJohn.Forte@Sun.COM 
10347836SJohn.Forte@Sun.COM 			optionList = options;
10357836SJohn.Forte@Sun.COM 			for (opIndex = 0; optionList->optval; optionList++,
10367836SJohn.Forte@Sun.COM 			    opIndex++) {
10377836SJohn.Forte@Sun.COM 				if (B_FALSE == bFoundOption[opIndex]) {
10387836SJohn.Forte@Sun.COM 					/* LINTED E_SEC_PRINTF_VAR_FMT */
10397836SJohn.Forte@Sun.COM 					(void) fprintf(stderr,
10407836SJohn.Forte@Sun.COM 					    getTextString(
10417836SJohn.Forte@Sun.COM 				    ERR_LU_NOT_FOUND_WITH_MISSING_LU_STR),
10427836SJohn.Forte@Sun.COM 					    optionList->optarg);
10437836SJohn.Forte@Sun.COM 					(void) fprintf(stderr, "\n");
10447836SJohn.Forte@Sun.COM 				}
10457836SJohn.Forte@Sun.COM 			}
10467836SJohn.Forte@Sun.COM 
10477836SJohn.Forte@Sun.COM 
10487836SJohn.Forte@Sun.COM 
10497836SJohn.Forte@Sun.COM 		} /* end loop through operands */
10507836SJohn.Forte@Sun.COM 	} /* we have operands and/or options */
10517836SJohn.Forte@Sun.COM 
10527836SJohn.Forte@Sun.COM 
10537836SJohn.Forte@Sun.COM 	return (mpstatus);
10547836SJohn.Forte@Sun.COM }
10557836SJohn.Forte@Sun.COM 
10567836SJohn.Forte@Sun.COM 
10577836SJohn.Forte@Sun.COM /*
10587836SJohn.Forte@Sun.COM  * ****************************************************************************
10597836SJohn.Forte@Sun.COM  *
10607836SJohn.Forte@Sun.COM  * compareLUName -
10617836SJohn.Forte@Sun.COM  * 	compare names directly and via devid if no match directly
10627836SJohn.Forte@Sun.COM  *
10637836SJohn.Forte@Sun.COM  * cmpString		- first string to compare
10647836SJohn.Forte@Sun.COM  * deviceProperty	- string from properties
10657836SJohn.Forte@Sun.COM  * sizeToCompare	- size of deviceProperty
10667836SJohn.Forte@Sun.COM  *
10677836SJohn.Forte@Sun.COM  * returns 	B_TRUE if the strings match either directly or via devid
10687836SJohn.Forte@Sun.COM  *		B_FALSE otherwise
10697836SJohn.Forte@Sun.COM  *
10707836SJohn.Forte@Sun.COM  * ****************************************************************************
10717836SJohn.Forte@Sun.COM  */
10727836SJohn.Forte@Sun.COM boolean_t
compareLUName(MP_CHAR * cmpString,MP_CHAR * deviceProperty)10737836SJohn.Forte@Sun.COM compareLUName(MP_CHAR *cmpString, MP_CHAR *deviceProperty)
10747836SJohn.Forte@Sun.COM {
10757836SJohn.Forte@Sun.COM 
10767836SJohn.Forte@Sun.COM 	boolean_t				isSame = B_FALSE;
10777836SJohn.Forte@Sun.COM 	int 					fd1, fd2;
10787836SJohn.Forte@Sun.COM 	ddi_devid_t				devid1 = NULL, devid2 = NULL;
10797836SJohn.Forte@Sun.COM 
10807836SJohn.Forte@Sun.COM 	if (0 == strcmp(cmpString, deviceProperty)) {
10817836SJohn.Forte@Sun.COM 		isSame = B_TRUE;
10827836SJohn.Forte@Sun.COM 	} else {
10837836SJohn.Forte@Sun.COM 		/* user input didn't match, try via devid */
10847836SJohn.Forte@Sun.COM 		/*
10857836SJohn.Forte@Sun.COM 		 * I don't see a reason to print the error for
10867836SJohn.Forte@Sun.COM 		 * any of these since they'll get the error at
10877836SJohn.Forte@Sun.COM 		 * the end anyway
10887836SJohn.Forte@Sun.COM 		 */
10897836SJohn.Forte@Sun.COM 
10907916SHyon.Kim@Sun.COM 		fd1 = fd2 = -1;
10917836SJohn.Forte@Sun.COM 		if (((fd1 = open(cmpString, O_RDONLY|O_NDELAY)) >= 0) &&
10927836SJohn.Forte@Sun.COM 		    ((fd2 = open(deviceProperty, O_RDONLY|O_NDELAY)) >= 0) &&
10937836SJohn.Forte@Sun.COM 		    (devid_get(fd1, &devid1) == 0) &&
10947836SJohn.Forte@Sun.COM 		    (devid_get(fd2, &devid2) == 0) &&
10957836SJohn.Forte@Sun.COM 		    ((NULL != devid1) && (NULL != devid2))) {
10967836SJohn.Forte@Sun.COM 			if (0 ==
10977836SJohn.Forte@Sun.COM 			    (devid_compare(devid1, devid2))) {
10987836SJohn.Forte@Sun.COM 				isSame = B_TRUE;
10997836SJohn.Forte@Sun.COM 			}
11007836SJohn.Forte@Sun.COM 		}
11017836SJohn.Forte@Sun.COM 
11027836SJohn.Forte@Sun.COM 		if (NULL != devid1) {
11037836SJohn.Forte@Sun.COM 			devid_free(devid1);
11047836SJohn.Forte@Sun.COM 		}
11057836SJohn.Forte@Sun.COM 		if (NULL != devid2) {
11067836SJohn.Forte@Sun.COM 			devid_free(devid2);
11077836SJohn.Forte@Sun.COM 		}
11087916SHyon.Kim@Sun.COM 
11097916SHyon.Kim@Sun.COM 		if (fd1 >= 0) {
11107916SHyon.Kim@Sun.COM 			(void) close(fd1);
11117916SHyon.Kim@Sun.COM 		}
11127916SHyon.Kim@Sun.COM 		if (fd2 >= 0) {
11137916SHyon.Kim@Sun.COM 			(void) close(fd2);
11147916SHyon.Kim@Sun.COM 		}
11157836SJohn.Forte@Sun.COM 	} /* compare */
11167836SJohn.Forte@Sun.COM 
11177836SJohn.Forte@Sun.COM 	return (isSame);
11187836SJohn.Forte@Sun.COM }
11197836SJohn.Forte@Sun.COM 
11207836SJohn.Forte@Sun.COM 
11217836SJohn.Forte@Sun.COM /*
11227836SJohn.Forte@Sun.COM  * ****************************************************************************
11237836SJohn.Forte@Sun.COM  *
11247836SJohn.Forte@Sun.COM  * listIndivudualLogicalUnit -
11257836SJohn.Forte@Sun.COM  * 	Used by list logical unit cli.
11267836SJohn.Forte@Sun.COM  *	Displays info about an LU
11277836SJohn.Forte@Sun.COM  *
11287836SJohn.Forte@Sun.COM  * luOid	- LU to list
11297836SJohn.Forte@Sun.COM  * luProps	- properties of he LU to list
11307836SJohn.Forte@Sun.COM  *
11317836SJohn.Forte@Sun.COM  * ****************************************************************************
11327836SJohn.Forte@Sun.COM  */
11337836SJohn.Forte@Sun.COM int
listIndividualLogicalUnit(MP_OID luOid,MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES luProps)11347836SJohn.Forte@Sun.COM listIndividualLogicalUnit(MP_OID luOid,
11357836SJohn.Forte@Sun.COM 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES luProps)
11367836SJohn.Forte@Sun.COM {
11377836SJohn.Forte@Sun.COM 	MP_PATH_LOGICAL_UNIT_PROPERTIES		pathProps;
11387836SJohn.Forte@Sun.COM 	MP_OID_LIST				*pPathOidListArray;
11397836SJohn.Forte@Sun.COM 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
1140*10696SDavid.Hollister@Sun.COM 	int					numOperationalPaths, pa;
11417836SJohn.Forte@Sun.COM 
11427836SJohn.Forte@Sun.COM 	(void) printf("\t");
11437836SJohn.Forte@Sun.COM 	displayArray(luProps.deviceFileName, sizeof (luProps.deviceFileName));
11447836SJohn.Forte@Sun.COM 	(void) printf("\n");
11457836SJohn.Forte@Sun.COM 
11467836SJohn.Forte@Sun.COM 	mpstatus = MP_GetAssociatedPathOidList(luOid,
11477836SJohn.Forte@Sun.COM 	    &pPathOidListArray);
11487836SJohn.Forte@Sun.COM 	if (mpstatus != MP_STATUS_SUCCESS) {
11497836SJohn.Forte@Sun.COM 		/* LINTED E_SEC_PRINTF_VAR_FMT */
11507836SJohn.Forte@Sun.COM 		(void) fprintf(stderr,
11517836SJohn.Forte@Sun.COM 		    getTextString(ERR_NO_LU_PATH_INFO_WITH_MISSING_LU_STR),
1152*10696SDavid.Hollister@Sun.COM 		    getStringArray(luProps.deviceFileName,
11537836SJohn.Forte@Sun.COM 		    sizeof (luProps.deviceFileName)));
11547836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "\n");
11557836SJohn.Forte@Sun.COM 		return (mpstatus);
11567836SJohn.Forte@Sun.COM 	}
11577836SJohn.Forte@Sun.COM 	(void) printf("\t\t%s %d\n",
11587836SJohn.Forte@Sun.COM 	    getTextString(TEXT_LB_PATH_COUNT), pPathOidListArray->oidCount);
11597836SJohn.Forte@Sun.COM 
11607836SJohn.Forte@Sun.COM 	numOperationalPaths = 0;
11617836SJohn.Forte@Sun.COM 	for (pa = 0; pa < pPathOidListArray->oidCount; pa++) {
11627836SJohn.Forte@Sun.COM 		(void) memset(&pathProps, 0,
11637836SJohn.Forte@Sun.COM 		    sizeof (MP_PATH_LOGICAL_UNIT_PROPERTIES));
11647836SJohn.Forte@Sun.COM 		mpstatus =
11657836SJohn.Forte@Sun.COM 		    MP_GetPathLogicalUnitProperties(
11667836SJohn.Forte@Sun.COM 		    pPathOidListArray->oids[pa], &pathProps);
11677836SJohn.Forte@Sun.COM 		if (mpstatus != MP_STATUS_SUCCESS) {
11687836SJohn.Forte@Sun.COM 			(void) fprintf(stderr, "%s:  %s\n",
11697836SJohn.Forte@Sun.COM 			    cmdName, getTextString(ERR_NO_PROPERTIES));
11707836SJohn.Forte@Sun.COM 			return (mpstatus);
11717836SJohn.Forte@Sun.COM 		}
11727836SJohn.Forte@Sun.COM 
11737836SJohn.Forte@Sun.COM 		/* cycle through and check status of each for */
11747836SJohn.Forte@Sun.COM 		/* operation path count */
11757836SJohn.Forte@Sun.COM 		if (MP_PATH_STATE_OKAY == pathProps.pathState) {
11767836SJohn.Forte@Sun.COM 			numOperationalPaths++;
11777836SJohn.Forte@Sun.COM 		}
11787836SJohn.Forte@Sun.COM 	}
11797836SJohn.Forte@Sun.COM 
11807836SJohn.Forte@Sun.COM 	(void) printf("\t\t%s %d\n",
11817836SJohn.Forte@Sun.COM 	    getTextString(TEXT_LB_OP_PATH_COUNT), numOperationalPaths);
11827836SJohn.Forte@Sun.COM 
11837836SJohn.Forte@Sun.COM 	return (mpstatus);
11847836SJohn.Forte@Sun.COM }
11857836SJohn.Forte@Sun.COM 
11867836SJohn.Forte@Sun.COM 
11877836SJohn.Forte@Sun.COM /*
11887836SJohn.Forte@Sun.COM  * ****************************************************************************
11897836SJohn.Forte@Sun.COM  *
11907836SJohn.Forte@Sun.COM  * showLogicalUnit -
11917836SJohn.Forte@Sun.COM  * 	mpathadm show {logical-unit | LU} <logical-unit name>, ...
11927836SJohn.Forte@Sun.COM  *
11937836SJohn.Forte@Sun.COM  * operandLen	- number of operands user passed into the cli
11947836SJohn.Forte@Sun.COM  * operand	- pointer to operand list from user
11957836SJohn.Forte@Sun.COM  *
11967836SJohn.Forte@Sun.COM  * ****************************************************************************
11977836SJohn.Forte@Sun.COM  */
11987836SJohn.Forte@Sun.COM int
showLogicalUnit(int operandLen,char * operand[])11997836SJohn.Forte@Sun.COM showLogicalUnit(int operandLen, char *operand[])
12007836SJohn.Forte@Sun.COM {
12017836SJohn.Forte@Sun.COM 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
12027836SJohn.Forte@Sun.COM 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES	luProps;
12037836SJohn.Forte@Sun.COM 	MP_PLUGIN_PROPERTIES			pluginProps;
1204*10696SDavid.Hollister@Sun.COM 	MP_OID					luOid, pluginOid;
12057836SJohn.Forte@Sun.COM 
12067836SJohn.Forte@Sun.COM 	int					op;
12077836SJohn.Forte@Sun.COM 
12087836SJohn.Forte@Sun.COM 	for (op = 0; op < operandLen; op++) {
12097836SJohn.Forte@Sun.COM 		if (op > 0) {
12107836SJohn.Forte@Sun.COM 			(void) printf("\n");
12117836SJohn.Forte@Sun.COM 		}
12127836SJohn.Forte@Sun.COM 		if (B_TRUE == getLogicalUnitOid(operand[op], &luOid)) {
12137836SJohn.Forte@Sun.COM 			(void) memset(&luProps, 0,
12147836SJohn.Forte@Sun.COM 			    sizeof (MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES));
12157836SJohn.Forte@Sun.COM 			mpstatus =
12167836SJohn.Forte@Sun.COM 			    MP_GetMPLogicalUnitProperties(
12177836SJohn.Forte@Sun.COM 			    luOid, &luProps);
12187836SJohn.Forte@Sun.COM 			if (mpstatus != MP_STATUS_SUCCESS) {
12197836SJohn.Forte@Sun.COM 				(void) fprintf(stderr, "%s:  %s\n",
12207836SJohn.Forte@Sun.COM 				    cmdName, getTextString(ERR_NO_PROPERTIES));
12217836SJohn.Forte@Sun.COM 				return (mpstatus);
12227836SJohn.Forte@Sun.COM 			}
12237836SJohn.Forte@Sun.COM 
12247836SJohn.Forte@Sun.COM 			mpstatus =
12257836SJohn.Forte@Sun.COM 			    MP_GetAssociatedPluginOid(luOid, &pluginOid);
12267836SJohn.Forte@Sun.COM 			if (mpstatus != MP_STATUS_SUCCESS) {
12277836SJohn.Forte@Sun.COM 				(void) fprintf(stderr, "%s:  %s\n",
12287836SJohn.Forte@Sun.COM 				    cmdName,
12297836SJohn.Forte@Sun.COM 				    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
12307836SJohn.Forte@Sun.COM 				return (mpstatus);
12317836SJohn.Forte@Sun.COM 			}
12327836SJohn.Forte@Sun.COM 
12337836SJohn.Forte@Sun.COM 			mpstatus =
12347836SJohn.Forte@Sun.COM 			    MP_GetPluginProperties(pluginOid, &pluginProps);
12357836SJohn.Forte@Sun.COM 			if (mpstatus != MP_STATUS_SUCCESS) {
12367836SJohn.Forte@Sun.COM 				(void) fprintf(stderr, "%s:  %s\n",
12377836SJohn.Forte@Sun.COM 				    cmdName, getTextString(ERR_NO_PROPERTIES));
12387836SJohn.Forte@Sun.COM 				return (mpstatus);
12397836SJohn.Forte@Sun.COM 			}
12407836SJohn.Forte@Sun.COM 
12417836SJohn.Forte@Sun.COM 			if (showIndividualLogicalUnit(luOid, luProps,
12427836SJohn.Forte@Sun.COM 			    pluginProps) != 0) {
12437836SJohn.Forte@Sun.COM 				return (ERROR_CLI_FAILED);
12447836SJohn.Forte@Sun.COM 			}
12457836SJohn.Forte@Sun.COM 
12467836SJohn.Forte@Sun.COM 		} else {
12477836SJohn.Forte@Sun.COM 			/* LINTED E_SEC_PRINTF_VAR_FMT */
12487836SJohn.Forte@Sun.COM 			(void) fprintf(stderr, getTextString(
12497836SJohn.Forte@Sun.COM 			    ERR_LU_NOT_FOUND_WITH_MISSING_LU_STR),
12507836SJohn.Forte@Sun.COM 			    operand[op]);
12517836SJohn.Forte@Sun.COM 			(void) printf("\n");
12527836SJohn.Forte@Sun.COM 		}
12537836SJohn.Forte@Sun.COM 
12547836SJohn.Forte@Sun.COM 	} /* for each operand */
12557836SJohn.Forte@Sun.COM 
12567836SJohn.Forte@Sun.COM 	return (mpstatus);
12577836SJohn.Forte@Sun.COM }
12587836SJohn.Forte@Sun.COM 
12597836SJohn.Forte@Sun.COM 
12607836SJohn.Forte@Sun.COM /*
12617836SJohn.Forte@Sun.COM  * ****************************************************************************
12627836SJohn.Forte@Sun.COM  *
12637836SJohn.Forte@Sun.COM  * showIndivudualLogicalUnit -
12647836SJohn.Forte@Sun.COM  * 	Used by show logical unit cli.
12657836SJohn.Forte@Sun.COM  *	Displays info about an LU
12667836SJohn.Forte@Sun.COM  *
12677836SJohn.Forte@Sun.COM  * luOid	- LU to show
12687836SJohn.Forte@Sun.COM  * luProps	- properties of he LU to show
12697836SJohn.Forte@Sun.COM  * pluginProps	- propertis of the plugin this LU belongs to
12707836SJohn.Forte@Sun.COM  *
12717836SJohn.Forte@Sun.COM  * ****************************************************************************
12727836SJohn.Forte@Sun.COM  */
12737836SJohn.Forte@Sun.COM int
showIndividualLogicalUnit(MP_OID luOid,MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES luProps,MP_PLUGIN_PROPERTIES pluginProps)12747836SJohn.Forte@Sun.COM showIndividualLogicalUnit(MP_OID luOid,
12757836SJohn.Forte@Sun.COM 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES luProps,
12767836SJohn.Forte@Sun.COM 	MP_PLUGIN_PROPERTIES pluginProps)
12777836SJohn.Forte@Sun.COM {
12787836SJohn.Forte@Sun.COM 	MP_PATH_LOGICAL_UNIT_PROPERTIES		pathProps;
12797836SJohn.Forte@Sun.COM 	MP_TARGET_PORT_GROUP_PROPERTIES		tpgProps;
12807836SJohn.Forte@Sun.COM 	MP_TARGET_PORT_PROPERTIES 		tportProps;
12817836SJohn.Forte@Sun.COM 	MP_INITIATOR_PORT_PROPERTIES 		initProps;
1282*10696SDavid.Hollister@Sun.COM 	MP_OID_LIST	*pPathOidListArray, *pTPGOidListArray,
1283*10696SDavid.Hollister@Sun.COM 	    *pTportOidListArray;
12847836SJohn.Forte@Sun.COM 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
12857836SJohn.Forte@Sun.COM 	boolean_t				showTportLabel = B_TRUE;
12867836SJohn.Forte@Sun.COM 
1287*10696SDavid.Hollister@Sun.COM 	int					pa, tpg, tport;
12887836SJohn.Forte@Sun.COM 
12897836SJohn.Forte@Sun.COM 	(void) printf("%s  ", getTextString(TEXT_LB_LOGICAL_UNIT));
12907836SJohn.Forte@Sun.COM 	displayArray(luProps.deviceFileName, sizeof (luProps.deviceFileName));
12917836SJohn.Forte@Sun.COM 	(void) printf("\n");
12927836SJohn.Forte@Sun.COM 	(void) printf("\t%s  %s\n", getTextString(TEXT_LB_MPATH_SUPPORT),
1293*10696SDavid.Hollister@Sun.COM 	    pluginProps.fileName);
12947836SJohn.Forte@Sun.COM 
12957836SJohn.Forte@Sun.COM 	(void) printf("\t%s  ", getTextString(TEXT_LB_VENDOR));
12967836SJohn.Forte@Sun.COM 	displayArray(luProps.vendor,
12977836SJohn.Forte@Sun.COM 	    sizeof (luProps.vendor));
12987836SJohn.Forte@Sun.COM 	(void) printf("\n\t%s  ", getTextString(TEXT_LB_PRODUCT));
12997836SJohn.Forte@Sun.COM 	displayArray(luProps.product,
13007836SJohn.Forte@Sun.COM 	    sizeof (luProps.product));
13017836SJohn.Forte@Sun.COM 	(void) printf("\n\t%s  ", getTextString(TEXT_LB_REVISION));
13027836SJohn.Forte@Sun.COM 	displayArray(luProps.revision,
13037836SJohn.Forte@Sun.COM 	    sizeof (luProps.revision));
13047836SJohn.Forte@Sun.COM 	(void) printf("\n\t%s  ", getTextString(TEXT_LB_INQUIRY_NAME_TYPE));
13057836SJohn.Forte@Sun.COM 	displayLogicalUnitNameTypeString(luProps.nameType);
13067836SJohn.Forte@Sun.COM 	(void) printf("\n\t%s  ", getTextString(TEXT_LB_INQUIRY_NAME));
13077836SJohn.Forte@Sun.COM 	displayArray(luProps.name, sizeof (luProps.name));
13087836SJohn.Forte@Sun.COM 	(void) printf("\n\t%s  %s\n", getTextString(TEXT_LB_ASYMMETRIC),
13097836SJohn.Forte@Sun.COM 	    (MP_TRUE == luProps.asymmetric)?
13107836SJohn.Forte@Sun.COM 	    getTextString(TEXT_YES):getTextString(TEXT_NO));
13117836SJohn.Forte@Sun.COM 
13127836SJohn.Forte@Sun.COM 	(void) printf("\t%s  ", getTextString(TEXT_LB_CURR_LOAD_BALANCE));
13137836SJohn.Forte@Sun.COM 	/* don't ignore load balance type none. */
13147836SJohn.Forte@Sun.COM 	if (luProps.currentLoadBalanceType == 0) {
13157836SJohn.Forte@Sun.COM 		(void) printf("%s", getTextString(TEXT_LBTYPE_NONE));
13167836SJohn.Forte@Sun.COM 	} else {
13177836SJohn.Forte@Sun.COM 		displayLoadBalanceString(luProps.currentLoadBalanceType);
13187836SJohn.Forte@Sun.COM 	}
13197836SJohn.Forte@Sun.COM 	(void) printf("\n");
13207836SJohn.Forte@Sun.COM 
13217836SJohn.Forte@Sun.COM 	(void) printf("\t%s  ", getTextString(TEXT_LB_LU_GROUP_ID));
13227836SJohn.Forte@Sun.COM 	if (0xffffffff == luProps.logicalUnitGroupID) {
13237836SJohn.Forte@Sun.COM 		(void) printf("%s\n", getTextString(TEXT_NA));
13247836SJohn.Forte@Sun.COM 	} else {
13257836SJohn.Forte@Sun.COM 		(void) printf("0x%x\n", luProps.logicalUnitGroupID);
13267836SJohn.Forte@Sun.COM 	}
13277836SJohn.Forte@Sun.COM 
13287836SJohn.Forte@Sun.COM 	(void) printf("\t%s  ", getTextString(TEXT_LB_AUTO_FB));
13297836SJohn.Forte@Sun.COM 	if (MP_FALSE == pluginProps.autoFailbackSupport) {
13307836SJohn.Forte@Sun.COM 		(void) printf("%s\n", getTextString(TEXT_NA));
13317836SJohn.Forte@Sun.COM 	} else {
13327836SJohn.Forte@Sun.COM 		(void) printf("%s\n", (MP_TRUE == luProps.autoFailbackEnabled)?
13337836SJohn.Forte@Sun.COM 		    getTextString(TEXT_ON):getTextString(TEXT_OFF));
13347836SJohn.Forte@Sun.COM 	}
13357836SJohn.Forte@Sun.COM 
13367836SJohn.Forte@Sun.COM 	(void) printf("\t%s  ", getTextString(TEXT_LB_AUTO_PROB));
13377836SJohn.Forte@Sun.COM 	if (MP_FALSE == pluginProps.autoProbingSupport) {
13387836SJohn.Forte@Sun.COM 		(void) printf("%s\n", getTextString(TEXT_NA));
13397836SJohn.Forte@Sun.COM 	} else {
13407836SJohn.Forte@Sun.COM 		(void) printf("%s\n", (MP_TRUE == luProps.autoProbingEnabled)?
13417836SJohn.Forte@Sun.COM 		    getTextString(TEXT_ON):getTextString(TEXT_OFF));
13427836SJohn.Forte@Sun.COM 	}
13437836SJohn.Forte@Sun.COM 
13447836SJohn.Forte@Sun.COM 
13457836SJohn.Forte@Sun.COM 	/* get path info */
13467836SJohn.Forte@Sun.COM 	mpstatus = MP_GetAssociatedPathOidList(luOid, &pPathOidListArray);
13477836SJohn.Forte@Sun.COM 	if (mpstatus != MP_STATUS_SUCCESS) {
13487836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s:  %s", cmdName,
13497836SJohn.Forte@Sun.COM 		    getTextString(ERR_NO_LU_PATH_INFO));
13507836SJohn.Forte@Sun.COM 		displayArray(luProps.deviceFileName,
13517836SJohn.Forte@Sun.COM 		    sizeof (luProps.deviceFileName));
13527836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "\n");
13537836SJohn.Forte@Sun.COM 		return (mpstatus);
13547836SJohn.Forte@Sun.COM 	}
13557836SJohn.Forte@Sun.COM 
13567836SJohn.Forte@Sun.COM 	(void) printf("\n\t%s  \n", getTextString(TEXT_LB_PATH_INFO));
13577836SJohn.Forte@Sun.COM 
13587836SJohn.Forte@Sun.COM 	for (pa = 0; pa < pPathOidListArray->oidCount; pa++) {
13597836SJohn.Forte@Sun.COM 		(void) memset(&pathProps, 0,
13607836SJohn.Forte@Sun.COM 		    sizeof (MP_PATH_LOGICAL_UNIT_PROPERTIES));
13617836SJohn.Forte@Sun.COM 		mpstatus = MP_GetPathLogicalUnitProperties(
13627836SJohn.Forte@Sun.COM 		    pPathOidListArray->oids[pa], &pathProps);
13637836SJohn.Forte@Sun.COM 		if (mpstatus != MP_STATUS_SUCCESS) {
13647836SJohn.Forte@Sun.COM 			(void) fprintf(stderr, "%s:  %s\n",
13657836SJohn.Forte@Sun.COM 			    cmdName, getTextString(ERR_NO_PROPERTIES));
13667836SJohn.Forte@Sun.COM 			return (mpstatus);
13677836SJohn.Forte@Sun.COM 		}
13687836SJohn.Forte@Sun.COM 
13697836SJohn.Forte@Sun.COM 		(void) printf("\t\t%s  ",
13707836SJohn.Forte@Sun.COM 		    getTextString(TEXT_LB_INIT_PORT_NAME));
13717836SJohn.Forte@Sun.COM 		if ((mpstatus =
13727836SJohn.Forte@Sun.COM 		    MP_GetInitiatorPortProperties(pathProps.initiatorPortOid,
13737836SJohn.Forte@Sun.COM 		    &initProps)) != MP_STATUS_SUCCESS) {
13747836SJohn.Forte@Sun.COM 			(void) printf("%s\n", getTextString(TEXT_UNKNOWN));
13757836SJohn.Forte@Sun.COM 		} else {
13767836SJohn.Forte@Sun.COM 			displayArray(initProps.portID,
13777836SJohn.Forte@Sun.COM 			    sizeof (initProps.portID));
13787836SJohn.Forte@Sun.COM 			(void) printf("\n");
13797836SJohn.Forte@Sun.COM 		}
13807836SJohn.Forte@Sun.COM 
13817836SJohn.Forte@Sun.COM 		(void) printf("\t\t%s  ",
13827836SJohn.Forte@Sun.COM 		    getTextString(TEXT_LB_TARGET_PORT_NAME));
13837836SJohn.Forte@Sun.COM 		if ((mpstatus =
13847836SJohn.Forte@Sun.COM 		    MP_GetTargetPortProperties(pathProps.targetPortOid,
13857836SJohn.Forte@Sun.COM 		    &tportProps)) != MP_STATUS_SUCCESS) {
13867836SJohn.Forte@Sun.COM 			(void) printf("%s\n", getTextString(TEXT_UNKNOWN));
13877836SJohn.Forte@Sun.COM 		} else {
13887836SJohn.Forte@Sun.COM 			displayArray(tportProps.portID,
13897836SJohn.Forte@Sun.COM 			    sizeof (tportProps.portID));
13907836SJohn.Forte@Sun.COM 			(void) printf("\n");
13917836SJohn.Forte@Sun.COM 		}
13927836SJohn.Forte@Sun.COM 
13937836SJohn.Forte@Sun.COM 		(void) printf("\t\t%s  ", getTextString(TEXT_LB_OVERRIDE_PATH));
13947836SJohn.Forte@Sun.COM 		if (MP_FALSE == pluginProps.canOverridePaths) {
13957836SJohn.Forte@Sun.COM 			(void) printf("%s\n", getTextString(TEXT_NA));
13967836SJohn.Forte@Sun.COM 		} else if (luProps.overridePath.objectSequenceNumber ==
13977836SJohn.Forte@Sun.COM 		    pPathOidListArray->oids[pa].objectSequenceNumber) {
13987836SJohn.Forte@Sun.COM 			(void) printf("%s\n", getTextString(TEXT_YES));
13997836SJohn.Forte@Sun.COM 		} else {
14007836SJohn.Forte@Sun.COM 			(void) printf("%s\n", getTextString(TEXT_NO));
14017836SJohn.Forte@Sun.COM 		}
14027836SJohn.Forte@Sun.COM 
14037836SJohn.Forte@Sun.COM 		(void) printf("\t\t%s  %s\n", getTextString(TEXT_LB_PATH_STATE),
14047836SJohn.Forte@Sun.COM 		    getPathStateStr(pathProps.pathState));
14057836SJohn.Forte@Sun.COM 
14067836SJohn.Forte@Sun.COM 		(void) printf("\t\t%s  %s\n\n", getTextString(TEXT_LB_DISABLED),
14077836SJohn.Forte@Sun.COM 		    pathProps.disabled?getTextString(TEXT_YES):
14087836SJohn.Forte@Sun.COM 		    getTextString(TEXT_NO));
14097836SJohn.Forte@Sun.COM 
14107836SJohn.Forte@Sun.COM 	}
14117836SJohn.Forte@Sun.COM 
14127836SJohn.Forte@Sun.COM 	/* get tpg info */
14137836SJohn.Forte@Sun.COM 	mpstatus = MP_GetAssociatedTPGOidList(luOid, &pTPGOidListArray);
14147836SJohn.Forte@Sun.COM 	if (mpstatus != MP_STATUS_SUCCESS) {
14157836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s:  %s", cmdName,
14167836SJohn.Forte@Sun.COM 		    getTextString(ERR_NO_ASSOC_TPGS));
14177836SJohn.Forte@Sun.COM 	} else {
14187836SJohn.Forte@Sun.COM 
14197836SJohn.Forte@Sun.COM 	/* display tpg info only if is assymetric */
14207836SJohn.Forte@Sun.COM 	if (MP_TRUE == luProps.asymmetric) {
14217836SJohn.Forte@Sun.COM 		(void) printf("\t%s  \n", getTextString(TEXT_LB_TPG_INFO));
14227836SJohn.Forte@Sun.COM 	}
14237836SJohn.Forte@Sun.COM 
14247836SJohn.Forte@Sun.COM 		for (tpg = 0; tpg < pTPGOidListArray->oidCount; tpg++) {
14257836SJohn.Forte@Sun.COM 			(void) memset(&tpgProps, 0,
14267836SJohn.Forte@Sun.COM 			    sizeof (MP_TARGET_PORT_GROUP_PROPERTIES));
14277836SJohn.Forte@Sun.COM 			mpstatus = MP_GetTargetPortGroupProperties(
14287836SJohn.Forte@Sun.COM 			    pTPGOidListArray->oids[tpg], &tpgProps);
14297836SJohn.Forte@Sun.COM 			if (mpstatus != MP_STATUS_SUCCESS) {
14307836SJohn.Forte@Sun.COM 				(void) fprintf(stderr, "%s:  %s",
14317836SJohn.Forte@Sun.COM 				    cmdName, getTextString(ERR_NO_PROPERTIES));
14327836SJohn.Forte@Sun.COM 			} else {
14337836SJohn.Forte@Sun.COM 				/* display tpg info only if is assymetric */
14347836SJohn.Forte@Sun.COM 				if (tpg > 0) {
14357836SJohn.Forte@Sun.COM 					(void) printf("\n");
14367836SJohn.Forte@Sun.COM 				}
14377836SJohn.Forte@Sun.COM 				if (MP_TRUE == luProps.asymmetric) {
14387836SJohn.Forte@Sun.COM 					(void) printf("\t\t%s  %d\n",
14397836SJohn.Forte@Sun.COM 					    getTextString(TEXT_LB_ID),
14407836SJohn.Forte@Sun.COM 					    tpgProps.tpgID);
14417836SJohn.Forte@Sun.COM 					(void) printf("\t\t%s  %s\n",
14427836SJohn.Forte@Sun.COM 					    getTextString(
14437836SJohn.Forte@Sun.COM 					    TEXT_LB_EXPLICIT_FAILOVER),
14447836SJohn.Forte@Sun.COM 					    (MP_TRUE ==
14457836SJohn.Forte@Sun.COM 					    tpgProps.explicitFailover)?
14467836SJohn.Forte@Sun.COM 					    getTextString(TEXT_YES):
14477836SJohn.Forte@Sun.COM 					    getTextString(TEXT_NO));
14487836SJohn.Forte@Sun.COM 					(void) printf("\t\t%s  %s\n",
14497836SJohn.Forte@Sun.COM 					    getTextString(
14507836SJohn.Forte@Sun.COM 					    TEXT_LB_ACCESS_STATE),
14517836SJohn.Forte@Sun.COM 					    getAccessStateStr(
14527836SJohn.Forte@Sun.COM 					    tpgProps.accessState));
14537836SJohn.Forte@Sun.COM 					    /* display label for each tpg. */
1454*10696SDavid.Hollister@Sun.COM 					(void) printf("\t\t%s\n",
1455*10696SDavid.Hollister@Sun.COM 					    getTextString(TEXT_TPORT_LIST));
14567836SJohn.Forte@Sun.COM 				} else {
14577836SJohn.Forte@Sun.COM 					/* display label once for symmetric. */
14587836SJohn.Forte@Sun.COM 					if (B_TRUE == showTportLabel) {
1459*10696SDavid.Hollister@Sun.COM 					/* begin back-up indentation */
1460*10696SDavid.Hollister@Sun.COM 					(void) printf("\t%s\n",
1461*10696SDavid.Hollister@Sun.COM 					    getTextString(TEXT_TPORT_LIST));
1462*10696SDavid.Hollister@Sun.COM 					showTportLabel = B_FALSE;
1463*10696SDavid.Hollister@Sun.COM 					/* end back-up indentation */
14647836SJohn.Forte@Sun.COM 					}
14657836SJohn.Forte@Sun.COM 				}
14667836SJohn.Forte@Sun.COM 
14677836SJohn.Forte@Sun.COM 				/* get target port info */
14687836SJohn.Forte@Sun.COM 				mpstatus = MP_GetTargetPortOidList(
14697836SJohn.Forte@Sun.COM 				    pTPGOidListArray->oids[tpg],
14707836SJohn.Forte@Sun.COM 				    &pTportOidListArray);
14717836SJohn.Forte@Sun.COM 				if (mpstatus != MP_STATUS_SUCCESS) {
14727836SJohn.Forte@Sun.COM 					(void) fprintf(stderr, "%s:  %s",
14737836SJohn.Forte@Sun.COM 					    cmdName,
14747836SJohn.Forte@Sun.COM 					    getTextString(ERR_NO_ASSOC_TPORTS));
14757836SJohn.Forte@Sun.COM 				} else {
14767836SJohn.Forte@Sun.COM 
14777836SJohn.Forte@Sun.COM /* begin back-up indentation */
14787836SJohn.Forte@Sun.COM 	for (tport = 0; tport < pTportOidListArray->oidCount; tport++) {
14797836SJohn.Forte@Sun.COM 		(void) memset(&tportProps, 0,
14807836SJohn.Forte@Sun.COM 		    sizeof (MP_TARGET_PORT_PROPERTIES));
14817836SJohn.Forte@Sun.COM 		if ((mpstatus =
14827836SJohn.Forte@Sun.COM 		    MP_GetTargetPortProperties(pTportOidListArray->oids[tport],
14837836SJohn.Forte@Sun.COM 		    &tportProps)) != MP_STATUS_SUCCESS) {
14847836SJohn.Forte@Sun.COM 			(void) fprintf(stderr, "%s:  %s",
1485*10696SDavid.Hollister@Sun.COM 			    cmdName, getTextString(ERR_NO_PROPERTIES));
14867836SJohn.Forte@Sun.COM 		} else {
14877836SJohn.Forte@Sun.COM 			if (MP_TRUE == luProps.asymmetric) {
14887836SJohn.Forte@Sun.COM 				(void) printf("\t\t\t%s  ",
1489*10696SDavid.Hollister@Sun.COM 				    getTextString(TEXT_LB_NAME));
14907836SJohn.Forte@Sun.COM 				displayArray(tportProps.portID,
1491*10696SDavid.Hollister@Sun.COM 				    sizeof (tportProps.portID));
14927836SJohn.Forte@Sun.COM 				(void) printf("\n\t\t\t%s  %d\n",
1493*10696SDavid.Hollister@Sun.COM 				    getTextString(TEXT_LB_RELATIVE_ID),
1494*10696SDavid.Hollister@Sun.COM 				    tportProps.relativePortID);
14957836SJohn.Forte@Sun.COM 			} else {
14967836SJohn.Forte@Sun.COM 				(void) printf("\t\t%s  ",
1497*10696SDavid.Hollister@Sun.COM 				    getTextString(TEXT_LB_NAME));
14987836SJohn.Forte@Sun.COM 				displayArray(tportProps.portID,
1499*10696SDavid.Hollister@Sun.COM 				    sizeof (tportProps.portID));
15007836SJohn.Forte@Sun.COM 				(void) printf("\n\t\t%s  %d\n",
1501*10696SDavid.Hollister@Sun.COM 				    getTextString(TEXT_LB_RELATIVE_ID),
1502*10696SDavid.Hollister@Sun.COM 				    tportProps.relativePortID);
15037836SJohn.Forte@Sun.COM 			}
15047836SJohn.Forte@Sun.COM 			/* insert blank line if not the last target port. */
15057836SJohn.Forte@Sun.COM 			if (!(tport == (pTportOidListArray->oidCount - 1))) {
1506*10696SDavid.Hollister@Sun.COM 				(void) printf("\n");
15077836SJohn.Forte@Sun.COM 			}
15087836SJohn.Forte@Sun.COM 		}
15097836SJohn.Forte@Sun.COM 	} /* for each target port */
15107836SJohn.Forte@Sun.COM /* end back-up indentation */
15117836SJohn.Forte@Sun.COM 
15127836SJohn.Forte@Sun.COM 				} /* else got target port props */
15137836SJohn.Forte@Sun.COM 			} /* else got TPG props */
15147836SJohn.Forte@Sun.COM 		} /* for each TPG */
15157836SJohn.Forte@Sun.COM 	} /* else got tpg list */
15167836SJohn.Forte@Sun.COM 
15177836SJohn.Forte@Sun.COM 
15187836SJohn.Forte@Sun.COM 	return (mpstatus);
15197836SJohn.Forte@Sun.COM }
15207836SJohn.Forte@Sun.COM 
15217836SJohn.Forte@Sun.COM 
15227836SJohn.Forte@Sun.COM /*
15237836SJohn.Forte@Sun.COM  * ****************************************************************************
15247836SJohn.Forte@Sun.COM  *
15257836SJohn.Forte@Sun.COM  * modifyLogicalUnit -
15267836SJohn.Forte@Sun.COM  * 	mpathadm modify {logical-unit | LU} [options] <logical-unit name>, ...
15277836SJohn.Forte@Sun.COM  *
15287836SJohn.Forte@Sun.COM  * operandLen	- number of operands user passed into the cli
15297836SJohn.Forte@Sun.COM  * operand	- pointer to operand list from user
15307836SJohn.Forte@Sun.COM  * options	- pointer to option list from user
15317836SJohn.Forte@Sun.COM  *
15327836SJohn.Forte@Sun.COM  * ****************************************************************************
15337836SJohn.Forte@Sun.COM  */
15347836SJohn.Forte@Sun.COM int
modifyLogicalUnit(int operandLen,char * operand[],cmdOptions_t * options)15357836SJohn.Forte@Sun.COM modifyLogicalUnit(int operandLen, char *operand[], cmdOptions_t *options)
15367836SJohn.Forte@Sun.COM {
15377836SJohn.Forte@Sun.COM 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
15387836SJohn.Forte@Sun.COM 	MP_OID					luOid;
15397836SJohn.Forte@Sun.COM 	cmdOptions_t 				*optionList = options;
1540*10696SDavid.Hollister@Sun.COM 	char	*cmdStr = getTextString(TEXT_UNKNOWN);
15417836SJohn.Forte@Sun.COM 	int					op;
15427836SJohn.Forte@Sun.COM 
15437836SJohn.Forte@Sun.COM 	for (op = 0; op < operandLen; op++) {
15447836SJohn.Forte@Sun.COM 		if (B_TRUE != getLogicalUnitOid(operand[op], &luOid)) {
15457836SJohn.Forte@Sun.COM 			/* LINTED E_SEC_PRINTF_VAR_FMT */
15467836SJohn.Forte@Sun.COM 			(void) fprintf(stderr,
15477836SJohn.Forte@Sun.COM 			    getTextString(ERR_LU_NOT_FOUND_WITH_MISSING_LU_STR),
15487836SJohn.Forte@Sun.COM 			    operand[op]);
15497836SJohn.Forte@Sun.COM 			(void) printf("\n");
15507836SJohn.Forte@Sun.COM 			return (ERROR_CLI_FAILED);
15517836SJohn.Forte@Sun.COM 		}
15527836SJohn.Forte@Sun.COM 
15537836SJohn.Forte@Sun.COM 		/* we found the lu oid, now change the options requested */
15547836SJohn.Forte@Sun.COM 		switch (optionList->optval) {
15557836SJohn.Forte@Sun.COM 			case 'a':
15567836SJohn.Forte@Sun.COM 				/* modify autofailback */
15577836SJohn.Forte@Sun.COM 				cmdStr = getTextString(TEXT_AUTO_FAILBACK);
15587836SJohn.Forte@Sun.COM 				if (0 == strcasecmp(optionList->optarg,
15597836SJohn.Forte@Sun.COM 				    getTextString(TEXT_ON))) {
15607836SJohn.Forte@Sun.COM 					mpstatus =
15617836SJohn.Forte@Sun.COM 					    MP_EnableAutoFailback(luOid);
15627836SJohn.Forte@Sun.COM 				} else if (0 == strcasecmp(optionList->optarg,
15637836SJohn.Forte@Sun.COM 				    getTextString(TEXT_OFF))) {
15647836SJohn.Forte@Sun.COM 					mpstatus =
15657836SJohn.Forte@Sun.COM 					    MP_DisableAutoFailback(luOid);
15667836SJohn.Forte@Sun.COM 				} else {
1567*10696SDavid.Hollister@Sun.COM 				/* begin back-up indentation */
1568*10696SDavid.Hollister@Sun.COM 				/* LINTED E_SEC_PRINTF_VAR_FMT */
1569*10696SDavid.Hollister@Sun.COM 				(void) fprintf(stderr, getTextString(
15707836SJohn.Forte@Sun.COM 				    ERR_FAILED_TO_CHANGE_OPTION_WITH_REASON),
1571*10696SDavid.Hollister@Sun.COM 				    cmdStr, getTextString(
1572*10696SDavid.Hollister@Sun.COM 				    TEXT_ILLEGAL_ARGUMENT));
1573*10696SDavid.Hollister@Sun.COM 				(void) printf("\n");
1574*10696SDavid.Hollister@Sun.COM 				return (ERROR_CLI_FAILED);
1575*10696SDavid.Hollister@Sun.COM 				/* start back-up indentation */
15767836SJohn.Forte@Sun.COM 				}
15777836SJohn.Forte@Sun.COM 				break;
15787836SJohn.Forte@Sun.COM 			case 'p':
15797836SJohn.Forte@Sun.COM 				/* modify autoprobing */
15807836SJohn.Forte@Sun.COM 				cmdStr = getTextString(TEXT_AUTO_PROBING);
15817836SJohn.Forte@Sun.COM 				if (0 == strcasecmp(optionList->optarg,
15827836SJohn.Forte@Sun.COM 				    getTextString(TEXT_ON))) {
15837836SJohn.Forte@Sun.COM 					mpstatus =
15847836SJohn.Forte@Sun.COM 					    MP_EnableAutoProbing(luOid);
15857836SJohn.Forte@Sun.COM 				} else if (0 == strcasecmp(optionList->optarg,
1586*10696SDavid.Hollister@Sun.COM 				    getTextString(TEXT_OFF))) {
15877836SJohn.Forte@Sun.COM 					mpstatus =
15887836SJohn.Forte@Sun.COM 					    MP_DisableAutoProbing(luOid);
15897836SJohn.Forte@Sun.COM 				} else {
1590*10696SDavid.Hollister@Sun.COM 				/* begin back-up indentation */
1591*10696SDavid.Hollister@Sun.COM 				/* LINTED E_SEC_PRINTF_VAR_FMT */
1592*10696SDavid.Hollister@Sun.COM 				(void) fprintf(stderr, getTextString(
15937836SJohn.Forte@Sun.COM 				    ERR_FAILED_TO_CHANGE_OPTION_WITH_REASON),
1594*10696SDavid.Hollister@Sun.COM 				    cmdStr, getTextString(
1595*10696SDavid.Hollister@Sun.COM 				    TEXT_ILLEGAL_ARGUMENT));
1596*10696SDavid.Hollister@Sun.COM 				(void) printf("\n");
1597*10696SDavid.Hollister@Sun.COM 				return (ERROR_CLI_FAILED);
1598*10696SDavid.Hollister@Sun.COM 				/* end back-up indentation */
15997836SJohn.Forte@Sun.COM 				}
16007836SJohn.Forte@Sun.COM 				break;
16017836SJohn.Forte@Sun.COM 			case 'b':
16027836SJohn.Forte@Sun.COM 				/* modify loadbalance type */
16037836SJohn.Forte@Sun.COM 				cmdStr = getTextString(TEXT_LOAD_BALANCE);
16047836SJohn.Forte@Sun.COM 				mpstatus =
16057836SJohn.Forte@Sun.COM 				    MP_SetLogicalUnitLoadBalanceType(luOid,
16067836SJohn.Forte@Sun.COM 				    getLbValueFromString(optionList->optarg));
16077836SJohn.Forte@Sun.COM 				break;
16087836SJohn.Forte@Sun.COM 
16097836SJohn.Forte@Sun.COM 		} /* switch */
16107836SJohn.Forte@Sun.COM 		if (MP_STATUS_SUCCESS != mpstatus) {
16117836SJohn.Forte@Sun.COM 			/* LINTED E_SEC_PRINTF_VAR_FMT */
16127836SJohn.Forte@Sun.COM 			(void) fprintf(stderr,
16137836SJohn.Forte@Sun.COM 			    getTextString(
16147836SJohn.Forte@Sun.COM 			    ERR_FAILED_TO_CHANGE_OPTION_WITH_REASON),
16157836SJohn.Forte@Sun.COM 			    cmdStr, getMpStatusStr(mpstatus));
16167836SJohn.Forte@Sun.COM 			(void) printf("\n");
16177836SJohn.Forte@Sun.COM 			return (ERROR_CLI_FAILED);
16187836SJohn.Forte@Sun.COM 		}
16197836SJohn.Forte@Sun.COM 	} /* for each operand */
16207836SJohn.Forte@Sun.COM 	return (mpstatus);
16217836SJohn.Forte@Sun.COM }
16227836SJohn.Forte@Sun.COM 
16237836SJohn.Forte@Sun.COM 
16247836SJohn.Forte@Sun.COM /*
16257836SJohn.Forte@Sun.COM  * ****************************************************************************
16267836SJohn.Forte@Sun.COM  *
16277836SJohn.Forte@Sun.COM  * failoverLogicalUnit -
16287836SJohn.Forte@Sun.COM  * 	mpathadm failover {logical-unit | LU} <logical-unit name>, ...
16297836SJohn.Forte@Sun.COM  *
16307836SJohn.Forte@Sun.COM  * operand	- pointer to operand list from user
16317836SJohn.Forte@Sun.COM  *
16327836SJohn.Forte@Sun.COM  * ****************************************************************************
16337836SJohn.Forte@Sun.COM  */
16347836SJohn.Forte@Sun.COM int
failoverLogicalUnit(char * operand[])16357836SJohn.Forte@Sun.COM failoverLogicalUnit(char *operand[])
16367836SJohn.Forte@Sun.COM {
16377836SJohn.Forte@Sun.COM 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
16387836SJohn.Forte@Sun.COM 	MP_OID					luOid;
16397836SJohn.Forte@Sun.COM 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES	luProps;
16407836SJohn.Forte@Sun.COM 	MP_TARGET_PORT_GROUP_PROPERTIES		tpgProps;
16417836SJohn.Forte@Sun.COM 	MP_OID_LIST				*pTpgOidListArray;
16427836SJohn.Forte@Sun.COM 	boolean_t				bFoundIt = B_FALSE;
16437836SJohn.Forte@Sun.COM 	MP_TPG_STATE_PAIR			tpgStatePair;
16447836SJohn.Forte@Sun.COM 
16457836SJohn.Forte@Sun.COM 	int					tpg;
16467836SJohn.Forte@Sun.COM 
16477836SJohn.Forte@Sun.COM 	if (B_TRUE != getLogicalUnitOid(operand[0], &luOid)) {
16487836SJohn.Forte@Sun.COM 		/* LINTED E_SEC_PRINTF_VAR_FMT */
16497836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, getTextString(
16507836SJohn.Forte@Sun.COM 		    ERR_LU_NOT_FOUND_WITH_MISSING_LU_STR),
16517836SJohn.Forte@Sun.COM 		    operand[0]);
16527836SJohn.Forte@Sun.COM 		(void) printf("\n");
16537836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
16547836SJohn.Forte@Sun.COM 	}
16557836SJohn.Forte@Sun.COM 
16567836SJohn.Forte@Sun.COM 	/* get LUN properties and check to be sure it's asymmetric */
16577836SJohn.Forte@Sun.COM 	(void) memset(&luProps, 0,
16587836SJohn.Forte@Sun.COM 	    sizeof (MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES));
16597836SJohn.Forte@Sun.COM 	mpstatus =
16607836SJohn.Forte@Sun.COM 	    MP_GetMPLogicalUnitProperties(luOid, &luProps);
16617836SJohn.Forte@Sun.COM 	if (mpstatus != MP_STATUS_SUCCESS) {
16627836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s:  %s\n",
16637836SJohn.Forte@Sun.COM 		    cmdName, getTextString(ERR_NO_PROPERTIES));
16647836SJohn.Forte@Sun.COM 		return (mpstatus);
16657836SJohn.Forte@Sun.COM 	}
16667836SJohn.Forte@Sun.COM 
16677836SJohn.Forte@Sun.COM 	if (MP_TRUE != luProps.asymmetric) {
16687836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s:  %s\n",
16697836SJohn.Forte@Sun.COM 		    cmdName, getTextString(ERR_LU_NOT_ASYMMETRIC));
16707836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
16717836SJohn.Forte@Sun.COM 	}
16727836SJohn.Forte@Sun.COM 
16737836SJohn.Forte@Sun.COM 	/* get TPGs for this LUN */
16747836SJohn.Forte@Sun.COM 	mpstatus =
16757836SJohn.Forte@Sun.COM 	    MP_GetAssociatedTPGOidList(luOid, &pTpgOidListArray);
16767836SJohn.Forte@Sun.COM 	if (mpstatus != MP_STATUS_SUCCESS) {
16777836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s:  %s\n",
1678*10696SDavid.Hollister@Sun.COM 		    cmdName, getTextString(ERR_NO_ASSOC_TPGS));
16797836SJohn.Forte@Sun.COM 		return (mpstatus);
16807836SJohn.Forte@Sun.COM 	}
16817836SJohn.Forte@Sun.COM 
16827836SJohn.Forte@Sun.COM 	/* pick a TPG whose state is active or standby, and change it */
16837836SJohn.Forte@Sun.COM 	/* to opposite via MP_SetTPGAccessState */
16847836SJohn.Forte@Sun.COM 	bFoundIt = B_FALSE;
16857836SJohn.Forte@Sun.COM 	for (tpg = 0; tpg < pTpgOidListArray->oidCount; tpg++) {
16867836SJohn.Forte@Sun.COM 		(void) memset(&tpgProps, 0,
16877836SJohn.Forte@Sun.COM 		    sizeof (MP_TARGET_PORT_GROUP_PROPERTIES));
16887836SJohn.Forte@Sun.COM 		mpstatus =
16897836SJohn.Forte@Sun.COM 		    MP_GetTargetPortGroupProperties(
16907836SJohn.Forte@Sun.COM 		    pTpgOidListArray->oids[tpg], &tpgProps);
16917836SJohn.Forte@Sun.COM 		if (mpstatus != MP_STATUS_SUCCESS) {
16927836SJohn.Forte@Sun.COM 			(void) fprintf(stderr, "%s:  %s\n",
16937836SJohn.Forte@Sun.COM 			    cmdName, getTextString(ERR_NO_PROPERTIES));
16947836SJohn.Forte@Sun.COM 			return (ERROR_CLI_FAILED);
16957836SJohn.Forte@Sun.COM 		}
16967836SJohn.Forte@Sun.COM 		if (MP_FALSE == tpgProps.explicitFailover) {
16977836SJohn.Forte@Sun.COM 			(void) fprintf(stderr, "%s:  %s\n",
1698*10696SDavid.Hollister@Sun.COM 			    cmdName, getTextString(ERR_NO_FAILOVER_ALLOWED));
16997836SJohn.Forte@Sun.COM 			return (ERROR_CLI_FAILED);
17007836SJohn.Forte@Sun.COM 		}
17017836SJohn.Forte@Sun.COM 
17027836SJohn.Forte@Sun.COM 		/* find one that is standby */
17037836SJohn.Forte@Sun.COM 		if ((MP_ACCESS_STATE_STANDBY ==
17047836SJohn.Forte@Sun.COM 		    tpgProps.accessState) && (B_FALSE == bFoundIt)) {
17057836SJohn.Forte@Sun.COM 
17067836SJohn.Forte@Sun.COM 			bFoundIt = B_TRUE;
17077836SJohn.Forte@Sun.COM 
17087836SJohn.Forte@Sun.COM 			tpgStatePair.tpgOid =
17097836SJohn.Forte@Sun.COM 			    pTpgOidListArray->oids[tpg];
17107836SJohn.Forte@Sun.COM 			tpgStatePair.desiredState =
17117836SJohn.Forte@Sun.COM 			    MP_ACCESS_STATE_ACTIVE;
17127836SJohn.Forte@Sun.COM 			mpstatus =
17137836SJohn.Forte@Sun.COM 			    MP_SetTPGAccess(luOid, 1, &tpgStatePair);
17147836SJohn.Forte@Sun.COM 			if (MP_STATUS_SUCCESS != mpstatus) {
1715*10696SDavid.Hollister@Sun.COM 			/* begin back-up indentation */
1716*10696SDavid.Hollister@Sun.COM 			/* LINTED E_SEC_PRINTF_VAR_FMT */
1717*10696SDavid.Hollister@Sun.COM 			(void) fprintf(stderr, getTextString(
17187836SJohn.Forte@Sun.COM 			    ERR_FAILED_TO_FAILOVER_WITH_REASON),
17197836SJohn.Forte@Sun.COM 			    getMpStatusStr(mpstatus));
1720*10696SDavid.Hollister@Sun.COM 			(void) printf("\n");
1721*10696SDavid.Hollister@Sun.COM 			return (mpstatus);
1722*10696SDavid.Hollister@Sun.COM 			/* end back-up indentation */
17237836SJohn.Forte@Sun.COM 			}
17247836SJohn.Forte@Sun.COM 		}
17257836SJohn.Forte@Sun.COM 
17267836SJohn.Forte@Sun.COM 
17277836SJohn.Forte@Sun.COM 	} /* for each tpg */
17287836SJohn.Forte@Sun.COM 
17297836SJohn.Forte@Sun.COM 	if (B_FALSE == bFoundIt) {
17307836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s:  %s\n",
17317836SJohn.Forte@Sun.COM 		    cmdName, getTextString(ERR_LU_ACCESS_STATE_UNCHANGED));
17327836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
17337836SJohn.Forte@Sun.COM 	}
17347836SJohn.Forte@Sun.COM 
17357836SJohn.Forte@Sun.COM 	return (mpstatus);
17367836SJohn.Forte@Sun.COM }
17377836SJohn.Forte@Sun.COM 
17387836SJohn.Forte@Sun.COM 
17397836SJohn.Forte@Sun.COM /*
17407836SJohn.Forte@Sun.COM  * ****************************************************************************
17417836SJohn.Forte@Sun.COM  *
17427836SJohn.Forte@Sun.COM  * getLogicalUnitOid -
17437836SJohn.Forte@Sun.COM  *	Search through all plugins and get the OID for specified logical unit
17447836SJohn.Forte@Sun.COM  *
17457836SJohn.Forte@Sun.COM  * luFileName	- file name of LU (specified by the user) to find
17467836SJohn.Forte@Sun.COM  * pLuOid	- OID to return
17477836SJohn.Forte@Sun.COM  *
17487836SJohn.Forte@Sun.COM  * ****************************************************************************
17497836SJohn.Forte@Sun.COM  */
17507836SJohn.Forte@Sun.COM boolean_t
getLogicalUnitOid(MP_CHAR * luFileName,MP_OID * pluOid)17517836SJohn.Forte@Sun.COM getLogicalUnitOid(MP_CHAR *luFileName, MP_OID *pluOid)
17527836SJohn.Forte@Sun.COM {
17537836SJohn.Forte@Sun.COM 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
17547836SJohn.Forte@Sun.COM 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES	luProps;
17557836SJohn.Forte@Sun.COM 	MP_PLUGIN_PROPERTIES			pluginProps;
1756*10696SDavid.Hollister@Sun.COM 	MP_OID_LIST	*pPluginOidList, *pLogicalUnitOidList;
17577836SJohn.Forte@Sun.COM 	boolean_t				foundIt = B_FALSE;
17587836SJohn.Forte@Sun.COM 
1759*10696SDavid.Hollister@Sun.COM 	int					i, lu;
17607836SJohn.Forte@Sun.COM 
17617836SJohn.Forte@Sun.COM 	int 					fd1, fd2;
1762*10696SDavid.Hollister@Sun.COM 	ddi_devid_t				devid1, devid2;
17637836SJohn.Forte@Sun.COM 
17647836SJohn.Forte@Sun.COM 	if (NULL == pluOid) {
17657836SJohn.Forte@Sun.COM 		/* print some kind of error msg here - should never happen */
17667836SJohn.Forte@Sun.COM 		/* LINTED E_SEC_PRINTF_VAR_FMT */
17677836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, getTextString(ERR_MEMORY_ALLOCATION));
17687836SJohn.Forte@Sun.COM 		(void) printf("\n");
17697836SJohn.Forte@Sun.COM 		return (B_FALSE);
17707836SJohn.Forte@Sun.COM 	}
17717836SJohn.Forte@Sun.COM 
17727836SJohn.Forte@Sun.COM 	pluOid->objectSequenceNumber = 0;
17737836SJohn.Forte@Sun.COM 	pluOid->objectType = 0;
17747836SJohn.Forte@Sun.COM 	pluOid->ownerId = 0;
17757836SJohn.Forte@Sun.COM 
17767836SJohn.Forte@Sun.COM 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
1777*10696SDavid.Hollister@Sun.COM 	    != MP_STATUS_SUCCESS) {
17787836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s: %s\n", cmdName,
17797836SJohn.Forte@Sun.COM 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
17807836SJohn.Forte@Sun.COM 		return (B_FALSE);
17817836SJohn.Forte@Sun.COM 	}
17827836SJohn.Forte@Sun.COM 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
17837836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s: %s\n", cmdName,
1784*10696SDavid.Hollister@Sun.COM 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
17857836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
17867836SJohn.Forte@Sun.COM 	}
17877836SJohn.Forte@Sun.COM 	for (i = 0; i < pPluginOidList->oidCount; i++) {
17887836SJohn.Forte@Sun.COM 
17897836SJohn.Forte@Sun.COM 		/* get properties so we can list the name */
17907836SJohn.Forte@Sun.COM 		(void) memset(&pluginProps, 0, sizeof (MP_PLUGIN_PROPERTIES));
17917836SJohn.Forte@Sun.COM 		if ((mpstatus =
17927836SJohn.Forte@Sun.COM 		    MP_GetPluginProperties(pPluginOidList->oids[i],
17937836SJohn.Forte@Sun.COM 		    &pluginProps)) != MP_STATUS_SUCCESS) {
1794*10696SDavid.Hollister@Sun.COM 			(void) fprintf(stderr, "%s:  %s\n",
1795*10696SDavid.Hollister@Sun.COM 			    cmdName, getTextString(ERR_NO_PROPERTIES));
1796*10696SDavid.Hollister@Sun.COM 			return (B_FALSE);
17977836SJohn.Forte@Sun.COM 		}
17987836SJohn.Forte@Sun.COM 
17997836SJohn.Forte@Sun.COM 		/* attempt to find this logical unit */
18007836SJohn.Forte@Sun.COM 		mpstatus = MP_GetMultipathLus(pPluginOidList->oids[i],
18017836SJohn.Forte@Sun.COM 		    &pLogicalUnitOidList);
18027836SJohn.Forte@Sun.COM 		if (mpstatus != MP_STATUS_SUCCESS) {
18037836SJohn.Forte@Sun.COM 			(void) fprintf(stderr, "%s:  %s\n",
18047836SJohn.Forte@Sun.COM 			    cmdName, getTextString(ERR_NO_LU_LIST));
18057836SJohn.Forte@Sun.COM 			return (B_FALSE);
18067836SJohn.Forte@Sun.COM 		}
18077836SJohn.Forte@Sun.COM 
18087836SJohn.Forte@Sun.COM 		for (lu = 0; (lu < pLogicalUnitOidList->oidCount) &&
18097836SJohn.Forte@Sun.COM 		    (B_FALSE == foundIt); lu++) {
18107836SJohn.Forte@Sun.COM 
18117836SJohn.Forte@Sun.COM 			/* get lu properties so we can check the name */
18127836SJohn.Forte@Sun.COM 			(void) memset(&luProps, 0,
18137836SJohn.Forte@Sun.COM 			    sizeof (MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES));
18147836SJohn.Forte@Sun.COM 			mpstatus =
18157836SJohn.Forte@Sun.COM 			    MP_GetMPLogicalUnitProperties(
18167836SJohn.Forte@Sun.COM 			    pLogicalUnitOidList->oids[lu], &luProps);
18177836SJohn.Forte@Sun.COM 			if (mpstatus != MP_STATUS_SUCCESS) {
18187836SJohn.Forte@Sun.COM 				(void) fprintf(stderr, "%s:  %s\n",
18197836SJohn.Forte@Sun.COM 				    cmdName, getTextString(ERR_NO_PROPERTIES));
18207836SJohn.Forte@Sun.COM 				return (B_FALSE);
18217836SJohn.Forte@Sun.COM 			}
18227836SJohn.Forte@Sun.COM 
1823*10696SDavid.Hollister@Sun.COM 			if (compareLUName(luFileName, luProps.deviceFileName)
1824*10696SDavid.Hollister@Sun.COM 			    == B_TRUE) {
18257836SJohn.Forte@Sun.COM 				foundIt = B_TRUE;
18267836SJohn.Forte@Sun.COM 			} else {
18277836SJohn.Forte@Sun.COM 				/* user input didn't match, try via devid */
18287836SJohn.Forte@Sun.COM 				/*
18297836SJohn.Forte@Sun.COM 				 * I don't see a reason to print the error for
18307836SJohn.Forte@Sun.COM 				 * any of these since they'll get the error at
18317836SJohn.Forte@Sun.COM 				 * the end anyway
18327836SJohn.Forte@Sun.COM 				 */
18337836SJohn.Forte@Sun.COM 
18347916SHyon.Kim@Sun.COM 				fd1 = fd2 = -1;
1835*10696SDavid.Hollister@Sun.COM 				devid1 = devid2 = NULL;
18367836SJohn.Forte@Sun.COM 				if (((fd1 = open(luFileName,
1837*10696SDavid.Hollister@Sun.COM 				    O_RDONLY|O_NDELAY)) >= 0) &&
18387836SJohn.Forte@Sun.COM 				    ((fd2 = open(luProps.deviceFileName,
1839*10696SDavid.Hollister@Sun.COM 				    O_RDONLY|O_NDELAY)) >= 0) &&
18407836SJohn.Forte@Sun.COM 				    (devid_get(fd1, &devid1) == 0) &&
18417836SJohn.Forte@Sun.COM 				    (devid_get(fd2, &devid2) == 0) &&
18427836SJohn.Forte@Sun.COM 				    ((NULL != devid1) && (NULL != devid2))) {
18437836SJohn.Forte@Sun.COM 					if (0 ==
18447836SJohn.Forte@Sun.COM 					    (devid_compare(devid1, devid2))) {
18457836SJohn.Forte@Sun.COM 						foundIt = B_TRUE;
18467836SJohn.Forte@Sun.COM 					}
18477836SJohn.Forte@Sun.COM 				}
18487836SJohn.Forte@Sun.COM 
18497836SJohn.Forte@Sun.COM 				if (NULL != devid1) {
18507836SJohn.Forte@Sun.COM 					devid_free(devid1);
18517836SJohn.Forte@Sun.COM 				}
18527836SJohn.Forte@Sun.COM 				if (NULL != devid2) {
18537836SJohn.Forte@Sun.COM 					devid_free(devid2);
18547836SJohn.Forte@Sun.COM 				}
18557916SHyon.Kim@Sun.COM 
18567916SHyon.Kim@Sun.COM 				if (fd1 >= 0) {
18577916SHyon.Kim@Sun.COM 					(void) close(fd1);
18587916SHyon.Kim@Sun.COM 				}
18597916SHyon.Kim@Sun.COM 				if (fd2 >= 0) {
18607916SHyon.Kim@Sun.COM 					(void) close(fd2);
18617916SHyon.Kim@Sun.COM 				}
18627836SJohn.Forte@Sun.COM 			}
18637836SJohn.Forte@Sun.COM 			if (B_TRUE == foundIt) {
18647836SJohn.Forte@Sun.COM 				pluOid->objectSequenceNumber =
18657836SJohn.Forte@Sun.COM 				    pLogicalUnitOidList->
18667836SJohn.Forte@Sun.COM 				    oids[lu].objectSequenceNumber;
18677836SJohn.Forte@Sun.COM 				pluOid->objectType =
18687836SJohn.Forte@Sun.COM 				    pLogicalUnitOidList->
18697836SJohn.Forte@Sun.COM 				    oids[lu].objectType;
18707836SJohn.Forte@Sun.COM 				pluOid->ownerId =
18717836SJohn.Forte@Sun.COM 				    pLogicalUnitOidList->oids[lu].ownerId;
18727836SJohn.Forte@Sun.COM 			}
18737836SJohn.Forte@Sun.COM 		}
18747836SJohn.Forte@Sun.COM 	}
18757836SJohn.Forte@Sun.COM 
18767836SJohn.Forte@Sun.COM 	return (foundIt);
18777836SJohn.Forte@Sun.COM }
18787836SJohn.Forte@Sun.COM 
18797836SJohn.Forte@Sun.COM 
18807836SJohn.Forte@Sun.COM /*
18817836SJohn.Forte@Sun.COM  * ****************************************************************************
18827836SJohn.Forte@Sun.COM  *
18837836SJohn.Forte@Sun.COM  * listInitiatorPort -
18847836SJohn.Forte@Sun.COM  * 	mpathadm list initiator-port [<initiator-port name>, ...]
18857836SJohn.Forte@Sun.COM  *
18867836SJohn.Forte@Sun.COM  * operandLen	- number of operands user passed into the cli
18877836SJohn.Forte@Sun.COM  * operand	- pointer to operand list from user
18887836SJohn.Forte@Sun.COM  *
18897836SJohn.Forte@Sun.COM  * ****************************************************************************
18907836SJohn.Forte@Sun.COM  */
18917836SJohn.Forte@Sun.COM int
listInitiatorPort(int operandLen,char * operand[])18927836SJohn.Forte@Sun.COM listInitiatorPort(int operandLen, char *operand[])
18937836SJohn.Forte@Sun.COM {
18947836SJohn.Forte@Sun.COM 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
18957836SJohn.Forte@Sun.COM 	MP_INITIATOR_PORT_PROPERTIES 		initProps;
1896*10696SDavid.Hollister@Sun.COM 	MP_OID_LIST	*pPluginOidList, *pInitOidList;
18977836SJohn.Forte@Sun.COM 	boolean_t				bListIt = B_FALSE;
18987836SJohn.Forte@Sun.COM 	boolean_t				*foundOp;
18997836SJohn.Forte@Sun.COM 
1900*10696SDavid.Hollister@Sun.COM 	int		ol, i, iport;
19017836SJohn.Forte@Sun.COM 
19027836SJohn.Forte@Sun.COM 	foundOp = malloc((sizeof (boolean_t)) * operandLen);
19037836SJohn.Forte@Sun.COM 	if (NULL == foundOp) {
19047836SJohn.Forte@Sun.COM 		(void) fprintf(stdout, "%s\n",
19057836SJohn.Forte@Sun.COM 		    getTextString(ERR_MEMORY_ALLOCATION));
19067836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
19077836SJohn.Forte@Sun.COM 	}
19087836SJohn.Forte@Sun.COM 
19097836SJohn.Forte@Sun.COM 	for (ol = 0; ol < operandLen; ol++) {
19107836SJohn.Forte@Sun.COM 		foundOp[ol] = B_FALSE;
19117836SJohn.Forte@Sun.COM 	}
19127836SJohn.Forte@Sun.COM 
19137836SJohn.Forte@Sun.COM 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
1914*10696SDavid.Hollister@Sun.COM 	    != MP_STATUS_SUCCESS) {
19157836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s: %s\n", cmdName,
19167836SJohn.Forte@Sun.COM 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
19177836SJohn.Forte@Sun.COM 		return (mpstatus);
19187836SJohn.Forte@Sun.COM 	}
19197836SJohn.Forte@Sun.COM 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
19207836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s: %s\n", cmdName,
19217836SJohn.Forte@Sun.COM 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
19227836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
19237836SJohn.Forte@Sun.COM 	}
19247836SJohn.Forte@Sun.COM 
19257836SJohn.Forte@Sun.COM 	for (i = 0; i < pPluginOidList->oidCount; i++) {
19267836SJohn.Forte@Sun.COM 		mpstatus =
19277836SJohn.Forte@Sun.COM 		    MP_GetInitiatorPortOidList(pPluginOidList->oids[i],
19287836SJohn.Forte@Sun.COM 		    &pInitOidList);
19297836SJohn.Forte@Sun.COM 		if (mpstatus != MP_STATUS_SUCCESS) {
19307836SJohn.Forte@Sun.COM 			/* LINTED E_SEC_PRINTF_VAR_FMT */
19317836SJohn.Forte@Sun.COM 			(void) fprintf(stderr,
19327836SJohn.Forte@Sun.COM 			    getTextString(ERR_NO_INIT_PORT_LIST_WITH_REASON),
19337836SJohn.Forte@Sun.COM 			    getMpStatusStr(mpstatus));
19347836SJohn.Forte@Sun.COM 			(void) printf("\n");
19357836SJohn.Forte@Sun.COM 		} else if ((NULL == pInitOidList) ||
1936*10696SDavid.Hollister@Sun.COM 		    (pInitOidList->oidCount < 1)) {
19377836SJohn.Forte@Sun.COM 			(void) fprintf(stderr, "%s: %s\n", cmdName,
19387836SJohn.Forte@Sun.COM 			    getTextString(ERR_NO_INIT_PORTS));
19397836SJohn.Forte@Sun.COM 		} else {
19407836SJohn.Forte@Sun.COM 			for (iport = 0;
19417836SJohn.Forte@Sun.COM 			    iport < pInitOidList->oidCount; iport ++) {
19427836SJohn.Forte@Sun.COM 				bListIt = B_FALSE;
19437836SJohn.Forte@Sun.COM 				if ((mpstatus =
19447836SJohn.Forte@Sun.COM 				    MP_GetInitiatorPortProperties(
19457836SJohn.Forte@Sun.COM 				    pInitOidList->oids[iport],
19467836SJohn.Forte@Sun.COM 				    &initProps)) != MP_STATUS_SUCCESS) {
19477836SJohn.Forte@Sun.COM 					(void) fprintf(stderr,
19487836SJohn.Forte@Sun.COM 					    "%s: %s\n", cmdName,
19497836SJohn.Forte@Sun.COM 					    getTextString(ERR_NO_PROPERTIES));
19507836SJohn.Forte@Sun.COM 				} else {
19517836SJohn.Forte@Sun.COM 					/* if no operands listed, */
19527836SJohn.Forte@Sun.COM 					/* list all we find */
19537836SJohn.Forte@Sun.COM 					if (0 == operandLen) {
19547836SJohn.Forte@Sun.COM 						bListIt = B_TRUE;
19557836SJohn.Forte@Sun.COM 					} else {
19567836SJohn.Forte@Sun.COM 
19577836SJohn.Forte@Sun.COM 						/* check each operand */
19587836SJohn.Forte@Sun.COM 						/* Is it */
19597836SJohn.Forte@Sun.COM 						/* the one we want to list? */
19607836SJohn.Forte@Sun.COM 						for (ol = 0;
19617836SJohn.Forte@Sun.COM 						    ol < operandLen; ol++) {
19627836SJohn.Forte@Sun.COM 							if (0 ==
19637836SJohn.Forte@Sun.COM 							    strcmp(operand[ol],
19647836SJohn.Forte@Sun.COM 							    initProps.
19657836SJohn.Forte@Sun.COM 							    portID)) {
19667836SJohn.Forte@Sun.COM 								bListIt =
19677836SJohn.Forte@Sun.COM 								    B_TRUE;
19687836SJohn.Forte@Sun.COM 								foundOp[ol] =
19697836SJohn.Forte@Sun.COM 								    B_TRUE;
19707836SJohn.Forte@Sun.COM 							}
19717836SJohn.Forte@Sun.COM 						}
19727836SJohn.Forte@Sun.COM 					}
19737836SJohn.Forte@Sun.COM 				}
19747836SJohn.Forte@Sun.COM 
19757836SJohn.Forte@Sun.COM 				if (B_TRUE == bListIt) {
19767836SJohn.Forte@Sun.COM 
19777836SJohn.Forte@Sun.COM 					if (listIndividualInitiatorPort(
19787836SJohn.Forte@Sun.COM 					    initProps) != 0) {
19797836SJohn.Forte@Sun.COM 						return (ERROR_CLI_FAILED);
19807836SJohn.Forte@Sun.COM 					}
19817836SJohn.Forte@Sun.COM 
19827836SJohn.Forte@Sun.COM 				} /* list It */
19837836SJohn.Forte@Sun.COM 
19847836SJohn.Forte@Sun.COM 			} /* for each initiator port */
19857836SJohn.Forte@Sun.COM 		} /* else found an init port */
19867836SJohn.Forte@Sun.COM 
19877836SJohn.Forte@Sun.COM 	} /* for each plugin */
19887836SJohn.Forte@Sun.COM 
19897836SJohn.Forte@Sun.COM 	for (ol = 0; ol < operandLen; ol++) {
19907836SJohn.Forte@Sun.COM 		if (B_FALSE == foundOp[ol]) {
19917836SJohn.Forte@Sun.COM 			/* LINTED E_SEC_PRINTF_VAR_FMT */
19927836SJohn.Forte@Sun.COM 			(void) fprintf(stderr, getTextString(
19937836SJohn.Forte@Sun.COM 			    ERR_INIT_PORT_NOT_FOUND_WITH_MISSING_LU_STR),
19947836SJohn.Forte@Sun.COM 			    operand[ol]);
19957836SJohn.Forte@Sun.COM 			(void) printf("\n");
19967836SJohn.Forte@Sun.COM 		}
19977836SJohn.Forte@Sun.COM 	}
19987836SJohn.Forte@Sun.COM 
19997836SJohn.Forte@Sun.COM 	return (mpstatus);
20007836SJohn.Forte@Sun.COM }
20017836SJohn.Forte@Sun.COM 
20027836SJohn.Forte@Sun.COM 
20037836SJohn.Forte@Sun.COM /*
20047836SJohn.Forte@Sun.COM  * ****************************************************************************
20057836SJohn.Forte@Sun.COM  *
20067836SJohn.Forte@Sun.COM  * listIndividualInitiatorPort -
20077836SJohn.Forte@Sun.COM  * 	used by listInitiatorPort to list info for one init port
20087836SJohn.Forte@Sun.COM  *
20097836SJohn.Forte@Sun.COM  * initProps	- properties of initiator port to list
20107836SJohn.Forte@Sun.COM  *
20117836SJohn.Forte@Sun.COM  * ****************************************************************************
20127836SJohn.Forte@Sun.COM  */
20137836SJohn.Forte@Sun.COM int
listIndividualInitiatorPort(MP_INITIATOR_PORT_PROPERTIES initProps)20147836SJohn.Forte@Sun.COM listIndividualInitiatorPort(MP_INITIATOR_PORT_PROPERTIES initProps)
20157836SJohn.Forte@Sun.COM {
20167836SJohn.Forte@Sun.COM 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
20177836SJohn.Forte@Sun.COM 
20187836SJohn.Forte@Sun.COM 	(void) printf("%s  ", getTextString(TEXT_LB_INITATOR_PORT));
20197836SJohn.Forte@Sun.COM 	displayArray(initProps.portID,
2020*10696SDavid.Hollister@Sun.COM 	    sizeof (initProps.portID));
20217836SJohn.Forte@Sun.COM 	(void) printf("\n");
20227836SJohn.Forte@Sun.COM 
20237836SJohn.Forte@Sun.COM 	return (mpstatus);
20247836SJohn.Forte@Sun.COM 
20257836SJohn.Forte@Sun.COM }
20267836SJohn.Forte@Sun.COM 
20277836SJohn.Forte@Sun.COM 
20287836SJohn.Forte@Sun.COM /*
20297836SJohn.Forte@Sun.COM  * ****************************************************************************
20307836SJohn.Forte@Sun.COM  *
20317836SJohn.Forte@Sun.COM  * showInitiatorPort -
20327836SJohn.Forte@Sun.COM  * 	mpathadm show initiator-port <initiator-port name>, ...
20337836SJohn.Forte@Sun.COM  *
20347836SJohn.Forte@Sun.COM  * operandLen	- number of operands user passed into the cli
20357836SJohn.Forte@Sun.COM  * operand	- pointer to operand list from user
20367836SJohn.Forte@Sun.COM  *
20377836SJohn.Forte@Sun.COM  * ****************************************************************************
20387836SJohn.Forte@Sun.COM  */
20397836SJohn.Forte@Sun.COM int
showInitiatorPort(int operandLen,char * operand[])20407836SJohn.Forte@Sun.COM showInitiatorPort(int operandLen, char *operand[])
20417836SJohn.Forte@Sun.COM {
20427836SJohn.Forte@Sun.COM 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
20437836SJohn.Forte@Sun.COM 	MP_INITIATOR_PORT_PROPERTIES 		initProps;
2044*10696SDavid.Hollister@Sun.COM 	MP_OID_LIST	*pPluginOidList, *pInitOidList;
2045*10696SDavid.Hollister@Sun.COM 	boolean_t	bListIt = B_FALSE, bFoundIt = B_FALSE;
2046*10696SDavid.Hollister@Sun.COM 	int		op, i, iport;
20477836SJohn.Forte@Sun.COM 
20487836SJohn.Forte@Sun.COM 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
2049*10696SDavid.Hollister@Sun.COM 	    != MP_STATUS_SUCCESS) {
20507836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s: %s\n", cmdName,
20517836SJohn.Forte@Sun.COM 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
20527836SJohn.Forte@Sun.COM 		return (mpstatus);
20537836SJohn.Forte@Sun.COM 	}
20547836SJohn.Forte@Sun.COM 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
20557836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s: %s\n", cmdName,
20567836SJohn.Forte@Sun.COM 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
20577836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
20587836SJohn.Forte@Sun.COM 	}
20597836SJohn.Forte@Sun.COM 
20607836SJohn.Forte@Sun.COM 	for (op = 0; op < operandLen; op++) {
20617836SJohn.Forte@Sun.COM 	bFoundIt = B_FALSE;
20627836SJohn.Forte@Sun.COM 
20637836SJohn.Forte@Sun.COM 		for (i = 0; i < pPluginOidList->oidCount; i++) {
20647836SJohn.Forte@Sun.COM 
20657836SJohn.Forte@Sun.COM 			mpstatus =
20667836SJohn.Forte@Sun.COM 			    MP_GetInitiatorPortOidList(pPluginOidList->oids[i],
20677836SJohn.Forte@Sun.COM 			    &pInitOidList);
20687836SJohn.Forte@Sun.COM 			if (mpstatus != MP_STATUS_SUCCESS) {
20697836SJohn.Forte@Sun.COM 				/* LINTED E_SEC_PRINTF_VAR_FMT */
20707836SJohn.Forte@Sun.COM 				(void) fprintf(stderr,
20717836SJohn.Forte@Sun.COM 				    getTextString(
20727836SJohn.Forte@Sun.COM 				    ERR_NO_INIT_PORT_LIST_WITH_REASON),
20737836SJohn.Forte@Sun.COM 				    getMpStatusStr(mpstatus));
20747836SJohn.Forte@Sun.COM 				(void) printf("\n");
20757836SJohn.Forte@Sun.COM 			} else if ((NULL == pInitOidList) ||
20767836SJohn.Forte@Sun.COM 			    (pInitOidList->oidCount < 1)) {
20777836SJohn.Forte@Sun.COM 				(void) fprintf(stderr, "%s: %s\n", cmdName,
20787836SJohn.Forte@Sun.COM 				    getTextString(ERR_NO_INIT_PORTS));
20797836SJohn.Forte@Sun.COM 			} else {
20807836SJohn.Forte@Sun.COM 
20817836SJohn.Forte@Sun.COM 				for (iport = 0;
20827836SJohn.Forte@Sun.COM 				    iport < pInitOidList->oidCount;
20837836SJohn.Forte@Sun.COM 				    iport ++) {
20847836SJohn.Forte@Sun.COM 					bListIt = B_FALSE;
20857836SJohn.Forte@Sun.COM 
20867836SJohn.Forte@Sun.COM 					if ((mpstatus =
20877836SJohn.Forte@Sun.COM 					    MP_GetInitiatorPortProperties(
20887836SJohn.Forte@Sun.COM 					    pInitOidList->oids[iport],
20897836SJohn.Forte@Sun.COM 					    &initProps))
20907836SJohn.Forte@Sun.COM 					    != MP_STATUS_SUCCESS) {
2091*10696SDavid.Hollister@Sun.COM 					/* begin back-up indentation */
2092*10696SDavid.Hollister@Sun.COM 					(void) fprintf(stderr,
2093*10696SDavid.Hollister@Sun.COM 					    "%s: %s\n", cmdName,
20947836SJohn.Forte@Sun.COM 					    getTextString(ERR_NO_PROPERTIES));
2095*10696SDavid.Hollister@Sun.COM 					/* end back-up indentation */
20967836SJohn.Forte@Sun.COM 					} else {
20977836SJohn.Forte@Sun.COM 						if (0 == strcmp(operand[op],
20987836SJohn.Forte@Sun.COM 						    initProps.portID)) {
20997836SJohn.Forte@Sun.COM 							bListIt = B_TRUE;
21007836SJohn.Forte@Sun.COM 							bFoundIt = B_TRUE;
21017836SJohn.Forte@Sun.COM 						}
21027836SJohn.Forte@Sun.COM 					}
21037836SJohn.Forte@Sun.COM 
21047836SJohn.Forte@Sun.COM 					if (B_TRUE == bListIt) {
21057836SJohn.Forte@Sun.COM 						mpstatus =
2106*10696SDavid.Hollister@Sun.COM 						    showIndividualInitiatorPort(
2107*10696SDavid.Hollister@Sun.COM 						    initProps);
21087836SJohn.Forte@Sun.COM 						if (0 != mpstatus) {
21097836SJohn.Forte@Sun.COM 							return (mpstatus);
21107836SJohn.Forte@Sun.COM 						}
21117836SJohn.Forte@Sun.COM 
21127836SJohn.Forte@Sun.COM 					} /* list It */
21137836SJohn.Forte@Sun.COM 
21147836SJohn.Forte@Sun.COM 				} /* for each initiator port */
21157836SJohn.Forte@Sun.COM 			} /* else found an init port */
21167836SJohn.Forte@Sun.COM 
21177836SJohn.Forte@Sun.COM 		} /* for each plugin */
21187836SJohn.Forte@Sun.COM 
21197836SJohn.Forte@Sun.COM 		if (B_FALSE == bFoundIt) {
21207836SJohn.Forte@Sun.COM 			/* need temp string here since we need to fill in a */
21217836SJohn.Forte@Sun.COM 			/* name in the error string */
21227836SJohn.Forte@Sun.COM 			/* LINTED E_SEC_PRINTF_VAR_FMT */
21237836SJohn.Forte@Sun.COM 			(void) fprintf(stderr, getTextString(
21247836SJohn.Forte@Sun.COM 			    ERR_INIT_PORT_NOT_FOUND_WITH_MISSING_LU_STR),
21257836SJohn.Forte@Sun.COM 			    operand[op]);
21267836SJohn.Forte@Sun.COM 			(void) printf("\n");
21277836SJohn.Forte@Sun.COM 		}
21287836SJohn.Forte@Sun.COM 
21297836SJohn.Forte@Sun.COM 	} /* for each operand */
21307836SJohn.Forte@Sun.COM 
21317836SJohn.Forte@Sun.COM 	return (mpstatus);
21327836SJohn.Forte@Sun.COM }
21337836SJohn.Forte@Sun.COM 
21347836SJohn.Forte@Sun.COM 
21357836SJohn.Forte@Sun.COM /*
21367836SJohn.Forte@Sun.COM  * ****************************************************************************
21377836SJohn.Forte@Sun.COM  *
21387836SJohn.Forte@Sun.COM  * showIndividualInitiatorPort -
21397836SJohn.Forte@Sun.COM  * 	used by showInitiatorPort to show info for one init port
21407836SJohn.Forte@Sun.COM  *
21417836SJohn.Forte@Sun.COM  * initProps	- properties of initiator port to show
21427836SJohn.Forte@Sun.COM  *
21437836SJohn.Forte@Sun.COM  * ****************************************************************************
21447836SJohn.Forte@Sun.COM  */
21457836SJohn.Forte@Sun.COM int
showIndividualInitiatorPort(MP_INITIATOR_PORT_PROPERTIES initProps)21467836SJohn.Forte@Sun.COM showIndividualInitiatorPort(MP_INITIATOR_PORT_PROPERTIES initProps)
21477836SJohn.Forte@Sun.COM {
21487836SJohn.Forte@Sun.COM 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
21497836SJohn.Forte@Sun.COM 
21507836SJohn.Forte@Sun.COM 	(void) printf("%s  ", getTextString(TEXT_LB_INITATOR_PORT));
21517836SJohn.Forte@Sun.COM 	displayArray(initProps.portID,
21527836SJohn.Forte@Sun.COM 	    sizeof (initProps.portID));
21537836SJohn.Forte@Sun.COM 
21547836SJohn.Forte@Sun.COM 	(void) printf("\n\t%s  ", getTextString(TEXT_LB_TRANSPORT_TYPE));
21557836SJohn.Forte@Sun.COM 	displayTransportTypeString(initProps.portType);
21567836SJohn.Forte@Sun.COM 	(void) printf("\n");
21577836SJohn.Forte@Sun.COM 
21587836SJohn.Forte@Sun.COM 	(void) printf("\t%s  ", getTextString(TEXT_LB_OS_DEVICE_FILE));
21597836SJohn.Forte@Sun.COM 	displayArray(initProps.osDeviceFile,
21607836SJohn.Forte@Sun.COM 	    sizeof (initProps.osDeviceFile));
21617836SJohn.Forte@Sun.COM 	(void) printf("\n");
21627836SJohn.Forte@Sun.COM 
21637836SJohn.Forte@Sun.COM 	return (mpstatus);
21647836SJohn.Forte@Sun.COM }
21657836SJohn.Forte@Sun.COM 
21667836SJohn.Forte@Sun.COM 
21677836SJohn.Forte@Sun.COM /*
21687836SJohn.Forte@Sun.COM  * ****************************************************************************
21697836SJohn.Forte@Sun.COM  *
21707836SJohn.Forte@Sun.COM  * enablePath -
21717836SJohn.Forte@Sun.COM  * 	mpathadm enable path -i <initiator-port>
21727836SJohn.Forte@Sun.COM  *		-t <target-port name> -l <logical-unit name>
21737836SJohn.Forte@Sun.COM  *
21747836SJohn.Forte@Sun.COM  * options	- pointer to option list from user
21757836SJohn.Forte@Sun.COM  *
21767836SJohn.Forte@Sun.COM  * ****************************************************************************
21777836SJohn.Forte@Sun.COM  */
21787836SJohn.Forte@Sun.COM int
enablePath(cmdOptions_t * options)21797836SJohn.Forte@Sun.COM enablePath(cmdOptions_t *options)
21807836SJohn.Forte@Sun.COM {
21817836SJohn.Forte@Sun.COM 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
21827836SJohn.Forte@Sun.COM 	MP_OID					pathOid;
21837836SJohn.Forte@Sun.COM 
21847836SJohn.Forte@Sun.COM 	cmdOptions_t 				*optionList = options;
2185*10696SDavid.Hollister@Sun.COM 	boolean_t   bHaveInit = B_FALSE, bHaveTarg = B_FALSE, bHaveLu = B_FALSE;
21867836SJohn.Forte@Sun.COM 
21877836SJohn.Forte@Sun.COM 	for (; optionList->optval; optionList++) {
21887836SJohn.Forte@Sun.COM 		switch (optionList->optval) {
21897836SJohn.Forte@Sun.COM 			case 'i':
21907836SJohn.Forte@Sun.COM 				/* have init port name */
21917836SJohn.Forte@Sun.COM 				bHaveInit = B_TRUE;
21927836SJohn.Forte@Sun.COM 				break;
21937836SJohn.Forte@Sun.COM 			case 't':
21947836SJohn.Forte@Sun.COM 				/* have target port id */
21957836SJohn.Forte@Sun.COM 				bHaveTarg = B_TRUE;
21967836SJohn.Forte@Sun.COM 				break;
21977836SJohn.Forte@Sun.COM 			case 'l':
21987836SJohn.Forte@Sun.COM 				/* have LU name */
21997836SJohn.Forte@Sun.COM 				bHaveLu = B_TRUE;
22007836SJohn.Forte@Sun.COM 				break;
22017836SJohn.Forte@Sun.COM 		}
22027836SJohn.Forte@Sun.COM 	}
22037836SJohn.Forte@Sun.COM 	if (B_FALSE == bHaveInit) {
22047836SJohn.Forte@Sun.COM 		/* LINTED E_SEC_PRINTF_VAR_FMT */
22057836SJohn.Forte@Sun.COM 		(void) fprintf(stderr,
22067836SJohn.Forte@Sun.COM 		    getTextString(ERR_FAILED_TO_ENABLE_PATH_WITH_REASON),
22077836SJohn.Forte@Sun.COM 		    getTextString(MISSING_INIT_PORT_NAME));
22087836SJohn.Forte@Sun.COM 		(void) printf("\n");
22097836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
22107836SJohn.Forte@Sun.COM 	} else if (B_FALSE == bHaveTarg) {
22117836SJohn.Forte@Sun.COM 		/* LINTED E_SEC_PRINTF_VAR_FMT */
22127836SJohn.Forte@Sun.COM 		(void) fprintf(stderr,
22137836SJohn.Forte@Sun.COM 		    getTextString(ERR_FAILED_TO_ENABLE_PATH_WITH_REASON),
22147836SJohn.Forte@Sun.COM 		    getTextString(MISSING_TARGET_PORT_NAME));
22157836SJohn.Forte@Sun.COM 		(void) printf("\n");
22167836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
22177836SJohn.Forte@Sun.COM 	} else if (B_FALSE == bHaveLu) {
22187836SJohn.Forte@Sun.COM 		/* LINTED E_SEC_PRINTF_VAR_FMT */
22197836SJohn.Forte@Sun.COM 		(void) fprintf(stderr,
22207836SJohn.Forte@Sun.COM 		    getTextString(ERR_FAILED_TO_ENABLE_PATH_WITH_REASON),
22217836SJohn.Forte@Sun.COM 		    getTextString(MISSING_LU_NAME));
22227836SJohn.Forte@Sun.COM 		(void) printf("\n");
22237836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
22247836SJohn.Forte@Sun.COM 	}
22257836SJohn.Forte@Sun.COM 
22267836SJohn.Forte@Sun.COM 	if (B_FALSE == getPathOid(options, &pathOid)) {
22277836SJohn.Forte@Sun.COM 		/* LINTED E_SEC_PRINTF_VAR_FMT */
22287836SJohn.Forte@Sun.COM 		(void) fprintf(stderr,
22297836SJohn.Forte@Sun.COM 		    getTextString(ERR_FAILED_TO_ENABLE_PATH_WITH_REASON),
22307836SJohn.Forte@Sun.COM 		    getTextString(FAILED_TO_FIND_PATH));
22317836SJohn.Forte@Sun.COM 		(void) printf("\n");
22327836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
22337836SJohn.Forte@Sun.COM 	}
22347836SJohn.Forte@Sun.COM 
22357836SJohn.Forte@Sun.COM 	/* found the path, attempt to enable it */
22367836SJohn.Forte@Sun.COM 	mpstatus =  MP_EnablePath(pathOid);
22377836SJohn.Forte@Sun.COM 	if (mpstatus != MP_STATUS_SUCCESS) {
22387836SJohn.Forte@Sun.COM 		/* LINTED E_SEC_PRINTF_VAR_FMT */
22397836SJohn.Forte@Sun.COM 		(void) fprintf(stderr,
22407836SJohn.Forte@Sun.COM 		    getTextString(ERR_FAILED_TO_ENABLE_PATH_WITH_REASON),
22417836SJohn.Forte@Sun.COM 		    getMpStatusStr(mpstatus));
22427836SJohn.Forte@Sun.COM 		(void) printf("\n");
22437836SJohn.Forte@Sun.COM 		return (mpstatus);
22447836SJohn.Forte@Sun.COM 	}
22457836SJohn.Forte@Sun.COM 
22467836SJohn.Forte@Sun.COM 	return (mpstatus);
22477836SJohn.Forte@Sun.COM }
22487836SJohn.Forte@Sun.COM 
22497836SJohn.Forte@Sun.COM 
22507836SJohn.Forte@Sun.COM /*
22517836SJohn.Forte@Sun.COM  * ****************************************************************************
22527836SJohn.Forte@Sun.COM  *
22537836SJohn.Forte@Sun.COM  * disablePath -
22547836SJohn.Forte@Sun.COM  * 	mpathadm disable path -i <initiator-port>
22557836SJohn.Forte@Sun.COM  *		-t <target-port name> -l <logical-unit name>
22567836SJohn.Forte@Sun.COM  *
22577836SJohn.Forte@Sun.COM  * options	- pointer to option list from user
22587836SJohn.Forte@Sun.COM  *
22597836SJohn.Forte@Sun.COM  * ****************************************************************************
22607836SJohn.Forte@Sun.COM  */
22617836SJohn.Forte@Sun.COM int
disablePath(cmdOptions_t * options)22627836SJohn.Forte@Sun.COM disablePath(cmdOptions_t *options)
22637836SJohn.Forte@Sun.COM {
22647836SJohn.Forte@Sun.COM 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
22657836SJohn.Forte@Sun.COM 	MP_OID					pathOid;
22667836SJohn.Forte@Sun.COM 
22677836SJohn.Forte@Sun.COM 	cmdOptions_t 				*optionList = options;
2268*10696SDavid.Hollister@Sun.COM 	boolean_t	bHaveInit = B_FALSE, bHaveTarg = B_FALSE,
2269*10696SDavid.Hollister@Sun.COM 	    bHaveLu = B_FALSE;
22707836SJohn.Forte@Sun.COM 
22717836SJohn.Forte@Sun.COM 	for (; optionList->optval; optionList++) {
22727836SJohn.Forte@Sun.COM 		switch (optionList->optval) {
22737836SJohn.Forte@Sun.COM 			case 'i':
22747836SJohn.Forte@Sun.COM 				/* have init port name */
22757836SJohn.Forte@Sun.COM 				bHaveInit = B_TRUE;
22767836SJohn.Forte@Sun.COM 				break;
22777836SJohn.Forte@Sun.COM 			case 't':
22787836SJohn.Forte@Sun.COM 				/* have target port id */
22797836SJohn.Forte@Sun.COM 				bHaveTarg = B_TRUE;
22807836SJohn.Forte@Sun.COM 				break;
22817836SJohn.Forte@Sun.COM 			case 'l':
22827836SJohn.Forte@Sun.COM 				/* have LU name */
22837836SJohn.Forte@Sun.COM 				bHaveLu = B_TRUE;
22847836SJohn.Forte@Sun.COM 				break;
22857836SJohn.Forte@Sun.COM 		}
22867836SJohn.Forte@Sun.COM 	}
22877836SJohn.Forte@Sun.COM 	if (B_FALSE == bHaveInit) {
22887836SJohn.Forte@Sun.COM 		/* LINTED E_SEC_PRINTF_VAR_FMT */
22897836SJohn.Forte@Sun.COM 		(void) fprintf(stderr,
22907836SJohn.Forte@Sun.COM 		    getTextString(ERR_FAILED_TO_DISABLE_PATH_WITH_REASON),
22917836SJohn.Forte@Sun.COM 		    getTextString(MISSING_INIT_PORT_NAME));
22927836SJohn.Forte@Sun.COM 		(void) printf("\n");
22937836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
22947836SJohn.Forte@Sun.COM 	} else if (B_FALSE == bHaveTarg) {
22957836SJohn.Forte@Sun.COM 		/* LINTED E_SEC_PRINTF_VAR_FMT */
22967836SJohn.Forte@Sun.COM 		(void) fprintf(stderr,
22977836SJohn.Forte@Sun.COM 		    getTextString(ERR_FAILED_TO_DISABLE_PATH_WITH_REASON),
22987836SJohn.Forte@Sun.COM 		    getTextString(MISSING_TARGET_PORT_NAME));
22997836SJohn.Forte@Sun.COM 		(void) printf("\n");
23007836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
23017836SJohn.Forte@Sun.COM 	} else if (B_FALSE == bHaveLu) {
23027836SJohn.Forte@Sun.COM 		/* LINTED E_SEC_PRINTF_VAR_FMT */
23037836SJohn.Forte@Sun.COM 		(void) fprintf(stderr,
23047836SJohn.Forte@Sun.COM 		    getTextString(ERR_FAILED_TO_DISABLE_PATH_WITH_REASON),
23057836SJohn.Forte@Sun.COM 		    getTextString(MISSING_LU_NAME));
23067836SJohn.Forte@Sun.COM 		(void) printf("\n");
23077836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
23087836SJohn.Forte@Sun.COM 	}
23097836SJohn.Forte@Sun.COM 
23107836SJohn.Forte@Sun.COM 	if (B_FALSE == getPathOid(options, &pathOid)) {
23117836SJohn.Forte@Sun.COM 		/* LINTED E_SEC_PRINTF_VAR_FMT */
23127836SJohn.Forte@Sun.COM 		(void) fprintf(stderr,
23137836SJohn.Forte@Sun.COM 		    getTextString(ERR_FAILED_TO_DISABLE_PATH_WITH_REASON),
23147836SJohn.Forte@Sun.COM 		    getTextString(FAILED_TO_FIND_PATH));
23157836SJohn.Forte@Sun.COM 		(void) printf("\n");
23167836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
23177836SJohn.Forte@Sun.COM 	}
23187836SJohn.Forte@Sun.COM 
23197836SJohn.Forte@Sun.COM 	/* found the path, attempt to enable it */
23207836SJohn.Forte@Sun.COM 	mpstatus =  MP_DisablePath(pathOid);
23217836SJohn.Forte@Sun.COM 	if (MP_STATUS_SUCCESS != mpstatus) {
23227836SJohn.Forte@Sun.COM 		/* LINTED E_SEC_PRINTF_VAR_FMT */
23237836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, getTextString(
23247836SJohn.Forte@Sun.COM 		    ERR_FAILED_TO_DISABLE_PATH_WITH_REASON),
23257836SJohn.Forte@Sun.COM 		    getMpStatusStr(mpstatus));
23267836SJohn.Forte@Sun.COM 		(void) printf("\n");
23277836SJohn.Forte@Sun.COM 		return (mpstatus);
23287836SJohn.Forte@Sun.COM 	}
23297836SJohn.Forte@Sun.COM 
23307836SJohn.Forte@Sun.COM 
23317836SJohn.Forte@Sun.COM 	return (mpstatus);
23327836SJohn.Forte@Sun.COM }
23337836SJohn.Forte@Sun.COM 
23347836SJohn.Forte@Sun.COM 
23357836SJohn.Forte@Sun.COM /*
23367836SJohn.Forte@Sun.COM  * ****************************************************************************
23377836SJohn.Forte@Sun.COM  *
23387836SJohn.Forte@Sun.COM  * overridePath -
23397836SJohn.Forte@Sun.COM  * 	mpathadm override path {-i <initiator-port>
23407836SJohn.Forte@Sun.COM  *		-t <target-port name> | -c} <logical-unit name>
23417836SJohn.Forte@Sun.COM  *
23427836SJohn.Forte@Sun.COM  * options	- pointer to option list from user
23437836SJohn.Forte@Sun.COM  *
23447836SJohn.Forte@Sun.COM  * ****************************************************************************
23457836SJohn.Forte@Sun.COM  */
23467836SJohn.Forte@Sun.COM int
overridePath(cmdOptions_t * options)23477836SJohn.Forte@Sun.COM overridePath(cmdOptions_t *options)
23487836SJohn.Forte@Sun.COM {
23497836SJohn.Forte@Sun.COM 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
23507836SJohn.Forte@Sun.COM 	MP_OID					pathOid, luOid;
23517836SJohn.Forte@Sun.COM 	boolean_t				bCancelOverride = B_FALSE;
23527836SJohn.Forte@Sun.COM 	MP_CHAR					pLuDeviceFileName[256];
23537836SJohn.Forte@Sun.COM 	cmdOptions_t 				*optionList = options;
23547836SJohn.Forte@Sun.COM 
23557836SJohn.Forte@Sun.COM 	/* First check to see if we have the cancel option, */
23567836SJohn.Forte@Sun.COM 	/* May as well save off the lun while we're at it */
23577836SJohn.Forte@Sun.COM 	for (; optionList->optval; optionList++) {
23587836SJohn.Forte@Sun.COM 		switch (optionList->optval) {
23597836SJohn.Forte@Sun.COM 			case 'c':
23607836SJohn.Forte@Sun.COM 				/* we have a cancel */
23617836SJohn.Forte@Sun.COM 				bCancelOverride = B_TRUE;
23627836SJohn.Forte@Sun.COM 				break;
23637836SJohn.Forte@Sun.COM 			case 'l':
23647836SJohn.Forte@Sun.COM 				/* we have a lun- save it while we're here */
23657836SJohn.Forte@Sun.COM 				(void) memcpy(pLuDeviceFileName,
23667836SJohn.Forte@Sun.COM 				    optionList->optarg, 256);
23677836SJohn.Forte@Sun.COM 				break;
23687836SJohn.Forte@Sun.COM 		}
23697836SJohn.Forte@Sun.COM 	}
23707836SJohn.Forte@Sun.COM 
23717836SJohn.Forte@Sun.COM 	if (B_TRUE == bCancelOverride) {
23727836SJohn.Forte@Sun.COM 		/* if we have the cancel option, */
23737836SJohn.Forte@Sun.COM 		if (getLogicalUnitOid(pLuDeviceFileName, &luOid) == B_FALSE) {
23747836SJohn.Forte@Sun.COM 			/* LINTED E_SEC_PRINTF_VAR_FMT */
23757836SJohn.Forte@Sun.COM 			(void) fprintf(stderr,
23767836SJohn.Forte@Sun.COM 			    getTextString(
23777836SJohn.Forte@Sun.COM 			    ERR_FAILED_TO_CANCEL_OVERRIDE_PATH_WITH_REASON),
23787836SJohn.Forte@Sun.COM 			    getTextString(LU_NOT_FOUND));
23797836SJohn.Forte@Sun.COM 			(void) printf("\n");
23807836SJohn.Forte@Sun.COM 			return (ERROR_CLI_FAILED);
23817836SJohn.Forte@Sun.COM 		}
23827836SJohn.Forte@Sun.COM 
23837836SJohn.Forte@Sun.COM 		/* cancel the override path for the specified LU */
23847836SJohn.Forte@Sun.COM 		mpstatus = MP_CancelOverridePath(luOid);
23857836SJohn.Forte@Sun.COM 		if (MP_STATUS_SUCCESS != mpstatus) {
23867836SJohn.Forte@Sun.COM 			/* LINTED E_SEC_PRINTF_VAR_FMT */
23877836SJohn.Forte@Sun.COM 			(void) fprintf(stderr,
23887836SJohn.Forte@Sun.COM 			    getTextString(
23897836SJohn.Forte@Sun.COM 			    ERR_FAILED_TO_CANCEL_OVERRIDE_PATH_WITH_REASON),
23907836SJohn.Forte@Sun.COM 			    getMpStatusStr(mpstatus));
23917836SJohn.Forte@Sun.COM 			(void) printf("\n");
23927836SJohn.Forte@Sun.COM 			return (mpstatus);
23937836SJohn.Forte@Sun.COM 		}
23947836SJohn.Forte@Sun.COM 	} else {
23957836SJohn.Forte@Sun.COM 		/* must be wanting to override the path */
23967836SJohn.Forte@Sun.COM 		if (getLogicalUnitOid(pLuDeviceFileName, &luOid) == B_FALSE) {
23977836SJohn.Forte@Sun.COM 			/* LINTED E_SEC_PRINTF_VAR_FMT */
23987836SJohn.Forte@Sun.COM 			(void) fprintf(stderr,
23997836SJohn.Forte@Sun.COM 			    getTextString(
24007836SJohn.Forte@Sun.COM 			    ERR_FAILED_TO_OVERRIDE_PATH_WITH_REASON),
24017836SJohn.Forte@Sun.COM 			    getTextString(LU_NOT_FOUND));
24027836SJohn.Forte@Sun.COM 			(void) printf("\n");
24037836SJohn.Forte@Sun.COM 			return (ERROR_CLI_FAILED);
24047836SJohn.Forte@Sun.COM 		}
24057836SJohn.Forte@Sun.COM 
24067836SJohn.Forte@Sun.COM 		if (B_FALSE == getPathOid(options, &pathOid)) {
24077836SJohn.Forte@Sun.COM 			/* LINTED E_SEC_PRINTF_VAR_FMT */
24087836SJohn.Forte@Sun.COM 			(void) fprintf(stderr,
24097836SJohn.Forte@Sun.COM 			    getTextString(
24107836SJohn.Forte@Sun.COM 			    ERR_FAILED_TO_OVERRIDE_PATH_WITH_REASON),
24117836SJohn.Forte@Sun.COM 			    getTextString(FAILED_TO_FIND_PATH));
24127836SJohn.Forte@Sun.COM 
24137836SJohn.Forte@Sun.COM 			(void) printf("\n");
24147836SJohn.Forte@Sun.COM 			return (ERROR_CLI_FAILED);
24157836SJohn.Forte@Sun.COM 		}
24167836SJohn.Forte@Sun.COM 
24177836SJohn.Forte@Sun.COM 		/* attempt to set the override path */
24187836SJohn.Forte@Sun.COM 		mpstatus =  MP_SetOverridePath(luOid, pathOid);
24197836SJohn.Forte@Sun.COM 		if (mpstatus != MP_STATUS_SUCCESS) {
24207836SJohn.Forte@Sun.COM 			/* LINTED E_SEC_PRINTF_VAR_FMT */
24217836SJohn.Forte@Sun.COM 			(void) fprintf(stderr,
24227836SJohn.Forte@Sun.COM 			    getTextString(
24237836SJohn.Forte@Sun.COM 			    ERR_FAILED_TO_OVERRIDE_PATH_WITH_REASON),
24247836SJohn.Forte@Sun.COM 			    getMpStatusStr(mpstatus));
24257836SJohn.Forte@Sun.COM 			(void) printf("\n");
24267836SJohn.Forte@Sun.COM 			return (mpstatus);
24277836SJohn.Forte@Sun.COM 		}
24287836SJohn.Forte@Sun.COM 	}
24297836SJohn.Forte@Sun.COM 
24307836SJohn.Forte@Sun.COM 	return (mpstatus);
24317836SJohn.Forte@Sun.COM }
24327836SJohn.Forte@Sun.COM 
24337836SJohn.Forte@Sun.COM 
24347836SJohn.Forte@Sun.COM /*
24357836SJohn.Forte@Sun.COM  * ****************************************************************************
24367836SJohn.Forte@Sun.COM  *
24377836SJohn.Forte@Sun.COM  * getPathOid -
24387836SJohn.Forte@Sun.COM  *	Search through all plugins and get the OID for specified path
24397836SJohn.Forte@Sun.COM  *
24407836SJohn.Forte@Sun.COM  * operand	- pointer to operand list from user
24417836SJohn.Forte@Sun.COM  * options	- pointer to option list from user
24427836SJohn.Forte@Sun.COM  *
24437836SJohn.Forte@Sun.COM  * ****************************************************************************
24447836SJohn.Forte@Sun.COM  */
24457836SJohn.Forte@Sun.COM boolean_t
getPathOid(cmdOptions_t * options,MP_OID * pPathOid)24467836SJohn.Forte@Sun.COM getPathOid(cmdOptions_t *options, MP_OID *pPathOid)
24477836SJohn.Forte@Sun.COM {
24487836SJohn.Forte@Sun.COM 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
24497836SJohn.Forte@Sun.COM 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES 	luProps;
24507836SJohn.Forte@Sun.COM 	MP_PATH_LOGICAL_UNIT_PROPERTIES		pathProps;
24517836SJohn.Forte@Sun.COM 	MP_INITIATOR_PORT_PROPERTIES		initProps;
24527836SJohn.Forte@Sun.COM 	MP_TARGET_PORT_PROPERTIES		targProps;
24537836SJohn.Forte@Sun.COM 
2454*10696SDavid.Hollister@Sun.COM 	MP_OID_LIST	*pPluginOidList, *pLogicalUnitOidList,
2455*10696SDavid.Hollister@Sun.COM 	    *pathOidListArray;
24567836SJohn.Forte@Sun.COM 
24577836SJohn.Forte@Sun.COM 	boolean_t				bFoundIt = B_FALSE;
24587836SJohn.Forte@Sun.COM 	MP_CHAR					initPortID[256];
24597836SJohn.Forte@Sun.COM 	MP_CHAR					targetPortID[256];
24607836SJohn.Forte@Sun.COM 	MP_CHAR					luDeviceFileName[256];
2461*10696SDavid.Hollister@Sun.COM 	boolean_t	bHaveTarg = B_FALSE, bHaveLu = B_FALSE,
2462*10696SDavid.Hollister@Sun.COM 	    bHaveInit = B_FALSE;
24637836SJohn.Forte@Sun.COM 	cmdOptions_t 				*optionList = options;
24647836SJohn.Forte@Sun.COM 
2465*10696SDavid.Hollister@Sun.COM 	int					i, lu, pa;
24667836SJohn.Forte@Sun.COM 	if (NULL == pPathOid) {
24677836SJohn.Forte@Sun.COM 		return (B_FALSE);
24687836SJohn.Forte@Sun.COM 	}
24697836SJohn.Forte@Sun.COM 
24707836SJohn.Forte@Sun.COM 	for (; optionList->optval; optionList++) {
24717836SJohn.Forte@Sun.COM 		switch (optionList->optval) {
24727836SJohn.Forte@Sun.COM 			case 'i':
24737836SJohn.Forte@Sun.COM 				/* save init port name */
24747836SJohn.Forte@Sun.COM 				(void) memcpy(initPortID,
24757836SJohn.Forte@Sun.COM 				    optionList->optarg, 256);
24767836SJohn.Forte@Sun.COM 				bHaveInit = B_TRUE;
24777836SJohn.Forte@Sun.COM 				break;
24787836SJohn.Forte@Sun.COM 			case 't':
24797836SJohn.Forte@Sun.COM 				/* save target port id */
24807836SJohn.Forte@Sun.COM 				(void) memcpy(targetPortID,
24817836SJohn.Forte@Sun.COM 				    optionList->optarg, 256);
24827836SJohn.Forte@Sun.COM 				bHaveTarg = B_TRUE;
24837836SJohn.Forte@Sun.COM 				break;
24847836SJohn.Forte@Sun.COM 			case 'l':
24857836SJohn.Forte@Sun.COM 				/* save LU name */
24867836SJohn.Forte@Sun.COM 				(void) memcpy(luDeviceFileName,
24877836SJohn.Forte@Sun.COM 				    optionList->optarg, 256);
24887836SJohn.Forte@Sun.COM 				bHaveLu = B_TRUE;
24897836SJohn.Forte@Sun.COM 				break;
24907836SJohn.Forte@Sun.COM 		}
24917836SJohn.Forte@Sun.COM 	}
24927836SJohn.Forte@Sun.COM 
24937836SJohn.Forte@Sun.COM 
24947836SJohn.Forte@Sun.COM 	if ((B_FALSE == bHaveInit) ||
24957836SJohn.Forte@Sun.COM 	    (B_FALSE == bHaveTarg) ||
24967836SJohn.Forte@Sun.COM 	    (B_FALSE == bHaveLu)) {
24977836SJohn.Forte@Sun.COM 		/* if we don't have all three pieces, we can't find the path */
24987836SJohn.Forte@Sun.COM 
24997836SJohn.Forte@Sun.COM 		return (B_FALSE);
25007836SJohn.Forte@Sun.COM 	}
25017836SJohn.Forte@Sun.COM 
25027836SJohn.Forte@Sun.COM 	/* get the plugin ist */
25037836SJohn.Forte@Sun.COM 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
25047836SJohn.Forte@Sun.COM 	    != MP_STATUS_SUCCESS) {
25057836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s: %s\n", cmdName,
25067836SJohn.Forte@Sun.COM 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
25077836SJohn.Forte@Sun.COM 		return (B_FALSE);
25087836SJohn.Forte@Sun.COM 	}
25097836SJohn.Forte@Sun.COM 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
25107836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s: %s\n", cmdName,
25117836SJohn.Forte@Sun.COM 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
25127836SJohn.Forte@Sun.COM 		return (B_FALSE);
25137836SJohn.Forte@Sun.COM 	}
25147836SJohn.Forte@Sun.COM 
25157836SJohn.Forte@Sun.COM 	for (i = 0; i < pPluginOidList->oidCount; i++) {
25167836SJohn.Forte@Sun.COM 
25177836SJohn.Forte@Sun.COM 		/* get Logical Unit list */
25187836SJohn.Forte@Sun.COM 		mpstatus = MP_GetMultipathLus(pPluginOidList->oids[i],
25197836SJohn.Forte@Sun.COM 		    &pLogicalUnitOidList);
25207836SJohn.Forte@Sun.COM 		if (mpstatus != MP_STATUS_SUCCESS) {
25217836SJohn.Forte@Sun.COM 			(void) fprintf(stderr, "%s:  %s\n",
25227836SJohn.Forte@Sun.COM 			    cmdName, getTextString(ERR_NO_LU_LIST));
25237836SJohn.Forte@Sun.COM 			return (B_FALSE);
25247836SJohn.Forte@Sun.COM 		}
25257836SJohn.Forte@Sun.COM 
25267836SJohn.Forte@Sun.COM 		for (lu = 0; (lu < pLogicalUnitOidList->oidCount) &&
2527*10696SDavid.Hollister@Sun.COM 		    (B_FALSE == bFoundIt); lu++) {
25287836SJohn.Forte@Sun.COM 
25297836SJohn.Forte@Sun.COM 			/* get lu properties so we can check the name */
25307836SJohn.Forte@Sun.COM 			(void) memset(&luProps, 0,
25317836SJohn.Forte@Sun.COM 			    sizeof (MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES));
25327836SJohn.Forte@Sun.COM 			mpstatus =
25337836SJohn.Forte@Sun.COM 			    MP_GetMPLogicalUnitProperties(
25347836SJohn.Forte@Sun.COM 			    pLogicalUnitOidList->oids[lu], &luProps);
25357836SJohn.Forte@Sun.COM 			if (mpstatus != MP_STATUS_SUCCESS) {
25367836SJohn.Forte@Sun.COM 				(void) fprintf(stderr, "%s:  %s\n",
25377836SJohn.Forte@Sun.COM 				    cmdName, getTextString(ERR_NO_PROPERTIES));
25387836SJohn.Forte@Sun.COM 				return (B_FALSE);
25397836SJohn.Forte@Sun.COM 			}
2540*10696SDavid.Hollister@Sun.COM 			if (compareLUName(luDeviceFileName,
2541*10696SDavid.Hollister@Sun.COM 			    luProps.deviceFileName) == B_TRUE) {
25427836SJohn.Forte@Sun.COM 				/* get paths for this LU and search from here */
25437836SJohn.Forte@Sun.COM 				mpstatus =
25447836SJohn.Forte@Sun.COM 				    MP_GetAssociatedPathOidList(
25457836SJohn.Forte@Sun.COM 				    pLogicalUnitOidList->oids[lu],
25467836SJohn.Forte@Sun.COM 				    &pathOidListArray);
25477836SJohn.Forte@Sun.COM 				if (mpstatus != MP_STATUS_SUCCESS) {
25487836SJohn.Forte@Sun.COM 					/* LINTED E_SEC_PRINTF_VAR_FMT */
25497836SJohn.Forte@Sun.COM 					(void) fprintf(stderr,
25507836SJohn.Forte@Sun.COM 					    getTextString(
25517836SJohn.Forte@Sun.COM 					    ERR_FAILED_TO_FIND_PATH));
25527836SJohn.Forte@Sun.COM 					(void) printf("\n");
25537836SJohn.Forte@Sun.COM 					return (B_FALSE);
25547836SJohn.Forte@Sun.COM 				}
25557836SJohn.Forte@Sun.COM 
25567836SJohn.Forte@Sun.COM 				for (pa = 0;
2557*10696SDavid.Hollister@Sun.COM 				    (pa < pathOidListArray->oidCount) &&
2558*10696SDavid.Hollister@Sun.COM 				    (B_FALSE == bFoundIt); pa++) {
25597836SJohn.Forte@Sun.COM 					mpstatus =
25607836SJohn.Forte@Sun.COM 					    MP_GetPathLogicalUnitProperties
25617836SJohn.Forte@Sun.COM 					    (pathOidListArray->oids[pa],
25627836SJohn.Forte@Sun.COM 					    &pathProps);
25637836SJohn.Forte@Sun.COM 					if (mpstatus != MP_STATUS_SUCCESS) {
25647836SJohn.Forte@Sun.COM 						(void) fprintf(stderr,
25657836SJohn.Forte@Sun.COM 						    "%s:  %s\n", cmdName,
25667836SJohn.Forte@Sun.COM 						    getTextString(
25677836SJohn.Forte@Sun.COM 						    ERR_NO_PROPERTIES));
25687836SJohn.Forte@Sun.COM 						return (B_FALSE);
25697836SJohn.Forte@Sun.COM 					}
25707836SJohn.Forte@Sun.COM 
25717836SJohn.Forte@Sun.COM 					/*
25727836SJohn.Forte@Sun.COM 					 * get properties of iniator port and
25737836SJohn.Forte@Sun.COM 					 * target port to see if we have the
25747836SJohn.Forte@Sun.COM 					 * right path
25757836SJohn.Forte@Sun.COM 					 */
25767836SJohn.Forte@Sun.COM 					mpstatus =
25777836SJohn.Forte@Sun.COM 					    MP_GetInitiatorPortProperties(
25787836SJohn.Forte@Sun.COM 					    pathProps.initiatorPortOid,
25797836SJohn.Forte@Sun.COM 					    &initProps);
25807836SJohn.Forte@Sun.COM 
25817836SJohn.Forte@Sun.COM 					if (mpstatus != MP_STATUS_SUCCESS) {
25827836SJohn.Forte@Sun.COM 						(void) fprintf(stderr,
25837836SJohn.Forte@Sun.COM 						    "%s:  %s\n", cmdName,
25847836SJohn.Forte@Sun.COM 						    getTextString(
25857836SJohn.Forte@Sun.COM 						    ERR_NO_PROPERTIES));
25867836SJohn.Forte@Sun.COM 						return (B_FALSE);
25877836SJohn.Forte@Sun.COM 					}
25887836SJohn.Forte@Sun.COM 	if (0 == strcmp(initPortID, initProps.portID)) {
25897836SJohn.Forte@Sun.COM 		/* lu and init port matches, check target port */
25907836SJohn.Forte@Sun.COM 		mpstatus = MP_GetTargetPortProperties(pathProps.targetPortOid,
25917836SJohn.Forte@Sun.COM 		    &targProps);
25927836SJohn.Forte@Sun.COM 		if (mpstatus != MP_STATUS_SUCCESS) {
25937836SJohn.Forte@Sun.COM 			(void) fprintf(stderr, "%s:  %s\n", cmdName,
25947836SJohn.Forte@Sun.COM 			    getTextString(ERR_NO_PROPERTIES));
25957836SJohn.Forte@Sun.COM 			return (B_FALSE);
25967836SJohn.Forte@Sun.COM 		}
25977836SJohn.Forte@Sun.COM 
25987836SJohn.Forte@Sun.COM 		if (0 == strcmp(targetPortID, targProps.portID)) {
25997836SJohn.Forte@Sun.COM 			/* we found our path */
26007836SJohn.Forte@Sun.COM 			pPathOid->objectSequenceNumber =
26017836SJohn.Forte@Sun.COM 			    pathOidListArray->oids[pa].objectSequenceNumber;
26027836SJohn.Forte@Sun.COM 			pPathOid->objectType =
26037836SJohn.Forte@Sun.COM 			    pathOidListArray->oids[pa].objectType;
26047836SJohn.Forte@Sun.COM 			pPathOid->ownerId = pathOidListArray->oids[pa].ownerId;
26057836SJohn.Forte@Sun.COM 			bFoundIt = B_TRUE;
26067836SJohn.Forte@Sun.COM 		}
26077836SJohn.Forte@Sun.COM 	} /* init port matched */
26087836SJohn.Forte@Sun.COM 
26097836SJohn.Forte@Sun.COM 				} /* for each path associated with this lu */
26107836SJohn.Forte@Sun.COM 
26117836SJohn.Forte@Sun.COM 			} /* lu matched */
26127836SJohn.Forte@Sun.COM 
26137836SJohn.Forte@Sun.COM 		} /* for each lu */
26147836SJohn.Forte@Sun.COM 
26157836SJohn.Forte@Sun.COM 	} /* for each plugin */
26167836SJohn.Forte@Sun.COM 
26177836SJohn.Forte@Sun.COM 	return (bFoundIt);
26187836SJohn.Forte@Sun.COM }
26197836SJohn.Forte@Sun.COM 
26207836SJohn.Forte@Sun.COM 
26217836SJohn.Forte@Sun.COM /*
26227836SJohn.Forte@Sun.COM  * ****************************************************************************
26237836SJohn.Forte@Sun.COM  *
26247836SJohn.Forte@Sun.COM  * getLbValueFromString
26257836SJohn.Forte@Sun.COM  * 	Gets the MP_LOAD_BALANCE_TYPE specified load balance type string
26267836SJohn.Forte@Sun.COM  *
26277836SJohn.Forte@Sun.COM  * lbStr	- load balance string defined in the .h file
26287836SJohn.Forte@Sun.COM  *		This is what users will be required to feed into the
26297836SJohn.Forte@Sun.COM  *		modify lu command.
26307836SJohn.Forte@Sun.COM  *
26317836SJohn.Forte@Sun.COM  * ****************************************************************************
26327836SJohn.Forte@Sun.COM  */
26337836SJohn.Forte@Sun.COM MP_LOAD_BALANCE_TYPE
getLbValueFromString(char * lbStr)26347836SJohn.Forte@Sun.COM getLbValueFromString(char *lbStr)
26357836SJohn.Forte@Sun.COM {
26367836SJohn.Forte@Sun.COM 	MP_LOAD_BALANCE_TYPE		lbVal = MP_LOAD_BALANCE_TYPE_UNKNOWN;
26377836SJohn.Forte@Sun.COM 
26387836SJohn.Forte@Sun.COM 	if (0 == strcmp(lbStr, getTextString(TEXT_LBTYPE_ROUNDROBIN))) {
26397836SJohn.Forte@Sun.COM 		lbVal = MP_LOAD_BALANCE_TYPE_ROUNDROBIN;
26407836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr, getTextString(TEXT_LBTYPE_LEASTBLOCKS))) {
26417836SJohn.Forte@Sun.COM 		lbVal = MP_LOAD_BALANCE_TYPE_LEASTBLOCKS;
26427836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr, getTextString(TEXT_LBTYPE_LEASTIO))) {
26437836SJohn.Forte@Sun.COM 		lbVal = MP_LOAD_BALANCE_TYPE_LEASTIO;
26447836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr, getTextString(TEXT_LBTYPE_DEVICEPROD))) {
26457836SJohn.Forte@Sun.COM 		lbVal = MP_LOAD_BALANCE_TYPE_DEVICE_PRODUCT;
26467836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr, getTextString(TEXT_LBTYPE_LBAREGION))) {
26477836SJohn.Forte@Sun.COM 		lbVal = MP_LOAD_BALANCE_TYPE_LBA_REGION;
26487836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr,
26497836SJohn.Forte@Sun.COM 	    getTextString(TEXT_LBTYPE_FAILOVER_ONLY))) {
26507836SJohn.Forte@Sun.COM 		lbVal = MP_LOAD_BALANCE_TYPE_FAILOVER_ONLY;
26517836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr, getTextString(TEXT_LBTYPE_UNKNOWN))) {
26527836SJohn.Forte@Sun.COM 		lbVal = MP_LOAD_BALANCE_TYPE_UNKNOWN;
26537836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr, getTextString(TEXT_LBTYPE_NONE))) {
26547836SJohn.Forte@Sun.COM 		lbVal = 0;
26557836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr,
26567836SJohn.Forte@Sun.COM 	    getTextString(TEXT_LBTYPE_PROPRIETARY1))) {
26577836SJohn.Forte@Sun.COM 		lbVal = ((MP_UINT32)0x00000001)<<16;
26587836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr,
26597836SJohn.Forte@Sun.COM 	    getTextString(TEXT_LBTYPE_PROPRIETARY2))) {
26607836SJohn.Forte@Sun.COM 		lbVal = ((MP_UINT32)0x00000001)<<17;
26617836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr,
26627836SJohn.Forte@Sun.COM 	    getTextString(TEXT_LBTYPE_PROPRIETARY3))) {
26637836SJohn.Forte@Sun.COM 		lbVal = ((MP_UINT32)0x00000001)<<18;
26647836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr,
26657836SJohn.Forte@Sun.COM 	    getTextString(TEXT_LBTYPE_PROPRIETARY4))) {
26667836SJohn.Forte@Sun.COM 		lbVal = ((MP_UINT32)0x00000001)<<19;
26677836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr,
26687836SJohn.Forte@Sun.COM 	    getTextString(TEXT_LBTYPE_PROPRIETARY5))) {
26697836SJohn.Forte@Sun.COM 		lbVal = ((MP_UINT32)0x00000001)<<20;
26707836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr,
26717836SJohn.Forte@Sun.COM 	    getTextString(TEXT_LBTYPE_PROPRIETARY6))) {
26727836SJohn.Forte@Sun.COM 		lbVal = ((MP_UINT32)0x00000001)<<21;
26737836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr,
26747836SJohn.Forte@Sun.COM 	    getTextString(TEXT_LBTYPE_PROPRIETARY7))) {
26757836SJohn.Forte@Sun.COM 		lbVal = ((MP_UINT32)0x00000001)<<22;
26767836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr,
26777836SJohn.Forte@Sun.COM 	    getTextString(TEXT_LBTYPE_PROPRIETARY8))) {
26787836SJohn.Forte@Sun.COM 		lbVal = ((MP_UINT32)0x00000001)<<23;
26797836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr,
26807836SJohn.Forte@Sun.COM 	    getTextString(TEXT_LBTYPE_PROPRIETARY9))) {
26817836SJohn.Forte@Sun.COM 		lbVal = ((MP_UINT32)0x00000001)<<24;
26827836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr,
26837836SJohn.Forte@Sun.COM 	    getTextString(TEXT_LBTYPE_PROPRIETARY10))) {
26847836SJohn.Forte@Sun.COM 		lbVal = ((MP_UINT32)0x00000001)<<25;
26857836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr,
26867836SJohn.Forte@Sun.COM 	    getTextString(TEXT_LBTYPE_PROPRIETARY11))) {
26877836SJohn.Forte@Sun.COM 		lbVal = ((MP_UINT32)0x00000001)<<26;
26887836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr,
26897836SJohn.Forte@Sun.COM 	    getTextString(TEXT_LBTYPE_PROPRIETARY12))) {
26907836SJohn.Forte@Sun.COM 		lbVal = ((MP_UINT32)0x00000001)<<27;
26917836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr,
26927836SJohn.Forte@Sun.COM 	    getTextString(TEXT_LBTYPE_PROPRIETARY13))) {
26937836SJohn.Forte@Sun.COM 		lbVal = ((MP_UINT32)0x00000001)<<28;
26947836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr,
26957836SJohn.Forte@Sun.COM 	    getTextString(TEXT_LBTYPE_PROPRIETARY14))) {
26967836SJohn.Forte@Sun.COM 		lbVal = ((MP_UINT32)0x00000001)<<29;
26977836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr,
26987836SJohn.Forte@Sun.COM 	    getTextString(TEXT_LBTYPE_PROPRIETARY15))) {
26997836SJohn.Forte@Sun.COM 		lbVal = ((MP_UINT32)0x00000001)<<30;
27007836SJohn.Forte@Sun.COM 	} else if (0 == strcmp(lbStr,
27017836SJohn.Forte@Sun.COM 	    getTextString(TEXT_LBTYPE_PROPRIETARY16))) {
27027836SJohn.Forte@Sun.COM 		lbVal = ((MP_UINT32)0x00000001)<<31;
27037836SJohn.Forte@Sun.COM 	}
27047836SJohn.Forte@Sun.COM 
27057836SJohn.Forte@Sun.COM 	return (lbVal);
27067836SJohn.Forte@Sun.COM 
27077836SJohn.Forte@Sun.COM 
27087836SJohn.Forte@Sun.COM } /* end getLbValueFromString */
27097836SJohn.Forte@Sun.COM 
27107836SJohn.Forte@Sun.COM 
27117836SJohn.Forte@Sun.COM /*
27127836SJohn.Forte@Sun.COM  * ****************************************************************************
27137836SJohn.Forte@Sun.COM  *
27147836SJohn.Forte@Sun.COM  * displayLogicalUnitNameTypeString
27157836SJohn.Forte@Sun.COM  * 	Displays the text equivalent string for the MP_LOGICAL_UNIT_NAME_TYPE
27167836SJohn.Forte@Sun.COM  *	specified load balance type
27177836SJohn.Forte@Sun.COM  *
27187836SJohn.Forte@Sun.COM  * typeVal	- load balance type defined in the MPAPI spec
27197836SJohn.Forte@Sun.COM  *
27207836SJohn.Forte@Sun.COM  * ****************************************************************************
27217836SJohn.Forte@Sun.COM  */
27227836SJohn.Forte@Sun.COM void
displayLogicalUnitNameTypeString(MP_LOGICAL_UNIT_NAME_TYPE typeVal)27237836SJohn.Forte@Sun.COM displayLogicalUnitNameTypeString(MP_LOGICAL_UNIT_NAME_TYPE typeVal)
27247836SJohn.Forte@Sun.COM {
27257836SJohn.Forte@Sun.COM 
27267836SJohn.Forte@Sun.COM 	char					*typeString;
27277836SJohn.Forte@Sun.COM 
27287836SJohn.Forte@Sun.COM 	switch (typeVal) {
27297836SJohn.Forte@Sun.COM 
27307836SJohn.Forte@Sun.COM 		case MP_LU_NAME_TYPE_UNKNOWN:
27317836SJohn.Forte@Sun.COM 			typeString = getTextString(TEXT_NAME_TYPE_UNKNOWN);
27327836SJohn.Forte@Sun.COM 			break;
27337836SJohn.Forte@Sun.COM 		case MP_LU_NAME_TYPE_VPD83_TYPE1:
27347836SJohn.Forte@Sun.COM 			typeString = getTextString(TEXT_NAME_TYPE_VPD83_TYPE1);
27357836SJohn.Forte@Sun.COM 			break;
27367836SJohn.Forte@Sun.COM 		case MP_LU_NAME_TYPE_VPD83_TYPE2:
27377836SJohn.Forte@Sun.COM 			typeString = getTextString(TEXT_NAME_TYPE_VPD83_TYPE2);
27387836SJohn.Forte@Sun.COM 			break;
27397836SJohn.Forte@Sun.COM 		case MP_LU_NAME_TYPE_VPD83_TYPE3:
27407836SJohn.Forte@Sun.COM 			typeString = getTextString(TEXT_NAME_TYPE_VPD83_TYPE3);
27417836SJohn.Forte@Sun.COM 			break;
27427836SJohn.Forte@Sun.COM 		case MP_LU_NAME_TYPE_DEVICE_SPECIFIC:
27437836SJohn.Forte@Sun.COM 			typeString =
2744*10696SDavid.Hollister@Sun.COM 			    getTextString(TEXT_NAME_TYPE_DEVICE_SPECIFIC);
27457836SJohn.Forte@Sun.COM 			break;
27467836SJohn.Forte@Sun.COM 		default:
27477836SJohn.Forte@Sun.COM 			typeString = getTextString(TEXT_UNKNOWN);
27487836SJohn.Forte@Sun.COM 			break;
27497836SJohn.Forte@Sun.COM 	}
27507836SJohn.Forte@Sun.COM 
27517836SJohn.Forte@Sun.COM 	(void) printf("%s", typeString);
27527836SJohn.Forte@Sun.COM 
27537836SJohn.Forte@Sun.COM 
27547836SJohn.Forte@Sun.COM } /* end displayLogicalUnitNameTypeString */
27557836SJohn.Forte@Sun.COM 
27567836SJohn.Forte@Sun.COM /*
27577836SJohn.Forte@Sun.COM  * ****************************************************************************
27587836SJohn.Forte@Sun.COM  *
27597836SJohn.Forte@Sun.COM  * displayLoadBalanceString
27607836SJohn.Forte@Sun.COM  * 	Displays the text equivalent string for the MP_LOAD_BALANCE_TYPE
27617836SJohn.Forte@Sun.COM  *	specified load balance type
27627836SJohn.Forte@Sun.COM  *
27637836SJohn.Forte@Sun.COM  * lbVal	- load balance type defined in the MPAPI spec
27647836SJohn.Forte@Sun.COM  *
27657836SJohn.Forte@Sun.COM  * ****************************************************************************
27667836SJohn.Forte@Sun.COM  */
27677836SJohn.Forte@Sun.COM void
displayLoadBalanceString(MP_LOAD_BALANCE_TYPE lbVal)27687836SJohn.Forte@Sun.COM displayLoadBalanceString(MP_LOAD_BALANCE_TYPE lbVal)
27697836SJohn.Forte@Sun.COM {
27707836SJohn.Forte@Sun.COM 
27717836SJohn.Forte@Sun.COM 	char					*lbString;
27727836SJohn.Forte@Sun.COM 
27737836SJohn.Forte@Sun.COM 	switch (lbVal) {
27747836SJohn.Forte@Sun.COM 
27757836SJohn.Forte@Sun.COM 		case MP_LOAD_BALANCE_TYPE_UNKNOWN:
27767836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_UNKNOWN);
27777836SJohn.Forte@Sun.COM 			break;
27787836SJohn.Forte@Sun.COM 		case MP_LOAD_BALANCE_TYPE_ROUNDROBIN:
27797836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_ROUNDROBIN);
27807836SJohn.Forte@Sun.COM 			break;
27817836SJohn.Forte@Sun.COM 		case MP_LOAD_BALANCE_TYPE_LEASTBLOCKS:
27827836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_LEASTBLOCKS);
27837836SJohn.Forte@Sun.COM 			break;
27847836SJohn.Forte@Sun.COM 		case MP_LOAD_BALANCE_TYPE_LEASTIO:
27857836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_LEASTIO);
27867836SJohn.Forte@Sun.COM 			break;
27877836SJohn.Forte@Sun.COM 		case MP_LOAD_BALANCE_TYPE_DEVICE_PRODUCT:
27887836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_DEVICEPROD);
27897836SJohn.Forte@Sun.COM 			break;
27907836SJohn.Forte@Sun.COM 		case MP_LOAD_BALANCE_TYPE_LBA_REGION:
27917836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_LBAREGION);
27927836SJohn.Forte@Sun.COM 			break;
27937836SJohn.Forte@Sun.COM 		case MP_LOAD_BALANCE_TYPE_FAILOVER_ONLY:
27947836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_FAILOVER_ONLY);
27957836SJohn.Forte@Sun.COM 			break;
27967836SJohn.Forte@Sun.COM 		case (((MP_UINT32)0x00000001)<<16):
27977836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY1);
27987836SJohn.Forte@Sun.COM 			break;
27997836SJohn.Forte@Sun.COM 		case (((MP_UINT32)0x00000001)<<17):
28007836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY2);
28017836SJohn.Forte@Sun.COM 			break;
28027836SJohn.Forte@Sun.COM 		case (((MP_UINT32)0x00000001)<<18):
28037836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY3);
28047836SJohn.Forte@Sun.COM 			break;
28057836SJohn.Forte@Sun.COM 		case (((MP_UINT32)0x00000001)<<19):
28067836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY4);
28077836SJohn.Forte@Sun.COM 			break;
28087836SJohn.Forte@Sun.COM 		case (((MP_UINT32)0x00000001)<<20):
28097836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY5);
28107836SJohn.Forte@Sun.COM 			break;
28117836SJohn.Forte@Sun.COM 		case (((MP_UINT32)0x00000001)<<21):
28127836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY6);
28137836SJohn.Forte@Sun.COM 			break;
28147836SJohn.Forte@Sun.COM 		case (((MP_UINT32)0x00000001)<<22):
28157836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY7);
28167836SJohn.Forte@Sun.COM 			break;
28177836SJohn.Forte@Sun.COM 		case (((MP_UINT32)0x00000001)<<23):
28187836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY8);
28197836SJohn.Forte@Sun.COM 			break;
28207836SJohn.Forte@Sun.COM 		case (((MP_UINT32)0x00000001)<<24):
28217836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY9);
28227836SJohn.Forte@Sun.COM 			break;
28237836SJohn.Forte@Sun.COM 		case (((MP_UINT32)0x00000001)<<25):
28247836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY10);
28257836SJohn.Forte@Sun.COM 			break;
28267836SJohn.Forte@Sun.COM 		case (((MP_UINT32)0x00000001)<<26):
28277836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY11);
28287836SJohn.Forte@Sun.COM 			break;
28297836SJohn.Forte@Sun.COM 		case (((MP_UINT32)0x00000001)<<27):
28307836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY12);
28317836SJohn.Forte@Sun.COM 			break;
28327836SJohn.Forte@Sun.COM 		case (((MP_UINT32)0x00000001)<<28):
28337836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY13);
28347836SJohn.Forte@Sun.COM 			break;
28357836SJohn.Forte@Sun.COM 		case (((MP_UINT32)0x00000001)<<29):
28367836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY14);
28377836SJohn.Forte@Sun.COM 			break;
28387836SJohn.Forte@Sun.COM 		case (((MP_UINT32)0x00000001)<<30):
28397836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY15);
28407836SJohn.Forte@Sun.COM 			break;
28417836SJohn.Forte@Sun.COM 		case (((MP_UINT32)0x00000001)<<31):
28427836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY16);
28437836SJohn.Forte@Sun.COM 			break;
28447836SJohn.Forte@Sun.COM 		default:
28457836SJohn.Forte@Sun.COM 			lbString = getTextString(TEXT_UNKNOWN);
28467836SJohn.Forte@Sun.COM 			break;
28477836SJohn.Forte@Sun.COM 	}
28487836SJohn.Forte@Sun.COM 
28497836SJohn.Forte@Sun.COM 	(void) printf("%s", lbString);
28507836SJohn.Forte@Sun.COM 
28517836SJohn.Forte@Sun.COM 
28527836SJohn.Forte@Sun.COM } /* end displayLoadBalanceString */
28537836SJohn.Forte@Sun.COM 
28547836SJohn.Forte@Sun.COM /*
28557836SJohn.Forte@Sun.COM  * ****************************************************************************
28567836SJohn.Forte@Sun.COM  *
28577836SJohn.Forte@Sun.COM  * displayTransportTypeString
28587836SJohn.Forte@Sun.COM  * 	Displays the text equivalent string for the MP_PORT_TRANSPORT_TYPE
28597836SJohn.Forte@Sun.COM  *	specified load balance type
28607836SJohn.Forte@Sun.COM  *
28617836SJohn.Forte@Sun.COM  * transportTypeVal	- transport type defined in the MPAPI spec
28627836SJohn.Forte@Sun.COM  *
28637836SJohn.Forte@Sun.COM  * ****************************************************************************
28647836SJohn.Forte@Sun.COM  */
28657836SJohn.Forte@Sun.COM void
displayTransportTypeString(MP_PORT_TRANSPORT_TYPE transportTypeVal)28667836SJohn.Forte@Sun.COM displayTransportTypeString(MP_PORT_TRANSPORT_TYPE transportTypeVal)
28677836SJohn.Forte@Sun.COM {
28687836SJohn.Forte@Sun.COM 
28697836SJohn.Forte@Sun.COM 	char					*ttypeString;
28707836SJohn.Forte@Sun.COM 	switch (transportTypeVal) {
28717836SJohn.Forte@Sun.COM 
28727836SJohn.Forte@Sun.COM 		case MP_PORT_TRANSPORT_TYPE_MPNODE:
28737836SJohn.Forte@Sun.COM 			ttypeString =
28747836SJohn.Forte@Sun.COM 			    getTextString(TEXT_TRANS_PORT_TYPE_MPNODE);
28757836SJohn.Forte@Sun.COM 			break;
28767836SJohn.Forte@Sun.COM 		case MP_PORT_TRANSPORT_TYPE_FC:
28777836SJohn.Forte@Sun.COM 			ttypeString = getTextString(TEXT_TRANS_PORT_TYPE_FC);
28787836SJohn.Forte@Sun.COM 			break;
28797836SJohn.Forte@Sun.COM 		case MP_PORT_TRANSPORT_TYPE_SPI:
28807836SJohn.Forte@Sun.COM 			ttypeString = getTextString(TEXT_TRANS_PORT_TYPE_SPI);
28817836SJohn.Forte@Sun.COM 			break;
28827836SJohn.Forte@Sun.COM 		case MP_PORT_TRANSPORT_TYPE_ISCSI:
28837836SJohn.Forte@Sun.COM 			ttypeString = getTextString(TEXT_TRANS_PORT_TYPE_ISCSI);
28847836SJohn.Forte@Sun.COM 			break;
28857836SJohn.Forte@Sun.COM 		case MP_PORT_TRANSPORT_TYPE_IFB:
28867836SJohn.Forte@Sun.COM 			ttypeString = getTextString(TEXT_TRANS_PORT_TYPE_IFB);
28877836SJohn.Forte@Sun.COM 			break;
28887836SJohn.Forte@Sun.COM 		default:
28897836SJohn.Forte@Sun.COM 			ttypeString = getTextString(TEXT_UNKNOWN);
28907836SJohn.Forte@Sun.COM 			break;
28917836SJohn.Forte@Sun.COM 	}
28927836SJohn.Forte@Sun.COM 
28937836SJohn.Forte@Sun.COM 	(void) printf("%s", ttypeString);
28947836SJohn.Forte@Sun.COM 
28957836SJohn.Forte@Sun.COM } /* end displayTransportTypeString */
28967836SJohn.Forte@Sun.COM 
28977836SJohn.Forte@Sun.COM 
28987836SJohn.Forte@Sun.COM /*
28997836SJohn.Forte@Sun.COM  * ****************************************************************************
29007836SJohn.Forte@Sun.COM  *
29017836SJohn.Forte@Sun.COM  * getMpStatusStr
29027836SJohn.Forte@Sun.COM  * 	Gets the string description for the specified load balance type value
29037836SJohn.Forte@Sun.COM  *
29047836SJohn.Forte@Sun.COM  * mpstatus	- MP_STATUS value
29057836SJohn.Forte@Sun.COM  *
29067836SJohn.Forte@Sun.COM  * ****************************************************************************
29077836SJohn.Forte@Sun.COM  */
29087836SJohn.Forte@Sun.COM char *
getMpStatusStr(MP_STATUS mpstatus)29097836SJohn.Forte@Sun.COM getMpStatusStr(MP_STATUS mpstatus)
29107836SJohn.Forte@Sun.COM {
29117836SJohn.Forte@Sun.COM 	char					*statString;
29127836SJohn.Forte@Sun.COM 
29137836SJohn.Forte@Sun.COM 	switch (mpstatus) {
29147836SJohn.Forte@Sun.COM 		case MP_STATUS_SUCCESS:
29157836SJohn.Forte@Sun.COM 			statString = getTextString(TEXT_MPSTATUS_SUCCESS);
29167836SJohn.Forte@Sun.COM 			break;
29177836SJohn.Forte@Sun.COM 		case MP_STATUS_INVALID_PARAMETER:
29187836SJohn.Forte@Sun.COM 			statString = getTextString(TEXT_MPSTATUS_INV_PARAMETER);
29197836SJohn.Forte@Sun.COM 			break;
29207836SJohn.Forte@Sun.COM 		case MP_STATUS_UNKNOWN_FN:
29217836SJohn.Forte@Sun.COM 			statString = getTextString(TEXT_MPSTATUS_UNKNOWN_FN);
29227836SJohn.Forte@Sun.COM 			break;
29237836SJohn.Forte@Sun.COM 		case MP_STATUS_FAILED:
29247836SJohn.Forte@Sun.COM 			statString = getTextString(TEXT_MPSTATUS_FAILED);
29257836SJohn.Forte@Sun.COM 			break;
29267836SJohn.Forte@Sun.COM 		case MP_STATUS_INSUFFICIENT_MEMORY:
29277836SJohn.Forte@Sun.COM 			statString = getTextString(TEXT_MPSTATUS_INSUFF_MEMORY);
29287836SJohn.Forte@Sun.COM 			break;
29297836SJohn.Forte@Sun.COM 		case MP_STATUS_INVALID_OBJECT_TYPE:
29307836SJohn.Forte@Sun.COM 			statString = getTextString(TEXT_MPSTATUS_INV_OBJ_TYPE);
29317836SJohn.Forte@Sun.COM 			break;
29327836SJohn.Forte@Sun.COM 		case MP_STATUS_UNSUPPORTED:
29337836SJohn.Forte@Sun.COM 			statString = getTextString(TEXT_MPSTATUS_UNSUPPORTED);
29347836SJohn.Forte@Sun.COM 			break;
29357836SJohn.Forte@Sun.COM 		case MP_STATUS_OBJECT_NOT_FOUND:
29367836SJohn.Forte@Sun.COM 			statString = getTextString(TEXT_MPSTATUS_OBJ_NOT_FOUND);
29377836SJohn.Forte@Sun.COM 			break;
29387836SJohn.Forte@Sun.COM 		case MP_STATUS_ACCESS_STATE_INVALID:
29397836SJohn.Forte@Sun.COM 			statString = getTextString(TEXT_MPSTATUS_UNSUPPORTED);
29407836SJohn.Forte@Sun.COM 			break;
29417836SJohn.Forte@Sun.COM 		case MP_STATUS_FN_REPLACED:
29427836SJohn.Forte@Sun.COM 			statString = getTextString(TEXT_MPSTATUS_FN_REPLACED);
29437836SJohn.Forte@Sun.COM 			break;
29447836SJohn.Forte@Sun.COM 		case MP_STATUS_PATH_NONOPERATIONAL:
29457836SJohn.Forte@Sun.COM 			statString = getTextString(TEXT_MPSTATUS_PATH_NONOP);
29467836SJohn.Forte@Sun.COM 			break;
29477836SJohn.Forte@Sun.COM 		case MP_STATUS_TRY_AGAIN:
29487836SJohn.Forte@Sun.COM 			statString = getTextString(TEXT_MPSTATUS_TRY_AGAIN);
29497836SJohn.Forte@Sun.COM 			break;
29507836SJohn.Forte@Sun.COM 		case MP_STATUS_NOT_PERMITTED:
29517836SJohn.Forte@Sun.COM 			statString = getTextString(TEXT_MPSTATUS_NOT_PERMITTED);
29527836SJohn.Forte@Sun.COM 			break;
29537836SJohn.Forte@Sun.COM 		default:
29547836SJohn.Forte@Sun.COM 			statString = getTextString(TEXT_UNKNOWN);
29557836SJohn.Forte@Sun.COM 			break;
29567836SJohn.Forte@Sun.COM 	}
29577836SJohn.Forte@Sun.COM 
29587836SJohn.Forte@Sun.COM 	return (statString);
29597836SJohn.Forte@Sun.COM } /* end getMpStatusStr */
29607836SJohn.Forte@Sun.COM 
29617836SJohn.Forte@Sun.COM 
29627836SJohn.Forte@Sun.COM /*
29637836SJohn.Forte@Sun.COM  * ****************************************************************************
29647836SJohn.Forte@Sun.COM  *
29657836SJohn.Forte@Sun.COM  * GetPathStateStr
29667836SJohn.Forte@Sun.COM  * 	Gets the string description for the specified path state type value
29677836SJohn.Forte@Sun.COM  *
29687836SJohn.Forte@Sun.COM  * pathState	- MP_PATH_STATE values
29697836SJohn.Forte@Sun.COM  *
29707836SJohn.Forte@Sun.COM  * ****************************************************************************
29717836SJohn.Forte@Sun.COM  */
29727836SJohn.Forte@Sun.COM char *
getPathStateStr(MP_PATH_STATE pathState)29737836SJohn.Forte@Sun.COM getPathStateStr(MP_PATH_STATE pathState)
29747836SJohn.Forte@Sun.COM {
29757836SJohn.Forte@Sun.COM 	char					*pathString;
29767836SJohn.Forte@Sun.COM 
29777836SJohn.Forte@Sun.COM 	switch (pathState) {
29787836SJohn.Forte@Sun.COM 		case MP_PATH_STATE_OKAY:
29797836SJohn.Forte@Sun.COM 			pathString = getTextString(TEXT_PATH_STATE_OKAY);
29807836SJohn.Forte@Sun.COM 			break;
29817836SJohn.Forte@Sun.COM 		case MP_PATH_STATE_PATH_ERR:
29827836SJohn.Forte@Sun.COM 			pathString = getTextString(TEXT_PATH_STATE_PATH_ERR);
29837836SJohn.Forte@Sun.COM 			break;
29847836SJohn.Forte@Sun.COM 		case MP_PATH_STATE_LU_ERR:
29857836SJohn.Forte@Sun.COM 			pathString = getTextString(TEXT_PATH_STATE_LU_ERR);
29867836SJohn.Forte@Sun.COM 			break;
29877836SJohn.Forte@Sun.COM 		case MP_PATH_STATE_RESERVED:
29887836SJohn.Forte@Sun.COM 			pathString = getTextString(TEXT_PATH_STATE_RESERVED);
29897836SJohn.Forte@Sun.COM 			break;
29907836SJohn.Forte@Sun.COM 		case MP_PATH_STATE_REMOVED:
29917836SJohn.Forte@Sun.COM 			pathString = getTextString(TEXT_PATH_STATE_REMOVED);
29927836SJohn.Forte@Sun.COM 			break;
29937836SJohn.Forte@Sun.COM 		case MP_PATH_STATE_TRANSITIONING:
29947836SJohn.Forte@Sun.COM 			pathString =
29957836SJohn.Forte@Sun.COM 			    getTextString(TEXT_PATH_STATE_TRANSITIONING);
29967836SJohn.Forte@Sun.COM 			break;
29977836SJohn.Forte@Sun.COM 		case MP_PATH_STATE_OPERATIONAL_CLOSED:
29987836SJohn.Forte@Sun.COM 			pathString =
29997836SJohn.Forte@Sun.COM 			    getTextString(TEXT_PATH_STATE_OPERATIONAL_CLOSED);
30007836SJohn.Forte@Sun.COM 			break;
30017836SJohn.Forte@Sun.COM 		case MP_PATH_STATE_INVALID_CLOSED:
30027836SJohn.Forte@Sun.COM 			pathString =
30037836SJohn.Forte@Sun.COM 			    getTextString(TEXT_PATH_STATE_INVALID_CLOSED);
30047836SJohn.Forte@Sun.COM 			break;
30057836SJohn.Forte@Sun.COM 		case MP_PATH_STATE_OFFLINE_CLOSED:
30067836SJohn.Forte@Sun.COM 			pathString =
30077836SJohn.Forte@Sun.COM 			    getTextString(TEXT_PATH_STATE_OFFLINE_CLOSED);
30087836SJohn.Forte@Sun.COM 			break;
30097836SJohn.Forte@Sun.COM 		default:
30107836SJohn.Forte@Sun.COM 			pathString = getTextString(TEXT_UNKNOWN);
30117836SJohn.Forte@Sun.COM 			break;
30127836SJohn.Forte@Sun.COM 	}
30137836SJohn.Forte@Sun.COM 
30147836SJohn.Forte@Sun.COM 	return (pathString);
30157836SJohn.Forte@Sun.COM } /* end getPathStateStr */
30167836SJohn.Forte@Sun.COM 
30177836SJohn.Forte@Sun.COM 
30187836SJohn.Forte@Sun.COM 
30197836SJohn.Forte@Sun.COM /*
30207836SJohn.Forte@Sun.COM  * ****************************************************************************
30217836SJohn.Forte@Sun.COM  *
30227836SJohn.Forte@Sun.COM  * getAccessStateStr
30237836SJohn.Forte@Sun.COM  * 	Gets the string description for the specified access state type value
30247836SJohn.Forte@Sun.COM  *
30257836SJohn.Forte@Sun.COM  * accessState	- MP_ACCESS_STATE_TYPE values
30267836SJohn.Forte@Sun.COM  *
30277836SJohn.Forte@Sun.COM  * ****************************************************************************
30287836SJohn.Forte@Sun.COM  */
30297836SJohn.Forte@Sun.COM char *
getAccessStateStr(MP_ACCESS_STATE_TYPE accessState)30307836SJohn.Forte@Sun.COM getAccessStateStr(MP_ACCESS_STATE_TYPE accessState)
30317836SJohn.Forte@Sun.COM {
30327836SJohn.Forte@Sun.COM 	char					*accessString;
30337836SJohn.Forte@Sun.COM 
30347836SJohn.Forte@Sun.COM 	switch (accessState) {
30357836SJohn.Forte@Sun.COM 		case MP_ACCESS_STATE_ACTIVE_OPTIMIZED:
30367836SJohn.Forte@Sun.COM 			accessString =
30377836SJohn.Forte@Sun.COM 			    getTextString(TEXT_ACCESS_STATE_ACTIVE_OPTIMIZED);
30387836SJohn.Forte@Sun.COM 			break;
30397836SJohn.Forte@Sun.COM 		case MP_ACCESS_STATE_ACTIVE_NONOPTIMIZED:
30407836SJohn.Forte@Sun.COM 			accessString =
30417836SJohn.Forte@Sun.COM 			    getTextString(
30427836SJohn.Forte@Sun.COM 			    TEXT_ACCESS_STATE_ACTIVE_NONOPTIMIZED);
30437836SJohn.Forte@Sun.COM 			break;
30447836SJohn.Forte@Sun.COM 		case MP_ACCESS_STATE_STANDBY:
30457836SJohn.Forte@Sun.COM 			accessString =
30467836SJohn.Forte@Sun.COM 			    getTextString(TEXT_ACCESS_STATE_STANDBY);
30477836SJohn.Forte@Sun.COM 			break;
30487836SJohn.Forte@Sun.COM 		case MP_ACCESS_STATE_UNAVAILABLE:
30497836SJohn.Forte@Sun.COM 			accessString =
30507836SJohn.Forte@Sun.COM 			    getTextString(TEXT_ACCESS_STATE_UNAVAILABLE);
30517836SJohn.Forte@Sun.COM 			break;
30527836SJohn.Forte@Sun.COM 		case MP_ACCESS_STATE_TRANSITIONING:
30537836SJohn.Forte@Sun.COM 			accessString =
30547836SJohn.Forte@Sun.COM 			    getTextString(TEXT_ACCESS_STATE_TRANSITIONING);
30557836SJohn.Forte@Sun.COM 			break;
30567836SJohn.Forte@Sun.COM 		case MP_ACCESS_STATE_ACTIVE:
30577836SJohn.Forte@Sun.COM 			accessString = getTextString(TEXT_ACCESS_STATE_ACTIVE);
30587836SJohn.Forte@Sun.COM 			break;
30597836SJohn.Forte@Sun.COM 		default:
30607836SJohn.Forte@Sun.COM 			accessString = getTextString(TEXT_UNKNOWN);
30617836SJohn.Forte@Sun.COM 			break;
30627836SJohn.Forte@Sun.COM 	}
30637836SJohn.Forte@Sun.COM 	return (accessString);
30647836SJohn.Forte@Sun.COM } /* end getAccessStateStr */
30657836SJohn.Forte@Sun.COM 
30667836SJohn.Forte@Sun.COM 
30677836SJohn.Forte@Sun.COM /*
30687836SJohn.Forte@Sun.COM  * ****************************************************************************
30697836SJohn.Forte@Sun.COM  *
30707836SJohn.Forte@Sun.COM  * displayArray
30717836SJohn.Forte@Sun.COM  * 	Print out the specified array.
30727836SJohn.Forte@Sun.COM  *
30737836SJohn.Forte@Sun.COM  * arrayToDisplay	- array to display
30747836SJohn.Forte@Sun.COM  * arraySize		- size of array to display
30757836SJohn.Forte@Sun.COM  *
30767836SJohn.Forte@Sun.COM  * ****************************************************************************
30777836SJohn.Forte@Sun.COM  */
30787836SJohn.Forte@Sun.COM void
displayArray(MP_CHAR * arrayToDisplay,int arraySize)30797836SJohn.Forte@Sun.COM displayArray(MP_CHAR *arrayToDisplay, int arraySize)
30807836SJohn.Forte@Sun.COM {
30817836SJohn.Forte@Sun.COM 	int					i;
30827836SJohn.Forte@Sun.COM 
30837836SJohn.Forte@Sun.COM 	for (i = 0; i < arraySize; i++) {
30847836SJohn.Forte@Sun.COM 		if ('\0' != arrayToDisplay[i]) {
30857836SJohn.Forte@Sun.COM 			(void) fprintf(stdout, "%c", arrayToDisplay[i]);
30867836SJohn.Forte@Sun.COM 		}
30877836SJohn.Forte@Sun.COM 	}
30887836SJohn.Forte@Sun.COM 
30897836SJohn.Forte@Sun.COM }
30907836SJohn.Forte@Sun.COM 
30917836SJohn.Forte@Sun.COM 
30927836SJohn.Forte@Sun.COM /*
30937836SJohn.Forte@Sun.COM  * ****************************************************************************
30947836SJohn.Forte@Sun.COM  *
30957836SJohn.Forte@Sun.COM  * getStringArray
30967836SJohn.Forte@Sun.COM  * 	Return a null terminated array for the specified array as a string,
30977836SJohn.Forte@Sun.COM  *	This is used for inputting into the %s in formatted strings.
30987836SJohn.Forte@Sun.COM  *
30997836SJohn.Forte@Sun.COM  * arrayToDisplay	- array to display
31007836SJohn.Forte@Sun.COM  * arraySize		- size of array to display
31017836SJohn.Forte@Sun.COM  *
31027836SJohn.Forte@Sun.COM  * ****************************************************************************
31037836SJohn.Forte@Sun.COM  */
31047836SJohn.Forte@Sun.COM MP_CHAR *
getStringArray(MP_CHAR * arrayToDisplay,int arraySize)31057836SJohn.Forte@Sun.COM getStringArray(MP_CHAR *arrayToDisplay, int arraySize)
31067836SJohn.Forte@Sun.COM {
31077836SJohn.Forte@Sun.COM 	MP_CHAR					*newStr;
31087836SJohn.Forte@Sun.COM 
31097836SJohn.Forte@Sun.COM 	int					i;
31107836SJohn.Forte@Sun.COM 
31117836SJohn.Forte@Sun.COM 	newStr = malloc(((sizeof (MP_CHAR)) * arraySize) + 1);
31127836SJohn.Forte@Sun.COM 	if (NULL == newStr) {
31137836SJohn.Forte@Sun.COM 		(void) fprintf(stdout, "%s\n",
31147836SJohn.Forte@Sun.COM 		    getTextString(ERR_MEMORY_ALLOCATION));
31157836SJohn.Forte@Sun.COM 	} else {
31167836SJohn.Forte@Sun.COM 
31177836SJohn.Forte@Sun.COM 		for (i = 0; i < arraySize; i++) {
31187836SJohn.Forte@Sun.COM 			newStr[i] = arrayToDisplay[i];
31197836SJohn.Forte@Sun.COM 		}
31207836SJohn.Forte@Sun.COM 		newStr[arraySize] = '\0';
31217836SJohn.Forte@Sun.COM 	}
31227836SJohn.Forte@Sun.COM 
31237836SJohn.Forte@Sun.COM 	return (newStr);
31247836SJohn.Forte@Sun.COM }
31257836SJohn.Forte@Sun.COM 
31267836SJohn.Forte@Sun.COM 
31277836SJohn.Forte@Sun.COM /*
31287836SJohn.Forte@Sun.COM  * ****************************************************************************
31297836SJohn.Forte@Sun.COM  *
31307836SJohn.Forte@Sun.COM  * displayWideArray
31317836SJohn.Forte@Sun.COM  * 	Print out the specified wide character array as a string,
31327836SJohn.Forte@Sun.COM  * 	adding the null termination
31337836SJohn.Forte@Sun.COM  *
31347836SJohn.Forte@Sun.COM  * arrayToDisplay	- array to display
31357836SJohn.Forte@Sun.COM  * arraySize		- size of array to display
31367836SJohn.Forte@Sun.COM  *
31377836SJohn.Forte@Sun.COM  * ****************************************************************************
31387836SJohn.Forte@Sun.COM  */
31397836SJohn.Forte@Sun.COM void
displayWideArray(MP_WCHAR * arrayToDisplay,int arraySize)31407836SJohn.Forte@Sun.COM displayWideArray(MP_WCHAR *arrayToDisplay, int arraySize)
31417836SJohn.Forte@Sun.COM {
31427836SJohn.Forte@Sun.COM 	int					i;
31437836SJohn.Forte@Sun.COM 	int					numChars = arraySize/4;
31447836SJohn.Forte@Sun.COM 
31457836SJohn.Forte@Sun.COM 	for (i = 0; i < numChars; i++) {
31467836SJohn.Forte@Sun.COM 		if (L'\0' != arrayToDisplay[i]) {
31477836SJohn.Forte@Sun.COM 			(void) fprintf(stdout, "%wc", arrayToDisplay[i]);
31487836SJohn.Forte@Sun.COM 		}
31497836SJohn.Forte@Sun.COM 	}
31507836SJohn.Forte@Sun.COM }
31517836SJohn.Forte@Sun.COM 
31527836SJohn.Forte@Sun.COM 
31537836SJohn.Forte@Sun.COM /*
31547836SJohn.Forte@Sun.COM  * ****************************************************************************
31557836SJohn.Forte@Sun.COM  *
31567836SJohn.Forte@Sun.COM  * listfunc
31577836SJohn.Forte@Sun.COM  * 	Used by cmdparse for list clis
31587836SJohn.Forte@Sun.COM  *
31597836SJohn.Forte@Sun.COM  * ****************************************************************************
31607836SJohn.Forte@Sun.COM  */
31617836SJohn.Forte@Sun.COM /*ARGSUSED*/
31627836SJohn.Forte@Sun.COM static int
listFunc(int operandLen,char * operand[],int object,cmdOptions_t * options,void * addArgs)31637836SJohn.Forte@Sun.COM listFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
31647836SJohn.Forte@Sun.COM     void *addArgs)
31657836SJohn.Forte@Sun.COM {
31667836SJohn.Forte@Sun.COM 	int 					ret = 0;
31677836SJohn.Forte@Sun.COM 
31687836SJohn.Forte@Sun.COM 	switch (object) {
31697836SJohn.Forte@Sun.COM 		case MPATH_SUPPORT:
31707836SJohn.Forte@Sun.COM 			ret = listMpathSupport(operandLen, operand);
31717836SJohn.Forte@Sun.COM 			break;
31727836SJohn.Forte@Sun.COM 		case LOGICAL_UNIT:
31737836SJohn.Forte@Sun.COM 			ret = listLogicalUnit(operandLen, operand, options);
31747836SJohn.Forte@Sun.COM 			break;
31757836SJohn.Forte@Sun.COM 		case INITIATOR_PORT:
31767836SJohn.Forte@Sun.COM 			ret = listInitiatorPort(operandLen, operand);
31777836SJohn.Forte@Sun.COM 			break;
31787836SJohn.Forte@Sun.COM 		default:
31797836SJohn.Forte@Sun.COM 			(void) fprintf(stderr, "%s: %s\n",
3180*10696SDavid.Hollister@Sun.COM 			    cmdName, getTextString(TEXT_UNKNOWN_OBJECT));
31817836SJohn.Forte@Sun.COM 			ret = 1;
31827836SJohn.Forte@Sun.COM 			break;
31837836SJohn.Forte@Sun.COM 	}
31847836SJohn.Forte@Sun.COM 
31857836SJohn.Forte@Sun.COM 	return (ret);
31867836SJohn.Forte@Sun.COM }
31877836SJohn.Forte@Sun.COM 
31887836SJohn.Forte@Sun.COM 
31897836SJohn.Forte@Sun.COM /*
31907836SJohn.Forte@Sun.COM  * ****************************************************************************
31917836SJohn.Forte@Sun.COM  *
31927836SJohn.Forte@Sun.COM  * showFunc
31937836SJohn.Forte@Sun.COM  * 	used bycmdparse for show clis
31947836SJohn.Forte@Sun.COM  *
31957836SJohn.Forte@Sun.COM  * ****************************************************************************
31967836SJohn.Forte@Sun.COM  */
31977836SJohn.Forte@Sun.COM /*ARGSUSED*/
31987836SJohn.Forte@Sun.COM static int
showFunc(int operandLen,char * operand[],int object,cmdOptions_t * options,void * addArgs)31997836SJohn.Forte@Sun.COM showFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
32007836SJohn.Forte@Sun.COM     void *addArgs)
32017836SJohn.Forte@Sun.COM {
32027836SJohn.Forte@Sun.COM 	int 					ret = 0;
32037836SJohn.Forte@Sun.COM 
32047836SJohn.Forte@Sun.COM 	switch (object) {
32057836SJohn.Forte@Sun.COM 		case MPATH_SUPPORT:
32067836SJohn.Forte@Sun.COM 			ret = showMpathSupport(operandLen, operand);
32077836SJohn.Forte@Sun.COM 			break;
32087836SJohn.Forte@Sun.COM 		case LOGICAL_UNIT:
32097836SJohn.Forte@Sun.COM 			ret = showLogicalUnit(operandLen, operand);
32107836SJohn.Forte@Sun.COM 			break;
32117836SJohn.Forte@Sun.COM 		case INITIATOR_PORT:
32127836SJohn.Forte@Sun.COM 			ret = showInitiatorPort(operandLen, operand);
32137836SJohn.Forte@Sun.COM 			break;
32147836SJohn.Forte@Sun.COM 		default:
32157836SJohn.Forte@Sun.COM 			ret = 1;
32167836SJohn.Forte@Sun.COM 			break;
32177836SJohn.Forte@Sun.COM 	}
32187836SJohn.Forte@Sun.COM 
32197836SJohn.Forte@Sun.COM 	return (ret);
32207836SJohn.Forte@Sun.COM }
32217836SJohn.Forte@Sun.COM 
32227836SJohn.Forte@Sun.COM 
32237836SJohn.Forte@Sun.COM /*
32247836SJohn.Forte@Sun.COM  * ****************************************************************************
32257836SJohn.Forte@Sun.COM  *
32267836SJohn.Forte@Sun.COM  * modifyFunc
32277836SJohn.Forte@Sun.COM  * 	Used by cmdparse for midify clis
32287836SJohn.Forte@Sun.COM  *
32297836SJohn.Forte@Sun.COM  *
32307836SJohn.Forte@Sun.COM  * ****************************************************************************
32317836SJohn.Forte@Sun.COM  */
32327836SJohn.Forte@Sun.COM /*ARGSUSED*/
32337836SJohn.Forte@Sun.COM static int
modifyFunc(int operandLen,char * operand[],int object,cmdOptions_t * options,void * addArgs)32347836SJohn.Forte@Sun.COM modifyFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
32357836SJohn.Forte@Sun.COM     void *addArgs)
32367836SJohn.Forte@Sun.COM {
32377836SJohn.Forte@Sun.COM 	int 					ret = 0;
32387836SJohn.Forte@Sun.COM 
32397836SJohn.Forte@Sun.COM 	switch (object) {
32407836SJohn.Forte@Sun.COM 		case MPATH_SUPPORT:
32417836SJohn.Forte@Sun.COM 			ret = modifyMpathSupport(operandLen, operand, options);
32427836SJohn.Forte@Sun.COM 			break;
32437836SJohn.Forte@Sun.COM 		case LOGICAL_UNIT:
32447836SJohn.Forte@Sun.COM 			ret = modifyLogicalUnit(operandLen, operand, options);
32457836SJohn.Forte@Sun.COM 			break;
32467836SJohn.Forte@Sun.COM 		default:
32477836SJohn.Forte@Sun.COM 			ret = 1;
32487836SJohn.Forte@Sun.COM 			break;
32497836SJohn.Forte@Sun.COM 	}
32507836SJohn.Forte@Sun.COM 
32517836SJohn.Forte@Sun.COM 
32527836SJohn.Forte@Sun.COM 	return (ret);
32537836SJohn.Forte@Sun.COM }
32547836SJohn.Forte@Sun.COM 
32557836SJohn.Forte@Sun.COM 
32567836SJohn.Forte@Sun.COM /*
32577836SJohn.Forte@Sun.COM  * ****************************************************************************
32587836SJohn.Forte@Sun.COM  *
32597836SJohn.Forte@Sun.COM  * enableFunc
32607836SJohn.Forte@Sun.COM  * 	Used by cmdpars for enable clis
32617836SJohn.Forte@Sun.COM  *
32627836SJohn.Forte@Sun.COM  * ****************************************************************************
32637836SJohn.Forte@Sun.COM  */
32647836SJohn.Forte@Sun.COM /*ARGSUSED*/
32657836SJohn.Forte@Sun.COM static int
enableFunc(int operandLen,char * operand[],int object,cmdOptions_t * options,void * addArgs)32667836SJohn.Forte@Sun.COM enableFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
32677836SJohn.Forte@Sun.COM     void *addArgs)
32687836SJohn.Forte@Sun.COM {
32697836SJohn.Forte@Sun.COM 	int 					ret = 0;
32707836SJohn.Forte@Sun.COM 
32717836SJohn.Forte@Sun.COM 	switch (object) {
32727836SJohn.Forte@Sun.COM 		case PATH:
32737836SJohn.Forte@Sun.COM 			ret = enablePath(options);
32747836SJohn.Forte@Sun.COM 			break;
32757836SJohn.Forte@Sun.COM 		default:
32767836SJohn.Forte@Sun.COM 			ret = 1;
32777836SJohn.Forte@Sun.COM 			break;
32787836SJohn.Forte@Sun.COM 	}
32797836SJohn.Forte@Sun.COM 
32807836SJohn.Forte@Sun.COM 	return (ret);
32817836SJohn.Forte@Sun.COM }
32827836SJohn.Forte@Sun.COM 
32837836SJohn.Forte@Sun.COM 
32847836SJohn.Forte@Sun.COM /*
32857836SJohn.Forte@Sun.COM  * ****************************************************************************
32867836SJohn.Forte@Sun.COM  *
32877836SJohn.Forte@Sun.COM  * disableFunc
32887836SJohn.Forte@Sun.COM  * 	Used by cmdpars for disable clis
32897836SJohn.Forte@Sun.COM  *
32907836SJohn.Forte@Sun.COM  * ****************************************************************************
32917836SJohn.Forte@Sun.COM  */
32927836SJohn.Forte@Sun.COM /*ARGSUSED*/
32937836SJohn.Forte@Sun.COM static int
disableFunc(int operandLen,char * operand[],int object,cmdOptions_t * options,void * addArgs)32947836SJohn.Forte@Sun.COM disableFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
32957836SJohn.Forte@Sun.COM     void *addArgs)
32967836SJohn.Forte@Sun.COM {
32977836SJohn.Forte@Sun.COM 	int 					ret = 0;
32987836SJohn.Forte@Sun.COM 
32997836SJohn.Forte@Sun.COM 	switch (object) {
33007836SJohn.Forte@Sun.COM 		case PATH:
33017836SJohn.Forte@Sun.COM 			ret = disablePath(options);
33027836SJohn.Forte@Sun.COM 			break;
33037836SJohn.Forte@Sun.COM 		default:
33047836SJohn.Forte@Sun.COM 			ret = 1;
33057836SJohn.Forte@Sun.COM 			break;
33067836SJohn.Forte@Sun.COM 	}
33077836SJohn.Forte@Sun.COM 
33087836SJohn.Forte@Sun.COM 	return (ret);
33097836SJohn.Forte@Sun.COM }
33107836SJohn.Forte@Sun.COM 
33117836SJohn.Forte@Sun.COM 
33127836SJohn.Forte@Sun.COM /*
33137836SJohn.Forte@Sun.COM  * ****************************************************************************
33147836SJohn.Forte@Sun.COM  *
33157836SJohn.Forte@Sun.COM  * failoverFunc
33167836SJohn.Forte@Sun.COM  * 	Used by cmdpars for failover clis
33177836SJohn.Forte@Sun.COM  *
33187836SJohn.Forte@Sun.COM  * ****************************************************************************
33197836SJohn.Forte@Sun.COM  */
33207836SJohn.Forte@Sun.COM /*ARGSUSED*/
33217836SJohn.Forte@Sun.COM static int
failoverFunc(int operandLen,char * operand[],int object,cmdOptions_t * options,void * addArgs)33227836SJohn.Forte@Sun.COM failoverFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
33237836SJohn.Forte@Sun.COM     void *addArgs)
33247836SJohn.Forte@Sun.COM {
33257836SJohn.Forte@Sun.COM 	int 					ret = 0;
33267836SJohn.Forte@Sun.COM 
33277836SJohn.Forte@Sun.COM 	switch (object) {
33287836SJohn.Forte@Sun.COM 		case LOGICAL_UNIT:
33297836SJohn.Forte@Sun.COM 			ret = failoverLogicalUnit(operand);
33307836SJohn.Forte@Sun.COM 			break;
33317836SJohn.Forte@Sun.COM 		default:
33327836SJohn.Forte@Sun.COM 			ret = 1;
33337836SJohn.Forte@Sun.COM 			break;
33347836SJohn.Forte@Sun.COM 	}
33357836SJohn.Forte@Sun.COM 
33367836SJohn.Forte@Sun.COM 	return (ret);
33377836SJohn.Forte@Sun.COM }
33387836SJohn.Forte@Sun.COM 
33397836SJohn.Forte@Sun.COM 
33407836SJohn.Forte@Sun.COM /*
33417836SJohn.Forte@Sun.COM  * ****************************************************************************
33427836SJohn.Forte@Sun.COM  *
33437836SJohn.Forte@Sun.COM  * overrideFunc
33447836SJohn.Forte@Sun.COM  * 	Used by cmdpars for override clis
33457836SJohn.Forte@Sun.COM  *
33467836SJohn.Forte@Sun.COM  * ****************************************************************************
33477836SJohn.Forte@Sun.COM  */
33487836SJohn.Forte@Sun.COM /*ARGSUSED*/
33497836SJohn.Forte@Sun.COM static int
overrideFunc(int operandLen,char * operand[],int object,cmdOptions_t * options,void * addArgs)33507836SJohn.Forte@Sun.COM overrideFunc(int operandLen, char *operand[],
33517836SJohn.Forte@Sun.COM 	int object, cmdOptions_t *options,
33527836SJohn.Forte@Sun.COM     void *addArgs)
33537836SJohn.Forte@Sun.COM {
33547836SJohn.Forte@Sun.COM 	int 					ret = 0;
33557836SJohn.Forte@Sun.COM 
33567836SJohn.Forte@Sun.COM 	switch (object) {
33577836SJohn.Forte@Sun.COM 		case PATH:
33587836SJohn.Forte@Sun.COM 			ret = overridePath(options);
33597836SJohn.Forte@Sun.COM 			break;
33607836SJohn.Forte@Sun.COM 		default:
33617836SJohn.Forte@Sun.COM 			ret = 1;
33627836SJohn.Forte@Sun.COM 			break;
33637836SJohn.Forte@Sun.COM 	}
33647836SJohn.Forte@Sun.COM 
33657836SJohn.Forte@Sun.COM 
33667836SJohn.Forte@Sun.COM 	return (ret);
33677836SJohn.Forte@Sun.COM }
33687836SJohn.Forte@Sun.COM 
33697836SJohn.Forte@Sun.COM 
33707836SJohn.Forte@Sun.COM /*
33717836SJohn.Forte@Sun.COM  * *************************************************************************
33727836SJohn.Forte@Sun.COM  *
33737836SJohn.Forte@Sun.COM  * main
33747836SJohn.Forte@Sun.COM  *
33757836SJohn.Forte@Sun.COM  * *************************************************************************
33767836SJohn.Forte@Sun.COM  */
33777836SJohn.Forte@Sun.COM int
main(int argc,char * argv[])33787836SJohn.Forte@Sun.COM main(int argc, char *argv[])
33797836SJohn.Forte@Sun.COM {
33807836SJohn.Forte@Sun.COM 	synTables_t 			synTables;
33817836SJohn.Forte@Sun.COM 	char 				versionString[VERSION_STRING_MAX_LEN];
33827836SJohn.Forte@Sun.COM 	int 				ret;
33837836SJohn.Forte@Sun.COM 	int 				funcRet;
33847836SJohn.Forte@Sun.COM 	void 				*subcommandArgs = NULL;
33857836SJohn.Forte@Sun.COM 
33867836SJohn.Forte@Sun.COM 	/* set global command name */
33877836SJohn.Forte@Sun.COM 	cmdName = getExecBasename(argv[0]);
33887836SJohn.Forte@Sun.COM 
33897836SJohn.Forte@Sun.COM 	(void) sprintf(versionString, "%2s.%2s",
33907836SJohn.Forte@Sun.COM 	    VERSION_STRING_MAJOR, VERSION_STRING_MINOR);
33917836SJohn.Forte@Sun.COM 	synTables.versionString = versionString;
33927836SJohn.Forte@Sun.COM 	synTables.longOptionTbl = &longOptions[0];
33937836SJohn.Forte@Sun.COM 	synTables.subcommandTbl = &subcommands[0];
33947836SJohn.Forte@Sun.COM 	synTables.objectTbl = &objects[0];
33957836SJohn.Forte@Sun.COM 	synTables.objectRulesTbl = &objectRules[0];
33967836SJohn.Forte@Sun.COM 	synTables.optionRulesTbl = &optionRules[0];
33977836SJohn.Forte@Sun.COM 
33987836SJohn.Forte@Sun.COM 	ret = cmdParse(argc, argv, /* SUB_COMMAND_ISSUED, */ synTables,
33997836SJohn.Forte@Sun.COM 	    subcommandArgs, &funcRet);
34007836SJohn.Forte@Sun.COM 	if (ret == 1) {
34017836SJohn.Forte@Sun.COM 		(void) fprintf(stdout, "%s %s(1M)\n",
34027836SJohn.Forte@Sun.COM 		    getTextString(TEXT_MORE_INFO), cmdName);
34037836SJohn.Forte@Sun.COM 		return (ERROR_CLI_FAILED);
34047836SJohn.Forte@Sun.COM 	} else if (ret == -1) {
34057836SJohn.Forte@Sun.COM 		perror(argv[0]);
34067836SJohn.Forte@Sun.COM 		return (1);
34077836SJohn.Forte@Sun.COM 	}
34087836SJohn.Forte@Sun.COM 
34097836SJohn.Forte@Sun.COM 	if (funcRet != 0) {
34107836SJohn.Forte@Sun.COM 		(void) fprintf(stderr, "%s: %s\n",
34117836SJohn.Forte@Sun.COM 		    argv[0], getTextString(TEXT_UNABLE_TO_COMPLETE));
34127836SJohn.Forte@Sun.COM 		return (1);
34137836SJohn.Forte@Sun.COM 	}
34147836SJohn.Forte@Sun.COM 	return (0);
34157836SJohn.Forte@Sun.COM 
34167836SJohn.Forte@Sun.COM } /* end main */
3417