xref: /titanic_50/usr/src/cmd/mpathadm/mpathadm.c (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
1*fcf3ce44SJohn Forte /*
2*fcf3ce44SJohn Forte  * CDDL HEADER START
3*fcf3ce44SJohn Forte  *
4*fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5*fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6*fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7*fcf3ce44SJohn Forte  *
8*fcf3ce44SJohn Forte  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*fcf3ce44SJohn Forte  * or http://www.opensolaris.org/os/licensing.
10*fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11*fcf3ce44SJohn Forte  * and limitations under the License.
12*fcf3ce44SJohn Forte  *
13*fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14*fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16*fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17*fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18*fcf3ce44SJohn Forte  *
19*fcf3ce44SJohn Forte  * CDDL HEADER END
20*fcf3ce44SJohn Forte  */
21*fcf3ce44SJohn Forte /*
22*fcf3ce44SJohn Forte  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*fcf3ce44SJohn Forte  * Use is subject to license terms.
24*fcf3ce44SJohn Forte  */
25*fcf3ce44SJohn Forte 
26*fcf3ce44SJohn Forte /*
27*fcf3ce44SJohn Forte  * mpathadm.c : MP API CLI program
28*fcf3ce44SJohn Forte  *
29*fcf3ce44SJohn Forte  */
30*fcf3ce44SJohn Forte 
31*fcf3ce44SJohn Forte #include <libintl.h>
32*fcf3ce44SJohn Forte 
33*fcf3ce44SJohn Forte #include <mpapi.h>
34*fcf3ce44SJohn Forte #include "cmdparse.h"
35*fcf3ce44SJohn Forte #include "mpathadm_text.h"
36*fcf3ce44SJohn Forte #include "mpathadm.h"
37*fcf3ce44SJohn Forte 
38*fcf3ce44SJohn Forte #include <sys/types.h>
39*fcf3ce44SJohn Forte #include <sys/stat.h>
40*fcf3ce44SJohn Forte #include <unistd.h>
41*fcf3ce44SJohn Forte #include <stdlib.h>
42*fcf3ce44SJohn Forte #include <devid.h>
43*fcf3ce44SJohn Forte #include <fcntl.h>
44*fcf3ce44SJohn Forte 
45*fcf3ce44SJohn Forte /* helper functions */
46*fcf3ce44SJohn Forte static char *getExecBasename(char *);
47*fcf3ce44SJohn Forte 
48*fcf3ce44SJohn Forte /* object functions per subcommand */
49*fcf3ce44SJohn Forte static int listFunc(int, char **, int, cmdOptions_t *, void *);
50*fcf3ce44SJohn Forte static int showFunc(int, char **, int, cmdOptions_t *, void *);
51*fcf3ce44SJohn Forte static int modifyFunc(int, char **, int, cmdOptions_t *, void *);
52*fcf3ce44SJohn Forte static int enableFunc(int, char **, int, cmdOptions_t *, void *);
53*fcf3ce44SJohn Forte static int disableFunc(int, char **, int, cmdOptions_t *, void *);
54*fcf3ce44SJohn Forte static int failoverFunc(int, char **, int, cmdOptions_t *, void *);
55*fcf3ce44SJohn Forte static int overrideFunc(int, char **, int, cmdOptions_t *, void *);
56*fcf3ce44SJohn Forte 
57*fcf3ce44SJohn Forte #define	VERSION_STRING_MAX_LEN	10
58*fcf3ce44SJohn Forte 
59*fcf3ce44SJohn Forte #define	OPTIONSTRING_NAME	"name"
60*fcf3ce44SJohn Forte #define	OPTIONSTRING_TPNAME	"target-port name"
61*fcf3ce44SJohn Forte #define	OPTIONSTRING_ONOFF	"on/off"
62*fcf3ce44SJohn Forte #define	OPTIONSTRING_LBTYPE	"loadbalance type"
63*fcf3ce44SJohn Forte #define	OPTIONSTRING_IPORT	"initiator-port name"
64*fcf3ce44SJohn Forte #define	OPTIONSTRING_LUNIT	"logical-unit name"
65*fcf3ce44SJohn Forte #define	OPTIONSTRING_CANCEL	"cancel"
66*fcf3ce44SJohn Forte #define	OPTIONSTRING_VALUE	"value"
67*fcf3ce44SJohn Forte 
68*fcf3ce44SJohn Forte /*
69*fcf3ce44SJohn Forte  * Version number: (copied from iscsiadm)
70*fcf3ce44SJohn Forte  *  MAJOR - This should only change when there is an incompatible change made
71*fcf3ce44SJohn Forte  *  to the interfaces or the output.
72*fcf3ce44SJohn Forte  *
73*fcf3ce44SJohn Forte  *  MINOR - This should change whenever there is a new command or new feature
74*fcf3ce44SJohn Forte  *  with no incompatible change.
75*fcf3ce44SJohn Forte  */
76*fcf3ce44SJohn Forte #define	VERSION_STRING_MAJOR	    "1"
77*fcf3ce44SJohn Forte #define	VERSION_STRING_MINOR	    "0"
78*fcf3ce44SJohn Forte 
79*fcf3ce44SJohn Forte 
80*fcf3ce44SJohn Forte /* globals */
81*fcf3ce44SJohn Forte static char *cmdName;
82*fcf3ce44SJohn Forte 
83*fcf3ce44SJohn Forte 
84*fcf3ce44SJohn Forte /*
85*fcf3ce44SJohn Forte  * ****************************************************************************
86*fcf3ce44SJohn Forte  *
87*fcf3ce44SJohn Forte  * getExecBasename - copied from iscsiadm code
88*fcf3ce44SJohn Forte  *
89*fcf3ce44SJohn Forte  * input:
90*fcf3ce44SJohn Forte  *  execFullName - exec name of program (argv[0])
91*fcf3ce44SJohn Forte  *
92*fcf3ce44SJohn Forte  * Returns:
93*fcf3ce44SJohn Forte  *  command name portion of execFullName
94*fcf3ce44SJohn Forte  *
95*fcf3ce44SJohn Forte  * ****************************************************************************
96*fcf3ce44SJohn Forte  */
97*fcf3ce44SJohn Forte static char *
98*fcf3ce44SJohn Forte getExecBasename(char *execFullname)
99*fcf3ce44SJohn Forte {
100*fcf3ce44SJohn Forte 	char 				*lastSlash, *execBasename;
101*fcf3ce44SJohn Forte 
102*fcf3ce44SJohn Forte 	/* guard against '/' at end of command invocation */
103*fcf3ce44SJohn Forte 	for (;;) {
104*fcf3ce44SJohn Forte 		lastSlash = strrchr(execFullname, '/');
105*fcf3ce44SJohn Forte 		if (lastSlash == NULL) {
106*fcf3ce44SJohn Forte 			execBasename = execFullname;
107*fcf3ce44SJohn Forte 			break;
108*fcf3ce44SJohn Forte 		} else {
109*fcf3ce44SJohn Forte 			execBasename = lastSlash + 1;
110*fcf3ce44SJohn Forte 			if (*execBasename == '\0') {
111*fcf3ce44SJohn Forte 				*lastSlash = '\0';
112*fcf3ce44SJohn Forte 				continue;
113*fcf3ce44SJohn Forte 			}
114*fcf3ce44SJohn Forte 			break;
115*fcf3ce44SJohn Forte 		}
116*fcf3ce44SJohn Forte 	}
117*fcf3ce44SJohn Forte 	return (execBasename);
118*fcf3ce44SJohn Forte }
119*fcf3ce44SJohn Forte 
120*fcf3ce44SJohn Forte 
121*fcf3ce44SJohn Forte /*
122*fcf3ce44SJohn Forte  * Add new options here
123*fcf3ce44SJohn Forte  */
124*fcf3ce44SJohn Forte 
125*fcf3ce44SJohn Forte /* tables set up based on cmdparse instructions */
126*fcf3ce44SJohn Forte optionTbl_t longOptions[] = {
127*fcf3ce44SJohn Forte 	{"inqname", required_arg, 'n', OPTIONSTRING_NAME},
128*fcf3ce44SJohn Forte 	{"target-port", required_arg, 't', OPTIONSTRING_TPNAME},
129*fcf3ce44SJohn Forte 	{"autofailback", required_arg, 'a', OPTIONSTRING_ONOFF},
130*fcf3ce44SJohn Forte 	{"autoprobe", required_arg, 'p', OPTIONSTRING_ONOFF},
131*fcf3ce44SJohn Forte 	{"loadbalance", required_arg, 'b', OPTIONSTRING_LBTYPE},
132*fcf3ce44SJohn Forte 	{"initiator-port", required_arg, 'i', OPTIONSTRING_IPORT},
133*fcf3ce44SJohn Forte 	{"logical-unit", required_arg, 'l', OPTIONSTRING_LUNIT},
134*fcf3ce44SJohn Forte 	{"cancel", no_arg, 'c', OPTIONSTRING_CANCEL},
135*fcf3ce44SJohn Forte 	{"vendor-id", required_arg, 'd', OPTIONSTRING_VALUE},
136*fcf3ce44SJohn Forte 	{NULL, 0, 0, 0}
137*fcf3ce44SJohn Forte };
138*fcf3ce44SJohn Forte 
139*fcf3ce44SJohn Forte 
140*fcf3ce44SJohn Forte /*
141*fcf3ce44SJohn Forte  * Add new subcommands here
142*fcf3ce44SJohn Forte  */
143*fcf3ce44SJohn Forte subcommand_t subcommands[] = {
144*fcf3ce44SJohn Forte 	{"list", LIST, listFunc},
145*fcf3ce44SJohn Forte 	{"show", SHOW, showFunc},
146*fcf3ce44SJohn Forte 	{"modify", MODIFY, modifyFunc},
147*fcf3ce44SJohn Forte 	{"enable", ENABLE, enableFunc},
148*fcf3ce44SJohn Forte 	{"disable", DISABLE, disableFunc},
149*fcf3ce44SJohn Forte 	{"failover", FAILOVER, failoverFunc},
150*fcf3ce44SJohn Forte 	{"override", OVERRIDE, overrideFunc},
151*fcf3ce44SJohn Forte 	{NULL, 0, NULL}
152*fcf3ce44SJohn Forte };
153*fcf3ce44SJohn Forte 
154*fcf3ce44SJohn Forte /*
155*fcf3ce44SJohn Forte  * Add objects here
156*fcf3ce44SJohn Forte  */
157*fcf3ce44SJohn Forte object_t objects[] = {
158*fcf3ce44SJohn Forte 	{"mpath-support", MPATH_SUPPORT},
159*fcf3ce44SJohn Forte 	{"logical-unit", LOGICAL_UNIT},
160*fcf3ce44SJohn Forte 	{"LU", LOGICAL_UNIT},
161*fcf3ce44SJohn Forte 	{"initiator-port", INITIATOR_PORT},
162*fcf3ce44SJohn Forte 	{"path", PATH},
163*fcf3ce44SJohn Forte 	{NULL, 0}
164*fcf3ce44SJohn Forte };
165*fcf3ce44SJohn Forte 
166*fcf3ce44SJohn Forte /*
167*fcf3ce44SJohn Forte  * Rules for subcommands and objects
168*fcf3ce44SJohn Forte  *
169*fcf3ce44SJohn Forte  * command
170*fcf3ce44SJohn Forte  *
171*fcf3ce44SJohn Forte  * reqOpCmd -> subcommands that must have an operand
172*fcf3ce44SJohn Forte  * optOpCmd -> subcommands that may have an operand
173*fcf3ce44SJohn Forte  * noOpCmd -> subcommands that will have no operand
174*fcf3ce44SJohn Forte  * invCmd -> subcommands that are invalid
175*fcf3ce44SJohn Forte  * multOpCmd -> subcommands that can accept multiple operands
176*fcf3ce44SJohn Forte  * operandDefinition -> Usage definition for the operand of this object
177*fcf3ce44SJohn Forte  */
178*fcf3ce44SJohn Forte objectRules_t objectRules[] = {
179*fcf3ce44SJohn Forte 	{MPATH_SUPPORT, SHOW|MODIFY|ADD, LIST|REMOVE, 0,
180*fcf3ce44SJohn Forte 	    ENABLE|DISABLE|FAILOVER|OVERRIDE, LIST|SHOW|MODIFY,
181*fcf3ce44SJohn Forte 	    "mpath-support name"},
182*fcf3ce44SJohn Forte 	{INITIATOR_PORT, SHOW, LIST, 0,
183*fcf3ce44SJohn Forte 	    MODIFY|ENABLE|DISABLE|FAILOVER|OVERRIDE|ADD|REMOVE, LIST|SHOW,
184*fcf3ce44SJohn Forte 	    "initiator-port name"},
185*fcf3ce44SJohn Forte 	{LOGICAL_UNIT, SHOW|MODIFY|FAILOVER, LIST, 0,
186*fcf3ce44SJohn Forte 	    ENABLE|DISABLE|OVERRIDE|ADD|REMOVE, LIST|SHOW|MODIFY,
187*fcf3ce44SJohn Forte 	    "logical-unit name"},
188*fcf3ce44SJohn Forte 	{PATH, 0, 0, ENABLE|DISABLE|OVERRIDE,
189*fcf3ce44SJohn Forte 	    SHOW|LIST|MODIFY|FAILOVER|ADD|REMOVE, 0,
190*fcf3ce44SJohn Forte 	    "initiator-port name"},
191*fcf3ce44SJohn Forte 	{0, 0, 0, 0, 0, NULL}
192*fcf3ce44SJohn Forte };
193*fcf3ce44SJohn Forte 
194*fcf3ce44SJohn Forte /*
195*fcf3ce44SJohn Forte  * list of objects, subcommands, valid short options, required flag and
196*fcf3ce44SJohn Forte  * exclusive option string
197*fcf3ce44SJohn Forte  *
198*fcf3ce44SJohn Forte  * If it's not here, there are no options for that object.
199*fcf3ce44SJohn Forte  */
200*fcf3ce44SJohn Forte optionRules_t optionRules[] = {
201*fcf3ce44SJohn Forte 	{LOGICAL_UNIT, LIST, "nt", B_FALSE, NULL},
202*fcf3ce44SJohn Forte 	{LOGICAL_UNIT, MODIFY, "apb", B_TRUE, NULL},
203*fcf3ce44SJohn Forte 	{MPATH_SUPPORT, MODIFY, "apb", B_TRUE, NULL},
204*fcf3ce44SJohn Forte 	{MPATH_SUPPORT, ADD, "d", B_TRUE, NULL},
205*fcf3ce44SJohn Forte 	{MPATH_SUPPORT, REMOVE, "d", B_TRUE, NULL},
206*fcf3ce44SJohn Forte 	{PATH, ENABLE, "itl", B_TRUE, NULL},
207*fcf3ce44SJohn Forte 	{PATH, DISABLE, "itl", B_TRUE, NULL},
208*fcf3ce44SJohn Forte 	{PATH, OVERRIDE, "itlc", B_TRUE, NULL},
209*fcf3ce44SJohn Forte 	{0, 0, 0, 0, 0}
210*fcf3ce44SJohn Forte };
211*fcf3ce44SJohn Forte 
212*fcf3ce44SJohn Forte 
213*fcf3ce44SJohn Forte /*
214*fcf3ce44SJohn Forte  * ****************************************************************************
215*fcf3ce44SJohn Forte  *
216*fcf3ce44SJohn Forte  * listMpathSupport - mpathadm list mpath-support
217*fcf3ce44SJohn Forte  *
218*fcf3ce44SJohn Forte  * operandLen	- number of operands user passed into the cli
219*fcf3ce44SJohn Forte  * operand	- pointer to operand list from user
220*fcf3ce44SJohn Forte  *
221*fcf3ce44SJohn Forte  * ****************************************************************************
222*fcf3ce44SJohn Forte  */
223*fcf3ce44SJohn Forte int
224*fcf3ce44SJohn Forte listMpathSupport(int operandLen, char *operand[])
225*fcf3ce44SJohn Forte {
226*fcf3ce44SJohn Forte 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
227*fcf3ce44SJohn Forte 	MP_PLUGIN_PROPERTIES			pluginProps;
228*fcf3ce44SJohn Forte 	MP_OID_LIST				*pPluginOidList;
229*fcf3ce44SJohn Forte 	boolean_t				shown = B_FALSE;
230*fcf3ce44SJohn Forte 	/* number of plugins listed */
231*fcf3ce44SJohn Forte 	int					i,
232*fcf3ce44SJohn Forte 						op;
233*fcf3ce44SJohn Forte 
234*fcf3ce44SJohn Forte 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
235*fcf3ce44SJohn Forte 	    != MP_STATUS_SUCCESS) {
236*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s: %s\n", cmdName,
237*fcf3ce44SJohn Forte 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
238*fcf3ce44SJohn Forte 		return (mpstatus);
239*fcf3ce44SJohn Forte 	}
240*fcf3ce44SJohn Forte 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
241*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s: %s\n", cmdName,
242*fcf3ce44SJohn Forte 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
243*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
244*fcf3ce44SJohn Forte 	}
245*fcf3ce44SJohn Forte 
246*fcf3ce44SJohn Forte 
247*fcf3ce44SJohn Forte 	/* loop through operands first */
248*fcf3ce44SJohn Forte 	for (op = 0; (op < operandLen) |
249*fcf3ce44SJohn Forte 	    ((0 == operandLen) && (B_FALSE == shown)); op++) {
250*fcf3ce44SJohn Forte 		shown = B_TRUE;
251*fcf3ce44SJohn Forte 		for (i = 0; i < pPluginOidList->oidCount; i++) {
252*fcf3ce44SJohn Forte 
253*fcf3ce44SJohn Forte 			(void) memset(&pluginProps, 0,
254*fcf3ce44SJohn Forte 			    sizeof (MP_PLUGIN_PROPERTIES));
255*fcf3ce44SJohn Forte 			mpstatus =
256*fcf3ce44SJohn Forte 			    MP_GetPluginProperties(pPluginOidList->oids[i],
257*fcf3ce44SJohn Forte 			    &pluginProps);
258*fcf3ce44SJohn Forte 			if (mpstatus != MP_STATUS_SUCCESS) {
259*fcf3ce44SJohn Forte 				(void) fprintf(stderr, "%s:  %s\n",
260*fcf3ce44SJohn Forte 				    cmdName, getTextString(ERR_NO_PROPERTIES));
261*fcf3ce44SJohn Forte 			} else {
262*fcf3ce44SJohn Forte 				if (0 == operandLen) {
263*fcf3ce44SJohn Forte 					/* if no operands, list them all */
264*fcf3ce44SJohn Forte 					(void) printf("%s  %s\n",
265*fcf3ce44SJohn Forte 					    getTextString(
266*fcf3ce44SJohn Forte 					    TEXT_LB_MPATH_SUPPORT),
267*fcf3ce44SJohn Forte 					    pluginProps.fileName);
268*fcf3ce44SJohn Forte 				} else {
269*fcf3ce44SJohn Forte 					/* if there is an operand... */
270*fcf3ce44SJohn Forte 					/* ... compare and display if match */
271*fcf3ce44SJohn Forte 					if (0 ==
272*fcf3ce44SJohn Forte 					    strcmp(operand[op],
273*fcf3ce44SJohn Forte 					    pluginProps.fileName)) {
274*fcf3ce44SJohn Forte 						(void) printf("%s  %s\n",
275*fcf3ce44SJohn Forte 						    getTextString(
276*fcf3ce44SJohn Forte 						    TEXT_LB_MPATH_SUPPORT),
277*fcf3ce44SJohn Forte 						    pluginProps.fileName);
278*fcf3ce44SJohn Forte 					} else {
279*fcf3ce44SJohn Forte 					/* LINTED E_SEC_PRINTF_VAR_FMT */
280*fcf3ce44SJohn Forte 						(void) fprintf(stderr,
281*fcf3ce44SJohn Forte 						    getTextString(
282*fcf3ce44SJohn Forte 				    ERR_CANT_FIND_MPATH_SUPPORT_WITH_NAME),
283*fcf3ce44SJohn Forte 						    operand[op]);
284*fcf3ce44SJohn Forte 						(void) printf("\n");
285*fcf3ce44SJohn Forte 					}
286*fcf3ce44SJohn Forte 				}
287*fcf3ce44SJohn Forte 			}
288*fcf3ce44SJohn Forte 		}
289*fcf3ce44SJohn Forte 	}
290*fcf3ce44SJohn Forte 
291*fcf3ce44SJohn Forte 	return (mpstatus);
292*fcf3ce44SJohn Forte }
293*fcf3ce44SJohn Forte 
294*fcf3ce44SJohn Forte 
295*fcf3ce44SJohn Forte /*
296*fcf3ce44SJohn Forte  * ****************************************************************************
297*fcf3ce44SJohn Forte  *
298*fcf3ce44SJohn Forte  * showMpathSupport - mpathadm show mpath-support <mpath-support name>, ...
299*fcf3ce44SJohn Forte  *
300*fcf3ce44SJohn Forte  * operandLen	- number of operands user passed into the cli
301*fcf3ce44SJohn Forte  * operand	- pointer to operand list from user
302*fcf3ce44SJohn Forte  *
303*fcf3ce44SJohn Forte  * ****************************************************************************
304*fcf3ce44SJohn Forte  */
305*fcf3ce44SJohn Forte int
306*fcf3ce44SJohn Forte showMpathSupport(int operandLen, char *operand[])
307*fcf3ce44SJohn Forte {
308*fcf3ce44SJohn Forte 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
309*fcf3ce44SJohn Forte 	MP_PLUGIN_PROPERTIES			pluginProps;
310*fcf3ce44SJohn Forte 	MP_OID_LIST				*pPluginOidList;
311*fcf3ce44SJohn Forte 	MP_OID_LIST				*deviceOidListArray;
312*fcf3ce44SJohn Forte 	MP_DEVICE_PRODUCT_PROPERTIES		devProps;
313*fcf3ce44SJohn Forte 	boolean_t				bListIt = B_FALSE;
314*fcf3ce44SJohn Forte 	int					op,
315*fcf3ce44SJohn Forte 						i,
316*fcf3ce44SJohn Forte 						j;
317*fcf3ce44SJohn Forte 	MP_LOAD_BALANCE_TYPE 			lb;
318*fcf3ce44SJohn Forte 
319*fcf3ce44SJohn Forte 
320*fcf3ce44SJohn Forte 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList)) !=
321*fcf3ce44SJohn Forte 	    MP_STATUS_SUCCESS) {
322*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s:  %s\n",
323*fcf3ce44SJohn Forte 		    cmdName, getTextString(ERR_NO_MPATH_SUPPORT_LIST));
324*fcf3ce44SJohn Forte 		return (mpstatus);
325*fcf3ce44SJohn Forte 	}
326*fcf3ce44SJohn Forte 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
327*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s:  %s\n",
328*fcf3ce44SJohn Forte 		    cmdName, getTextString(ERR_NO_MPATH_SUPPORT_LIST));
329*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
330*fcf3ce44SJohn Forte 	}
331*fcf3ce44SJohn Forte 
332*fcf3ce44SJohn Forte 	for (op = 0; op < operandLen; op++) {
333*fcf3ce44SJohn Forte 	    bListIt = B_FALSE;
334*fcf3ce44SJohn Forte 
335*fcf3ce44SJohn Forte 		for (i = 0; i < pPluginOidList->oidCount; i++) {
336*fcf3ce44SJohn Forte 
337*fcf3ce44SJohn Forte 			(void) memset(&pluginProps, 0,
338*fcf3ce44SJohn Forte 			    sizeof (MP_PLUGIN_PROPERTIES));
339*fcf3ce44SJohn Forte 			mpstatus =
340*fcf3ce44SJohn Forte 			    MP_GetPluginProperties(pPluginOidList->oids[i],
341*fcf3ce44SJohn Forte 			    &pluginProps);
342*fcf3ce44SJohn Forte 			if (MP_STATUS_SUCCESS != mpstatus) {
343*fcf3ce44SJohn Forte 				(void) fprintf(stderr, "%s: %s\n",
344*fcf3ce44SJohn Forte 				    cmdName, getTextString(ERR_NO_PROPERTIES));
345*fcf3ce44SJohn Forte 				return (mpstatus);
346*fcf3ce44SJohn Forte 				}
347*fcf3ce44SJohn Forte 
348*fcf3ce44SJohn Forte 				if (0 == operandLen) {
349*fcf3ce44SJohn Forte 					/* if no operand, list it */
350*fcf3ce44SJohn Forte 					bListIt = B_TRUE;
351*fcf3ce44SJohn Forte 				} else {
352*fcf3ce44SJohn Forte 					/* ... compare and display if match */
353*fcf3ce44SJohn Forte 					if (0 ==
354*fcf3ce44SJohn Forte 					    strcmp(operand[op],
355*fcf3ce44SJohn Forte 					    pluginProps.fileName)) {
356*fcf3ce44SJohn Forte 						bListIt = B_TRUE;
357*fcf3ce44SJohn Forte 				}
358*fcf3ce44SJohn Forte 			}
359*fcf3ce44SJohn Forte 
360*fcf3ce44SJohn Forte 			if (B_TRUE != bListIt) {
361*fcf3ce44SJohn Forte 				break;
362*fcf3ce44SJohn Forte 			}
363*fcf3ce44SJohn Forte 
364*fcf3ce44SJohn Forte 			(void) printf("%s  %s\n",
365*fcf3ce44SJohn Forte 			    getTextString(TEXT_LB_MPATH_SUPPORT),
366*fcf3ce44SJohn Forte 			    pluginProps.fileName);
367*fcf3ce44SJohn Forte 
368*fcf3ce44SJohn Forte 			/* display the info for this plugin */
369*fcf3ce44SJohn Forte 			(void) printf("\t%s  ", getTextString(TEXT_LB_VENDOR));
370*fcf3ce44SJohn Forte 			displayWideArray(pluginProps.vendor,
371*fcf3ce44SJohn Forte 			    sizeof (pluginProps.vendor));
372*fcf3ce44SJohn Forte 			(void) printf("\n\t%s  ",
373*fcf3ce44SJohn Forte 			    getTextString(TEXT_LB_DRIVER_NAME));
374*fcf3ce44SJohn Forte 			displayArray(pluginProps.driverName,
375*fcf3ce44SJohn Forte 			    sizeof (pluginProps.driverName));
376*fcf3ce44SJohn Forte 			(void) printf("\n\t%s  ",
377*fcf3ce44SJohn Forte 			    getTextString(TEXT_LB_DEFAULT_LB));
378*fcf3ce44SJohn Forte 			/* don't ignore load balance type none. */
379*fcf3ce44SJohn Forte 			if (pluginProps.defaultloadBalanceType == 0) {
380*fcf3ce44SJohn Forte 			    (void) printf("%s",
381*fcf3ce44SJohn Forte 			    getTextString(TEXT_LBTYPE_NONE));
382*fcf3ce44SJohn Forte 			} else {
383*fcf3ce44SJohn Forte 			    displayLoadBalanceString(
384*fcf3ce44SJohn Forte 			    pluginProps.defaultloadBalanceType);
385*fcf3ce44SJohn Forte 			}
386*fcf3ce44SJohn Forte 			(void) printf("\n");
387*fcf3ce44SJohn Forte 
388*fcf3ce44SJohn Forte 
389*fcf3ce44SJohn Forte 			(void) printf("\t%s  \n",
390*fcf3ce44SJohn Forte 			    getTextString(TEXT_LB_SUPPORTED_LB));
391*fcf3ce44SJohn Forte 			/* check each bit, display string if found set */
392*fcf3ce44SJohn Forte 			if (pluginProps.supportedLoadBalanceTypes == 0) {
393*fcf3ce44SJohn Forte 				(void) printf("\t\t%s\n",
394*fcf3ce44SJohn Forte 					getTextString(TEXT_LBTYPE_NONE));
395*fcf3ce44SJohn Forte 			} else {
396*fcf3ce44SJohn Forte 			    lb = 1;
397*fcf3ce44SJohn Forte 			    do {
398*fcf3ce44SJohn Forte 				if (0 != (lb &
399*fcf3ce44SJohn Forte 				    pluginProps.supportedLoadBalanceTypes)) {
400*fcf3ce44SJohn Forte 					(void) printf("\t\t");
401*fcf3ce44SJohn Forte 					displayLoadBalanceString(lb &
402*fcf3ce44SJohn Forte 					pluginProps.supportedLoadBalanceTypes);
403*fcf3ce44SJohn Forte 					(void) printf("\n");
404*fcf3ce44SJohn Forte 				}
405*fcf3ce44SJohn Forte 				lb = lb<<1;
406*fcf3ce44SJohn Forte 			    } while (lb < 0x80000000);
407*fcf3ce44SJohn Forte 			}
408*fcf3ce44SJohn Forte 
409*fcf3ce44SJohn Forte 			(void) printf("\t%s  %s\n",
410*fcf3ce44SJohn Forte 			    getTextString(TEXT_LB_ALLOWS_ACT_TPG),
411*fcf3ce44SJohn Forte 			    (MP_TRUE == pluginProps.canSetTPGAccess)?
412*fcf3ce44SJohn Forte 			    getTextString(TEXT_YES):getTextString(TEXT_NO));
413*fcf3ce44SJohn Forte 			(void) printf("\t%s  %s\n",
414*fcf3ce44SJohn Forte 			    getTextString(TEXT_LB_ALLOWS_PATH_OV),
415*fcf3ce44SJohn Forte 			    (MP_TRUE == pluginProps.canOverridePaths)?
416*fcf3ce44SJohn Forte 			    getTextString(TEXT_YES):getTextString(TEXT_NO));
417*fcf3ce44SJohn Forte 			(void) printf("\t%s  %d\n",
418*fcf3ce44SJohn Forte 			    getTextString(TEXT_LB_SUPP_AUTO_FB),
419*fcf3ce44SJohn Forte 			    pluginProps.autoFailbackSupport);
420*fcf3ce44SJohn Forte 			if ((MP_AUTOFAILBACK_SUPPORT_PLUGIN  ==
421*fcf3ce44SJohn Forte 			    pluginProps.autoFailbackSupport) |
422*fcf3ce44SJohn Forte 			    (MP_AUTOFAILBACK_SUPPORT_PLUGINANDMPLU
423*fcf3ce44SJohn Forte 			    == pluginProps.autoFailbackSupport)) {
424*fcf3ce44SJohn Forte 				(void) printf("\t%s  %s\n",
425*fcf3ce44SJohn Forte 				    getTextString(TEXT_LB_AUTO_FB),
426*fcf3ce44SJohn Forte 				    pluginProps.pluginAutoFailbackEnabled?\
427*fcf3ce44SJohn Forte 				    getTextString(TEXT_ON):
428*fcf3ce44SJohn Forte 				    getTextString(TEXT_OFF));
429*fcf3ce44SJohn Forte 				(void) printf("\t%s  %d/%d\n",
430*fcf3ce44SJohn Forte 				    getTextString(TEXT_LB_FB_POLLING_RATE),
431*fcf3ce44SJohn Forte 				    pluginProps.currentFailbackPollingRate,
432*fcf3ce44SJohn Forte 				    pluginProps.failbackPollingRateMax);
433*fcf3ce44SJohn Forte 			} else {
434*fcf3ce44SJohn Forte 				(void) printf("\t%s  %s\n",
435*fcf3ce44SJohn Forte 				    getTextString(TEXT_LB_AUTO_FB),
436*fcf3ce44SJohn Forte 				    getTextString(TEXT_NA));
437*fcf3ce44SJohn Forte 				(void) printf("\t%s  %s/%s\n",
438*fcf3ce44SJohn Forte 				    getTextString(TEXT_LB_FB_POLLING_RATE),
439*fcf3ce44SJohn Forte 				    getTextString(TEXT_NA),
440*fcf3ce44SJohn Forte 				    getTextString(TEXT_NA));
441*fcf3ce44SJohn Forte 			}
442*fcf3ce44SJohn Forte 			(void) printf("\t%s  %d\n",
443*fcf3ce44SJohn Forte 			    getTextString(TEXT_LB_SUPP_AUTO_P),
444*fcf3ce44SJohn Forte 			    pluginProps.autoProbingSupport);
445*fcf3ce44SJohn Forte 			if ((MP_AUTOPROBING_SUPPORT_PLUGIN  ==
446*fcf3ce44SJohn Forte 			    pluginProps.autoProbingSupport) |
447*fcf3ce44SJohn Forte 			    (MP_AUTOPROBING_SUPPORT_PLUGIN ==
448*fcf3ce44SJohn Forte 			    pluginProps.autoProbingSupport)) {
449*fcf3ce44SJohn Forte 				(void) printf("\t%s  %s\n",
450*fcf3ce44SJohn Forte 				    getTextString(TEXT_LB_AUTO_PROB),
451*fcf3ce44SJohn Forte 				    (MP_TRUE ==
452*fcf3ce44SJohn Forte 				    pluginProps.pluginAutoProbingEnabled)?\
453*fcf3ce44SJohn Forte 				    getTextString(TEXT_YES):
454*fcf3ce44SJohn Forte 				    getTextString(TEXT_NO));
455*fcf3ce44SJohn Forte 				(void) printf("\t%s  %d/%d\n",
456*fcf3ce44SJohn Forte 				    getTextString(TEXT_LB_PR_POLLING_RATE),
457*fcf3ce44SJohn Forte 				    pluginProps.currentProbingPollingRate,
458*fcf3ce44SJohn Forte 				    pluginProps.probingPollingRateMax);
459*fcf3ce44SJohn Forte 			} else {
460*fcf3ce44SJohn Forte 				(void) printf("\t%s  %s\n",
461*fcf3ce44SJohn Forte 				    getTextString(TEXT_LB_AUTO_PROB),
462*fcf3ce44SJohn Forte 				    getTextString(TEXT_NA));
463*fcf3ce44SJohn Forte 				(void) printf("\t%s  %s/%s\n",
464*fcf3ce44SJohn Forte 				    getTextString(TEXT_LB_PR_POLLING_RATE),
465*fcf3ce44SJohn Forte 				    getTextString(TEXT_NA),
466*fcf3ce44SJohn Forte 				    getTextString(TEXT_NA));
467*fcf3ce44SJohn Forte 			}
468*fcf3ce44SJohn Forte 
469*fcf3ce44SJohn Forte 
470*fcf3ce44SJohn Forte 			(void) printf("\t%s\n",
471*fcf3ce44SJohn Forte 			    getTextString(TEXT_LB_SUPP_DEVICES));
472*fcf3ce44SJohn Forte 
473*fcf3ce44SJohn Forte 
474*fcf3ce44SJohn Forte 			if (MP_TRUE !=
475*fcf3ce44SJohn Forte 			    pluginProps.onlySupportsSpecifiedProducts) {
476*fcf3ce44SJohn Forte 				/* LINTED E_SEC_PRINTF_VAR_FMT */
477*fcf3ce44SJohn Forte 				(void) printf(getTextString(TEXT_ANY_DEVICE));
478*fcf3ce44SJohn Forte 			} else {
479*fcf3ce44SJohn Forte 				/* if only supports specific products, */
480*fcf3ce44SJohn Forte 				/* get device product properties supported */
481*fcf3ce44SJohn Forte 
482*fcf3ce44SJohn Forte 				mpstatus = MP_GetDeviceProductOidList(\
483*fcf3ce44SJohn Forte 				    pPluginOidList->oids[i],
484*fcf3ce44SJohn Forte 				    &deviceOidListArray);
485*fcf3ce44SJohn Forte 				if (mpstatus != MP_STATUS_SUCCESS) {
486*fcf3ce44SJohn Forte 					(void) fprintf(stderr, "%s:  %s\n",
487*fcf3ce44SJohn Forte 					    cmdName, getTextString(
488*fcf3ce44SJohn Forte 					    ERR_NO_SUPP_DEVICE_INFO));
489*fcf3ce44SJohn Forte 					/* can't get any more info, */
490*fcf3ce44SJohn Forte 					/* so we're done with this one */
491*fcf3ce44SJohn Forte 					break;
492*fcf3ce44SJohn Forte 				}
493*fcf3ce44SJohn Forte 
494*fcf3ce44SJohn Forte 				for (j = 0; j < deviceOidListArray->oidCount;
495*fcf3ce44SJohn Forte 				    j++) {
496*fcf3ce44SJohn Forte 					(void) memset(&devProps, 0,
497*fcf3ce44SJohn Forte 					sizeof (MP_DEVICE_PRODUCT_PROPERTIES));
498*fcf3ce44SJohn Forte 
499*fcf3ce44SJohn Forte 					if ((mpstatus =
500*fcf3ce44SJohn Forte 					    MP_GetDeviceProductProperties(\
501*fcf3ce44SJohn Forte 					    deviceOidListArray->oids[j],
502*fcf3ce44SJohn Forte 					    &devProps)) == MP_STATUS_SUCCESS) {
503*fcf3ce44SJohn Forte 
504*fcf3ce44SJohn Forte 						(void) printf("\t\t%s  ",
505*fcf3ce44SJohn Forte 						    getTextString(
506*fcf3ce44SJohn Forte 						    TEXT_LB_VENDOR));
507*fcf3ce44SJohn Forte 						displayArray(devProps.vendor,
508*fcf3ce44SJohn Forte 						    sizeof (devProps.vendor));
509*fcf3ce44SJohn Forte 						(void) printf("\n\t\t%s  ",
510*fcf3ce44SJohn Forte 						    getTextString(
511*fcf3ce44SJohn Forte 						    TEXT_LB_PRODUCT));
512*fcf3ce44SJohn Forte 						displayArray(devProps.product,
513*fcf3ce44SJohn Forte 						    sizeof (devProps.product));
514*fcf3ce44SJohn Forte 						(void) printf("\n\t\t%s  ",
515*fcf3ce44SJohn Forte 						    getTextString(
516*fcf3ce44SJohn Forte 						    TEXT_LB_REVISION));
517*fcf3ce44SJohn Forte 						displayArray(devProps.revision,
518*fcf3ce44SJohn Forte 						    sizeof (devProps.revision));
519*fcf3ce44SJohn Forte 
520*fcf3ce44SJohn Forte 						(void) printf("\n\t\t%s\n",
521*fcf3ce44SJohn Forte 						    getTextString(
522*fcf3ce44SJohn Forte 						    TEXT_LB_SUPPORTED_LB));
523*fcf3ce44SJohn Forte 			if (devProps.supportedLoadBalanceTypes == 0) {
524*fcf3ce44SJohn Forte 				(void) printf("\t\t\t%s\n",
525*fcf3ce44SJohn Forte 					getTextString(TEXT_LBTYPE_NONE));
526*fcf3ce44SJohn Forte 			} else {
527*fcf3ce44SJohn Forte 			    lb = 1;
528*fcf3ce44SJohn Forte 			    do {
529*fcf3ce44SJohn Forte 				if (0 != (lb &
530*fcf3ce44SJohn Forte 				    devProps.supportedLoadBalanceTypes)) {
531*fcf3ce44SJohn Forte 					(void) printf("\t\t\t");
532*fcf3ce44SJohn Forte 					displayLoadBalanceString(lb &
533*fcf3ce44SJohn Forte 					devProps.supportedLoadBalanceTypes);
534*fcf3ce44SJohn Forte 					(void) printf("\n");
535*fcf3ce44SJohn Forte 				}
536*fcf3ce44SJohn Forte 				lb = lb<<1;
537*fcf3ce44SJohn Forte 			    } while (lb < 0x80000000);
538*fcf3ce44SJohn Forte 			}
539*fcf3ce44SJohn Forte 
540*fcf3ce44SJohn Forte 
541*fcf3ce44SJohn Forte 						(void) printf("\n");
542*fcf3ce44SJohn Forte 
543*fcf3ce44SJohn Forte 					} else {
544*fcf3ce44SJohn Forte 						(void) fprintf(stderr,
545*fcf3ce44SJohn Forte 						    "%s:  %s\n", cmdName,
546*fcf3ce44SJohn Forte 						    getTextString(
547*fcf3ce44SJohn Forte 						    ERR_NO_SUPP_DEVICE_INFO));
548*fcf3ce44SJohn Forte 					}
549*fcf3ce44SJohn Forte 				} /* for j */
550*fcf3ce44SJohn Forte 			} /* if only supports specified devices */
551*fcf3ce44SJohn Forte 
552*fcf3ce44SJohn Forte 		} /* for each plugin */
553*fcf3ce44SJohn Forte 
554*fcf3ce44SJohn Forte 		if (B_FALSE == bListIt) {
555*fcf3ce44SJohn Forte 			/* LINTED E_SEC_PRINTF_VAR_FMT */
556*fcf3ce44SJohn Forte 			(void) fprintf(stderr, getTextString(
557*fcf3ce44SJohn Forte 			    ERR_CANT_FIND_MPATH_SUPPORT_WITH_NAME),
558*fcf3ce44SJohn Forte 			    operand[op]);
559*fcf3ce44SJohn Forte 			(void) printf("\n");
560*fcf3ce44SJohn Forte 
561*fcf3ce44SJohn Forte 		}
562*fcf3ce44SJohn Forte 
563*fcf3ce44SJohn Forte 	} /* for each operand */
564*fcf3ce44SJohn Forte 
565*fcf3ce44SJohn Forte 
566*fcf3ce44SJohn Forte 	return (mpstatus);
567*fcf3ce44SJohn Forte }
568*fcf3ce44SJohn Forte 
569*fcf3ce44SJohn Forte 
570*fcf3ce44SJohn Forte /*
571*fcf3ce44SJohn Forte  * ****************************************************************************
572*fcf3ce44SJohn Forte  *
573*fcf3ce44SJohn Forte  * modifyMpathSupport -
574*fcf3ce44SJohn Forte  * 	mpathadm modify mpath-support [options] <mpath-support name>, ...
575*fcf3ce44SJohn Forte  *
576*fcf3ce44SJohn Forte  * operandLen	- number of operands user passed into the cli
577*fcf3ce44SJohn Forte  * operand	- pointer to operand list from user
578*fcf3ce44SJohn Forte  * options	- pointer to option list from user
579*fcf3ce44SJohn Forte  *
580*fcf3ce44SJohn Forte  * ****************************************************************************
581*fcf3ce44SJohn Forte  */
582*fcf3ce44SJohn Forte int
583*fcf3ce44SJohn Forte modifyMpathSupport(int operandLen, char *operand[], cmdOptions_t *options)
584*fcf3ce44SJohn Forte {
585*fcf3ce44SJohn Forte 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
586*fcf3ce44SJohn Forte 	MP_PLUGIN_PROPERTIES			pluginProps;
587*fcf3ce44SJohn Forte 	MP_OID_LIST				*pPluginOidList;
588*fcf3ce44SJohn Forte 	boolean_t				bFoundIt = B_FALSE;
589*fcf3ce44SJohn Forte 	MP_OID					pluginOid;
590*fcf3ce44SJohn Forte 	cmdOptions_t 				*optionList = options;
591*fcf3ce44SJohn Forte 	char					*cmdStr =
592*fcf3ce44SJohn Forte 						    getTextString(
593*fcf3ce44SJohn Forte 						    TEXT_UNKNOWN);
594*fcf3ce44SJohn Forte 	int					op,
595*fcf3ce44SJohn Forte 						i,
596*fcf3ce44SJohn Forte 						lbValue;
597*fcf3ce44SJohn Forte 
598*fcf3ce44SJohn Forte 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
599*fcf3ce44SJohn Forte 	    != MP_STATUS_SUCCESS) {
600*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s: %s\n", cmdName,
601*fcf3ce44SJohn Forte 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
602*fcf3ce44SJohn Forte 		return (mpstatus);
603*fcf3ce44SJohn Forte 	}
604*fcf3ce44SJohn Forte 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
605*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s: %s\n", cmdName,
606*fcf3ce44SJohn Forte 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
607*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
608*fcf3ce44SJohn Forte 	}
609*fcf3ce44SJohn Forte 
610*fcf3ce44SJohn Forte 	for (op = 0; op < operandLen; op++) {
611*fcf3ce44SJohn Forte 		bFoundIt = B_FALSE;
612*fcf3ce44SJohn Forte 		for (i = 0;
613*fcf3ce44SJohn Forte 		    (i < pPluginOidList->oidCount) && (B_TRUE != bFoundIt);
614*fcf3ce44SJohn Forte 		    i++) {
615*fcf3ce44SJohn Forte 
616*fcf3ce44SJohn Forte 			(void) memset(&pluginProps, 0,
617*fcf3ce44SJohn Forte 			    sizeof (MP_PLUGIN_PROPERTIES));
618*fcf3ce44SJohn Forte 			if ((mpstatus =
619*fcf3ce44SJohn Forte 			    MP_GetPluginProperties(pPluginOidList->oids[i],
620*fcf3ce44SJohn Forte 			    &pluginProps)) == MP_STATUS_SUCCESS) {
621*fcf3ce44SJohn Forte 
622*fcf3ce44SJohn Forte 				if (0 == strcmp(operand[op],
623*fcf3ce44SJohn Forte 				    pluginProps.fileName)) {
624*fcf3ce44SJohn Forte 					bFoundIt = B_TRUE;
625*fcf3ce44SJohn Forte 					pluginOid = pPluginOidList->oids[i];
626*fcf3ce44SJohn Forte 				}
627*fcf3ce44SJohn Forte 			} else {
628*fcf3ce44SJohn Forte 				(void) fprintf(stderr, "%s:  %s\n",
629*fcf3ce44SJohn Forte 				    cmdName, getTextString(ERR_NO_PROPERTIES));
630*fcf3ce44SJohn Forte 			}
631*fcf3ce44SJohn Forte 
632*fcf3ce44SJohn Forte 			if (B_FALSE == bFoundIt) {
633*fcf3ce44SJohn Forte 				break;
634*fcf3ce44SJohn Forte 			}
635*fcf3ce44SJohn Forte 
636*fcf3ce44SJohn Forte /* begin back-up indentation */
637*fcf3ce44SJohn Forte 	/* we found the plugin oid */
638*fcf3ce44SJohn Forte 	/* now change the options requested */
639*fcf3ce44SJohn Forte 	switch (optionList->optval) {
640*fcf3ce44SJohn Forte 		case 'a':
641*fcf3ce44SJohn Forte 			/* modify autofailback */
642*fcf3ce44SJohn Forte 			cmdStr = getTextString(TEXT_AUTO_FAILBACK);
643*fcf3ce44SJohn Forte 			if (0 == strcasecmp(optionList->optarg,
644*fcf3ce44SJohn Forte 			    getTextString(TEXT_ON))) {
645*fcf3ce44SJohn Forte 				mpstatus =
646*fcf3ce44SJohn Forte 				    MP_EnableAutoFailback(pluginOid);
647*fcf3ce44SJohn Forte 			} else if (0 ==
648*fcf3ce44SJohn Forte 				strcasecmp(optionList->optarg,
649*fcf3ce44SJohn Forte 				    getTextString(TEXT_OFF))) {
650*fcf3ce44SJohn Forte 				mpstatus =
651*fcf3ce44SJohn Forte 				    MP_DisableAutoFailback(pluginOid);
652*fcf3ce44SJohn Forte 			} else {
653*fcf3ce44SJohn Forte 				/* LINTED E_SEC_PRINTF_VAR_FMT */
654*fcf3ce44SJohn Forte 				(void) fprintf(stderr, getTextString(
655*fcf3ce44SJohn Forte 				    ERR_FAILED_TO_CHANGE_OPTION_WITH_REASON),
656*fcf3ce44SJohn Forte 				    cmdStr,
657*fcf3ce44SJohn Forte 				    getTextString(TEXT_ILLEGAL_ARGUMENT));
658*fcf3ce44SJohn Forte 				(void) printf("\n");
659*fcf3ce44SJohn Forte 				return (ERROR_CLI_FAILED);
660*fcf3ce44SJohn Forte 			}
661*fcf3ce44SJohn Forte 			break;
662*fcf3ce44SJohn Forte 		case 'p':
663*fcf3ce44SJohn Forte 			/* modify autoprobing */
664*fcf3ce44SJohn Forte 			cmdStr = getTextString(TEXT_AUTO_PROBING);
665*fcf3ce44SJohn Forte 			if (0 == strcasecmp(optionList->optarg,
666*fcf3ce44SJohn Forte 			    getTextString(TEXT_ON))) {
667*fcf3ce44SJohn Forte 				mpstatus =
668*fcf3ce44SJohn Forte 				    MP_EnableAutoProbing(pluginOid);
669*fcf3ce44SJohn Forte 			} else if (0 ==
670*fcf3ce44SJohn Forte 				strcasecmp(optionList->optarg,
671*fcf3ce44SJohn Forte 				    getTextString(TEXT_OFF))) {
672*fcf3ce44SJohn Forte 				mpstatus =
673*fcf3ce44SJohn Forte 				    MP_DisableAutoProbing(pluginOid);
674*fcf3ce44SJohn Forte 			} else {
675*fcf3ce44SJohn Forte 				/* LINTED E_SEC_PRINTF_VAR_FMT */
676*fcf3ce44SJohn Forte 				(void) fprintf(stderr, getTextString(
677*fcf3ce44SJohn Forte 				    ERR_FAILED_TO_CHANGE_OPTION_WITH_REASON),
678*fcf3ce44SJohn Forte 				    cmdStr,
679*fcf3ce44SJohn Forte 				    getTextString(TEXT_ILLEGAL_ARGUMENT));
680*fcf3ce44SJohn Forte 				(void) printf("\n");
681*fcf3ce44SJohn Forte 				return (ERROR_CLI_FAILED);
682*fcf3ce44SJohn Forte 			}
683*fcf3ce44SJohn Forte 			break;
684*fcf3ce44SJohn Forte 		case 'b':
685*fcf3ce44SJohn Forte 			/* modify loadbalance type */
686*fcf3ce44SJohn Forte 			cmdStr = getTextString(TEXT_LOAD_BALANCE);
687*fcf3ce44SJohn Forte 			/* user of the cli sends text string, we need the int */
688*fcf3ce44SJohn Forte 			/* value to pass to the mpapi */
689*fcf3ce44SJohn Forte 			lbValue = getLbValueFromString(optionList->optarg);
690*fcf3ce44SJohn Forte 			mpstatus =
691*fcf3ce44SJohn Forte 			    MP_SetPluginLoadBalanceType(pluginOid,
692*fcf3ce44SJohn Forte 			    lbValue);
693*fcf3ce44SJohn Forte 			break;
694*fcf3ce44SJohn Forte 
695*fcf3ce44SJohn Forte 		} /* switch */
696*fcf3ce44SJohn Forte 		if (MP_STATUS_SUCCESS != mpstatus) {
697*fcf3ce44SJohn Forte 			/* LINTED E_SEC_PRINTF_VAR_FMT */
698*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
699*fcf3ce44SJohn Forte 			    getTextString(
700*fcf3ce44SJohn Forte 			    ERR_FAILED_TO_CHANGE_OPTION_WITH_REASON),
701*fcf3ce44SJohn Forte 			    cmdStr, getMpStatusStr(mpstatus));
702*fcf3ce44SJohn Forte 			(void) printf("\n");
703*fcf3ce44SJohn Forte 			return (mpstatus);
704*fcf3ce44SJohn Forte 		}
705*fcf3ce44SJohn Forte /* end back-up indentation */
706*fcf3ce44SJohn Forte 
707*fcf3ce44SJohn Forte 		} /* for each plugin */
708*fcf3ce44SJohn Forte 
709*fcf3ce44SJohn Forte 		if (B_FALSE == bFoundIt) {
710*fcf3ce44SJohn Forte 			/* LINTED E_SEC_PRINTF_VAR_FMT */
711*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
712*fcf3ce44SJohn Forte 			    getTextString(
713*fcf3ce44SJohn Forte 			    ERR_FAILED_TO_CHANGE_OPTION_WITH_REASON),
714*fcf3ce44SJohn Forte 			    cmdStr,
715*fcf3ce44SJohn Forte 			    getTextString(TEXT_MPATH_SUPPORT_NOT_FOUND));
716*fcf3ce44SJohn Forte 			(void) printf("\n");
717*fcf3ce44SJohn Forte 			return (ERROR_CLI_FAILED);
718*fcf3ce44SJohn Forte 		}
719*fcf3ce44SJohn Forte 
720*fcf3ce44SJohn Forte 	} /* for each operand */
721*fcf3ce44SJohn Forte 
722*fcf3ce44SJohn Forte 	return (mpstatus);
723*fcf3ce44SJohn Forte }
724*fcf3ce44SJohn Forte 
725*fcf3ce44SJohn Forte 
726*fcf3ce44SJohn Forte /*
727*fcf3ce44SJohn Forte  * ****************************************************************************
728*fcf3ce44SJohn Forte  *
729*fcf3ce44SJohn Forte  * listLogicalUnit -
730*fcf3ce44SJohn Forte  * 	mpathadm list {logical-unit | LU} [options] [<logical-unit name>, ...]
731*fcf3ce44SJohn Forte  *
732*fcf3ce44SJohn Forte  * operandLen	- number of operands user passed into the cli
733*fcf3ce44SJohn Forte  * operand	- pointer to operand list from user
734*fcf3ce44SJohn Forte  * options	- pointer to option list from user
735*fcf3ce44SJohn Forte  *
736*fcf3ce44SJohn Forte  * ****************************************************************************
737*fcf3ce44SJohn Forte  */
738*fcf3ce44SJohn Forte int
739*fcf3ce44SJohn Forte listLogicalUnit(int operandLen, char *operand[], cmdOptions_t *options)
740*fcf3ce44SJohn Forte {
741*fcf3ce44SJohn Forte 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
742*fcf3ce44SJohn Forte 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES	luProps;
743*fcf3ce44SJohn Forte 	MP_PLUGIN_PROPERTIES			pluginProps;
744*fcf3ce44SJohn Forte 	MP_TARGET_PORT_PROPERTIES		tportProps;
745*fcf3ce44SJohn Forte 	MP_OID_LIST				*pPluginOidList,
746*fcf3ce44SJohn Forte 						*pLogicalUnitOidList,
747*fcf3ce44SJohn Forte 						*pTpgOidListArray,
748*fcf3ce44SJohn Forte 						*pTportOidListArray;
749*fcf3ce44SJohn Forte 	boolean_t				bListIt = B_FALSE,
750*fcf3ce44SJohn Forte 						bFoundOperand = B_FALSE,
751*fcf3ce44SJohn Forte 						*bFoundOption,
752*fcf3ce44SJohn Forte 						bContinue = B_FALSE;
753*fcf3ce44SJohn Forte 	MP_OID					luOid;
754*fcf3ce44SJohn Forte 	cmdOptions_t 				*optionList = options;
755*fcf3ce44SJohn Forte 	int					opListCount = 0,
756*fcf3ce44SJohn Forte 						i = 0,
757*fcf3ce44SJohn Forte 						lu = 0,
758*fcf3ce44SJohn Forte 						tpg = 0,
759*fcf3ce44SJohn Forte 						opoffset = 0,
760*fcf3ce44SJohn Forte 						j = 0,
761*fcf3ce44SJohn Forte 						opStart = 0,
762*fcf3ce44SJohn Forte 						opEnd = 0,
763*fcf3ce44SJohn Forte 						opIndex;
764*fcf3ce44SJohn Forte 
765*fcf3ce44SJohn Forte 	/* count number of options */
766*fcf3ce44SJohn Forte 	for (; optionList->optval; optionList++) {
767*fcf3ce44SJohn Forte 		opListCount++;
768*fcf3ce44SJohn Forte 	}
769*fcf3ce44SJohn Forte 
770*fcf3ce44SJohn Forte 	bFoundOption = malloc((sizeof (boolean_t)) * opListCount);
771*fcf3ce44SJohn Forte 	if (NULL == bFoundOption) {
772*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%s\n",
773*fcf3ce44SJohn Forte 		    getTextString(ERR_MEMORY_ALLOCATION));
774*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
775*fcf3ce44SJohn Forte 	}
776*fcf3ce44SJohn Forte 
777*fcf3ce44SJohn Forte 	/* list to keep track of multiple options */
778*fcf3ce44SJohn Forte 	optionList = options;
779*fcf3ce44SJohn Forte 	for (opIndex = 0; opIndex < opListCount; opIndex++) {
780*fcf3ce44SJohn Forte 		bFoundOption[opIndex] = B_FALSE;
781*fcf3ce44SJohn Forte 	}
782*fcf3ce44SJohn Forte 
783*fcf3ce44SJohn Forte 	optionList = options;
784*fcf3ce44SJohn Forte 
785*fcf3ce44SJohn Forte 	/* if no operands or options, list everything we find */
786*fcf3ce44SJohn Forte 	if ((0 == operandLen) && (0 == opListCount)) {
787*fcf3ce44SJohn Forte 		if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
788*fcf3ce44SJohn Forte 		    != MP_STATUS_SUCCESS) {
789*fcf3ce44SJohn Forte 			(void) fprintf(stderr, "%s: %s\n", cmdName,
790*fcf3ce44SJohn Forte 			    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
791*fcf3ce44SJohn Forte 			return (mpstatus);
792*fcf3ce44SJohn Forte 		}
793*fcf3ce44SJohn Forte 		if ((NULL == pPluginOidList) ||
794*fcf3ce44SJohn Forte 		    (pPluginOidList->oidCount < 1)) {
795*fcf3ce44SJohn Forte 			(void) fprintf(stderr, "%s: %s\n", cmdName,
796*fcf3ce44SJohn Forte 			    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
797*fcf3ce44SJohn Forte 			return (ERROR_CLI_FAILED);
798*fcf3ce44SJohn Forte 		}
799*fcf3ce44SJohn Forte 
800*fcf3ce44SJohn Forte 		for (i = 0; i < pPluginOidList->oidCount; i++) {
801*fcf3ce44SJohn Forte 			/* get properties so we can list the name */
802*fcf3ce44SJohn Forte 			(void) memset(&pluginProps, 0,
803*fcf3ce44SJohn Forte 			    sizeof (MP_PLUGIN_PROPERTIES));
804*fcf3ce44SJohn Forte 			if ((mpstatus =
805*fcf3ce44SJohn Forte 			    MP_GetPluginProperties(pPluginOidList->oids[i],
806*fcf3ce44SJohn Forte 			    &pluginProps)) != MP_STATUS_SUCCESS) {
807*fcf3ce44SJohn Forte 				(void) fprintf(stderr, "%s:  %s\n",
808*fcf3ce44SJohn Forte 				    cmdName, getTextString(ERR_NO_PROPERTIES));
809*fcf3ce44SJohn Forte 				return (mpstatus);
810*fcf3ce44SJohn Forte 			}
811*fcf3ce44SJohn Forte 
812*fcf3ce44SJohn Forte 			/* attempt to find this logical unit */
813*fcf3ce44SJohn Forte 			mpstatus = MP_GetMultipathLus(pPluginOidList->oids[i],
814*fcf3ce44SJohn Forte 			    &pLogicalUnitOidList);
815*fcf3ce44SJohn Forte 			if (mpstatus != MP_STATUS_SUCCESS) {
816*fcf3ce44SJohn Forte 				(void) fprintf(stderr, "%s:  %s\n",
817*fcf3ce44SJohn Forte 				    cmdName, getTextString(ERR_NO_LU_LIST));
818*fcf3ce44SJohn Forte 				return (mpstatus);
819*fcf3ce44SJohn Forte 			}
820*fcf3ce44SJohn Forte 
821*fcf3ce44SJohn Forte 			for (lu = 0; lu < pLogicalUnitOidList->oidCount; lu++) {
822*fcf3ce44SJohn Forte 				/* get lu properties so we can check the name */
823*fcf3ce44SJohn Forte 				(void) memset(&luProps, 0,
824*fcf3ce44SJohn Forte 				sizeof (MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES));
825*fcf3ce44SJohn Forte 				mpstatus =
826*fcf3ce44SJohn Forte 				    MP_GetMPLogicalUnitProperties(
827*fcf3ce44SJohn Forte 				    pLogicalUnitOidList->oids[lu],
828*fcf3ce44SJohn Forte 				    &luProps);
829*fcf3ce44SJohn Forte 				if (mpstatus != MP_STATUS_SUCCESS) {
830*fcf3ce44SJohn Forte 					(void) fprintf(stderr, "%s:  %s\n",
831*fcf3ce44SJohn Forte 					    cmdName,
832*fcf3ce44SJohn Forte 					    getTextString(ERR_NO_PROPERTIES));
833*fcf3ce44SJohn Forte 					return (mpstatus);
834*fcf3ce44SJohn Forte 				}
835*fcf3ce44SJohn Forte 
836*fcf3ce44SJohn Forte 				luOid = pLogicalUnitOidList->oids[lu];
837*fcf3ce44SJohn Forte 				if (listIndividualLogicalUnit(luOid, luProps)
838*fcf3ce44SJohn Forte 				    != 0) {
839*fcf3ce44SJohn Forte 					return (ERROR_CLI_FAILED);
840*fcf3ce44SJohn Forte 				}
841*fcf3ce44SJohn Forte 			} /* for each LU */
842*fcf3ce44SJohn Forte 		} /* for each plugin */
843*fcf3ce44SJohn Forte 	} else { /* we have operands and/or options */
844*fcf3ce44SJohn Forte 
845*fcf3ce44SJohn Forte 		/* check if we have operands */
846*fcf3ce44SJohn Forte 		if (0 == operandLen) {
847*fcf3ce44SJohn Forte 			/* no operands */
848*fcf3ce44SJohn Forte 			opStart = -1;
849*fcf3ce44SJohn Forte 			opEnd = 0;
850*fcf3ce44SJohn Forte 		} else {
851*fcf3ce44SJohn Forte 			/* operands */
852*fcf3ce44SJohn Forte 			opStart = 0;
853*fcf3ce44SJohn Forte 			opEnd = operandLen;
854*fcf3ce44SJohn Forte 		}
855*fcf3ce44SJohn Forte 
856*fcf3ce44SJohn Forte 		if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
857*fcf3ce44SJohn Forte 		    != MP_STATUS_SUCCESS) {
858*fcf3ce44SJohn Forte 			(void) fprintf(stderr, "%s: %s\n", cmdName,
859*fcf3ce44SJohn Forte 			    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
860*fcf3ce44SJohn Forte 			return (mpstatus);
861*fcf3ce44SJohn Forte 		}
862*fcf3ce44SJohn Forte 		if ((NULL == pPluginOidList) ||
863*fcf3ce44SJohn Forte 		    (pPluginOidList->oidCount < 1)) {
864*fcf3ce44SJohn Forte 			(void) fprintf(stderr, "%s: %s\n", cmdName,
865*fcf3ce44SJohn Forte 			    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
866*fcf3ce44SJohn Forte 			return (ERROR_CLI_FAILED);
867*fcf3ce44SJohn Forte 		}
868*fcf3ce44SJohn Forte 
869*fcf3ce44SJohn Forte 		for (opoffset = opStart; opoffset < opEnd; opoffset++) {
870*fcf3ce44SJohn Forte 			/* loop through operands */
871*fcf3ce44SJohn Forte 			bFoundOperand = B_FALSE;
872*fcf3ce44SJohn Forte 
873*fcf3ce44SJohn Forte 			for (i = 0; i < pPluginOidList->oidCount; i++) {
874*fcf3ce44SJohn Forte 
875*fcf3ce44SJohn Forte 				/*
876*fcf3ce44SJohn Forte 				 * loop through plugin, and get properties
877*fcf3ce44SJohn Forte 				 * so we can list the name
878*fcf3ce44SJohn Forte 				 */
879*fcf3ce44SJohn Forte 				(void) memset(&pluginProps, 0,
880*fcf3ce44SJohn Forte 				    sizeof (MP_PLUGIN_PROPERTIES));
881*fcf3ce44SJohn Forte 				if ((mpstatus =
882*fcf3ce44SJohn Forte 				    MP_GetPluginProperties(
883*fcf3ce44SJohn Forte 				    pPluginOidList->oids[i], &pluginProps))
884*fcf3ce44SJohn Forte 				    != MP_STATUS_SUCCESS) {
885*fcf3ce44SJohn Forte 					(void) fprintf(stderr, "%s:  %s\n",
886*fcf3ce44SJohn Forte 					    cmdName,
887*fcf3ce44SJohn Forte 					    getTextString(ERR_NO_PROPERTIES));
888*fcf3ce44SJohn Forte 					return (mpstatus);
889*fcf3ce44SJohn Forte 				}
890*fcf3ce44SJohn Forte 
891*fcf3ce44SJohn Forte 				/* attempt to find this logical unit */
892*fcf3ce44SJohn Forte 				mpstatus =
893*fcf3ce44SJohn Forte 				    MP_GetMultipathLus(pPluginOidList->oids[i],
894*fcf3ce44SJohn Forte 				    &pLogicalUnitOidList);
895*fcf3ce44SJohn Forte 				if (mpstatus != MP_STATUS_SUCCESS) {
896*fcf3ce44SJohn Forte 					(void) fprintf(stderr, "%s:  %s\n",
897*fcf3ce44SJohn Forte 					    cmdName,
898*fcf3ce44SJohn Forte 					    getTextString(ERR_NO_LU_LIST));
899*fcf3ce44SJohn Forte 					return (mpstatus);
900*fcf3ce44SJohn Forte 				}
901*fcf3ce44SJohn Forte 
902*fcf3ce44SJohn Forte 				for (lu = 0;
903*fcf3ce44SJohn Forte 				    (lu < pLogicalUnitOidList->oidCount);
904*fcf3ce44SJohn Forte 				    lu++) {
905*fcf3ce44SJohn Forte 					bListIt = B_FALSE;
906*fcf3ce44SJohn Forte 					/* get lu props & check the name */
907*fcf3ce44SJohn Forte 					(void) memset(&luProps, 0,
908*fcf3ce44SJohn Forte 				sizeof (MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES));
909*fcf3ce44SJohn Forte 					mpstatus =
910*fcf3ce44SJohn Forte 					    MP_GetMPLogicalUnitProperties(
911*fcf3ce44SJohn Forte 					    pLogicalUnitOidList->oids[lu],
912*fcf3ce44SJohn Forte 					    &luProps);
913*fcf3ce44SJohn Forte 					if (mpstatus != MP_STATUS_SUCCESS) {
914*fcf3ce44SJohn Forte 						(void) fprintf(stderr,
915*fcf3ce44SJohn Forte 						    "%s:  %s\n", cmdName,
916*fcf3ce44SJohn Forte 						    getTextString(
917*fcf3ce44SJohn Forte 						    ERR_NO_PROPERTIES));
918*fcf3ce44SJohn Forte 						return (mpstatus);
919*fcf3ce44SJohn Forte 					}
920*fcf3ce44SJohn Forte 
921*fcf3ce44SJohn Forte 					/*
922*fcf3ce44SJohn Forte 					 * compare operand - is it a match?
923*fcf3ce44SJohn Forte 					 * If so, continue
924*fcf3ce44SJohn Forte 					 */
925*fcf3ce44SJohn Forte 
926*fcf3ce44SJohn Forte 					bContinue = B_TRUE;
927*fcf3ce44SJohn Forte 					if (operandLen > 0) {
928*fcf3ce44SJohn Forte 						bContinue =
929*fcf3ce44SJohn Forte 						    compareLUName(
930*fcf3ce44SJohn Forte 						    operand[opoffset],
931*fcf3ce44SJohn Forte 						    luProps.deviceFileName);
932*fcf3ce44SJohn Forte 					}
933*fcf3ce44SJohn Forte 
934*fcf3ce44SJohn Forte 					if (B_TRUE == bContinue) {
935*fcf3ce44SJohn Forte 
936*fcf3ce44SJohn Forte 						if (0 != opListCount) {
937*fcf3ce44SJohn Forte 							/* check options */
938*fcf3ce44SJohn Forte 
939*fcf3ce44SJohn Forte 
940*fcf3ce44SJohn Forte /* begin backup indentation */
941*fcf3ce44SJohn Forte optionList = options;
942*fcf3ce44SJohn Forte 
943*fcf3ce44SJohn Forte for (opIndex = 0; optionList->optval; optionList++, opIndex++) {
944*fcf3ce44SJohn Forte switch (optionList->optval) {
945*fcf3ce44SJohn Forte 	case 'n':
946*fcf3ce44SJohn Forte 		if (B_TRUE ==
947*fcf3ce44SJohn Forte 		    compareLUName(optionList->optarg, luProps.name)) {
948*fcf3ce44SJohn Forte 			bListIt = B_TRUE;
949*fcf3ce44SJohn Forte 			bFoundOperand = B_TRUE;
950*fcf3ce44SJohn Forte 			bFoundOption[opIndex] = B_TRUE;
951*fcf3ce44SJohn Forte 		}
952*fcf3ce44SJohn Forte 		break;
953*fcf3ce44SJohn Forte 	case 't':
954*fcf3ce44SJohn Forte 		/* get TPG list */
955*fcf3ce44SJohn Forte 		mpstatus =
956*fcf3ce44SJohn Forte 		    MP_GetAssociatedTPGOidList(pLogicalUnitOidList->oids[lu],
957*fcf3ce44SJohn Forte 		    &pTpgOidListArray);
958*fcf3ce44SJohn Forte 		if (mpstatus !=  MP_STATUS_SUCCESS) {
959*fcf3ce44SJohn Forte 			(void) fprintf(stderr,  "%s:  %s\n", cmdName,
960*fcf3ce44SJohn Forte 			    getTextString(ERR_NO_ASSOC_TPGS));
961*fcf3ce44SJohn Forte 			return (mpstatus);
962*fcf3ce44SJohn Forte 		}
963*fcf3ce44SJohn Forte 
964*fcf3ce44SJohn Forte 		/* get target ports */
965*fcf3ce44SJohn Forte 		for (tpg = 0;
966*fcf3ce44SJohn Forte 		    (NULL != pTpgOidListArray) &&
967*fcf3ce44SJohn Forte 		    (tpg < pTpgOidListArray->oidCount) &&
968*fcf3ce44SJohn Forte 		    (B_FALSE == bListIt); tpg++) {
969*fcf3ce44SJohn Forte 			mpstatus =
970*fcf3ce44SJohn Forte 			    MP_GetTargetPortOidList(pTpgOidListArray->oids[tpg],
971*fcf3ce44SJohn Forte 				&pTportOidListArray);
972*fcf3ce44SJohn Forte 			if (mpstatus != MP_STATUS_SUCCESS) {
973*fcf3ce44SJohn Forte 				(void) fprintf(stderr, "%s:  %s\n",
974*fcf3ce44SJohn Forte 				    cmdName,
975*fcf3ce44SJohn Forte 				    getTextString(ERR_NO_ASSOC_TPORTS));
976*fcf3ce44SJohn Forte 				return (mpstatus);
977*fcf3ce44SJohn Forte 			}
978*fcf3ce44SJohn Forte 
979*fcf3ce44SJohn Forte 			/* get target port properties for the name */
980*fcf3ce44SJohn Forte 			for (j = 0; (NULL != pTportOidListArray) &&
981*fcf3ce44SJohn Forte 			    (j < pTportOidListArray->oidCount) &&
982*fcf3ce44SJohn Forte 			    (B_FALSE == bListIt); j++) {
983*fcf3ce44SJohn Forte 				(void) memset(&tportProps, 0,
984*fcf3ce44SJohn Forte 				    sizeof (MP_TARGET_PORT_PROPERTIES));
985*fcf3ce44SJohn Forte 				mpstatus =
986*fcf3ce44SJohn Forte 				    MP_GetTargetPortProperties(
987*fcf3ce44SJohn Forte 				    pTportOidListArray->oids[j], &tportProps);
988*fcf3ce44SJohn Forte 				if (mpstatus != MP_STATUS_SUCCESS) {
989*fcf3ce44SJohn Forte 					(void) fprintf(stderr, "%s:  %s\n",
990*fcf3ce44SJohn Forte 					    cmdName,
991*fcf3ce44SJohn Forte 					    getTextString(ERR_NO_PROPERTIES));
992*fcf3ce44SJohn Forte 					return (mpstatus);
993*fcf3ce44SJohn Forte 				}
994*fcf3ce44SJohn Forte 
995*fcf3ce44SJohn Forte 
996*fcf3ce44SJohn Forte 				/* check the name */
997*fcf3ce44SJohn Forte 				if (0 == strcmp(optionList->optarg,
998*fcf3ce44SJohn Forte 				    tportProps.portID)) {
999*fcf3ce44SJohn Forte 					bListIt = B_TRUE;
1000*fcf3ce44SJohn Forte 					bFoundOperand = B_TRUE;
1001*fcf3ce44SJohn Forte 					bFoundOption[opIndex] = B_TRUE;
1002*fcf3ce44SJohn Forte 				}
1003*fcf3ce44SJohn Forte 			} /* for each target port */
1004*fcf3ce44SJohn Forte 		} /* for each tpg */
1005*fcf3ce44SJohn Forte 	} /* end switch */
1006*fcf3ce44SJohn Forte } /* loop through options */
1007*fcf3ce44SJohn Forte /* end back-up indentation */
1008*fcf3ce44SJohn Forte 
1009*fcf3ce44SJohn Forte 						} else {
1010*fcf3ce44SJohn Forte 							/*
1011*fcf3ce44SJohn Forte 							 * if no options,
1012*fcf3ce44SJohn Forte 							 * listit
1013*fcf3ce44SJohn Forte 							 */
1014*fcf3ce44SJohn Forte 							bListIt = B_TRUE;
1015*fcf3ce44SJohn Forte 							bFoundOperand = B_TRUE;
1016*fcf3ce44SJohn Forte 						}
1017*fcf3ce44SJohn Forte 					} /* end bContinue check */
1018*fcf3ce44SJohn Forte 
1019*fcf3ce44SJohn Forte 		if (bListIt) {
1020*fcf3ce44SJohn Forte 			(void) printf("%s  %s\n",
1021*fcf3ce44SJohn Forte 			    getTextString(TEXT_LB_MPATH_SUPPORT),
1022*fcf3ce44SJohn Forte 			    pluginProps.fileName);
1023*fcf3ce44SJohn Forte 			luOid = pLogicalUnitOidList->oids[lu];
1024*fcf3ce44SJohn Forte 			if (listIndividualLogicalUnit(luOid, luProps)
1025*fcf3ce44SJohn Forte 			    != 0) {
1026*fcf3ce44SJohn Forte 				return (ERROR_CLI_FAILED);
1027*fcf3ce44SJohn Forte 			}
1028*fcf3ce44SJohn Forte 
1029*fcf3ce44SJohn Forte 		}
1030*fcf3ce44SJohn Forte 
1031*fcf3ce44SJohn Forte 				} /* end LU loop */
1032*fcf3ce44SJohn Forte 			} /* end plugin loop */
1033*fcf3ce44SJohn Forte 			if ((0 == opListCount) && (0 != operandLen)) {
1034*fcf3ce44SJohn Forte 				if (B_FALSE == bFoundOperand) {
1035*fcf3ce44SJohn Forte 					/* option/operand combo not found */
1036*fcf3ce44SJohn Forte 					/* LINTED E_SEC_PRINTF_VAR_FMT */
1037*fcf3ce44SJohn Forte 					(void) fprintf(stderr,
1038*fcf3ce44SJohn Forte 					    getTextString(
1039*fcf3ce44SJohn Forte 				    ERR_LU_NOT_FOUND_WITH_MISSING_LU_STR),
1040*fcf3ce44SJohn Forte 					    operand[opoffset]);
1041*fcf3ce44SJohn Forte 					(void) fprintf(stderr, "\n");
1042*fcf3ce44SJohn Forte 				}
1043*fcf3ce44SJohn Forte 			}
1044*fcf3ce44SJohn Forte 
1045*fcf3ce44SJohn Forte 			optionList = options;
1046*fcf3ce44SJohn Forte 			for (opIndex = 0; optionList->optval; optionList++,
1047*fcf3ce44SJohn Forte 			    opIndex++) {
1048*fcf3ce44SJohn Forte 				if (B_FALSE == bFoundOption[opIndex]) {
1049*fcf3ce44SJohn Forte 					/* LINTED E_SEC_PRINTF_VAR_FMT */
1050*fcf3ce44SJohn Forte 					(void) fprintf(stderr,
1051*fcf3ce44SJohn Forte 					    getTextString(
1052*fcf3ce44SJohn Forte 				    ERR_LU_NOT_FOUND_WITH_MISSING_LU_STR),
1053*fcf3ce44SJohn Forte 					    optionList->optarg);
1054*fcf3ce44SJohn Forte 					(void) fprintf(stderr, "\n");
1055*fcf3ce44SJohn Forte 				}
1056*fcf3ce44SJohn Forte 			}
1057*fcf3ce44SJohn Forte 
1058*fcf3ce44SJohn Forte 
1059*fcf3ce44SJohn Forte 
1060*fcf3ce44SJohn Forte 		} /* end loop through operands */
1061*fcf3ce44SJohn Forte 	} /* we have operands and/or options */
1062*fcf3ce44SJohn Forte 
1063*fcf3ce44SJohn Forte 
1064*fcf3ce44SJohn Forte 	return (mpstatus);
1065*fcf3ce44SJohn Forte }
1066*fcf3ce44SJohn Forte 
1067*fcf3ce44SJohn Forte 
1068*fcf3ce44SJohn Forte /*
1069*fcf3ce44SJohn Forte  * ****************************************************************************
1070*fcf3ce44SJohn Forte  *
1071*fcf3ce44SJohn Forte  * compareLUName -
1072*fcf3ce44SJohn Forte  * 	compare names directly and via devid if no match directly
1073*fcf3ce44SJohn Forte  *
1074*fcf3ce44SJohn Forte  * cmpString		- first string to compare
1075*fcf3ce44SJohn Forte  * deviceProperty	- string from properties
1076*fcf3ce44SJohn Forte  * sizeToCompare	- size of deviceProperty
1077*fcf3ce44SJohn Forte  *
1078*fcf3ce44SJohn Forte  * returns 	B_TRUE if the strings match either directly or via devid
1079*fcf3ce44SJohn Forte  *		B_FALSE otherwise
1080*fcf3ce44SJohn Forte  *
1081*fcf3ce44SJohn Forte  * ****************************************************************************
1082*fcf3ce44SJohn Forte  */
1083*fcf3ce44SJohn Forte boolean_t
1084*fcf3ce44SJohn Forte compareLUName(MP_CHAR *cmpString, MP_CHAR *deviceProperty)
1085*fcf3ce44SJohn Forte {
1086*fcf3ce44SJohn Forte 
1087*fcf3ce44SJohn Forte 	boolean_t				isSame = B_FALSE;
1088*fcf3ce44SJohn Forte 	int 					fd1, fd2;
1089*fcf3ce44SJohn Forte 	ddi_devid_t				devid1 = NULL, devid2 = NULL;
1090*fcf3ce44SJohn Forte 
1091*fcf3ce44SJohn Forte 	if (0 == strcmp(cmpString, deviceProperty)) {
1092*fcf3ce44SJohn Forte 		isSame = B_TRUE;
1093*fcf3ce44SJohn Forte 	} else {
1094*fcf3ce44SJohn Forte 		/* user input didn't match, try via devid */
1095*fcf3ce44SJohn Forte 		/*
1096*fcf3ce44SJohn Forte 		 * I don't see a reason to print the error for
1097*fcf3ce44SJohn Forte 		 * any of these since they'll get the error at
1098*fcf3ce44SJohn Forte 		 * the end anyway
1099*fcf3ce44SJohn Forte 		 */
1100*fcf3ce44SJohn Forte 
1101*fcf3ce44SJohn Forte 		if (((fd1 = open(cmpString, O_RDONLY|O_NDELAY)) >= 0) &&
1102*fcf3ce44SJohn Forte 		    ((fd2 = open(deviceProperty, O_RDONLY|O_NDELAY)) >= 0) &&
1103*fcf3ce44SJohn Forte 		    (devid_get(fd1, &devid1) == 0) &&
1104*fcf3ce44SJohn Forte 		    (devid_get(fd2, &devid2) == 0) &&
1105*fcf3ce44SJohn Forte 		    ((NULL != devid1) && (NULL != devid2))) {
1106*fcf3ce44SJohn Forte 			if (0 ==
1107*fcf3ce44SJohn Forte 			    (devid_compare(devid1, devid2))) {
1108*fcf3ce44SJohn Forte 				isSame = B_TRUE;
1109*fcf3ce44SJohn Forte 			}
1110*fcf3ce44SJohn Forte 		}
1111*fcf3ce44SJohn Forte 
1112*fcf3ce44SJohn Forte 		if (NULL != devid1) {
1113*fcf3ce44SJohn Forte 			devid_free(devid1);
1114*fcf3ce44SJohn Forte 		}
1115*fcf3ce44SJohn Forte 		if (NULL != devid2) {
1116*fcf3ce44SJohn Forte 			devid_free(devid2);
1117*fcf3ce44SJohn Forte 		}
1118*fcf3ce44SJohn Forte 	} /* compare */
1119*fcf3ce44SJohn Forte 
1120*fcf3ce44SJohn Forte 	return (isSame);
1121*fcf3ce44SJohn Forte }
1122*fcf3ce44SJohn Forte 
1123*fcf3ce44SJohn Forte 
1124*fcf3ce44SJohn Forte /*
1125*fcf3ce44SJohn Forte  * ****************************************************************************
1126*fcf3ce44SJohn Forte  *
1127*fcf3ce44SJohn Forte  * listIndivudualLogicalUnit -
1128*fcf3ce44SJohn Forte  * 	Used by list logical unit cli.
1129*fcf3ce44SJohn Forte  *	Displays info about an LU
1130*fcf3ce44SJohn Forte  *
1131*fcf3ce44SJohn Forte  * luOid	- LU to list
1132*fcf3ce44SJohn Forte  * luProps	- properties of he LU to list
1133*fcf3ce44SJohn Forte  *
1134*fcf3ce44SJohn Forte  * ****************************************************************************
1135*fcf3ce44SJohn Forte  */
1136*fcf3ce44SJohn Forte int
1137*fcf3ce44SJohn Forte listIndividualLogicalUnit(MP_OID luOid,
1138*fcf3ce44SJohn Forte 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES luProps)
1139*fcf3ce44SJohn Forte {
1140*fcf3ce44SJohn Forte 	MP_PATH_LOGICAL_UNIT_PROPERTIES		pathProps;
1141*fcf3ce44SJohn Forte 	MP_OID_LIST				*pPathOidListArray;
1142*fcf3ce44SJohn Forte 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
1143*fcf3ce44SJohn Forte 	int					numOperationalPaths,
1144*fcf3ce44SJohn Forte 						pa;
1145*fcf3ce44SJohn Forte 
1146*fcf3ce44SJohn Forte 	(void) printf("\t");
1147*fcf3ce44SJohn Forte 	displayArray(luProps.deviceFileName, sizeof (luProps.deviceFileName));
1148*fcf3ce44SJohn Forte 	(void) printf("\n");
1149*fcf3ce44SJohn Forte 
1150*fcf3ce44SJohn Forte 	mpstatus = MP_GetAssociatedPathOidList(luOid,
1151*fcf3ce44SJohn Forte 	    &pPathOidListArray);
1152*fcf3ce44SJohn Forte 	if (mpstatus != MP_STATUS_SUCCESS) {
1153*fcf3ce44SJohn Forte 		/* LINTED E_SEC_PRINTF_VAR_FMT */
1154*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
1155*fcf3ce44SJohn Forte 		    getTextString(ERR_NO_LU_PATH_INFO_WITH_MISSING_LU_STR),
1156*fcf3ce44SJohn Forte 		getStringArray(luProps.deviceFileName,
1157*fcf3ce44SJohn Forte 		    sizeof (luProps.deviceFileName)));
1158*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "\n");
1159*fcf3ce44SJohn Forte 		return (mpstatus);
1160*fcf3ce44SJohn Forte 	}
1161*fcf3ce44SJohn Forte 	(void) printf("\t\t%s %d\n",
1162*fcf3ce44SJohn Forte 	    getTextString(TEXT_LB_PATH_COUNT), pPathOidListArray->oidCount);
1163*fcf3ce44SJohn Forte 
1164*fcf3ce44SJohn Forte 	numOperationalPaths = 0;
1165*fcf3ce44SJohn Forte 	for (pa = 0; pa < pPathOidListArray->oidCount; pa++) {
1166*fcf3ce44SJohn Forte 		(void) memset(&pathProps, 0,
1167*fcf3ce44SJohn Forte 		    sizeof (MP_PATH_LOGICAL_UNIT_PROPERTIES));
1168*fcf3ce44SJohn Forte 		mpstatus =
1169*fcf3ce44SJohn Forte 		    MP_GetPathLogicalUnitProperties(
1170*fcf3ce44SJohn Forte 		    pPathOidListArray->oids[pa], &pathProps);
1171*fcf3ce44SJohn Forte 		if (mpstatus != MP_STATUS_SUCCESS) {
1172*fcf3ce44SJohn Forte 			(void) fprintf(stderr, "%s:  %s\n",
1173*fcf3ce44SJohn Forte 			    cmdName, getTextString(ERR_NO_PROPERTIES));
1174*fcf3ce44SJohn Forte 			return (mpstatus);
1175*fcf3ce44SJohn Forte 		}
1176*fcf3ce44SJohn Forte 
1177*fcf3ce44SJohn Forte 		/* cycle through and check status of each for */
1178*fcf3ce44SJohn Forte 		/* operation path count */
1179*fcf3ce44SJohn Forte 		if (MP_PATH_STATE_OKAY == pathProps.pathState) {
1180*fcf3ce44SJohn Forte 			numOperationalPaths++;
1181*fcf3ce44SJohn Forte 		}
1182*fcf3ce44SJohn Forte 	}
1183*fcf3ce44SJohn Forte 
1184*fcf3ce44SJohn Forte 	(void) printf("\t\t%s %d\n",
1185*fcf3ce44SJohn Forte 	    getTextString(TEXT_LB_OP_PATH_COUNT), numOperationalPaths);
1186*fcf3ce44SJohn Forte 
1187*fcf3ce44SJohn Forte 	return (mpstatus);
1188*fcf3ce44SJohn Forte }
1189*fcf3ce44SJohn Forte 
1190*fcf3ce44SJohn Forte 
1191*fcf3ce44SJohn Forte /*
1192*fcf3ce44SJohn Forte  * ****************************************************************************
1193*fcf3ce44SJohn Forte  *
1194*fcf3ce44SJohn Forte  * showLogicalUnit -
1195*fcf3ce44SJohn Forte  * 	mpathadm show {logical-unit | LU} <logical-unit name>, ...
1196*fcf3ce44SJohn Forte  *
1197*fcf3ce44SJohn Forte  * operandLen	- number of operands user passed into the cli
1198*fcf3ce44SJohn Forte  * operand	- pointer to operand list from user
1199*fcf3ce44SJohn Forte  *
1200*fcf3ce44SJohn Forte  * ****************************************************************************
1201*fcf3ce44SJohn Forte  */
1202*fcf3ce44SJohn Forte int
1203*fcf3ce44SJohn Forte showLogicalUnit(int operandLen, char *operand[])
1204*fcf3ce44SJohn Forte {
1205*fcf3ce44SJohn Forte 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
1206*fcf3ce44SJohn Forte 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES	luProps;
1207*fcf3ce44SJohn Forte 	MP_PLUGIN_PROPERTIES			pluginProps;
1208*fcf3ce44SJohn Forte 	MP_OID					luOid,
1209*fcf3ce44SJohn Forte 						pluginOid;
1210*fcf3ce44SJohn Forte 
1211*fcf3ce44SJohn Forte 	int					op;
1212*fcf3ce44SJohn Forte 
1213*fcf3ce44SJohn Forte 	for (op = 0; op < operandLen; op++) {
1214*fcf3ce44SJohn Forte 		if (op > 0) {
1215*fcf3ce44SJohn Forte 			(void) printf("\n");
1216*fcf3ce44SJohn Forte 		}
1217*fcf3ce44SJohn Forte 		if (B_TRUE == getLogicalUnitOid(operand[op], &luOid)) {
1218*fcf3ce44SJohn Forte 			(void) memset(&luProps, 0,
1219*fcf3ce44SJohn Forte 			    sizeof (MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES));
1220*fcf3ce44SJohn Forte 			mpstatus =
1221*fcf3ce44SJohn Forte 			    MP_GetMPLogicalUnitProperties(
1222*fcf3ce44SJohn Forte 			    luOid, &luProps);
1223*fcf3ce44SJohn Forte 			if (mpstatus != MP_STATUS_SUCCESS) {
1224*fcf3ce44SJohn Forte 				(void) fprintf(stderr, "%s:  %s\n",
1225*fcf3ce44SJohn Forte 				    cmdName, getTextString(ERR_NO_PROPERTIES));
1226*fcf3ce44SJohn Forte 				return (mpstatus);
1227*fcf3ce44SJohn Forte 			}
1228*fcf3ce44SJohn Forte 
1229*fcf3ce44SJohn Forte 			mpstatus =
1230*fcf3ce44SJohn Forte 			    MP_GetAssociatedPluginOid(luOid, &pluginOid);
1231*fcf3ce44SJohn Forte 			if (mpstatus != MP_STATUS_SUCCESS) {
1232*fcf3ce44SJohn Forte 				(void) fprintf(stderr, "%s:  %s\n",
1233*fcf3ce44SJohn Forte 				    cmdName,
1234*fcf3ce44SJohn Forte 				    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
1235*fcf3ce44SJohn Forte 				return (mpstatus);
1236*fcf3ce44SJohn Forte 			}
1237*fcf3ce44SJohn Forte 
1238*fcf3ce44SJohn Forte 			mpstatus =
1239*fcf3ce44SJohn Forte 			    MP_GetPluginProperties(pluginOid, &pluginProps);
1240*fcf3ce44SJohn Forte 			if (mpstatus != MP_STATUS_SUCCESS) {
1241*fcf3ce44SJohn Forte 				(void) fprintf(stderr, "%s:  %s\n",
1242*fcf3ce44SJohn Forte 				    cmdName, getTextString(ERR_NO_PROPERTIES));
1243*fcf3ce44SJohn Forte 				return (mpstatus);
1244*fcf3ce44SJohn Forte 			}
1245*fcf3ce44SJohn Forte 
1246*fcf3ce44SJohn Forte 			if (showIndividualLogicalUnit(luOid, luProps,
1247*fcf3ce44SJohn Forte 			    pluginProps) != 0) {
1248*fcf3ce44SJohn Forte 				return (ERROR_CLI_FAILED);
1249*fcf3ce44SJohn Forte 			}
1250*fcf3ce44SJohn Forte 
1251*fcf3ce44SJohn Forte 		} else {
1252*fcf3ce44SJohn Forte 			/* LINTED E_SEC_PRINTF_VAR_FMT */
1253*fcf3ce44SJohn Forte 			(void) fprintf(stderr, getTextString(
1254*fcf3ce44SJohn Forte 			    ERR_LU_NOT_FOUND_WITH_MISSING_LU_STR),
1255*fcf3ce44SJohn Forte 			    operand[op]);
1256*fcf3ce44SJohn Forte 			(void) printf("\n");
1257*fcf3ce44SJohn Forte 		}
1258*fcf3ce44SJohn Forte 
1259*fcf3ce44SJohn Forte 	} /* for each operand */
1260*fcf3ce44SJohn Forte 
1261*fcf3ce44SJohn Forte 	return (mpstatus);
1262*fcf3ce44SJohn Forte }
1263*fcf3ce44SJohn Forte 
1264*fcf3ce44SJohn Forte 
1265*fcf3ce44SJohn Forte /*
1266*fcf3ce44SJohn Forte  * ****************************************************************************
1267*fcf3ce44SJohn Forte  *
1268*fcf3ce44SJohn Forte  * showIndivudualLogicalUnit -
1269*fcf3ce44SJohn Forte  * 	Used by show logical unit cli.
1270*fcf3ce44SJohn Forte  *	Displays info about an LU
1271*fcf3ce44SJohn Forte  *
1272*fcf3ce44SJohn Forte  * luOid	- LU to show
1273*fcf3ce44SJohn Forte  * luProps	- properties of he LU to show
1274*fcf3ce44SJohn Forte  * pluginProps	- propertis of the plugin this LU belongs to
1275*fcf3ce44SJohn Forte  *
1276*fcf3ce44SJohn Forte  * ****************************************************************************
1277*fcf3ce44SJohn Forte  */
1278*fcf3ce44SJohn Forte int
1279*fcf3ce44SJohn Forte showIndividualLogicalUnit(MP_OID luOid,
1280*fcf3ce44SJohn Forte 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES luProps,
1281*fcf3ce44SJohn Forte 	MP_PLUGIN_PROPERTIES pluginProps)
1282*fcf3ce44SJohn Forte {
1283*fcf3ce44SJohn Forte 	MP_PATH_LOGICAL_UNIT_PROPERTIES		pathProps;
1284*fcf3ce44SJohn Forte 	MP_TARGET_PORT_GROUP_PROPERTIES		tpgProps;
1285*fcf3ce44SJohn Forte 	MP_TARGET_PORT_PROPERTIES 		tportProps;
1286*fcf3ce44SJohn Forte 	MP_INITIATOR_PORT_PROPERTIES 		initProps;
1287*fcf3ce44SJohn Forte 	MP_OID_LIST				*pPathOidListArray,
1288*fcf3ce44SJohn Forte 						*pTPGOidListArray,
1289*fcf3ce44SJohn Forte 						*pTportOidListArray;
1290*fcf3ce44SJohn Forte 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
1291*fcf3ce44SJohn Forte 	boolean_t				showTportLabel = B_TRUE;
1292*fcf3ce44SJohn Forte 
1293*fcf3ce44SJohn Forte 	int					pa,
1294*fcf3ce44SJohn Forte 						tpg,
1295*fcf3ce44SJohn Forte 						tport;
1296*fcf3ce44SJohn Forte 
1297*fcf3ce44SJohn Forte 	(void) printf("%s  ", getTextString(TEXT_LB_LOGICAL_UNIT));
1298*fcf3ce44SJohn Forte 	displayArray(luProps.deviceFileName, sizeof (luProps.deviceFileName));
1299*fcf3ce44SJohn Forte 	(void) printf("\n");
1300*fcf3ce44SJohn Forte 	(void) printf("\t%s  %s\n", getTextString(TEXT_LB_MPATH_SUPPORT),
1301*fcf3ce44SJohn Forte 		pluginProps.fileName);
1302*fcf3ce44SJohn Forte 
1303*fcf3ce44SJohn Forte 	(void) printf("\t%s  ", getTextString(TEXT_LB_VENDOR));
1304*fcf3ce44SJohn Forte 	displayArray(luProps.vendor,
1305*fcf3ce44SJohn Forte 	    sizeof (luProps.vendor));
1306*fcf3ce44SJohn Forte 	(void) printf("\n\t%s  ", getTextString(TEXT_LB_PRODUCT));
1307*fcf3ce44SJohn Forte 	displayArray(luProps.product,
1308*fcf3ce44SJohn Forte 	    sizeof (luProps.product));
1309*fcf3ce44SJohn Forte 	(void) printf("\n\t%s  ", getTextString(TEXT_LB_REVISION));
1310*fcf3ce44SJohn Forte 	displayArray(luProps.revision,
1311*fcf3ce44SJohn Forte 	    sizeof (luProps.revision));
1312*fcf3ce44SJohn Forte 	(void) printf("\n\t%s  ", getTextString(TEXT_LB_INQUIRY_NAME_TYPE));
1313*fcf3ce44SJohn Forte 	displayLogicalUnitNameTypeString(luProps.nameType);
1314*fcf3ce44SJohn Forte 	(void) printf("\n\t%s  ", getTextString(TEXT_LB_INQUIRY_NAME));
1315*fcf3ce44SJohn Forte 	displayArray(luProps.name, sizeof (luProps.name));
1316*fcf3ce44SJohn Forte 	(void) printf("\n\t%s  %s\n", getTextString(TEXT_LB_ASYMMETRIC),
1317*fcf3ce44SJohn Forte 	    (MP_TRUE == luProps.asymmetric)?
1318*fcf3ce44SJohn Forte 	    getTextString(TEXT_YES):getTextString(TEXT_NO));
1319*fcf3ce44SJohn Forte 
1320*fcf3ce44SJohn Forte 	(void) printf("\t%s  ", getTextString(TEXT_LB_CURR_LOAD_BALANCE));
1321*fcf3ce44SJohn Forte 	/* don't ignore load balance type none. */
1322*fcf3ce44SJohn Forte 	if (luProps.currentLoadBalanceType == 0) {
1323*fcf3ce44SJohn Forte 		(void) printf("%s", getTextString(TEXT_LBTYPE_NONE));
1324*fcf3ce44SJohn Forte 	} else {
1325*fcf3ce44SJohn Forte 		displayLoadBalanceString(luProps.currentLoadBalanceType);
1326*fcf3ce44SJohn Forte 	}
1327*fcf3ce44SJohn Forte 	(void) printf("\n");
1328*fcf3ce44SJohn Forte 
1329*fcf3ce44SJohn Forte 	(void) printf("\t%s  ", getTextString(TEXT_LB_LU_GROUP_ID));
1330*fcf3ce44SJohn Forte 	if (0xffffffff == luProps.logicalUnitGroupID) {
1331*fcf3ce44SJohn Forte 		(void) printf("%s\n", getTextString(TEXT_NA));
1332*fcf3ce44SJohn Forte 	} else {
1333*fcf3ce44SJohn Forte 		(void) printf("0x%x\n", luProps.logicalUnitGroupID);
1334*fcf3ce44SJohn Forte 	}
1335*fcf3ce44SJohn Forte 
1336*fcf3ce44SJohn Forte 	(void) printf("\t%s  ", getTextString(TEXT_LB_AUTO_FB));
1337*fcf3ce44SJohn Forte 	if (MP_FALSE == pluginProps.autoFailbackSupport) {
1338*fcf3ce44SJohn Forte 		(void) printf("%s\n", getTextString(TEXT_NA));
1339*fcf3ce44SJohn Forte 	} else {
1340*fcf3ce44SJohn Forte 		(void) printf("%s\n", (MP_TRUE == luProps.autoFailbackEnabled)?
1341*fcf3ce44SJohn Forte 		    getTextString(TEXT_ON):getTextString(TEXT_OFF));
1342*fcf3ce44SJohn Forte 	}
1343*fcf3ce44SJohn Forte 
1344*fcf3ce44SJohn Forte 	(void) printf("\t%s  ", getTextString(TEXT_LB_AUTO_PROB));
1345*fcf3ce44SJohn Forte 	if (MP_FALSE == pluginProps.autoProbingSupport) {
1346*fcf3ce44SJohn Forte 		(void) printf("%s\n", getTextString(TEXT_NA));
1347*fcf3ce44SJohn Forte 	} else {
1348*fcf3ce44SJohn Forte 		(void) printf("%s\n", (MP_TRUE == luProps.autoProbingEnabled)?
1349*fcf3ce44SJohn Forte 		    getTextString(TEXT_ON):getTextString(TEXT_OFF));
1350*fcf3ce44SJohn Forte 	}
1351*fcf3ce44SJohn Forte 
1352*fcf3ce44SJohn Forte 
1353*fcf3ce44SJohn Forte 	/* get path info */
1354*fcf3ce44SJohn Forte 	mpstatus = MP_GetAssociatedPathOidList(luOid, &pPathOidListArray);
1355*fcf3ce44SJohn Forte 	if (mpstatus != MP_STATUS_SUCCESS) {
1356*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s:  %s", cmdName,
1357*fcf3ce44SJohn Forte 		    getTextString(ERR_NO_LU_PATH_INFO));
1358*fcf3ce44SJohn Forte 		displayArray(luProps.deviceFileName,
1359*fcf3ce44SJohn Forte 		    sizeof (luProps.deviceFileName));
1360*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "\n");
1361*fcf3ce44SJohn Forte 		return (mpstatus);
1362*fcf3ce44SJohn Forte 	}
1363*fcf3ce44SJohn Forte 
1364*fcf3ce44SJohn Forte 	(void) printf("\n\t%s  \n", getTextString(TEXT_LB_PATH_INFO));
1365*fcf3ce44SJohn Forte 
1366*fcf3ce44SJohn Forte 	for (pa = 0; pa < pPathOidListArray->oidCount; pa++) {
1367*fcf3ce44SJohn Forte 		(void) memset(&pathProps, 0,
1368*fcf3ce44SJohn Forte 		    sizeof (MP_PATH_LOGICAL_UNIT_PROPERTIES));
1369*fcf3ce44SJohn Forte 		mpstatus = MP_GetPathLogicalUnitProperties(
1370*fcf3ce44SJohn Forte 		    pPathOidListArray->oids[pa], &pathProps);
1371*fcf3ce44SJohn Forte 		if (mpstatus != MP_STATUS_SUCCESS) {
1372*fcf3ce44SJohn Forte 			(void) fprintf(stderr, "%s:  %s\n",
1373*fcf3ce44SJohn Forte 			    cmdName, getTextString(ERR_NO_PROPERTIES));
1374*fcf3ce44SJohn Forte 			return (mpstatus);
1375*fcf3ce44SJohn Forte 		}
1376*fcf3ce44SJohn Forte 
1377*fcf3ce44SJohn Forte 		(void) printf("\t\t%s  ",
1378*fcf3ce44SJohn Forte 		    getTextString(TEXT_LB_INIT_PORT_NAME));
1379*fcf3ce44SJohn Forte 		if ((mpstatus =
1380*fcf3ce44SJohn Forte 		    MP_GetInitiatorPortProperties(pathProps.initiatorPortOid,
1381*fcf3ce44SJohn Forte 		    &initProps)) != MP_STATUS_SUCCESS) {
1382*fcf3ce44SJohn Forte 			(void) printf("%s\n", getTextString(TEXT_UNKNOWN));
1383*fcf3ce44SJohn Forte 		} else {
1384*fcf3ce44SJohn Forte 			displayArray(initProps.portID,
1385*fcf3ce44SJohn Forte 			    sizeof (initProps.portID));
1386*fcf3ce44SJohn Forte 			(void) printf("\n");
1387*fcf3ce44SJohn Forte 		}
1388*fcf3ce44SJohn Forte 
1389*fcf3ce44SJohn Forte 		(void) printf("\t\t%s  ",
1390*fcf3ce44SJohn Forte 		    getTextString(TEXT_LB_TARGET_PORT_NAME));
1391*fcf3ce44SJohn Forte 		if ((mpstatus =
1392*fcf3ce44SJohn Forte 		    MP_GetTargetPortProperties(pathProps.targetPortOid,
1393*fcf3ce44SJohn Forte 		    &tportProps)) != MP_STATUS_SUCCESS) {
1394*fcf3ce44SJohn Forte 			(void) printf("%s\n", getTextString(TEXT_UNKNOWN));
1395*fcf3ce44SJohn Forte 		} else {
1396*fcf3ce44SJohn Forte 			displayArray(tportProps.portID,
1397*fcf3ce44SJohn Forte 			    sizeof (tportProps.portID));
1398*fcf3ce44SJohn Forte 			(void) printf("\n");
1399*fcf3ce44SJohn Forte 		}
1400*fcf3ce44SJohn Forte 
1401*fcf3ce44SJohn Forte 		(void) printf("\t\t%s  ", getTextString(TEXT_LB_OVERRIDE_PATH));
1402*fcf3ce44SJohn Forte 		if (MP_FALSE == pluginProps.canOverridePaths) {
1403*fcf3ce44SJohn Forte 			(void) printf("%s\n", getTextString(TEXT_NA));
1404*fcf3ce44SJohn Forte 		} else if (luProps.overridePath.objectSequenceNumber ==
1405*fcf3ce44SJohn Forte 		    pPathOidListArray->oids[pa].objectSequenceNumber) {
1406*fcf3ce44SJohn Forte 			(void) printf("%s\n", getTextString(TEXT_YES));
1407*fcf3ce44SJohn Forte 		} else {
1408*fcf3ce44SJohn Forte 			(void) printf("%s\n", getTextString(TEXT_NO));
1409*fcf3ce44SJohn Forte 		}
1410*fcf3ce44SJohn Forte 
1411*fcf3ce44SJohn Forte 		(void) printf("\t\t%s  %s\n", getTextString(TEXT_LB_PATH_STATE),
1412*fcf3ce44SJohn Forte 		    getPathStateStr(pathProps.pathState));
1413*fcf3ce44SJohn Forte 
1414*fcf3ce44SJohn Forte 		(void) printf("\t\t%s  %s\n\n", getTextString(TEXT_LB_DISABLED),
1415*fcf3ce44SJohn Forte 		    pathProps.disabled?getTextString(TEXT_YES):
1416*fcf3ce44SJohn Forte 		    getTextString(TEXT_NO));
1417*fcf3ce44SJohn Forte 
1418*fcf3ce44SJohn Forte 	}
1419*fcf3ce44SJohn Forte 
1420*fcf3ce44SJohn Forte 	/* get tpg info */
1421*fcf3ce44SJohn Forte 	mpstatus = MP_GetAssociatedTPGOidList(luOid, &pTPGOidListArray);
1422*fcf3ce44SJohn Forte 	if (mpstatus != MP_STATUS_SUCCESS) {
1423*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s:  %s", cmdName,
1424*fcf3ce44SJohn Forte 		    getTextString(ERR_NO_ASSOC_TPGS));
1425*fcf3ce44SJohn Forte 	} else {
1426*fcf3ce44SJohn Forte 
1427*fcf3ce44SJohn Forte 	/* display tpg info only if is assymetric */
1428*fcf3ce44SJohn Forte 	if (MP_TRUE == luProps.asymmetric) {
1429*fcf3ce44SJohn Forte 		(void) printf("\t%s  \n", getTextString(TEXT_LB_TPG_INFO));
1430*fcf3ce44SJohn Forte 	}
1431*fcf3ce44SJohn Forte 
1432*fcf3ce44SJohn Forte 		for (tpg = 0; tpg < pTPGOidListArray->oidCount; tpg++) {
1433*fcf3ce44SJohn Forte 			(void) memset(&tpgProps, 0,
1434*fcf3ce44SJohn Forte 			    sizeof (MP_TARGET_PORT_GROUP_PROPERTIES));
1435*fcf3ce44SJohn Forte 			mpstatus = MP_GetTargetPortGroupProperties(
1436*fcf3ce44SJohn Forte 			    pTPGOidListArray->oids[tpg], &tpgProps);
1437*fcf3ce44SJohn Forte 			if (mpstatus != MP_STATUS_SUCCESS) {
1438*fcf3ce44SJohn Forte 				(void) fprintf(stderr, "%s:  %s",
1439*fcf3ce44SJohn Forte 				    cmdName, getTextString(ERR_NO_PROPERTIES));
1440*fcf3ce44SJohn Forte 			} else {
1441*fcf3ce44SJohn Forte 				/* display tpg info only if is assymetric */
1442*fcf3ce44SJohn Forte 				if (tpg > 0) {
1443*fcf3ce44SJohn Forte 					(void) printf("\n");
1444*fcf3ce44SJohn Forte 				}
1445*fcf3ce44SJohn Forte 				if (MP_TRUE == luProps.asymmetric) {
1446*fcf3ce44SJohn Forte 					(void) printf("\t\t%s  %d\n",
1447*fcf3ce44SJohn Forte 					    getTextString(TEXT_LB_ID),
1448*fcf3ce44SJohn Forte 					    tpgProps.tpgID);
1449*fcf3ce44SJohn Forte 					(void) printf("\t\t%s  %s\n",
1450*fcf3ce44SJohn Forte 					    getTextString(
1451*fcf3ce44SJohn Forte 					    TEXT_LB_EXPLICIT_FAILOVER),
1452*fcf3ce44SJohn Forte 					    (MP_TRUE ==
1453*fcf3ce44SJohn Forte 					    tpgProps.explicitFailover)?
1454*fcf3ce44SJohn Forte 					    getTextString(TEXT_YES):
1455*fcf3ce44SJohn Forte 					    getTextString(TEXT_NO));
1456*fcf3ce44SJohn Forte 					(void) printf("\t\t%s  %s\n",
1457*fcf3ce44SJohn Forte 					    getTextString(
1458*fcf3ce44SJohn Forte 					    TEXT_LB_ACCESS_STATE),
1459*fcf3ce44SJohn Forte 					    getAccessStateStr(
1460*fcf3ce44SJohn Forte 					    tpgProps.accessState));
1461*fcf3ce44SJohn Forte 					    /* display label for each tpg. */
1462*fcf3ce44SJohn Forte 					    (void) printf("\t\t%s\n",
1463*fcf3ce44SJohn Forte 						getTextString(TEXT_TPORT_LIST));
1464*fcf3ce44SJohn Forte 				} else {
1465*fcf3ce44SJohn Forte 					/* display label once for symmetric. */
1466*fcf3ce44SJohn Forte 					if (B_TRUE == showTportLabel) {
1467*fcf3ce44SJohn Forte 						(void) printf("\t%s\n",
1468*fcf3ce44SJohn Forte 						getTextString(TEXT_TPORT_LIST));
1469*fcf3ce44SJohn Forte 						showTportLabel = B_FALSE;
1470*fcf3ce44SJohn Forte 					}
1471*fcf3ce44SJohn Forte 				}
1472*fcf3ce44SJohn Forte 
1473*fcf3ce44SJohn Forte 				/* get target port info */
1474*fcf3ce44SJohn Forte 				mpstatus = MP_GetTargetPortOidList(
1475*fcf3ce44SJohn Forte 				    pTPGOidListArray->oids[tpg],
1476*fcf3ce44SJohn Forte 				    &pTportOidListArray);
1477*fcf3ce44SJohn Forte 				if (mpstatus != MP_STATUS_SUCCESS) {
1478*fcf3ce44SJohn Forte 					(void) fprintf(stderr, "%s:  %s",
1479*fcf3ce44SJohn Forte 					    cmdName,
1480*fcf3ce44SJohn Forte 					    getTextString(ERR_NO_ASSOC_TPORTS));
1481*fcf3ce44SJohn Forte 				} else {
1482*fcf3ce44SJohn Forte 
1483*fcf3ce44SJohn Forte /* begin back-up indentation */
1484*fcf3ce44SJohn Forte 	for (tport = 0; tport < pTportOidListArray->oidCount; tport++) {
1485*fcf3ce44SJohn Forte 		(void) memset(&tportProps, 0,
1486*fcf3ce44SJohn Forte 		    sizeof (MP_TARGET_PORT_PROPERTIES));
1487*fcf3ce44SJohn Forte 		if ((mpstatus =
1488*fcf3ce44SJohn Forte 		    MP_GetTargetPortProperties(pTportOidListArray->oids[tport],
1489*fcf3ce44SJohn Forte 		    &tportProps)) != MP_STATUS_SUCCESS) {
1490*fcf3ce44SJohn Forte 			(void) fprintf(stderr, "%s:  %s",
1491*fcf3ce44SJohn Forte 			cmdName, getTextString(ERR_NO_PROPERTIES));
1492*fcf3ce44SJohn Forte 		} else {
1493*fcf3ce44SJohn Forte 			if (MP_TRUE == luProps.asymmetric) {
1494*fcf3ce44SJohn Forte 				(void) printf("\t\t\t%s  ",
1495*fcf3ce44SJohn Forte 				getTextString(TEXT_LB_NAME));
1496*fcf3ce44SJohn Forte 				displayArray(tportProps.portID,
1497*fcf3ce44SJohn Forte 					sizeof (tportProps.portID));
1498*fcf3ce44SJohn Forte 				(void) printf("\n\t\t\t%s  %d\n",
1499*fcf3ce44SJohn Forte 				getTextString(TEXT_LB_RELATIVE_ID),
1500*fcf3ce44SJohn Forte 				tportProps.relativePortID);
1501*fcf3ce44SJohn Forte 			} else {
1502*fcf3ce44SJohn Forte 				(void) printf("\t\t%s  ",
1503*fcf3ce44SJohn Forte 				getTextString(TEXT_LB_NAME));
1504*fcf3ce44SJohn Forte 				displayArray(tportProps.portID,
1505*fcf3ce44SJohn Forte 					sizeof (tportProps.portID));
1506*fcf3ce44SJohn Forte 				(void) printf("\n\t\t%s  %d\n",
1507*fcf3ce44SJohn Forte 				getTextString(TEXT_LB_RELATIVE_ID),
1508*fcf3ce44SJohn Forte 				tportProps.relativePortID);
1509*fcf3ce44SJohn Forte 			}
1510*fcf3ce44SJohn Forte 			/* insert blank line if not the last target port. */
1511*fcf3ce44SJohn Forte 			if (!(tport == (pTportOidListArray->oidCount - 1))) {
1512*fcf3ce44SJohn Forte 			    (void) printf("\n");
1513*fcf3ce44SJohn Forte 			}
1514*fcf3ce44SJohn Forte 		}
1515*fcf3ce44SJohn Forte 	} /* for each target port */
1516*fcf3ce44SJohn Forte /* end back-up indentation */
1517*fcf3ce44SJohn Forte 
1518*fcf3ce44SJohn Forte 				} /* else got target port props */
1519*fcf3ce44SJohn Forte 			} /* else got TPG props */
1520*fcf3ce44SJohn Forte 		} /* for each TPG */
1521*fcf3ce44SJohn Forte 	} /* else got tpg list */
1522*fcf3ce44SJohn Forte 
1523*fcf3ce44SJohn Forte 
1524*fcf3ce44SJohn Forte 	return (mpstatus);
1525*fcf3ce44SJohn Forte }
1526*fcf3ce44SJohn Forte 
1527*fcf3ce44SJohn Forte 
1528*fcf3ce44SJohn Forte /*
1529*fcf3ce44SJohn Forte  * ****************************************************************************
1530*fcf3ce44SJohn Forte  *
1531*fcf3ce44SJohn Forte  * modifyLogicalUnit -
1532*fcf3ce44SJohn Forte  * 	mpathadm modify {logical-unit | LU} [options] <logical-unit name>, ...
1533*fcf3ce44SJohn Forte  *
1534*fcf3ce44SJohn Forte  * operandLen	- number of operands user passed into the cli
1535*fcf3ce44SJohn Forte  * operand	- pointer to operand list from user
1536*fcf3ce44SJohn Forte  * options	- pointer to option list from user
1537*fcf3ce44SJohn Forte  *
1538*fcf3ce44SJohn Forte  * ****************************************************************************
1539*fcf3ce44SJohn Forte  */
1540*fcf3ce44SJohn Forte int
1541*fcf3ce44SJohn Forte modifyLogicalUnit(int operandLen, char *operand[], cmdOptions_t *options)
1542*fcf3ce44SJohn Forte {
1543*fcf3ce44SJohn Forte 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
1544*fcf3ce44SJohn Forte 	MP_OID					luOid;
1545*fcf3ce44SJohn Forte 	cmdOptions_t 				*optionList = options;
1546*fcf3ce44SJohn Forte 	char					*cmdStr =
1547*fcf3ce44SJohn Forte 						    getTextString(
1548*fcf3ce44SJohn Forte 						    TEXT_UNKNOWN);
1549*fcf3ce44SJohn Forte 	int					op;
1550*fcf3ce44SJohn Forte 
1551*fcf3ce44SJohn Forte 	for (op = 0; op < operandLen; op++) {
1552*fcf3ce44SJohn Forte 		if (B_TRUE != getLogicalUnitOid(operand[op], &luOid)) {
1553*fcf3ce44SJohn Forte 			/* LINTED E_SEC_PRINTF_VAR_FMT */
1554*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
1555*fcf3ce44SJohn Forte 			    getTextString(ERR_LU_NOT_FOUND_WITH_MISSING_LU_STR),
1556*fcf3ce44SJohn Forte 			    operand[op]);
1557*fcf3ce44SJohn Forte 			(void) printf("\n");
1558*fcf3ce44SJohn Forte 			return (ERROR_CLI_FAILED);
1559*fcf3ce44SJohn Forte 		}
1560*fcf3ce44SJohn Forte 
1561*fcf3ce44SJohn Forte 		/* we found the lu oid, now change the options requested */
1562*fcf3ce44SJohn Forte 		switch (optionList->optval) {
1563*fcf3ce44SJohn Forte 			case 'a':
1564*fcf3ce44SJohn Forte 				/* modify autofailback */
1565*fcf3ce44SJohn Forte 				cmdStr = getTextString(TEXT_AUTO_FAILBACK);
1566*fcf3ce44SJohn Forte 				if (0 == strcasecmp(optionList->optarg,
1567*fcf3ce44SJohn Forte 				    getTextString(TEXT_ON))) {
1568*fcf3ce44SJohn Forte 					mpstatus =
1569*fcf3ce44SJohn Forte 					    MP_EnableAutoFailback(luOid);
1570*fcf3ce44SJohn Forte 				} else if (0 == strcasecmp(optionList->optarg,
1571*fcf3ce44SJohn Forte 				    getTextString(TEXT_OFF))) {
1572*fcf3ce44SJohn Forte 					mpstatus =
1573*fcf3ce44SJohn Forte 					    MP_DisableAutoFailback(luOid);
1574*fcf3ce44SJohn Forte 				} else {
1575*fcf3ce44SJohn Forte 					/* LINTED E_SEC_PRINTF_VAR_FMT */
1576*fcf3ce44SJohn Forte 					(void) fprintf(stderr, getTextString(
1577*fcf3ce44SJohn Forte 				    ERR_FAILED_TO_CHANGE_OPTION_WITH_REASON),
1578*fcf3ce44SJohn Forte 					    cmdStr,
1579*fcf3ce44SJohn Forte 					    getTextString(
1580*fcf3ce44SJohn Forte 					    TEXT_ILLEGAL_ARGUMENT));
1581*fcf3ce44SJohn Forte 					(void) printf("\n");
1582*fcf3ce44SJohn Forte 					return (ERROR_CLI_FAILED);
1583*fcf3ce44SJohn Forte 				}
1584*fcf3ce44SJohn Forte 				break;
1585*fcf3ce44SJohn Forte 			case 'p':
1586*fcf3ce44SJohn Forte 				/* modify autoprobing */
1587*fcf3ce44SJohn Forte 				cmdStr = getTextString(TEXT_AUTO_PROBING);
1588*fcf3ce44SJohn Forte 				if (0 == strcasecmp(optionList->optarg,
1589*fcf3ce44SJohn Forte 				    getTextString(TEXT_ON))) {
1590*fcf3ce44SJohn Forte 					mpstatus =
1591*fcf3ce44SJohn Forte 					    MP_EnableAutoProbing(luOid);
1592*fcf3ce44SJohn Forte 				} else if (0 == strcasecmp(optionList->optarg,
1593*fcf3ce44SJohn Forte 					getTextString(TEXT_OFF))) {
1594*fcf3ce44SJohn Forte 					mpstatus =
1595*fcf3ce44SJohn Forte 					    MP_DisableAutoProbing(luOid);
1596*fcf3ce44SJohn Forte 				} else {
1597*fcf3ce44SJohn Forte 					/* LINTED E_SEC_PRINTF_VAR_FMT */
1598*fcf3ce44SJohn Forte 					(void) fprintf(stderr, getTextString(
1599*fcf3ce44SJohn Forte 				    ERR_FAILED_TO_CHANGE_OPTION_WITH_REASON),
1600*fcf3ce44SJohn Forte 					    cmdStr,
1601*fcf3ce44SJohn Forte 					    getTextString(
1602*fcf3ce44SJohn Forte 					    TEXT_ILLEGAL_ARGUMENT));
1603*fcf3ce44SJohn Forte 					(void) printf("\n");
1604*fcf3ce44SJohn Forte 					return (ERROR_CLI_FAILED);
1605*fcf3ce44SJohn Forte 				}
1606*fcf3ce44SJohn Forte 				break;
1607*fcf3ce44SJohn Forte 			case 'b':
1608*fcf3ce44SJohn Forte 				/* modify loadbalance type */
1609*fcf3ce44SJohn Forte 				cmdStr = getTextString(TEXT_LOAD_BALANCE);
1610*fcf3ce44SJohn Forte 				mpstatus =
1611*fcf3ce44SJohn Forte 				    MP_SetLogicalUnitLoadBalanceType(luOid,
1612*fcf3ce44SJohn Forte 				    getLbValueFromString(optionList->optarg));
1613*fcf3ce44SJohn Forte 				break;
1614*fcf3ce44SJohn Forte 
1615*fcf3ce44SJohn Forte 		} /* switch */
1616*fcf3ce44SJohn Forte 		if (MP_STATUS_SUCCESS != mpstatus) {
1617*fcf3ce44SJohn Forte 			/* LINTED E_SEC_PRINTF_VAR_FMT */
1618*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
1619*fcf3ce44SJohn Forte 			    getTextString(
1620*fcf3ce44SJohn Forte 			    ERR_FAILED_TO_CHANGE_OPTION_WITH_REASON),
1621*fcf3ce44SJohn Forte 			    cmdStr, getMpStatusStr(mpstatus));
1622*fcf3ce44SJohn Forte 			(void) printf("\n");
1623*fcf3ce44SJohn Forte 			return (ERROR_CLI_FAILED);
1624*fcf3ce44SJohn Forte 		}
1625*fcf3ce44SJohn Forte 	} /* for each operand */
1626*fcf3ce44SJohn Forte 	return (mpstatus);
1627*fcf3ce44SJohn Forte }
1628*fcf3ce44SJohn Forte 
1629*fcf3ce44SJohn Forte 
1630*fcf3ce44SJohn Forte /*
1631*fcf3ce44SJohn Forte  * ****************************************************************************
1632*fcf3ce44SJohn Forte  *
1633*fcf3ce44SJohn Forte  * failoverLogicalUnit -
1634*fcf3ce44SJohn Forte  * 	mpathadm failover {logical-unit | LU} <logical-unit name>, ...
1635*fcf3ce44SJohn Forte  *
1636*fcf3ce44SJohn Forte  * operand	- pointer to operand list from user
1637*fcf3ce44SJohn Forte  *
1638*fcf3ce44SJohn Forte  * ****************************************************************************
1639*fcf3ce44SJohn Forte  */
1640*fcf3ce44SJohn Forte int
1641*fcf3ce44SJohn Forte failoverLogicalUnit(char *operand[])
1642*fcf3ce44SJohn Forte {
1643*fcf3ce44SJohn Forte 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
1644*fcf3ce44SJohn Forte 	MP_OID					luOid;
1645*fcf3ce44SJohn Forte 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES	luProps;
1646*fcf3ce44SJohn Forte 	MP_TARGET_PORT_GROUP_PROPERTIES		tpgProps;
1647*fcf3ce44SJohn Forte 	MP_OID_LIST				*pTpgOidListArray;
1648*fcf3ce44SJohn Forte 	boolean_t				bFoundIt = B_FALSE;
1649*fcf3ce44SJohn Forte 	MP_TPG_STATE_PAIR			tpgStatePair;
1650*fcf3ce44SJohn Forte 
1651*fcf3ce44SJohn Forte 	int					tpg;
1652*fcf3ce44SJohn Forte 
1653*fcf3ce44SJohn Forte 	if (B_TRUE != getLogicalUnitOid(operand[0], &luOid)) {
1654*fcf3ce44SJohn Forte 		/* LINTED E_SEC_PRINTF_VAR_FMT */
1655*fcf3ce44SJohn Forte 		(void) fprintf(stderr, getTextString(
1656*fcf3ce44SJohn Forte 		    ERR_LU_NOT_FOUND_WITH_MISSING_LU_STR),
1657*fcf3ce44SJohn Forte 		    operand[0]);
1658*fcf3ce44SJohn Forte 		(void) printf("\n");
1659*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
1660*fcf3ce44SJohn Forte 	}
1661*fcf3ce44SJohn Forte 
1662*fcf3ce44SJohn Forte 	/* get LUN properties and check to be sure it's asymmetric */
1663*fcf3ce44SJohn Forte 	(void) memset(&luProps, 0,
1664*fcf3ce44SJohn Forte 	    sizeof (MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES));
1665*fcf3ce44SJohn Forte 	mpstatus =
1666*fcf3ce44SJohn Forte 	    MP_GetMPLogicalUnitProperties(luOid, &luProps);
1667*fcf3ce44SJohn Forte 	if (mpstatus != MP_STATUS_SUCCESS) {
1668*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s:  %s\n",
1669*fcf3ce44SJohn Forte 		    cmdName, getTextString(ERR_NO_PROPERTIES));
1670*fcf3ce44SJohn Forte 		return (mpstatus);
1671*fcf3ce44SJohn Forte 	}
1672*fcf3ce44SJohn Forte 
1673*fcf3ce44SJohn Forte 	if (MP_TRUE != luProps.asymmetric) {
1674*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s:  %s\n",
1675*fcf3ce44SJohn Forte 		    cmdName, getTextString(ERR_LU_NOT_ASYMMETRIC));
1676*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
1677*fcf3ce44SJohn Forte 	}
1678*fcf3ce44SJohn Forte 
1679*fcf3ce44SJohn Forte 	/* get TPGs for this LUN */
1680*fcf3ce44SJohn Forte 	mpstatus =
1681*fcf3ce44SJohn Forte 	    MP_GetAssociatedTPGOidList(luOid, &pTpgOidListArray);
1682*fcf3ce44SJohn Forte 	if (mpstatus != MP_STATUS_SUCCESS) {
1683*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s:  %s\n",
1684*fcf3ce44SJohn Forte 		cmdName, getTextString(ERR_NO_ASSOC_TPGS));
1685*fcf3ce44SJohn Forte 		return (mpstatus);
1686*fcf3ce44SJohn Forte 	}
1687*fcf3ce44SJohn Forte 
1688*fcf3ce44SJohn Forte 	/* pick a TPG whose state is active or standby, and change it */
1689*fcf3ce44SJohn Forte 	/* to opposite via MP_SetTPGAccessState */
1690*fcf3ce44SJohn Forte 	bFoundIt = B_FALSE;
1691*fcf3ce44SJohn Forte 	for (tpg = 0; tpg < pTpgOidListArray->oidCount; tpg++) {
1692*fcf3ce44SJohn Forte 		(void) memset(&tpgProps, 0,
1693*fcf3ce44SJohn Forte 		    sizeof (MP_TARGET_PORT_GROUP_PROPERTIES));
1694*fcf3ce44SJohn Forte 		mpstatus =
1695*fcf3ce44SJohn Forte 		    MP_GetTargetPortGroupProperties(
1696*fcf3ce44SJohn Forte 		    pTpgOidListArray->oids[tpg], &tpgProps);
1697*fcf3ce44SJohn Forte 		if (mpstatus != MP_STATUS_SUCCESS) {
1698*fcf3ce44SJohn Forte 			(void) fprintf(stderr, "%s:  %s\n",
1699*fcf3ce44SJohn Forte 			    cmdName, getTextString(ERR_NO_PROPERTIES));
1700*fcf3ce44SJohn Forte 			return (ERROR_CLI_FAILED);
1701*fcf3ce44SJohn Forte 		}
1702*fcf3ce44SJohn Forte 		if (MP_FALSE == tpgProps.explicitFailover) {
1703*fcf3ce44SJohn Forte 			(void) fprintf(stderr, "%s:  %s\n",
1704*fcf3ce44SJohn Forte 			cmdName, getTextString(ERR_NO_FAILOVER_ALLOWED));
1705*fcf3ce44SJohn Forte 			return (ERROR_CLI_FAILED);
1706*fcf3ce44SJohn Forte 		}
1707*fcf3ce44SJohn Forte 
1708*fcf3ce44SJohn Forte 		/* find one that is standby */
1709*fcf3ce44SJohn Forte 		if ((MP_ACCESS_STATE_STANDBY ==
1710*fcf3ce44SJohn Forte 		    tpgProps.accessState) && (B_FALSE == bFoundIt)) {
1711*fcf3ce44SJohn Forte 
1712*fcf3ce44SJohn Forte 			bFoundIt = B_TRUE;
1713*fcf3ce44SJohn Forte 
1714*fcf3ce44SJohn Forte 			tpgStatePair.tpgOid =
1715*fcf3ce44SJohn Forte 			    pTpgOidListArray->oids[tpg];
1716*fcf3ce44SJohn Forte 			tpgStatePair.desiredState =
1717*fcf3ce44SJohn Forte 			    MP_ACCESS_STATE_ACTIVE;
1718*fcf3ce44SJohn Forte 			mpstatus =
1719*fcf3ce44SJohn Forte 			    MP_SetTPGAccess(luOid, 1, &tpgStatePair);
1720*fcf3ce44SJohn Forte 			if (MP_STATUS_SUCCESS != mpstatus) {
1721*fcf3ce44SJohn Forte 				/* LINTED E_SEC_PRINTF_VAR_FMT */
1722*fcf3ce44SJohn Forte 				(void) fprintf(stderr, getTextString(
1723*fcf3ce44SJohn Forte 			    ERR_FAILED_TO_FAILOVER_WITH_REASON),
1724*fcf3ce44SJohn Forte 			    getMpStatusStr(mpstatus));
1725*fcf3ce44SJohn Forte 				(void) printf("\n");
1726*fcf3ce44SJohn Forte 				return (mpstatus);
1727*fcf3ce44SJohn Forte 			}
1728*fcf3ce44SJohn Forte 		}
1729*fcf3ce44SJohn Forte 
1730*fcf3ce44SJohn Forte 
1731*fcf3ce44SJohn Forte 	} /* for each tpg */
1732*fcf3ce44SJohn Forte 
1733*fcf3ce44SJohn Forte 	if (B_FALSE == bFoundIt) {
1734*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s:  %s\n",
1735*fcf3ce44SJohn Forte 		    cmdName, getTextString(ERR_LU_ACCESS_STATE_UNCHANGED));
1736*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
1737*fcf3ce44SJohn Forte 	}
1738*fcf3ce44SJohn Forte 
1739*fcf3ce44SJohn Forte 	return (mpstatus);
1740*fcf3ce44SJohn Forte }
1741*fcf3ce44SJohn Forte 
1742*fcf3ce44SJohn Forte 
1743*fcf3ce44SJohn Forte /*
1744*fcf3ce44SJohn Forte  * ****************************************************************************
1745*fcf3ce44SJohn Forte  *
1746*fcf3ce44SJohn Forte  * getLogicalUnitOid -
1747*fcf3ce44SJohn Forte  *	Search through all plugins and get the OID for specified logical unit
1748*fcf3ce44SJohn Forte  *
1749*fcf3ce44SJohn Forte  * luFileName	- file name of LU (specified by the user) to find
1750*fcf3ce44SJohn Forte  * pLuOid	- OID to return
1751*fcf3ce44SJohn Forte  *
1752*fcf3ce44SJohn Forte  * ****************************************************************************
1753*fcf3ce44SJohn Forte  */
1754*fcf3ce44SJohn Forte boolean_t
1755*fcf3ce44SJohn Forte getLogicalUnitOid(MP_CHAR *luFileName, MP_OID *pluOid)
1756*fcf3ce44SJohn Forte {
1757*fcf3ce44SJohn Forte 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
1758*fcf3ce44SJohn Forte 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES	luProps;
1759*fcf3ce44SJohn Forte 	MP_PLUGIN_PROPERTIES			pluginProps;
1760*fcf3ce44SJohn Forte 	MP_OID_LIST				*pPluginOidList,
1761*fcf3ce44SJohn Forte 						*pLogicalUnitOidList;
1762*fcf3ce44SJohn Forte 	boolean_t				foundIt = B_FALSE;
1763*fcf3ce44SJohn Forte 
1764*fcf3ce44SJohn Forte 	int					i,
1765*fcf3ce44SJohn Forte 						lu;
1766*fcf3ce44SJohn Forte 
1767*fcf3ce44SJohn Forte 	int 					fd1, fd2;
1768*fcf3ce44SJohn Forte 	ddi_devid_t				devid1 = NULL, devid2 = NULL;
1769*fcf3ce44SJohn Forte 
1770*fcf3ce44SJohn Forte 	if (NULL == pluOid) {
1771*fcf3ce44SJohn Forte 		/* print some kind of error msg here - should never happen */
1772*fcf3ce44SJohn Forte 		/* LINTED E_SEC_PRINTF_VAR_FMT */
1773*fcf3ce44SJohn Forte 		(void) fprintf(stderr, getTextString(ERR_MEMORY_ALLOCATION));
1774*fcf3ce44SJohn Forte 		(void) printf("\n");
1775*fcf3ce44SJohn Forte 		return (B_FALSE);
1776*fcf3ce44SJohn Forte 	}
1777*fcf3ce44SJohn Forte 
1778*fcf3ce44SJohn Forte 	pluOid->objectSequenceNumber = 0;
1779*fcf3ce44SJohn Forte 	pluOid->objectType = 0;
1780*fcf3ce44SJohn Forte 	pluOid->ownerId = 0;
1781*fcf3ce44SJohn Forte 
1782*fcf3ce44SJohn Forte 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
1783*fcf3ce44SJohn Forte 		!= MP_STATUS_SUCCESS) {
1784*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s: %s\n", cmdName,
1785*fcf3ce44SJohn Forte 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
1786*fcf3ce44SJohn Forte 		return (B_FALSE);
1787*fcf3ce44SJohn Forte 	}
1788*fcf3ce44SJohn Forte 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
1789*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s: %s\n", cmdName,
1790*fcf3ce44SJohn Forte 		getTextString(ERR_NO_MPATH_SUPPORT_LIST));
1791*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
1792*fcf3ce44SJohn Forte 	}
1793*fcf3ce44SJohn Forte 	for (i = 0; i < pPluginOidList->oidCount; i++) {
1794*fcf3ce44SJohn Forte 
1795*fcf3ce44SJohn Forte 		/* get properties so we can list the name */
1796*fcf3ce44SJohn Forte 		(void) memset(&pluginProps, 0, sizeof (MP_PLUGIN_PROPERTIES));
1797*fcf3ce44SJohn Forte 		if ((mpstatus =
1798*fcf3ce44SJohn Forte 		    MP_GetPluginProperties(pPluginOidList->oids[i],
1799*fcf3ce44SJohn Forte 		    &pluginProps)) != MP_STATUS_SUCCESS) {
1800*fcf3ce44SJohn Forte 				(void) fprintf(stderr, "%s:  %s\n",
1801*fcf3ce44SJohn Forte 				    cmdName, getTextString(ERR_NO_PROPERTIES));
1802*fcf3ce44SJohn Forte 				return (B_FALSE);
1803*fcf3ce44SJohn Forte 		}
1804*fcf3ce44SJohn Forte 
1805*fcf3ce44SJohn Forte 		/* attempt to find this logical unit */
1806*fcf3ce44SJohn Forte 		mpstatus = MP_GetMultipathLus(pPluginOidList->oids[i],
1807*fcf3ce44SJohn Forte 		    &pLogicalUnitOidList);
1808*fcf3ce44SJohn Forte 		if (mpstatus != MP_STATUS_SUCCESS) {
1809*fcf3ce44SJohn Forte 			(void) fprintf(stderr, "%s:  %s\n",
1810*fcf3ce44SJohn Forte 			    cmdName, getTextString(ERR_NO_LU_LIST));
1811*fcf3ce44SJohn Forte 			return (B_FALSE);
1812*fcf3ce44SJohn Forte 		}
1813*fcf3ce44SJohn Forte 
1814*fcf3ce44SJohn Forte 		for (lu = 0; (lu < pLogicalUnitOidList->oidCount) &&
1815*fcf3ce44SJohn Forte 		    (B_FALSE == foundIt); lu++) {
1816*fcf3ce44SJohn Forte 
1817*fcf3ce44SJohn Forte 			/* get lu properties so we can check the name */
1818*fcf3ce44SJohn Forte 			(void) memset(&luProps, 0,
1819*fcf3ce44SJohn Forte 			    sizeof (MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES));
1820*fcf3ce44SJohn Forte 			mpstatus =
1821*fcf3ce44SJohn Forte 			    MP_GetMPLogicalUnitProperties(
1822*fcf3ce44SJohn Forte 			    pLogicalUnitOidList->oids[lu], &luProps);
1823*fcf3ce44SJohn Forte 			if (mpstatus != MP_STATUS_SUCCESS) {
1824*fcf3ce44SJohn Forte 				(void) fprintf(stderr, "%s:  %s\n",
1825*fcf3ce44SJohn Forte 				    cmdName, getTextString(ERR_NO_PROPERTIES));
1826*fcf3ce44SJohn Forte 				return (B_FALSE);
1827*fcf3ce44SJohn Forte 			}
1828*fcf3ce44SJohn Forte 
1829*fcf3ce44SJohn Forte 			if (0 == strcmp(luFileName, luProps.deviceFileName)) {
1830*fcf3ce44SJohn Forte 				foundIt = B_TRUE;
1831*fcf3ce44SJohn Forte 			} else {
1832*fcf3ce44SJohn Forte 				/* user input didn't match, try via devid */
1833*fcf3ce44SJohn Forte 				/*
1834*fcf3ce44SJohn Forte 				 * I don't see a reason to print the error for
1835*fcf3ce44SJohn Forte 				 * any of these since they'll get the error at
1836*fcf3ce44SJohn Forte 				 * the end anyway
1837*fcf3ce44SJohn Forte 				 */
1838*fcf3ce44SJohn Forte 
1839*fcf3ce44SJohn Forte 
1840*fcf3ce44SJohn Forte 				if (((fd1 = open(luFileName,
1841*fcf3ce44SJohn Forte 					O_RDONLY|O_NDELAY)) >= 0) &&
1842*fcf3ce44SJohn Forte 				    ((fd2 = open(luProps.deviceFileName,
1843*fcf3ce44SJohn Forte 					O_RDONLY|O_NDELAY)) >= 0) &&
1844*fcf3ce44SJohn Forte 				    (devid_get(fd1, &devid1) == 0) &&
1845*fcf3ce44SJohn Forte 				    (devid_get(fd2, &devid2) == 0) &&
1846*fcf3ce44SJohn Forte 				    ((NULL != devid1) && (NULL != devid2))) {
1847*fcf3ce44SJohn Forte 					if (0 ==
1848*fcf3ce44SJohn Forte 					    (devid_compare(devid1, devid2))) {
1849*fcf3ce44SJohn Forte 						foundIt = B_TRUE;
1850*fcf3ce44SJohn Forte 					}
1851*fcf3ce44SJohn Forte 				}
1852*fcf3ce44SJohn Forte 
1853*fcf3ce44SJohn Forte 				if (NULL != devid1) {
1854*fcf3ce44SJohn Forte 					devid_free(devid1);
1855*fcf3ce44SJohn Forte 				}
1856*fcf3ce44SJohn Forte 				if (NULL != devid2) {
1857*fcf3ce44SJohn Forte 					devid_free(devid2);
1858*fcf3ce44SJohn Forte 				}
1859*fcf3ce44SJohn Forte 			}
1860*fcf3ce44SJohn Forte 			if (B_TRUE == foundIt) {
1861*fcf3ce44SJohn Forte 				pluOid->objectSequenceNumber =
1862*fcf3ce44SJohn Forte 				    pLogicalUnitOidList->
1863*fcf3ce44SJohn Forte 				    oids[lu].objectSequenceNumber;
1864*fcf3ce44SJohn Forte 				pluOid->objectType =
1865*fcf3ce44SJohn Forte 				    pLogicalUnitOidList->
1866*fcf3ce44SJohn Forte 				    oids[lu].objectType;
1867*fcf3ce44SJohn Forte 				pluOid->ownerId =
1868*fcf3ce44SJohn Forte 				    pLogicalUnitOidList->oids[lu].ownerId;
1869*fcf3ce44SJohn Forte 			}
1870*fcf3ce44SJohn Forte 		}
1871*fcf3ce44SJohn Forte 	}
1872*fcf3ce44SJohn Forte 
1873*fcf3ce44SJohn Forte 	return (foundIt);
1874*fcf3ce44SJohn Forte }
1875*fcf3ce44SJohn Forte 
1876*fcf3ce44SJohn Forte 
1877*fcf3ce44SJohn Forte /*
1878*fcf3ce44SJohn Forte  * ****************************************************************************
1879*fcf3ce44SJohn Forte  *
1880*fcf3ce44SJohn Forte  * listInitiatorPort -
1881*fcf3ce44SJohn Forte  * 	mpathadm list initiator-port [<initiator-port name>, ...]
1882*fcf3ce44SJohn Forte  *
1883*fcf3ce44SJohn Forte  * operandLen	- number of operands user passed into the cli
1884*fcf3ce44SJohn Forte  * operand	- pointer to operand list from user
1885*fcf3ce44SJohn Forte  *
1886*fcf3ce44SJohn Forte  * ****************************************************************************
1887*fcf3ce44SJohn Forte  */
1888*fcf3ce44SJohn Forte int
1889*fcf3ce44SJohn Forte listInitiatorPort(int operandLen, char *operand[])
1890*fcf3ce44SJohn Forte {
1891*fcf3ce44SJohn Forte 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
1892*fcf3ce44SJohn Forte 	MP_INITIATOR_PORT_PROPERTIES 		initProps;
1893*fcf3ce44SJohn Forte 	MP_OID_LIST				*pPluginOidList,
1894*fcf3ce44SJohn Forte 						*pInitOidList;
1895*fcf3ce44SJohn Forte 	boolean_t				bListIt = B_FALSE;
1896*fcf3ce44SJohn Forte 	boolean_t				*foundOp;
1897*fcf3ce44SJohn Forte 
1898*fcf3ce44SJohn Forte 	int					ol,
1899*fcf3ce44SJohn Forte 						i,
1900*fcf3ce44SJohn Forte 						iport;
1901*fcf3ce44SJohn Forte 
1902*fcf3ce44SJohn Forte 	foundOp = malloc((sizeof (boolean_t)) * operandLen);
1903*fcf3ce44SJohn Forte 	if (NULL == foundOp) {
1904*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%s\n",
1905*fcf3ce44SJohn Forte 		    getTextString(ERR_MEMORY_ALLOCATION));
1906*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
1907*fcf3ce44SJohn Forte 	}
1908*fcf3ce44SJohn Forte 
1909*fcf3ce44SJohn Forte 	for (ol = 0; ol < operandLen; ol++) {
1910*fcf3ce44SJohn Forte 		foundOp[ol] = B_FALSE;
1911*fcf3ce44SJohn Forte 	}
1912*fcf3ce44SJohn Forte 
1913*fcf3ce44SJohn Forte 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
1914*fcf3ce44SJohn Forte 		!= MP_STATUS_SUCCESS) {
1915*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s: %s\n", cmdName,
1916*fcf3ce44SJohn Forte 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
1917*fcf3ce44SJohn Forte 		return (mpstatus);
1918*fcf3ce44SJohn Forte 	}
1919*fcf3ce44SJohn Forte 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
1920*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s: %s\n", cmdName,
1921*fcf3ce44SJohn Forte 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
1922*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
1923*fcf3ce44SJohn Forte 	}
1924*fcf3ce44SJohn Forte 
1925*fcf3ce44SJohn Forte 	for (i = 0; i < pPluginOidList->oidCount; i++) {
1926*fcf3ce44SJohn Forte 		mpstatus =
1927*fcf3ce44SJohn Forte 		    MP_GetInitiatorPortOidList(pPluginOidList->oids[i],
1928*fcf3ce44SJohn Forte 		    &pInitOidList);
1929*fcf3ce44SJohn Forte 		if (mpstatus != MP_STATUS_SUCCESS) {
1930*fcf3ce44SJohn Forte 			/* LINTED E_SEC_PRINTF_VAR_FMT */
1931*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
1932*fcf3ce44SJohn Forte 			    getTextString(ERR_NO_INIT_PORT_LIST_WITH_REASON),
1933*fcf3ce44SJohn Forte 			    getMpStatusStr(mpstatus));
1934*fcf3ce44SJohn Forte 			(void) printf("\n");
1935*fcf3ce44SJohn Forte 		} else if ((NULL == pInitOidList) ||
1936*fcf3ce44SJohn Forte 			(pInitOidList->oidCount < 1)) {
1937*fcf3ce44SJohn Forte 			(void) fprintf(stderr, "%s: %s\n", cmdName,
1938*fcf3ce44SJohn Forte 			    getTextString(ERR_NO_INIT_PORTS));
1939*fcf3ce44SJohn Forte 		} else {
1940*fcf3ce44SJohn Forte 			for (iport = 0;
1941*fcf3ce44SJohn Forte 			    iport < pInitOidList->oidCount; iport ++) {
1942*fcf3ce44SJohn Forte 				bListIt = B_FALSE;
1943*fcf3ce44SJohn Forte 				if ((mpstatus =
1944*fcf3ce44SJohn Forte 				    MP_GetInitiatorPortProperties(
1945*fcf3ce44SJohn Forte 				    pInitOidList->oids[iport],
1946*fcf3ce44SJohn Forte 				    &initProps)) != MP_STATUS_SUCCESS) {
1947*fcf3ce44SJohn Forte 					(void) fprintf(stderr,
1948*fcf3ce44SJohn Forte 					    "%s: %s\n", cmdName,
1949*fcf3ce44SJohn Forte 					    getTextString(ERR_NO_PROPERTIES));
1950*fcf3ce44SJohn Forte 				} else {
1951*fcf3ce44SJohn Forte 					/* if no operands listed, */
1952*fcf3ce44SJohn Forte 					/* list all we find */
1953*fcf3ce44SJohn Forte 					if (0 == operandLen) {
1954*fcf3ce44SJohn Forte 						bListIt = B_TRUE;
1955*fcf3ce44SJohn Forte 					} else {
1956*fcf3ce44SJohn Forte 
1957*fcf3ce44SJohn Forte 						/* check each operand */
1958*fcf3ce44SJohn Forte 						/* Is it */
1959*fcf3ce44SJohn Forte 						/* the one we want to list? */
1960*fcf3ce44SJohn Forte 						for (ol = 0;
1961*fcf3ce44SJohn Forte 						    ol < operandLen; ol++) {
1962*fcf3ce44SJohn Forte 							if (0 ==
1963*fcf3ce44SJohn Forte 							    strcmp(operand[ol],
1964*fcf3ce44SJohn Forte 							    initProps.
1965*fcf3ce44SJohn Forte 							    portID)) {
1966*fcf3ce44SJohn Forte 								bListIt =
1967*fcf3ce44SJohn Forte 								    B_TRUE;
1968*fcf3ce44SJohn Forte 								foundOp[ol] =
1969*fcf3ce44SJohn Forte 								    B_TRUE;
1970*fcf3ce44SJohn Forte 							}
1971*fcf3ce44SJohn Forte 						}
1972*fcf3ce44SJohn Forte 					}
1973*fcf3ce44SJohn Forte 				}
1974*fcf3ce44SJohn Forte 
1975*fcf3ce44SJohn Forte 				if (B_TRUE == bListIt) {
1976*fcf3ce44SJohn Forte 
1977*fcf3ce44SJohn Forte 					if (listIndividualInitiatorPort(
1978*fcf3ce44SJohn Forte 					    initProps) != 0) {
1979*fcf3ce44SJohn Forte 						return (ERROR_CLI_FAILED);
1980*fcf3ce44SJohn Forte 					}
1981*fcf3ce44SJohn Forte 
1982*fcf3ce44SJohn Forte 				} /* list It */
1983*fcf3ce44SJohn Forte 
1984*fcf3ce44SJohn Forte 			} /* for each initiator port */
1985*fcf3ce44SJohn Forte 		} /* else found an init port */
1986*fcf3ce44SJohn Forte 
1987*fcf3ce44SJohn Forte 	} /* for each plugin */
1988*fcf3ce44SJohn Forte 
1989*fcf3ce44SJohn Forte 	for (ol = 0; ol < operandLen; ol++) {
1990*fcf3ce44SJohn Forte 		if (B_FALSE == foundOp[ol]) {
1991*fcf3ce44SJohn Forte 			/* LINTED E_SEC_PRINTF_VAR_FMT */
1992*fcf3ce44SJohn Forte 			(void) fprintf(stderr, getTextString(
1993*fcf3ce44SJohn Forte 			    ERR_INIT_PORT_NOT_FOUND_WITH_MISSING_LU_STR),
1994*fcf3ce44SJohn Forte 			    operand[ol]);
1995*fcf3ce44SJohn Forte 			(void) printf("\n");
1996*fcf3ce44SJohn Forte 		}
1997*fcf3ce44SJohn Forte 	}
1998*fcf3ce44SJohn Forte 
1999*fcf3ce44SJohn Forte 	return (mpstatus);
2000*fcf3ce44SJohn Forte }
2001*fcf3ce44SJohn Forte 
2002*fcf3ce44SJohn Forte 
2003*fcf3ce44SJohn Forte /*
2004*fcf3ce44SJohn Forte  * ****************************************************************************
2005*fcf3ce44SJohn Forte  *
2006*fcf3ce44SJohn Forte  * listIndividualInitiatorPort -
2007*fcf3ce44SJohn Forte  * 	used by listInitiatorPort to list info for one init port
2008*fcf3ce44SJohn Forte  *
2009*fcf3ce44SJohn Forte  * initProps	- properties of initiator port to list
2010*fcf3ce44SJohn Forte  *
2011*fcf3ce44SJohn Forte  * ****************************************************************************
2012*fcf3ce44SJohn Forte  */
2013*fcf3ce44SJohn Forte int
2014*fcf3ce44SJohn Forte listIndividualInitiatorPort(MP_INITIATOR_PORT_PROPERTIES initProps)
2015*fcf3ce44SJohn Forte {
2016*fcf3ce44SJohn Forte 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
2017*fcf3ce44SJohn Forte 
2018*fcf3ce44SJohn Forte 	(void) printf("%s  ", getTextString(TEXT_LB_INITATOR_PORT));
2019*fcf3ce44SJohn Forte 	displayArray(initProps.portID,
2020*fcf3ce44SJohn Forte 		sizeof (initProps.portID));
2021*fcf3ce44SJohn Forte 	(void) printf("\n");
2022*fcf3ce44SJohn Forte 
2023*fcf3ce44SJohn Forte 	return (mpstatus);
2024*fcf3ce44SJohn Forte 
2025*fcf3ce44SJohn Forte }
2026*fcf3ce44SJohn Forte 
2027*fcf3ce44SJohn Forte 
2028*fcf3ce44SJohn Forte /*
2029*fcf3ce44SJohn Forte  * ****************************************************************************
2030*fcf3ce44SJohn Forte  *
2031*fcf3ce44SJohn Forte  * showInitiatorPort -
2032*fcf3ce44SJohn Forte  * 	mpathadm show initiator-port <initiator-port name>, ...
2033*fcf3ce44SJohn Forte  *
2034*fcf3ce44SJohn Forte  * operandLen	- number of operands user passed into the cli
2035*fcf3ce44SJohn Forte  * operand	- pointer to operand list from user
2036*fcf3ce44SJohn Forte  *
2037*fcf3ce44SJohn Forte  * ****************************************************************************
2038*fcf3ce44SJohn Forte  */
2039*fcf3ce44SJohn Forte int
2040*fcf3ce44SJohn Forte showInitiatorPort(int operandLen, char *operand[])
2041*fcf3ce44SJohn Forte {
2042*fcf3ce44SJohn Forte 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
2043*fcf3ce44SJohn Forte 	MP_INITIATOR_PORT_PROPERTIES 		initProps;
2044*fcf3ce44SJohn Forte 	MP_OID_LIST				*pPluginOidList,
2045*fcf3ce44SJohn Forte 						*pInitOidList;
2046*fcf3ce44SJohn Forte 	boolean_t				bListIt = B_FALSE,
2047*fcf3ce44SJohn Forte 						bFoundIt = B_FALSE;
2048*fcf3ce44SJohn Forte 	int					op,
2049*fcf3ce44SJohn Forte 						i,
2050*fcf3ce44SJohn Forte 						iport;
2051*fcf3ce44SJohn Forte 
2052*fcf3ce44SJohn Forte 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
2053*fcf3ce44SJohn Forte 		!= MP_STATUS_SUCCESS) {
2054*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s: %s\n", cmdName,
2055*fcf3ce44SJohn Forte 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
2056*fcf3ce44SJohn Forte 		return (mpstatus);
2057*fcf3ce44SJohn Forte 	}
2058*fcf3ce44SJohn Forte 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
2059*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s: %s\n", cmdName,
2060*fcf3ce44SJohn Forte 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
2061*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
2062*fcf3ce44SJohn Forte 	}
2063*fcf3ce44SJohn Forte 
2064*fcf3ce44SJohn Forte 	for (op = 0; op < operandLen; op++) {
2065*fcf3ce44SJohn Forte 	bFoundIt = B_FALSE;
2066*fcf3ce44SJohn Forte 
2067*fcf3ce44SJohn Forte 		for (i = 0; i < pPluginOidList->oidCount; i++) {
2068*fcf3ce44SJohn Forte 
2069*fcf3ce44SJohn Forte 			mpstatus =
2070*fcf3ce44SJohn Forte 			    MP_GetInitiatorPortOidList(pPluginOidList->oids[i],
2071*fcf3ce44SJohn Forte 			    &pInitOidList);
2072*fcf3ce44SJohn Forte 			if (mpstatus != MP_STATUS_SUCCESS) {
2073*fcf3ce44SJohn Forte 				/* LINTED E_SEC_PRINTF_VAR_FMT */
2074*fcf3ce44SJohn Forte 				(void) fprintf(stderr,
2075*fcf3ce44SJohn Forte 				    getTextString(
2076*fcf3ce44SJohn Forte 				    ERR_NO_INIT_PORT_LIST_WITH_REASON),
2077*fcf3ce44SJohn Forte 				    getMpStatusStr(mpstatus));
2078*fcf3ce44SJohn Forte 				(void) printf("\n");
2079*fcf3ce44SJohn Forte 			} else if ((NULL == pInitOidList) ||
2080*fcf3ce44SJohn Forte 			    (pInitOidList->oidCount < 1)) {
2081*fcf3ce44SJohn Forte 				(void) fprintf(stderr, "%s: %s\n", cmdName,
2082*fcf3ce44SJohn Forte 				    getTextString(ERR_NO_INIT_PORTS));
2083*fcf3ce44SJohn Forte 			} else {
2084*fcf3ce44SJohn Forte 
2085*fcf3ce44SJohn Forte 				for (iport = 0;
2086*fcf3ce44SJohn Forte 				    iport < pInitOidList->oidCount;
2087*fcf3ce44SJohn Forte 				    iport ++) {
2088*fcf3ce44SJohn Forte 					bListIt = B_FALSE;
2089*fcf3ce44SJohn Forte 
2090*fcf3ce44SJohn Forte 					if ((mpstatus =
2091*fcf3ce44SJohn Forte 					    MP_GetInitiatorPortProperties(
2092*fcf3ce44SJohn Forte 					    pInitOidList->oids[iport],
2093*fcf3ce44SJohn Forte 					    &initProps))
2094*fcf3ce44SJohn Forte 					    != MP_STATUS_SUCCESS) {
2095*fcf3ce44SJohn Forte 						(void) fprintf(stderr,
2096*fcf3ce44SJohn Forte 						    "%s: %s\n", cmdName,
2097*fcf3ce44SJohn Forte 					    getTextString(ERR_NO_PROPERTIES));
2098*fcf3ce44SJohn Forte 					} else {
2099*fcf3ce44SJohn Forte 						if (0 == strcmp(operand[op],
2100*fcf3ce44SJohn Forte 						    initProps.portID)) {
2101*fcf3ce44SJohn Forte 							bListIt = B_TRUE;
2102*fcf3ce44SJohn Forte 							bFoundIt = B_TRUE;
2103*fcf3ce44SJohn Forte 						}
2104*fcf3ce44SJohn Forte 					}
2105*fcf3ce44SJohn Forte 
2106*fcf3ce44SJohn Forte 					if (B_TRUE == bListIt) {
2107*fcf3ce44SJohn Forte 						mpstatus =
2108*fcf3ce44SJohn Forte 						showIndividualInitiatorPort(
2109*fcf3ce44SJohn Forte 						initProps);
2110*fcf3ce44SJohn Forte 						if (0 != mpstatus) {
2111*fcf3ce44SJohn Forte 							return (mpstatus);
2112*fcf3ce44SJohn Forte 						}
2113*fcf3ce44SJohn Forte 
2114*fcf3ce44SJohn Forte 					} /* list It */
2115*fcf3ce44SJohn Forte 
2116*fcf3ce44SJohn Forte 				} /* for each initiator port */
2117*fcf3ce44SJohn Forte 			} /* else found an init port */
2118*fcf3ce44SJohn Forte 
2119*fcf3ce44SJohn Forte 		} /* for each plugin */
2120*fcf3ce44SJohn Forte 
2121*fcf3ce44SJohn Forte 		if (B_FALSE == bFoundIt) {
2122*fcf3ce44SJohn Forte 			/* need temp string here since we need to fill in a */
2123*fcf3ce44SJohn Forte 			/* name in the error string */
2124*fcf3ce44SJohn Forte 			/* LINTED E_SEC_PRINTF_VAR_FMT */
2125*fcf3ce44SJohn Forte 			(void) fprintf(stderr, getTextString(
2126*fcf3ce44SJohn Forte 			    ERR_INIT_PORT_NOT_FOUND_WITH_MISSING_LU_STR),
2127*fcf3ce44SJohn Forte 			    operand[op]);
2128*fcf3ce44SJohn Forte 			(void) printf("\n");
2129*fcf3ce44SJohn Forte 		}
2130*fcf3ce44SJohn Forte 
2131*fcf3ce44SJohn Forte 	} /* for each operand */
2132*fcf3ce44SJohn Forte 
2133*fcf3ce44SJohn Forte 	return (mpstatus);
2134*fcf3ce44SJohn Forte }
2135*fcf3ce44SJohn Forte 
2136*fcf3ce44SJohn Forte 
2137*fcf3ce44SJohn Forte /*
2138*fcf3ce44SJohn Forte  * ****************************************************************************
2139*fcf3ce44SJohn Forte  *
2140*fcf3ce44SJohn Forte  * showIndividualInitiatorPort -
2141*fcf3ce44SJohn Forte  * 	used by showInitiatorPort to show info for one init port
2142*fcf3ce44SJohn Forte  *
2143*fcf3ce44SJohn Forte  * initProps	- properties of initiator port to show
2144*fcf3ce44SJohn Forte  *
2145*fcf3ce44SJohn Forte  * ****************************************************************************
2146*fcf3ce44SJohn Forte  */
2147*fcf3ce44SJohn Forte int
2148*fcf3ce44SJohn Forte showIndividualInitiatorPort(MP_INITIATOR_PORT_PROPERTIES initProps)
2149*fcf3ce44SJohn Forte {
2150*fcf3ce44SJohn Forte 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
2151*fcf3ce44SJohn Forte 
2152*fcf3ce44SJohn Forte 	(void) printf("%s  ", getTextString(TEXT_LB_INITATOR_PORT));
2153*fcf3ce44SJohn Forte 	displayArray(initProps.portID,
2154*fcf3ce44SJohn Forte 	    sizeof (initProps.portID));
2155*fcf3ce44SJohn Forte 
2156*fcf3ce44SJohn Forte 	(void) printf("\n\t%s  ", getTextString(TEXT_LB_TRANSPORT_TYPE));
2157*fcf3ce44SJohn Forte 	displayTransportTypeString(initProps.portType);
2158*fcf3ce44SJohn Forte 	(void) printf("\n");
2159*fcf3ce44SJohn Forte 
2160*fcf3ce44SJohn Forte 	(void) printf("\t%s  ", getTextString(TEXT_LB_OS_DEVICE_FILE));
2161*fcf3ce44SJohn Forte 	displayArray(initProps.osDeviceFile,
2162*fcf3ce44SJohn Forte 	    sizeof (initProps.osDeviceFile));
2163*fcf3ce44SJohn Forte 	(void) printf("\n");
2164*fcf3ce44SJohn Forte 
2165*fcf3ce44SJohn Forte 	return (mpstatus);
2166*fcf3ce44SJohn Forte }
2167*fcf3ce44SJohn Forte 
2168*fcf3ce44SJohn Forte 
2169*fcf3ce44SJohn Forte /*
2170*fcf3ce44SJohn Forte  * ****************************************************************************
2171*fcf3ce44SJohn Forte  *
2172*fcf3ce44SJohn Forte  * enablePath -
2173*fcf3ce44SJohn Forte  * 	mpathadm enable path -i <initiator-port>
2174*fcf3ce44SJohn Forte  *		-t <target-port name> -l <logical-unit name>
2175*fcf3ce44SJohn Forte  *
2176*fcf3ce44SJohn Forte  * options	- pointer to option list from user
2177*fcf3ce44SJohn Forte  *
2178*fcf3ce44SJohn Forte  * ****************************************************************************
2179*fcf3ce44SJohn Forte  */
2180*fcf3ce44SJohn Forte int
2181*fcf3ce44SJohn Forte enablePath(cmdOptions_t *options)
2182*fcf3ce44SJohn Forte {
2183*fcf3ce44SJohn Forte 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
2184*fcf3ce44SJohn Forte 	MP_OID					pathOid;
2185*fcf3ce44SJohn Forte 
2186*fcf3ce44SJohn Forte 	cmdOptions_t 				*optionList = options;
2187*fcf3ce44SJohn Forte 	boolean_t				bHaveInit = B_FALSE,
2188*fcf3ce44SJohn Forte 						bHaveTarg = B_FALSE,
2189*fcf3ce44SJohn Forte 						bHaveLu = B_FALSE;
2190*fcf3ce44SJohn Forte 
2191*fcf3ce44SJohn Forte 	for (; optionList->optval; optionList++) {
2192*fcf3ce44SJohn Forte 		switch (optionList->optval) {
2193*fcf3ce44SJohn Forte 			case 'i':
2194*fcf3ce44SJohn Forte 				/* have init port name */
2195*fcf3ce44SJohn Forte 				bHaveInit = B_TRUE;
2196*fcf3ce44SJohn Forte 				break;
2197*fcf3ce44SJohn Forte 			case 't':
2198*fcf3ce44SJohn Forte 				/* have target port id */
2199*fcf3ce44SJohn Forte 				bHaveTarg = B_TRUE;
2200*fcf3ce44SJohn Forte 				break;
2201*fcf3ce44SJohn Forte 			case 'l':
2202*fcf3ce44SJohn Forte 				/* have LU name */
2203*fcf3ce44SJohn Forte 				bHaveLu = B_TRUE;
2204*fcf3ce44SJohn Forte 				break;
2205*fcf3ce44SJohn Forte 		}
2206*fcf3ce44SJohn Forte 	}
2207*fcf3ce44SJohn Forte 	if (B_FALSE == bHaveInit) {
2208*fcf3ce44SJohn Forte 		/* LINTED E_SEC_PRINTF_VAR_FMT */
2209*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
2210*fcf3ce44SJohn Forte 		    getTextString(ERR_FAILED_TO_ENABLE_PATH_WITH_REASON),
2211*fcf3ce44SJohn Forte 		    getTextString(MISSING_INIT_PORT_NAME));
2212*fcf3ce44SJohn Forte 		(void) printf("\n");
2213*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
2214*fcf3ce44SJohn Forte 	} else if (B_FALSE == bHaveTarg) {
2215*fcf3ce44SJohn Forte 		/* LINTED E_SEC_PRINTF_VAR_FMT */
2216*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
2217*fcf3ce44SJohn Forte 		    getTextString(ERR_FAILED_TO_ENABLE_PATH_WITH_REASON),
2218*fcf3ce44SJohn Forte 		    getTextString(MISSING_TARGET_PORT_NAME));
2219*fcf3ce44SJohn Forte 		(void) printf("\n");
2220*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
2221*fcf3ce44SJohn Forte 	} else if (B_FALSE == bHaveLu) {
2222*fcf3ce44SJohn Forte 		/* LINTED E_SEC_PRINTF_VAR_FMT */
2223*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
2224*fcf3ce44SJohn Forte 		    getTextString(ERR_FAILED_TO_ENABLE_PATH_WITH_REASON),
2225*fcf3ce44SJohn Forte 		    getTextString(MISSING_LU_NAME));
2226*fcf3ce44SJohn Forte 		(void) printf("\n");
2227*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
2228*fcf3ce44SJohn Forte 	}
2229*fcf3ce44SJohn Forte 
2230*fcf3ce44SJohn Forte 	if (B_FALSE == getPathOid(options, &pathOid)) {
2231*fcf3ce44SJohn Forte 		/* LINTED E_SEC_PRINTF_VAR_FMT */
2232*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
2233*fcf3ce44SJohn Forte 		    getTextString(ERR_FAILED_TO_ENABLE_PATH_WITH_REASON),
2234*fcf3ce44SJohn Forte 		    getTextString(FAILED_TO_FIND_PATH));
2235*fcf3ce44SJohn Forte 		(void) printf("\n");
2236*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
2237*fcf3ce44SJohn Forte 	}
2238*fcf3ce44SJohn Forte 
2239*fcf3ce44SJohn Forte 	/* found the path, attempt to enable it */
2240*fcf3ce44SJohn Forte 	mpstatus =  MP_EnablePath(pathOid);
2241*fcf3ce44SJohn Forte 	if (mpstatus != MP_STATUS_SUCCESS) {
2242*fcf3ce44SJohn Forte 		/* LINTED E_SEC_PRINTF_VAR_FMT */
2243*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
2244*fcf3ce44SJohn Forte 		    getTextString(ERR_FAILED_TO_ENABLE_PATH_WITH_REASON),
2245*fcf3ce44SJohn Forte 		    getMpStatusStr(mpstatus));
2246*fcf3ce44SJohn Forte 		(void) printf("\n");
2247*fcf3ce44SJohn Forte 		return (mpstatus);
2248*fcf3ce44SJohn Forte 	}
2249*fcf3ce44SJohn Forte 
2250*fcf3ce44SJohn Forte 	return (mpstatus);
2251*fcf3ce44SJohn Forte }
2252*fcf3ce44SJohn Forte 
2253*fcf3ce44SJohn Forte 
2254*fcf3ce44SJohn Forte /*
2255*fcf3ce44SJohn Forte  * ****************************************************************************
2256*fcf3ce44SJohn Forte  *
2257*fcf3ce44SJohn Forte  * disablePath -
2258*fcf3ce44SJohn Forte  * 	mpathadm disable path -i <initiator-port>
2259*fcf3ce44SJohn Forte  *		-t <target-port name> -l <logical-unit name>
2260*fcf3ce44SJohn Forte  *
2261*fcf3ce44SJohn Forte  * options	- pointer to option list from user
2262*fcf3ce44SJohn Forte  *
2263*fcf3ce44SJohn Forte  * ****************************************************************************
2264*fcf3ce44SJohn Forte  */
2265*fcf3ce44SJohn Forte int
2266*fcf3ce44SJohn Forte disablePath(cmdOptions_t *options)
2267*fcf3ce44SJohn Forte {
2268*fcf3ce44SJohn Forte 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
2269*fcf3ce44SJohn Forte 	MP_OID					pathOid;
2270*fcf3ce44SJohn Forte 
2271*fcf3ce44SJohn Forte 	cmdOptions_t 				*optionList = options;
2272*fcf3ce44SJohn Forte 	boolean_t				bHaveInit = B_FALSE,
2273*fcf3ce44SJohn Forte 						bHaveTarg = B_FALSE,
2274*fcf3ce44SJohn Forte 						bHaveLu = B_FALSE;
2275*fcf3ce44SJohn Forte 
2276*fcf3ce44SJohn Forte 	for (; optionList->optval; optionList++) {
2277*fcf3ce44SJohn Forte 		switch (optionList->optval) {
2278*fcf3ce44SJohn Forte 			case 'i':
2279*fcf3ce44SJohn Forte 				/* have init port name */
2280*fcf3ce44SJohn Forte 				bHaveInit = B_TRUE;
2281*fcf3ce44SJohn Forte 				break;
2282*fcf3ce44SJohn Forte 			case 't':
2283*fcf3ce44SJohn Forte 				/* have target port id */
2284*fcf3ce44SJohn Forte 				bHaveTarg = B_TRUE;
2285*fcf3ce44SJohn Forte 				break;
2286*fcf3ce44SJohn Forte 			case 'l':
2287*fcf3ce44SJohn Forte 				/* have LU name */
2288*fcf3ce44SJohn Forte 				bHaveLu = B_TRUE;
2289*fcf3ce44SJohn Forte 				break;
2290*fcf3ce44SJohn Forte 		}
2291*fcf3ce44SJohn Forte 	}
2292*fcf3ce44SJohn Forte 	if (B_FALSE == bHaveInit) {
2293*fcf3ce44SJohn Forte 		/* LINTED E_SEC_PRINTF_VAR_FMT */
2294*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
2295*fcf3ce44SJohn Forte 		    getTextString(ERR_FAILED_TO_DISABLE_PATH_WITH_REASON),
2296*fcf3ce44SJohn Forte 		    getTextString(MISSING_INIT_PORT_NAME));
2297*fcf3ce44SJohn Forte 		(void) printf("\n");
2298*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
2299*fcf3ce44SJohn Forte 	} else if (B_FALSE == bHaveTarg) {
2300*fcf3ce44SJohn Forte 		/* LINTED E_SEC_PRINTF_VAR_FMT */
2301*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
2302*fcf3ce44SJohn Forte 		    getTextString(ERR_FAILED_TO_DISABLE_PATH_WITH_REASON),
2303*fcf3ce44SJohn Forte 		    getTextString(MISSING_TARGET_PORT_NAME));
2304*fcf3ce44SJohn Forte 		(void) printf("\n");
2305*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
2306*fcf3ce44SJohn Forte 	} else if (B_FALSE == bHaveLu) {
2307*fcf3ce44SJohn Forte 		/* LINTED E_SEC_PRINTF_VAR_FMT */
2308*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
2309*fcf3ce44SJohn Forte 		    getTextString(ERR_FAILED_TO_DISABLE_PATH_WITH_REASON),
2310*fcf3ce44SJohn Forte 		    getTextString(MISSING_LU_NAME));
2311*fcf3ce44SJohn Forte 		(void) printf("\n");
2312*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
2313*fcf3ce44SJohn Forte 	}
2314*fcf3ce44SJohn Forte 
2315*fcf3ce44SJohn Forte 	if (B_FALSE == getPathOid(options, &pathOid)) {
2316*fcf3ce44SJohn Forte 		/* LINTED E_SEC_PRINTF_VAR_FMT */
2317*fcf3ce44SJohn Forte 		(void) fprintf(stderr,
2318*fcf3ce44SJohn Forte 		    getTextString(ERR_FAILED_TO_DISABLE_PATH_WITH_REASON),
2319*fcf3ce44SJohn Forte 		    getTextString(FAILED_TO_FIND_PATH));
2320*fcf3ce44SJohn Forte 		(void) printf("\n");
2321*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
2322*fcf3ce44SJohn Forte 	}
2323*fcf3ce44SJohn Forte 
2324*fcf3ce44SJohn Forte 	/* found the path, attempt to enable it */
2325*fcf3ce44SJohn Forte 	mpstatus =  MP_DisablePath(pathOid);
2326*fcf3ce44SJohn Forte 	if (MP_STATUS_SUCCESS != mpstatus) {
2327*fcf3ce44SJohn Forte 		/* LINTED E_SEC_PRINTF_VAR_FMT */
2328*fcf3ce44SJohn Forte 		(void) fprintf(stderr, getTextString(
2329*fcf3ce44SJohn Forte 		    ERR_FAILED_TO_DISABLE_PATH_WITH_REASON),
2330*fcf3ce44SJohn Forte 		    getMpStatusStr(mpstatus));
2331*fcf3ce44SJohn Forte 		(void) printf("\n");
2332*fcf3ce44SJohn Forte 		return (mpstatus);
2333*fcf3ce44SJohn Forte 	}
2334*fcf3ce44SJohn Forte 
2335*fcf3ce44SJohn Forte 
2336*fcf3ce44SJohn Forte 	return (mpstatus);
2337*fcf3ce44SJohn Forte }
2338*fcf3ce44SJohn Forte 
2339*fcf3ce44SJohn Forte 
2340*fcf3ce44SJohn Forte /*
2341*fcf3ce44SJohn Forte  * ****************************************************************************
2342*fcf3ce44SJohn Forte  *
2343*fcf3ce44SJohn Forte  * overridePath -
2344*fcf3ce44SJohn Forte  * 	mpathadm override path {-i <initiator-port>
2345*fcf3ce44SJohn Forte  *		-t <target-port name> | -c} <logical-unit name>
2346*fcf3ce44SJohn Forte  *
2347*fcf3ce44SJohn Forte  * options	- pointer to option list from user
2348*fcf3ce44SJohn Forte  *
2349*fcf3ce44SJohn Forte  * ****************************************************************************
2350*fcf3ce44SJohn Forte  */
2351*fcf3ce44SJohn Forte int
2352*fcf3ce44SJohn Forte overridePath(cmdOptions_t *options)
2353*fcf3ce44SJohn Forte {
2354*fcf3ce44SJohn Forte 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
2355*fcf3ce44SJohn Forte 	MP_OID					pathOid, luOid;
2356*fcf3ce44SJohn Forte 	boolean_t				bCancelOverride = B_FALSE;
2357*fcf3ce44SJohn Forte 	MP_CHAR					pLuDeviceFileName[256];
2358*fcf3ce44SJohn Forte 	cmdOptions_t 				*optionList = options;
2359*fcf3ce44SJohn Forte 
2360*fcf3ce44SJohn Forte 	/* First check to see if we have the cancel option, */
2361*fcf3ce44SJohn Forte 	/* May as well save off the lun while we're at it */
2362*fcf3ce44SJohn Forte 	for (; optionList->optval; optionList++) {
2363*fcf3ce44SJohn Forte 		switch (optionList->optval) {
2364*fcf3ce44SJohn Forte 			case 'c':
2365*fcf3ce44SJohn Forte 				/* we have a cancel */
2366*fcf3ce44SJohn Forte 				bCancelOverride = B_TRUE;
2367*fcf3ce44SJohn Forte 				break;
2368*fcf3ce44SJohn Forte 			case 'l':
2369*fcf3ce44SJohn Forte 				/* we have a lun- save it while we're here */
2370*fcf3ce44SJohn Forte 				(void) memcpy(pLuDeviceFileName,
2371*fcf3ce44SJohn Forte 				    optionList->optarg, 256);
2372*fcf3ce44SJohn Forte 				break;
2373*fcf3ce44SJohn Forte 		}
2374*fcf3ce44SJohn Forte 	}
2375*fcf3ce44SJohn Forte 
2376*fcf3ce44SJohn Forte 	if (B_TRUE == bCancelOverride) {
2377*fcf3ce44SJohn Forte 		/* if we have the cancel option, */
2378*fcf3ce44SJohn Forte 		if (getLogicalUnitOid(pLuDeviceFileName, &luOid) == B_FALSE) {
2379*fcf3ce44SJohn Forte 			/* LINTED E_SEC_PRINTF_VAR_FMT */
2380*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
2381*fcf3ce44SJohn Forte 			    getTextString(
2382*fcf3ce44SJohn Forte 			    ERR_FAILED_TO_CANCEL_OVERRIDE_PATH_WITH_REASON),
2383*fcf3ce44SJohn Forte 			    getTextString(LU_NOT_FOUND));
2384*fcf3ce44SJohn Forte 			(void) printf("\n");
2385*fcf3ce44SJohn Forte 			return (ERROR_CLI_FAILED);
2386*fcf3ce44SJohn Forte 		}
2387*fcf3ce44SJohn Forte 
2388*fcf3ce44SJohn Forte 		/* cancel the override path for the specified LU */
2389*fcf3ce44SJohn Forte 		mpstatus = MP_CancelOverridePath(luOid);
2390*fcf3ce44SJohn Forte 		if (MP_STATUS_SUCCESS != mpstatus) {
2391*fcf3ce44SJohn Forte 			/* LINTED E_SEC_PRINTF_VAR_FMT */
2392*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
2393*fcf3ce44SJohn Forte 			    getTextString(
2394*fcf3ce44SJohn Forte 			    ERR_FAILED_TO_CANCEL_OVERRIDE_PATH_WITH_REASON),
2395*fcf3ce44SJohn Forte 			    getMpStatusStr(mpstatus));
2396*fcf3ce44SJohn Forte 			(void) printf("\n");
2397*fcf3ce44SJohn Forte 			return (mpstatus);
2398*fcf3ce44SJohn Forte 		}
2399*fcf3ce44SJohn Forte 	} else {
2400*fcf3ce44SJohn Forte 		/* must be wanting to override the path */
2401*fcf3ce44SJohn Forte 		if (getLogicalUnitOid(pLuDeviceFileName, &luOid) == B_FALSE) {
2402*fcf3ce44SJohn Forte 			/* LINTED E_SEC_PRINTF_VAR_FMT */
2403*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
2404*fcf3ce44SJohn Forte 			    getTextString(
2405*fcf3ce44SJohn Forte 			    ERR_FAILED_TO_OVERRIDE_PATH_WITH_REASON),
2406*fcf3ce44SJohn Forte 			    getTextString(LU_NOT_FOUND));
2407*fcf3ce44SJohn Forte 			(void) printf("\n");
2408*fcf3ce44SJohn Forte 			return (ERROR_CLI_FAILED);
2409*fcf3ce44SJohn Forte 		}
2410*fcf3ce44SJohn Forte 
2411*fcf3ce44SJohn Forte 		if (B_FALSE == getPathOid(options, &pathOid)) {
2412*fcf3ce44SJohn Forte 			/* LINTED E_SEC_PRINTF_VAR_FMT */
2413*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
2414*fcf3ce44SJohn Forte 			    getTextString(
2415*fcf3ce44SJohn Forte 			    ERR_FAILED_TO_OVERRIDE_PATH_WITH_REASON),
2416*fcf3ce44SJohn Forte 			    getTextString(FAILED_TO_FIND_PATH));
2417*fcf3ce44SJohn Forte 
2418*fcf3ce44SJohn Forte 			(void) printf("\n");
2419*fcf3ce44SJohn Forte 			return (ERROR_CLI_FAILED);
2420*fcf3ce44SJohn Forte 		}
2421*fcf3ce44SJohn Forte 
2422*fcf3ce44SJohn Forte 		/* attempt to set the override path */
2423*fcf3ce44SJohn Forte 		mpstatus =  MP_SetOverridePath(luOid, pathOid);
2424*fcf3ce44SJohn Forte 		if (mpstatus != MP_STATUS_SUCCESS) {
2425*fcf3ce44SJohn Forte 			/* LINTED E_SEC_PRINTF_VAR_FMT */
2426*fcf3ce44SJohn Forte 			(void) fprintf(stderr,
2427*fcf3ce44SJohn Forte 			    getTextString(
2428*fcf3ce44SJohn Forte 			    ERR_FAILED_TO_OVERRIDE_PATH_WITH_REASON),
2429*fcf3ce44SJohn Forte 			    getMpStatusStr(mpstatus));
2430*fcf3ce44SJohn Forte 			(void) printf("\n");
2431*fcf3ce44SJohn Forte 			return (mpstatus);
2432*fcf3ce44SJohn Forte 		}
2433*fcf3ce44SJohn Forte 	}
2434*fcf3ce44SJohn Forte 
2435*fcf3ce44SJohn Forte 	return (mpstatus);
2436*fcf3ce44SJohn Forte }
2437*fcf3ce44SJohn Forte 
2438*fcf3ce44SJohn Forte 
2439*fcf3ce44SJohn Forte /*
2440*fcf3ce44SJohn Forte  * ****************************************************************************
2441*fcf3ce44SJohn Forte  *
2442*fcf3ce44SJohn Forte  * getPathOid -
2443*fcf3ce44SJohn Forte  *	Search through all plugins and get the OID for specified path
2444*fcf3ce44SJohn Forte  *
2445*fcf3ce44SJohn Forte  * operand	- pointer to operand list from user
2446*fcf3ce44SJohn Forte  * options	- pointer to option list from user
2447*fcf3ce44SJohn Forte  *
2448*fcf3ce44SJohn Forte  * ****************************************************************************
2449*fcf3ce44SJohn Forte  */
2450*fcf3ce44SJohn Forte boolean_t
2451*fcf3ce44SJohn Forte getPathOid(cmdOptions_t *options, MP_OID *pPathOid)
2452*fcf3ce44SJohn Forte {
2453*fcf3ce44SJohn Forte 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
2454*fcf3ce44SJohn Forte 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES 	luProps;
2455*fcf3ce44SJohn Forte 	MP_PATH_LOGICAL_UNIT_PROPERTIES		pathProps;
2456*fcf3ce44SJohn Forte 	MP_INITIATOR_PORT_PROPERTIES		initProps;
2457*fcf3ce44SJohn Forte 	MP_TARGET_PORT_PROPERTIES		targProps;
2458*fcf3ce44SJohn Forte 
2459*fcf3ce44SJohn Forte 	MP_OID_LIST				*pPluginOidList,
2460*fcf3ce44SJohn Forte 						*pLogicalUnitOidList,
2461*fcf3ce44SJohn Forte 						*pathOidListArray;
2462*fcf3ce44SJohn Forte 
2463*fcf3ce44SJohn Forte 	boolean_t				bFoundIt = B_FALSE;
2464*fcf3ce44SJohn Forte 	MP_CHAR					initPortID[256];
2465*fcf3ce44SJohn Forte 	MP_CHAR					targetPortID[256];
2466*fcf3ce44SJohn Forte 	MP_CHAR					luDeviceFileName[256];
2467*fcf3ce44SJohn Forte 	boolean_t				bHaveTarg = B_FALSE,
2468*fcf3ce44SJohn Forte 						bHaveLu = B_FALSE,
2469*fcf3ce44SJohn Forte 						bHaveInit = B_FALSE;
2470*fcf3ce44SJohn Forte 
2471*fcf3ce44SJohn Forte 
2472*fcf3ce44SJohn Forte 	cmdOptions_t 				*optionList = options;
2473*fcf3ce44SJohn Forte 
2474*fcf3ce44SJohn Forte 	int					i,
2475*fcf3ce44SJohn Forte 						lu,
2476*fcf3ce44SJohn Forte 						pa;
2477*fcf3ce44SJohn Forte 	if (NULL == pPathOid) {
2478*fcf3ce44SJohn Forte 		return (B_FALSE);
2479*fcf3ce44SJohn Forte 	}
2480*fcf3ce44SJohn Forte 
2481*fcf3ce44SJohn Forte 	for (; optionList->optval; optionList++) {
2482*fcf3ce44SJohn Forte 		switch (optionList->optval) {
2483*fcf3ce44SJohn Forte 			case 'i':
2484*fcf3ce44SJohn Forte 				/* save init port name */
2485*fcf3ce44SJohn Forte 				(void) memcpy(initPortID,
2486*fcf3ce44SJohn Forte 				    optionList->optarg, 256);
2487*fcf3ce44SJohn Forte 				bHaveInit = B_TRUE;
2488*fcf3ce44SJohn Forte 				break;
2489*fcf3ce44SJohn Forte 			case 't':
2490*fcf3ce44SJohn Forte 				/* save target port id */
2491*fcf3ce44SJohn Forte 				(void) memcpy(targetPortID,
2492*fcf3ce44SJohn Forte 				    optionList->optarg, 256);
2493*fcf3ce44SJohn Forte 				bHaveTarg = B_TRUE;
2494*fcf3ce44SJohn Forte 				break;
2495*fcf3ce44SJohn Forte 			case 'l':
2496*fcf3ce44SJohn Forte 				/* save LU name */
2497*fcf3ce44SJohn Forte 				(void) memcpy(luDeviceFileName,
2498*fcf3ce44SJohn Forte 				    optionList->optarg, 256);
2499*fcf3ce44SJohn Forte 				bHaveLu = B_TRUE;
2500*fcf3ce44SJohn Forte 				break;
2501*fcf3ce44SJohn Forte 		}
2502*fcf3ce44SJohn Forte 	}
2503*fcf3ce44SJohn Forte 
2504*fcf3ce44SJohn Forte 
2505*fcf3ce44SJohn Forte 	if ((B_FALSE == bHaveInit) ||
2506*fcf3ce44SJohn Forte 	    (B_FALSE == bHaveTarg) ||
2507*fcf3ce44SJohn Forte 	    (B_FALSE == bHaveLu)) {
2508*fcf3ce44SJohn Forte 		/* if we don't have all three pieces, we can't find the path */
2509*fcf3ce44SJohn Forte 
2510*fcf3ce44SJohn Forte 		return (B_FALSE);
2511*fcf3ce44SJohn Forte 	}
2512*fcf3ce44SJohn Forte 
2513*fcf3ce44SJohn Forte 	/* get the plugin ist */
2514*fcf3ce44SJohn Forte 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
2515*fcf3ce44SJohn Forte 	    != MP_STATUS_SUCCESS) {
2516*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s: %s\n", cmdName,
2517*fcf3ce44SJohn Forte 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
2518*fcf3ce44SJohn Forte 		return (B_FALSE);
2519*fcf3ce44SJohn Forte 	}
2520*fcf3ce44SJohn Forte 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
2521*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s: %s\n", cmdName,
2522*fcf3ce44SJohn Forte 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
2523*fcf3ce44SJohn Forte 		return (B_FALSE);
2524*fcf3ce44SJohn Forte 	}
2525*fcf3ce44SJohn Forte 
2526*fcf3ce44SJohn Forte 	for (i = 0; i < pPluginOidList->oidCount; i++) {
2527*fcf3ce44SJohn Forte 
2528*fcf3ce44SJohn Forte 		/* get Logical Unit list */
2529*fcf3ce44SJohn Forte 		mpstatus = MP_GetMultipathLus(pPluginOidList->oids[i],
2530*fcf3ce44SJohn Forte 		    &pLogicalUnitOidList);
2531*fcf3ce44SJohn Forte 		if (mpstatus != MP_STATUS_SUCCESS) {
2532*fcf3ce44SJohn Forte 			(void) fprintf(stderr, "%s:  %s\n",
2533*fcf3ce44SJohn Forte 			    cmdName, getTextString(ERR_NO_LU_LIST));
2534*fcf3ce44SJohn Forte 			return (B_FALSE);
2535*fcf3ce44SJohn Forte 		}
2536*fcf3ce44SJohn Forte 
2537*fcf3ce44SJohn Forte 		for (lu = 0; (lu < pLogicalUnitOidList->oidCount) &&
2538*fcf3ce44SJohn Forte 			(B_FALSE == bFoundIt); lu++) {
2539*fcf3ce44SJohn Forte 
2540*fcf3ce44SJohn Forte 			/* get lu properties so we can check the name */
2541*fcf3ce44SJohn Forte 			(void) memset(&luProps, 0,
2542*fcf3ce44SJohn Forte 			    sizeof (MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES));
2543*fcf3ce44SJohn Forte 			mpstatus =
2544*fcf3ce44SJohn Forte 			    MP_GetMPLogicalUnitProperties(
2545*fcf3ce44SJohn Forte 			    pLogicalUnitOidList->oids[lu], &luProps);
2546*fcf3ce44SJohn Forte 			if (mpstatus != MP_STATUS_SUCCESS) {
2547*fcf3ce44SJohn Forte 				(void) fprintf(stderr, "%s:  %s\n",
2548*fcf3ce44SJohn Forte 				    cmdName, getTextString(ERR_NO_PROPERTIES));
2549*fcf3ce44SJohn Forte 				return (B_FALSE);
2550*fcf3ce44SJohn Forte 			}
2551*fcf3ce44SJohn Forte 			if (0 == strcmp(luDeviceFileName,
2552*fcf3ce44SJohn Forte 			    luProps.deviceFileName)) {
2553*fcf3ce44SJohn Forte 				/* get paths for this LU and search from here */
2554*fcf3ce44SJohn Forte 				mpstatus =
2555*fcf3ce44SJohn Forte 				    MP_GetAssociatedPathOidList(
2556*fcf3ce44SJohn Forte 				    pLogicalUnitOidList->oids[lu],
2557*fcf3ce44SJohn Forte 				    &pathOidListArray);
2558*fcf3ce44SJohn Forte 				if (mpstatus != MP_STATUS_SUCCESS) {
2559*fcf3ce44SJohn Forte 					/* LINTED E_SEC_PRINTF_VAR_FMT */
2560*fcf3ce44SJohn Forte 					(void) fprintf(stderr,
2561*fcf3ce44SJohn Forte 					    getTextString(
2562*fcf3ce44SJohn Forte 					    ERR_FAILED_TO_FIND_PATH));
2563*fcf3ce44SJohn Forte 					(void) printf("\n");
2564*fcf3ce44SJohn Forte 					return (B_FALSE);
2565*fcf3ce44SJohn Forte 				}
2566*fcf3ce44SJohn Forte 
2567*fcf3ce44SJohn Forte 				for (pa = 0;
2568*fcf3ce44SJohn Forte 					(pa < pathOidListArray->oidCount) &&
2569*fcf3ce44SJohn Forte 					(B_FALSE == bFoundIt); pa++) {
2570*fcf3ce44SJohn Forte 					mpstatus =
2571*fcf3ce44SJohn Forte 					    MP_GetPathLogicalUnitProperties
2572*fcf3ce44SJohn Forte 					    (pathOidListArray->oids[pa],
2573*fcf3ce44SJohn Forte 					    &pathProps);
2574*fcf3ce44SJohn Forte 					if (mpstatus != MP_STATUS_SUCCESS) {
2575*fcf3ce44SJohn Forte 						(void) fprintf(stderr,
2576*fcf3ce44SJohn Forte 						    "%s:  %s\n", cmdName,
2577*fcf3ce44SJohn Forte 						    getTextString(
2578*fcf3ce44SJohn Forte 						    ERR_NO_PROPERTIES));
2579*fcf3ce44SJohn Forte 						return (B_FALSE);
2580*fcf3ce44SJohn Forte 					}
2581*fcf3ce44SJohn Forte 
2582*fcf3ce44SJohn Forte 					/*
2583*fcf3ce44SJohn Forte 					 * get properties of iniator port and
2584*fcf3ce44SJohn Forte 					 * target port to see if we have the
2585*fcf3ce44SJohn Forte 					 * right path
2586*fcf3ce44SJohn Forte 					 */
2587*fcf3ce44SJohn Forte 					mpstatus =
2588*fcf3ce44SJohn Forte 					    MP_GetInitiatorPortProperties(
2589*fcf3ce44SJohn Forte 					    pathProps.initiatorPortOid,
2590*fcf3ce44SJohn Forte 					    &initProps);
2591*fcf3ce44SJohn Forte 
2592*fcf3ce44SJohn Forte 					if (mpstatus != MP_STATUS_SUCCESS) {
2593*fcf3ce44SJohn Forte 						(void) fprintf(stderr,
2594*fcf3ce44SJohn Forte 						    "%s:  %s\n", cmdName,
2595*fcf3ce44SJohn Forte 						    getTextString(
2596*fcf3ce44SJohn Forte 						    ERR_NO_PROPERTIES));
2597*fcf3ce44SJohn Forte 						return (B_FALSE);
2598*fcf3ce44SJohn Forte 					}
2599*fcf3ce44SJohn Forte 	if (0 == strcmp(initPortID, initProps.portID)) {
2600*fcf3ce44SJohn Forte 		/* lu and init port matches, check target port */
2601*fcf3ce44SJohn Forte 		mpstatus = MP_GetTargetPortProperties(pathProps.targetPortOid,
2602*fcf3ce44SJohn Forte 		    &targProps);
2603*fcf3ce44SJohn Forte 		if (mpstatus != MP_STATUS_SUCCESS) {
2604*fcf3ce44SJohn Forte 			(void) fprintf(stderr, "%s:  %s\n", cmdName,
2605*fcf3ce44SJohn Forte 			    getTextString(ERR_NO_PROPERTIES));
2606*fcf3ce44SJohn Forte 			return (B_FALSE);
2607*fcf3ce44SJohn Forte 		}
2608*fcf3ce44SJohn Forte 
2609*fcf3ce44SJohn Forte 		if (0 == strcmp(targetPortID, targProps.portID)) {
2610*fcf3ce44SJohn Forte 			/* we found our path */
2611*fcf3ce44SJohn Forte 			pPathOid->objectSequenceNumber =
2612*fcf3ce44SJohn Forte 			    pathOidListArray->oids[pa].objectSequenceNumber;
2613*fcf3ce44SJohn Forte 			pPathOid->objectType =
2614*fcf3ce44SJohn Forte 			    pathOidListArray->oids[pa].objectType;
2615*fcf3ce44SJohn Forte 			pPathOid->ownerId = pathOidListArray->oids[pa].ownerId;
2616*fcf3ce44SJohn Forte 			bFoundIt = B_TRUE;
2617*fcf3ce44SJohn Forte 		}
2618*fcf3ce44SJohn Forte 	} /* init port matched */
2619*fcf3ce44SJohn Forte 
2620*fcf3ce44SJohn Forte 				} /* for each path associated with this lu */
2621*fcf3ce44SJohn Forte 
2622*fcf3ce44SJohn Forte 			} /* lu matched */
2623*fcf3ce44SJohn Forte 
2624*fcf3ce44SJohn Forte 		} /* for each lu */
2625*fcf3ce44SJohn Forte 
2626*fcf3ce44SJohn Forte 	} /* for each plugin */
2627*fcf3ce44SJohn Forte 
2628*fcf3ce44SJohn Forte 	return (bFoundIt);
2629*fcf3ce44SJohn Forte }
2630*fcf3ce44SJohn Forte 
2631*fcf3ce44SJohn Forte 
2632*fcf3ce44SJohn Forte /*
2633*fcf3ce44SJohn Forte  * ****************************************************************************
2634*fcf3ce44SJohn Forte  *
2635*fcf3ce44SJohn Forte  * getLbValueFromString
2636*fcf3ce44SJohn Forte  * 	Gets the MP_LOAD_BALANCE_TYPE specified load balance type string
2637*fcf3ce44SJohn Forte  *
2638*fcf3ce44SJohn Forte  * lbStr	- load balance string defined in the .h file
2639*fcf3ce44SJohn Forte  *		This is what users will be required to feed into the
2640*fcf3ce44SJohn Forte  *		modify lu command.
2641*fcf3ce44SJohn Forte  *
2642*fcf3ce44SJohn Forte  * ****************************************************************************
2643*fcf3ce44SJohn Forte  */
2644*fcf3ce44SJohn Forte MP_LOAD_BALANCE_TYPE
2645*fcf3ce44SJohn Forte getLbValueFromString(char *lbStr)
2646*fcf3ce44SJohn Forte {
2647*fcf3ce44SJohn Forte 	MP_LOAD_BALANCE_TYPE		lbVal = MP_LOAD_BALANCE_TYPE_UNKNOWN;
2648*fcf3ce44SJohn Forte 
2649*fcf3ce44SJohn Forte 	if (0 == strcmp(lbStr, getTextString(TEXT_LBTYPE_ROUNDROBIN))) {
2650*fcf3ce44SJohn Forte 		lbVal = MP_LOAD_BALANCE_TYPE_ROUNDROBIN;
2651*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr, getTextString(TEXT_LBTYPE_LEASTBLOCKS))) {
2652*fcf3ce44SJohn Forte 		lbVal = MP_LOAD_BALANCE_TYPE_LEASTBLOCKS;
2653*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr, getTextString(TEXT_LBTYPE_LEASTIO))) {
2654*fcf3ce44SJohn Forte 		lbVal = MP_LOAD_BALANCE_TYPE_LEASTIO;
2655*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr, getTextString(TEXT_LBTYPE_DEVICEPROD))) {
2656*fcf3ce44SJohn Forte 		lbVal = MP_LOAD_BALANCE_TYPE_DEVICE_PRODUCT;
2657*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr, getTextString(TEXT_LBTYPE_LBAREGION))) {
2658*fcf3ce44SJohn Forte 		lbVal = MP_LOAD_BALANCE_TYPE_LBA_REGION;
2659*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr,
2660*fcf3ce44SJohn Forte 	    getTextString(TEXT_LBTYPE_FAILOVER_ONLY))) {
2661*fcf3ce44SJohn Forte 		lbVal = MP_LOAD_BALANCE_TYPE_FAILOVER_ONLY;
2662*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr, getTextString(TEXT_LBTYPE_UNKNOWN))) {
2663*fcf3ce44SJohn Forte 		lbVal = MP_LOAD_BALANCE_TYPE_UNKNOWN;
2664*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr, getTextString(TEXT_LBTYPE_NONE))) {
2665*fcf3ce44SJohn Forte 		lbVal = 0;
2666*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr,
2667*fcf3ce44SJohn Forte 	    getTextString(TEXT_LBTYPE_PROPRIETARY1))) {
2668*fcf3ce44SJohn Forte 		lbVal = ((MP_UINT32)0x00000001)<<16;
2669*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr,
2670*fcf3ce44SJohn Forte 	    getTextString(TEXT_LBTYPE_PROPRIETARY2))) {
2671*fcf3ce44SJohn Forte 		lbVal = ((MP_UINT32)0x00000001)<<17;
2672*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr,
2673*fcf3ce44SJohn Forte 	    getTextString(TEXT_LBTYPE_PROPRIETARY3))) {
2674*fcf3ce44SJohn Forte 		lbVal = ((MP_UINT32)0x00000001)<<18;
2675*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr,
2676*fcf3ce44SJohn Forte 	    getTextString(TEXT_LBTYPE_PROPRIETARY4))) {
2677*fcf3ce44SJohn Forte 		lbVal = ((MP_UINT32)0x00000001)<<19;
2678*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr,
2679*fcf3ce44SJohn Forte 	    getTextString(TEXT_LBTYPE_PROPRIETARY5))) {
2680*fcf3ce44SJohn Forte 		lbVal = ((MP_UINT32)0x00000001)<<20;
2681*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr,
2682*fcf3ce44SJohn Forte 	    getTextString(TEXT_LBTYPE_PROPRIETARY6))) {
2683*fcf3ce44SJohn Forte 		lbVal = ((MP_UINT32)0x00000001)<<21;
2684*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr,
2685*fcf3ce44SJohn Forte 	    getTextString(TEXT_LBTYPE_PROPRIETARY7))) {
2686*fcf3ce44SJohn Forte 		lbVal = ((MP_UINT32)0x00000001)<<22;
2687*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr,
2688*fcf3ce44SJohn Forte 	    getTextString(TEXT_LBTYPE_PROPRIETARY8))) {
2689*fcf3ce44SJohn Forte 		lbVal = ((MP_UINT32)0x00000001)<<23;
2690*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr,
2691*fcf3ce44SJohn Forte 	    getTextString(TEXT_LBTYPE_PROPRIETARY9))) {
2692*fcf3ce44SJohn Forte 		lbVal = ((MP_UINT32)0x00000001)<<24;
2693*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr,
2694*fcf3ce44SJohn Forte 	    getTextString(TEXT_LBTYPE_PROPRIETARY10))) {
2695*fcf3ce44SJohn Forte 		lbVal = ((MP_UINT32)0x00000001)<<25;
2696*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr,
2697*fcf3ce44SJohn Forte 	    getTextString(TEXT_LBTYPE_PROPRIETARY11))) {
2698*fcf3ce44SJohn Forte 		lbVal = ((MP_UINT32)0x00000001)<<26;
2699*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr,
2700*fcf3ce44SJohn Forte 	    getTextString(TEXT_LBTYPE_PROPRIETARY12))) {
2701*fcf3ce44SJohn Forte 		lbVal = ((MP_UINT32)0x00000001)<<27;
2702*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr,
2703*fcf3ce44SJohn Forte 	    getTextString(TEXT_LBTYPE_PROPRIETARY13))) {
2704*fcf3ce44SJohn Forte 		lbVal = ((MP_UINT32)0x00000001)<<28;
2705*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr,
2706*fcf3ce44SJohn Forte 	    getTextString(TEXT_LBTYPE_PROPRIETARY14))) {
2707*fcf3ce44SJohn Forte 		lbVal = ((MP_UINT32)0x00000001)<<29;
2708*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr,
2709*fcf3ce44SJohn Forte 	    getTextString(TEXT_LBTYPE_PROPRIETARY15))) {
2710*fcf3ce44SJohn Forte 		lbVal = ((MP_UINT32)0x00000001)<<30;
2711*fcf3ce44SJohn Forte 	} else if (0 == strcmp(lbStr,
2712*fcf3ce44SJohn Forte 	    getTextString(TEXT_LBTYPE_PROPRIETARY16))) {
2713*fcf3ce44SJohn Forte 		lbVal = ((MP_UINT32)0x00000001)<<31;
2714*fcf3ce44SJohn Forte 	}
2715*fcf3ce44SJohn Forte 
2716*fcf3ce44SJohn Forte 	return (lbVal);
2717*fcf3ce44SJohn Forte 
2718*fcf3ce44SJohn Forte 
2719*fcf3ce44SJohn Forte } /* end getLbValueFromString */
2720*fcf3ce44SJohn Forte 
2721*fcf3ce44SJohn Forte 
2722*fcf3ce44SJohn Forte /*
2723*fcf3ce44SJohn Forte  * ****************************************************************************
2724*fcf3ce44SJohn Forte  *
2725*fcf3ce44SJohn Forte  * displayLogicalUnitNameTypeString
2726*fcf3ce44SJohn Forte  * 	Displays the text equivalent string for the MP_LOGICAL_UNIT_NAME_TYPE
2727*fcf3ce44SJohn Forte  *	specified load balance type
2728*fcf3ce44SJohn Forte  *
2729*fcf3ce44SJohn Forte  * typeVal	- load balance type defined in the MPAPI spec
2730*fcf3ce44SJohn Forte  *
2731*fcf3ce44SJohn Forte  * ****************************************************************************
2732*fcf3ce44SJohn Forte  */
2733*fcf3ce44SJohn Forte void
2734*fcf3ce44SJohn Forte displayLogicalUnitNameTypeString(MP_LOGICAL_UNIT_NAME_TYPE typeVal)
2735*fcf3ce44SJohn Forte {
2736*fcf3ce44SJohn Forte 
2737*fcf3ce44SJohn Forte 	char					*typeString;
2738*fcf3ce44SJohn Forte 
2739*fcf3ce44SJohn Forte 	switch (typeVal) {
2740*fcf3ce44SJohn Forte 
2741*fcf3ce44SJohn Forte 		case MP_LU_NAME_TYPE_UNKNOWN:
2742*fcf3ce44SJohn Forte 			typeString = getTextString(TEXT_NAME_TYPE_UNKNOWN);
2743*fcf3ce44SJohn Forte 			break;
2744*fcf3ce44SJohn Forte 		case MP_LU_NAME_TYPE_VPD83_TYPE1:
2745*fcf3ce44SJohn Forte 			typeString = getTextString(TEXT_NAME_TYPE_VPD83_TYPE1);
2746*fcf3ce44SJohn Forte 			break;
2747*fcf3ce44SJohn Forte 		case MP_LU_NAME_TYPE_VPD83_TYPE2:
2748*fcf3ce44SJohn Forte 			typeString = getTextString(TEXT_NAME_TYPE_VPD83_TYPE2);
2749*fcf3ce44SJohn Forte 			break;
2750*fcf3ce44SJohn Forte 		case MP_LU_NAME_TYPE_VPD83_TYPE3:
2751*fcf3ce44SJohn Forte 			typeString = getTextString(TEXT_NAME_TYPE_VPD83_TYPE3);
2752*fcf3ce44SJohn Forte 			break;
2753*fcf3ce44SJohn Forte 		case MP_LU_NAME_TYPE_DEVICE_SPECIFIC:
2754*fcf3ce44SJohn Forte 			typeString =
2755*fcf3ce44SJohn Forte 			getTextString(TEXT_NAME_TYPE_DEVICE_SPECIFIC);
2756*fcf3ce44SJohn Forte 			break;
2757*fcf3ce44SJohn Forte 		default:
2758*fcf3ce44SJohn Forte 			typeString = getTextString(TEXT_UNKNOWN);
2759*fcf3ce44SJohn Forte 			break;
2760*fcf3ce44SJohn Forte 	}
2761*fcf3ce44SJohn Forte 
2762*fcf3ce44SJohn Forte 	(void) printf("%s", typeString);
2763*fcf3ce44SJohn Forte 
2764*fcf3ce44SJohn Forte 
2765*fcf3ce44SJohn Forte } /* end displayLogicalUnitNameTypeString */
2766*fcf3ce44SJohn Forte 
2767*fcf3ce44SJohn Forte /*
2768*fcf3ce44SJohn Forte  * ****************************************************************************
2769*fcf3ce44SJohn Forte  *
2770*fcf3ce44SJohn Forte  * displayLoadBalanceString
2771*fcf3ce44SJohn Forte  * 	Displays the text equivalent string for the MP_LOAD_BALANCE_TYPE
2772*fcf3ce44SJohn Forte  *	specified load balance type
2773*fcf3ce44SJohn Forte  *
2774*fcf3ce44SJohn Forte  * lbVal	- load balance type defined in the MPAPI spec
2775*fcf3ce44SJohn Forte  *
2776*fcf3ce44SJohn Forte  * ****************************************************************************
2777*fcf3ce44SJohn Forte  */
2778*fcf3ce44SJohn Forte void
2779*fcf3ce44SJohn Forte displayLoadBalanceString(MP_LOAD_BALANCE_TYPE lbVal)
2780*fcf3ce44SJohn Forte {
2781*fcf3ce44SJohn Forte 
2782*fcf3ce44SJohn Forte 	char					*lbString;
2783*fcf3ce44SJohn Forte 
2784*fcf3ce44SJohn Forte 	switch (lbVal) {
2785*fcf3ce44SJohn Forte 
2786*fcf3ce44SJohn Forte 		case MP_LOAD_BALANCE_TYPE_UNKNOWN:
2787*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_UNKNOWN);
2788*fcf3ce44SJohn Forte 			break;
2789*fcf3ce44SJohn Forte 		case MP_LOAD_BALANCE_TYPE_ROUNDROBIN:
2790*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_ROUNDROBIN);
2791*fcf3ce44SJohn Forte 			break;
2792*fcf3ce44SJohn Forte 		case MP_LOAD_BALANCE_TYPE_LEASTBLOCKS:
2793*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_LEASTBLOCKS);
2794*fcf3ce44SJohn Forte 			break;
2795*fcf3ce44SJohn Forte 		case MP_LOAD_BALANCE_TYPE_LEASTIO:
2796*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_LEASTIO);
2797*fcf3ce44SJohn Forte 			break;
2798*fcf3ce44SJohn Forte 		case MP_LOAD_BALANCE_TYPE_DEVICE_PRODUCT:
2799*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_DEVICEPROD);
2800*fcf3ce44SJohn Forte 			break;
2801*fcf3ce44SJohn Forte 		case MP_LOAD_BALANCE_TYPE_LBA_REGION:
2802*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_LBAREGION);
2803*fcf3ce44SJohn Forte 			break;
2804*fcf3ce44SJohn Forte 		case MP_LOAD_BALANCE_TYPE_FAILOVER_ONLY:
2805*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_FAILOVER_ONLY);
2806*fcf3ce44SJohn Forte 			break;
2807*fcf3ce44SJohn Forte 		case (((MP_UINT32)0x00000001)<<16):
2808*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY1);
2809*fcf3ce44SJohn Forte 			break;
2810*fcf3ce44SJohn Forte 		case (((MP_UINT32)0x00000001)<<17):
2811*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY2);
2812*fcf3ce44SJohn Forte 			break;
2813*fcf3ce44SJohn Forte 		case (((MP_UINT32)0x00000001)<<18):
2814*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY3);
2815*fcf3ce44SJohn Forte 			break;
2816*fcf3ce44SJohn Forte 		case (((MP_UINT32)0x00000001)<<19):
2817*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY4);
2818*fcf3ce44SJohn Forte 			break;
2819*fcf3ce44SJohn Forte 		case (((MP_UINT32)0x00000001)<<20):
2820*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY5);
2821*fcf3ce44SJohn Forte 			break;
2822*fcf3ce44SJohn Forte 		case (((MP_UINT32)0x00000001)<<21):
2823*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY6);
2824*fcf3ce44SJohn Forte 			break;
2825*fcf3ce44SJohn Forte 		case (((MP_UINT32)0x00000001)<<22):
2826*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY7);
2827*fcf3ce44SJohn Forte 			break;
2828*fcf3ce44SJohn Forte 		case (((MP_UINT32)0x00000001)<<23):
2829*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY8);
2830*fcf3ce44SJohn Forte 			break;
2831*fcf3ce44SJohn Forte 		case (((MP_UINT32)0x00000001)<<24):
2832*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY9);
2833*fcf3ce44SJohn Forte 			break;
2834*fcf3ce44SJohn Forte 		case (((MP_UINT32)0x00000001)<<25):
2835*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY10);
2836*fcf3ce44SJohn Forte 			break;
2837*fcf3ce44SJohn Forte 		case (((MP_UINT32)0x00000001)<<26):
2838*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY11);
2839*fcf3ce44SJohn Forte 			break;
2840*fcf3ce44SJohn Forte 		case (((MP_UINT32)0x00000001)<<27):
2841*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY12);
2842*fcf3ce44SJohn Forte 			break;
2843*fcf3ce44SJohn Forte 		case (((MP_UINT32)0x00000001)<<28):
2844*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY13);
2845*fcf3ce44SJohn Forte 			break;
2846*fcf3ce44SJohn Forte 		case (((MP_UINT32)0x00000001)<<29):
2847*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY14);
2848*fcf3ce44SJohn Forte 			break;
2849*fcf3ce44SJohn Forte 		case (((MP_UINT32)0x00000001)<<30):
2850*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY15);
2851*fcf3ce44SJohn Forte 			break;
2852*fcf3ce44SJohn Forte 		case (((MP_UINT32)0x00000001)<<31):
2853*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_LBTYPE_PROPRIETARY16);
2854*fcf3ce44SJohn Forte 			break;
2855*fcf3ce44SJohn Forte 		default:
2856*fcf3ce44SJohn Forte 			lbString = getTextString(TEXT_UNKNOWN);
2857*fcf3ce44SJohn Forte 			break;
2858*fcf3ce44SJohn Forte 	}
2859*fcf3ce44SJohn Forte 
2860*fcf3ce44SJohn Forte 	(void) printf("%s", lbString);
2861*fcf3ce44SJohn Forte 
2862*fcf3ce44SJohn Forte 
2863*fcf3ce44SJohn Forte } /* end displayLoadBalanceString */
2864*fcf3ce44SJohn Forte 
2865*fcf3ce44SJohn Forte /*
2866*fcf3ce44SJohn Forte  * ****************************************************************************
2867*fcf3ce44SJohn Forte  *
2868*fcf3ce44SJohn Forte  * displayTransportTypeString
2869*fcf3ce44SJohn Forte  * 	Displays the text equivalent string for the MP_PORT_TRANSPORT_TYPE
2870*fcf3ce44SJohn Forte  *	specified load balance type
2871*fcf3ce44SJohn Forte  *
2872*fcf3ce44SJohn Forte  * transportTypeVal	- transport type defined in the MPAPI spec
2873*fcf3ce44SJohn Forte  *
2874*fcf3ce44SJohn Forte  * ****************************************************************************
2875*fcf3ce44SJohn Forte  */
2876*fcf3ce44SJohn Forte void
2877*fcf3ce44SJohn Forte displayTransportTypeString(MP_PORT_TRANSPORT_TYPE transportTypeVal)
2878*fcf3ce44SJohn Forte {
2879*fcf3ce44SJohn Forte 
2880*fcf3ce44SJohn Forte 	char					*ttypeString;
2881*fcf3ce44SJohn Forte 	switch (transportTypeVal) {
2882*fcf3ce44SJohn Forte 
2883*fcf3ce44SJohn Forte 		case MP_PORT_TRANSPORT_TYPE_MPNODE:
2884*fcf3ce44SJohn Forte 			ttypeString =
2885*fcf3ce44SJohn Forte 			    getTextString(TEXT_TRANS_PORT_TYPE_MPNODE);
2886*fcf3ce44SJohn Forte 			break;
2887*fcf3ce44SJohn Forte 		case MP_PORT_TRANSPORT_TYPE_FC:
2888*fcf3ce44SJohn Forte 			ttypeString = getTextString(TEXT_TRANS_PORT_TYPE_FC);
2889*fcf3ce44SJohn Forte 			break;
2890*fcf3ce44SJohn Forte 		case MP_PORT_TRANSPORT_TYPE_SPI:
2891*fcf3ce44SJohn Forte 			ttypeString = getTextString(TEXT_TRANS_PORT_TYPE_SPI);
2892*fcf3ce44SJohn Forte 			break;
2893*fcf3ce44SJohn Forte 		case MP_PORT_TRANSPORT_TYPE_ISCSI:
2894*fcf3ce44SJohn Forte 			ttypeString = getTextString(TEXT_TRANS_PORT_TYPE_ISCSI);
2895*fcf3ce44SJohn Forte 			break;
2896*fcf3ce44SJohn Forte 		case MP_PORT_TRANSPORT_TYPE_IFB:
2897*fcf3ce44SJohn Forte 			ttypeString = getTextString(TEXT_TRANS_PORT_TYPE_IFB);
2898*fcf3ce44SJohn Forte 			break;
2899*fcf3ce44SJohn Forte 		default:
2900*fcf3ce44SJohn Forte 			ttypeString = getTextString(TEXT_UNKNOWN);
2901*fcf3ce44SJohn Forte 			break;
2902*fcf3ce44SJohn Forte 	}
2903*fcf3ce44SJohn Forte 
2904*fcf3ce44SJohn Forte 	(void) printf("%s", ttypeString);
2905*fcf3ce44SJohn Forte 
2906*fcf3ce44SJohn Forte } /* end displayTransportTypeString */
2907*fcf3ce44SJohn Forte 
2908*fcf3ce44SJohn Forte 
2909*fcf3ce44SJohn Forte /*
2910*fcf3ce44SJohn Forte  * ****************************************************************************
2911*fcf3ce44SJohn Forte  *
2912*fcf3ce44SJohn Forte  * getMpStatusStr
2913*fcf3ce44SJohn Forte  * 	Gets the string description for the specified load balance type value
2914*fcf3ce44SJohn Forte  *
2915*fcf3ce44SJohn Forte  * mpstatus	- MP_STATUS value
2916*fcf3ce44SJohn Forte  *
2917*fcf3ce44SJohn Forte  * ****************************************************************************
2918*fcf3ce44SJohn Forte  */
2919*fcf3ce44SJohn Forte char *
2920*fcf3ce44SJohn Forte getMpStatusStr(MP_STATUS mpstatus)
2921*fcf3ce44SJohn Forte {
2922*fcf3ce44SJohn Forte 	char					*statString;
2923*fcf3ce44SJohn Forte 
2924*fcf3ce44SJohn Forte 	switch (mpstatus) {
2925*fcf3ce44SJohn Forte 		case MP_STATUS_SUCCESS:
2926*fcf3ce44SJohn Forte 			statString = getTextString(TEXT_MPSTATUS_SUCCESS);
2927*fcf3ce44SJohn Forte 			break;
2928*fcf3ce44SJohn Forte 		case MP_STATUS_INVALID_PARAMETER:
2929*fcf3ce44SJohn Forte 			statString = getTextString(TEXT_MPSTATUS_INV_PARAMETER);
2930*fcf3ce44SJohn Forte 			break;
2931*fcf3ce44SJohn Forte 		case MP_STATUS_UNKNOWN_FN:
2932*fcf3ce44SJohn Forte 			statString = getTextString(TEXT_MPSTATUS_UNKNOWN_FN);
2933*fcf3ce44SJohn Forte 			break;
2934*fcf3ce44SJohn Forte 		case MP_STATUS_FAILED:
2935*fcf3ce44SJohn Forte 			statString = getTextString(TEXT_MPSTATUS_FAILED);
2936*fcf3ce44SJohn Forte 			break;
2937*fcf3ce44SJohn Forte 		case MP_STATUS_INSUFFICIENT_MEMORY:
2938*fcf3ce44SJohn Forte 			statString = getTextString(TEXT_MPSTATUS_INSUFF_MEMORY);
2939*fcf3ce44SJohn Forte 			break;
2940*fcf3ce44SJohn Forte 		case MP_STATUS_INVALID_OBJECT_TYPE:
2941*fcf3ce44SJohn Forte 			statString = getTextString(TEXT_MPSTATUS_INV_OBJ_TYPE);
2942*fcf3ce44SJohn Forte 			break;
2943*fcf3ce44SJohn Forte 		case MP_STATUS_UNSUPPORTED:
2944*fcf3ce44SJohn Forte 			statString = getTextString(TEXT_MPSTATUS_UNSUPPORTED);
2945*fcf3ce44SJohn Forte 			break;
2946*fcf3ce44SJohn Forte 		case MP_STATUS_OBJECT_NOT_FOUND:
2947*fcf3ce44SJohn Forte 			statString = getTextString(TEXT_MPSTATUS_OBJ_NOT_FOUND);
2948*fcf3ce44SJohn Forte 			break;
2949*fcf3ce44SJohn Forte 		case MP_STATUS_ACCESS_STATE_INVALID:
2950*fcf3ce44SJohn Forte 			statString = getTextString(TEXT_MPSTATUS_UNSUPPORTED);
2951*fcf3ce44SJohn Forte 			break;
2952*fcf3ce44SJohn Forte 		case MP_STATUS_FN_REPLACED:
2953*fcf3ce44SJohn Forte 			statString = getTextString(TEXT_MPSTATUS_FN_REPLACED);
2954*fcf3ce44SJohn Forte 			break;
2955*fcf3ce44SJohn Forte 		case MP_STATUS_PATH_NONOPERATIONAL:
2956*fcf3ce44SJohn Forte 			statString = getTextString(TEXT_MPSTATUS_PATH_NONOP);
2957*fcf3ce44SJohn Forte 			break;
2958*fcf3ce44SJohn Forte 		case MP_STATUS_TRY_AGAIN:
2959*fcf3ce44SJohn Forte 			statString = getTextString(TEXT_MPSTATUS_TRY_AGAIN);
2960*fcf3ce44SJohn Forte 			break;
2961*fcf3ce44SJohn Forte 		case MP_STATUS_NOT_PERMITTED:
2962*fcf3ce44SJohn Forte 			statString = getTextString(TEXT_MPSTATUS_NOT_PERMITTED);
2963*fcf3ce44SJohn Forte 			break;
2964*fcf3ce44SJohn Forte 		default:
2965*fcf3ce44SJohn Forte 			statString = getTextString(TEXT_UNKNOWN);
2966*fcf3ce44SJohn Forte 			break;
2967*fcf3ce44SJohn Forte 	}
2968*fcf3ce44SJohn Forte 
2969*fcf3ce44SJohn Forte 	return (statString);
2970*fcf3ce44SJohn Forte } /* end getMpStatusStr */
2971*fcf3ce44SJohn Forte 
2972*fcf3ce44SJohn Forte 
2973*fcf3ce44SJohn Forte /*
2974*fcf3ce44SJohn Forte  * ****************************************************************************
2975*fcf3ce44SJohn Forte  *
2976*fcf3ce44SJohn Forte  * GetPathStateStr
2977*fcf3ce44SJohn Forte  * 	Gets the string description for the specified path state type value
2978*fcf3ce44SJohn Forte  *
2979*fcf3ce44SJohn Forte  * pathState	- MP_PATH_STATE values
2980*fcf3ce44SJohn Forte  *
2981*fcf3ce44SJohn Forte  * ****************************************************************************
2982*fcf3ce44SJohn Forte  */
2983*fcf3ce44SJohn Forte char *
2984*fcf3ce44SJohn Forte getPathStateStr(MP_PATH_STATE pathState)
2985*fcf3ce44SJohn Forte {
2986*fcf3ce44SJohn Forte 	char					*pathString;
2987*fcf3ce44SJohn Forte 
2988*fcf3ce44SJohn Forte 	switch (pathState) {
2989*fcf3ce44SJohn Forte 		case MP_PATH_STATE_OKAY:
2990*fcf3ce44SJohn Forte 			pathString = getTextString(TEXT_PATH_STATE_OKAY);
2991*fcf3ce44SJohn Forte 			break;
2992*fcf3ce44SJohn Forte 		case MP_PATH_STATE_PATH_ERR:
2993*fcf3ce44SJohn Forte 			pathString = getTextString(TEXT_PATH_STATE_PATH_ERR);
2994*fcf3ce44SJohn Forte 			break;
2995*fcf3ce44SJohn Forte 		case MP_PATH_STATE_LU_ERR:
2996*fcf3ce44SJohn Forte 			pathString = getTextString(TEXT_PATH_STATE_LU_ERR);
2997*fcf3ce44SJohn Forte 			break;
2998*fcf3ce44SJohn Forte 		case MP_PATH_STATE_RESERVED:
2999*fcf3ce44SJohn Forte 			pathString = getTextString(TEXT_PATH_STATE_RESERVED);
3000*fcf3ce44SJohn Forte 			break;
3001*fcf3ce44SJohn Forte 		case MP_PATH_STATE_REMOVED:
3002*fcf3ce44SJohn Forte 			pathString = getTextString(TEXT_PATH_STATE_REMOVED);
3003*fcf3ce44SJohn Forte 			break;
3004*fcf3ce44SJohn Forte 		case MP_PATH_STATE_TRANSITIONING:
3005*fcf3ce44SJohn Forte 			pathString =
3006*fcf3ce44SJohn Forte 			    getTextString(TEXT_PATH_STATE_TRANSITIONING);
3007*fcf3ce44SJohn Forte 			break;
3008*fcf3ce44SJohn Forte 		case MP_PATH_STATE_OPERATIONAL_CLOSED:
3009*fcf3ce44SJohn Forte 			pathString =
3010*fcf3ce44SJohn Forte 			    getTextString(TEXT_PATH_STATE_OPERATIONAL_CLOSED);
3011*fcf3ce44SJohn Forte 			break;
3012*fcf3ce44SJohn Forte 		case MP_PATH_STATE_INVALID_CLOSED:
3013*fcf3ce44SJohn Forte 			pathString =
3014*fcf3ce44SJohn Forte 			    getTextString(TEXT_PATH_STATE_INVALID_CLOSED);
3015*fcf3ce44SJohn Forte 			break;
3016*fcf3ce44SJohn Forte 		case MP_PATH_STATE_OFFLINE_CLOSED:
3017*fcf3ce44SJohn Forte 			pathString =
3018*fcf3ce44SJohn Forte 			    getTextString(TEXT_PATH_STATE_OFFLINE_CLOSED);
3019*fcf3ce44SJohn Forte 			break;
3020*fcf3ce44SJohn Forte 		default:
3021*fcf3ce44SJohn Forte 			pathString = getTextString(TEXT_UNKNOWN);
3022*fcf3ce44SJohn Forte 			break;
3023*fcf3ce44SJohn Forte 	}
3024*fcf3ce44SJohn Forte 
3025*fcf3ce44SJohn Forte 	return (pathString);
3026*fcf3ce44SJohn Forte } /* end getPathStateStr */
3027*fcf3ce44SJohn Forte 
3028*fcf3ce44SJohn Forte 
3029*fcf3ce44SJohn Forte 
3030*fcf3ce44SJohn Forte /*
3031*fcf3ce44SJohn Forte  * ****************************************************************************
3032*fcf3ce44SJohn Forte  *
3033*fcf3ce44SJohn Forte  * getAccessStateStr
3034*fcf3ce44SJohn Forte  * 	Gets the string description for the specified access state type value
3035*fcf3ce44SJohn Forte  *
3036*fcf3ce44SJohn Forte  * accessState	- MP_ACCESS_STATE_TYPE values
3037*fcf3ce44SJohn Forte  *
3038*fcf3ce44SJohn Forte  * ****************************************************************************
3039*fcf3ce44SJohn Forte  */
3040*fcf3ce44SJohn Forte char *
3041*fcf3ce44SJohn Forte getAccessStateStr(MP_ACCESS_STATE_TYPE accessState)
3042*fcf3ce44SJohn Forte {
3043*fcf3ce44SJohn Forte 	char					*accessString;
3044*fcf3ce44SJohn Forte 
3045*fcf3ce44SJohn Forte 	switch (accessState) {
3046*fcf3ce44SJohn Forte 		case MP_ACCESS_STATE_ACTIVE_OPTIMIZED:
3047*fcf3ce44SJohn Forte 			accessString =
3048*fcf3ce44SJohn Forte 			    getTextString(TEXT_ACCESS_STATE_ACTIVE_OPTIMIZED);
3049*fcf3ce44SJohn Forte 			break;
3050*fcf3ce44SJohn Forte 		case MP_ACCESS_STATE_ACTIVE_NONOPTIMIZED:
3051*fcf3ce44SJohn Forte 			accessString =
3052*fcf3ce44SJohn Forte 			    getTextString(
3053*fcf3ce44SJohn Forte 			    TEXT_ACCESS_STATE_ACTIVE_NONOPTIMIZED);
3054*fcf3ce44SJohn Forte 			break;
3055*fcf3ce44SJohn Forte 		case MP_ACCESS_STATE_STANDBY:
3056*fcf3ce44SJohn Forte 			accessString =
3057*fcf3ce44SJohn Forte 			    getTextString(TEXT_ACCESS_STATE_STANDBY);
3058*fcf3ce44SJohn Forte 			break;
3059*fcf3ce44SJohn Forte 		case MP_ACCESS_STATE_UNAVAILABLE:
3060*fcf3ce44SJohn Forte 			accessString =
3061*fcf3ce44SJohn Forte 			    getTextString(TEXT_ACCESS_STATE_UNAVAILABLE);
3062*fcf3ce44SJohn Forte 			break;
3063*fcf3ce44SJohn Forte 		case MP_ACCESS_STATE_TRANSITIONING:
3064*fcf3ce44SJohn Forte 			accessString =
3065*fcf3ce44SJohn Forte 			    getTextString(TEXT_ACCESS_STATE_TRANSITIONING);
3066*fcf3ce44SJohn Forte 			break;
3067*fcf3ce44SJohn Forte 		case MP_ACCESS_STATE_ACTIVE:
3068*fcf3ce44SJohn Forte 			accessString = getTextString(TEXT_ACCESS_STATE_ACTIVE);
3069*fcf3ce44SJohn Forte 			break;
3070*fcf3ce44SJohn Forte 		default:
3071*fcf3ce44SJohn Forte 			accessString = getTextString(TEXT_UNKNOWN);
3072*fcf3ce44SJohn Forte 			break;
3073*fcf3ce44SJohn Forte 	}
3074*fcf3ce44SJohn Forte 	return (accessString);
3075*fcf3ce44SJohn Forte } /* end getAccessStateStr */
3076*fcf3ce44SJohn Forte 
3077*fcf3ce44SJohn Forte 
3078*fcf3ce44SJohn Forte /*
3079*fcf3ce44SJohn Forte  * ****************************************************************************
3080*fcf3ce44SJohn Forte  *
3081*fcf3ce44SJohn Forte  * displayArray
3082*fcf3ce44SJohn Forte  * 	Print out the specified array.
3083*fcf3ce44SJohn Forte  *
3084*fcf3ce44SJohn Forte  * arrayToDisplay	- array to display
3085*fcf3ce44SJohn Forte  * arraySize		- size of array to display
3086*fcf3ce44SJohn Forte  *
3087*fcf3ce44SJohn Forte  * ****************************************************************************
3088*fcf3ce44SJohn Forte  */
3089*fcf3ce44SJohn Forte void
3090*fcf3ce44SJohn Forte displayArray(MP_CHAR *arrayToDisplay, int arraySize)
3091*fcf3ce44SJohn Forte {
3092*fcf3ce44SJohn Forte 	int					i;
3093*fcf3ce44SJohn Forte 
3094*fcf3ce44SJohn Forte 	for (i = 0; i < arraySize; i++) {
3095*fcf3ce44SJohn Forte 		if ('\0' != arrayToDisplay[i]) {
3096*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "%c", arrayToDisplay[i]);
3097*fcf3ce44SJohn Forte 		}
3098*fcf3ce44SJohn Forte 	}
3099*fcf3ce44SJohn Forte 
3100*fcf3ce44SJohn Forte }
3101*fcf3ce44SJohn Forte 
3102*fcf3ce44SJohn Forte 
3103*fcf3ce44SJohn Forte /*
3104*fcf3ce44SJohn Forte  * ****************************************************************************
3105*fcf3ce44SJohn Forte  *
3106*fcf3ce44SJohn Forte  * getStringArray
3107*fcf3ce44SJohn Forte  * 	Return a null terminated array for the specified array as a string,
3108*fcf3ce44SJohn Forte  *	This is used for inputting into the %s in formatted strings.
3109*fcf3ce44SJohn Forte  *
3110*fcf3ce44SJohn Forte  * arrayToDisplay	- array to display
3111*fcf3ce44SJohn Forte  * arraySize		- size of array to display
3112*fcf3ce44SJohn Forte  *
3113*fcf3ce44SJohn Forte  * ****************************************************************************
3114*fcf3ce44SJohn Forte  */
3115*fcf3ce44SJohn Forte MP_CHAR *
3116*fcf3ce44SJohn Forte getStringArray(MP_CHAR *arrayToDisplay, int arraySize)
3117*fcf3ce44SJohn Forte {
3118*fcf3ce44SJohn Forte 	MP_CHAR					*newStr;
3119*fcf3ce44SJohn Forte 
3120*fcf3ce44SJohn Forte 	int					i;
3121*fcf3ce44SJohn Forte 
3122*fcf3ce44SJohn Forte 	newStr = malloc(((sizeof (MP_CHAR)) * arraySize) + 1);
3123*fcf3ce44SJohn Forte 	if (NULL == newStr) {
3124*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%s\n",
3125*fcf3ce44SJohn Forte 		    getTextString(ERR_MEMORY_ALLOCATION));
3126*fcf3ce44SJohn Forte 	} else {
3127*fcf3ce44SJohn Forte 
3128*fcf3ce44SJohn Forte 		for (i = 0; i < arraySize; i++) {
3129*fcf3ce44SJohn Forte 			newStr[i] = arrayToDisplay[i];
3130*fcf3ce44SJohn Forte 		}
3131*fcf3ce44SJohn Forte 		newStr[arraySize] = '\0';
3132*fcf3ce44SJohn Forte 	}
3133*fcf3ce44SJohn Forte 
3134*fcf3ce44SJohn Forte 	return (newStr);
3135*fcf3ce44SJohn Forte }
3136*fcf3ce44SJohn Forte 
3137*fcf3ce44SJohn Forte 
3138*fcf3ce44SJohn Forte /*
3139*fcf3ce44SJohn Forte  * ****************************************************************************
3140*fcf3ce44SJohn Forte  *
3141*fcf3ce44SJohn Forte  * displayWideArray
3142*fcf3ce44SJohn Forte  * 	Print out the specified wide character array as a string,
3143*fcf3ce44SJohn Forte  * 	adding the null termination
3144*fcf3ce44SJohn Forte  *
3145*fcf3ce44SJohn Forte  * arrayToDisplay	- array to display
3146*fcf3ce44SJohn Forte  * arraySize		- size of array to display
3147*fcf3ce44SJohn Forte  *
3148*fcf3ce44SJohn Forte  * ****************************************************************************
3149*fcf3ce44SJohn Forte  */
3150*fcf3ce44SJohn Forte void
3151*fcf3ce44SJohn Forte displayWideArray(MP_WCHAR *arrayToDisplay, int arraySize)
3152*fcf3ce44SJohn Forte {
3153*fcf3ce44SJohn Forte 	int					i;
3154*fcf3ce44SJohn Forte 	int					numChars = arraySize/4;
3155*fcf3ce44SJohn Forte 
3156*fcf3ce44SJohn Forte 	for (i = 0; i < numChars; i++) {
3157*fcf3ce44SJohn Forte 		if (L'\0' != arrayToDisplay[i]) {
3158*fcf3ce44SJohn Forte 			(void) fprintf(stdout, "%wc", arrayToDisplay[i]);
3159*fcf3ce44SJohn Forte 		}
3160*fcf3ce44SJohn Forte 	}
3161*fcf3ce44SJohn Forte }
3162*fcf3ce44SJohn Forte 
3163*fcf3ce44SJohn Forte 
3164*fcf3ce44SJohn Forte /*
3165*fcf3ce44SJohn Forte  * ****************************************************************************
3166*fcf3ce44SJohn Forte  *
3167*fcf3ce44SJohn Forte  * listfunc
3168*fcf3ce44SJohn Forte  * 	Used by cmdparse for list clis
3169*fcf3ce44SJohn Forte  *
3170*fcf3ce44SJohn Forte  * ****************************************************************************
3171*fcf3ce44SJohn Forte  */
3172*fcf3ce44SJohn Forte /*ARGSUSED*/
3173*fcf3ce44SJohn Forte static int
3174*fcf3ce44SJohn Forte listFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
3175*fcf3ce44SJohn Forte     void *addArgs)
3176*fcf3ce44SJohn Forte {
3177*fcf3ce44SJohn Forte 	int 					ret = 0;
3178*fcf3ce44SJohn Forte 
3179*fcf3ce44SJohn Forte 	switch (object) {
3180*fcf3ce44SJohn Forte 		case MPATH_SUPPORT:
3181*fcf3ce44SJohn Forte 			ret = listMpathSupport(operandLen, operand);
3182*fcf3ce44SJohn Forte 			break;
3183*fcf3ce44SJohn Forte 		case LOGICAL_UNIT:
3184*fcf3ce44SJohn Forte 			ret = listLogicalUnit(operandLen, operand, options);
3185*fcf3ce44SJohn Forte 			break;
3186*fcf3ce44SJohn Forte 		case INITIATOR_PORT:
3187*fcf3ce44SJohn Forte 			ret = listInitiatorPort(operandLen, operand);
3188*fcf3ce44SJohn Forte 			break;
3189*fcf3ce44SJohn Forte 		default:
3190*fcf3ce44SJohn Forte 			(void) fprintf(stderr, "%s: %s\n",
3191*fcf3ce44SJohn Forte 		    cmdName, getTextString(TEXT_UNKNOWN_OBJECT));
3192*fcf3ce44SJohn Forte 			ret = 1;
3193*fcf3ce44SJohn Forte 			break;
3194*fcf3ce44SJohn Forte 	}
3195*fcf3ce44SJohn Forte 
3196*fcf3ce44SJohn Forte 	return (ret);
3197*fcf3ce44SJohn Forte }
3198*fcf3ce44SJohn Forte 
3199*fcf3ce44SJohn Forte 
3200*fcf3ce44SJohn Forte /*
3201*fcf3ce44SJohn Forte  * ****************************************************************************
3202*fcf3ce44SJohn Forte  *
3203*fcf3ce44SJohn Forte  * showFunc
3204*fcf3ce44SJohn Forte  * 	used bycmdparse for show clis
3205*fcf3ce44SJohn Forte  *
3206*fcf3ce44SJohn Forte  * ****************************************************************************
3207*fcf3ce44SJohn Forte  */
3208*fcf3ce44SJohn Forte /*ARGSUSED*/
3209*fcf3ce44SJohn Forte static int
3210*fcf3ce44SJohn Forte showFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
3211*fcf3ce44SJohn Forte     void *addArgs)
3212*fcf3ce44SJohn Forte {
3213*fcf3ce44SJohn Forte 	int 					ret = 0;
3214*fcf3ce44SJohn Forte 
3215*fcf3ce44SJohn Forte 	switch (object) {
3216*fcf3ce44SJohn Forte 		case MPATH_SUPPORT:
3217*fcf3ce44SJohn Forte 			ret = showMpathSupport(operandLen, operand);
3218*fcf3ce44SJohn Forte 			break;
3219*fcf3ce44SJohn Forte 		case LOGICAL_UNIT:
3220*fcf3ce44SJohn Forte 			ret = showLogicalUnit(operandLen, operand);
3221*fcf3ce44SJohn Forte 			break;
3222*fcf3ce44SJohn Forte 		case INITIATOR_PORT:
3223*fcf3ce44SJohn Forte 			ret = showInitiatorPort(operandLen, operand);
3224*fcf3ce44SJohn Forte 			break;
3225*fcf3ce44SJohn Forte 		default:
3226*fcf3ce44SJohn Forte 			ret = 1;
3227*fcf3ce44SJohn Forte 			break;
3228*fcf3ce44SJohn Forte 	}
3229*fcf3ce44SJohn Forte 
3230*fcf3ce44SJohn Forte 	return (ret);
3231*fcf3ce44SJohn Forte }
3232*fcf3ce44SJohn Forte 
3233*fcf3ce44SJohn Forte 
3234*fcf3ce44SJohn Forte /*
3235*fcf3ce44SJohn Forte  * ****************************************************************************
3236*fcf3ce44SJohn Forte  *
3237*fcf3ce44SJohn Forte  * modifyFunc
3238*fcf3ce44SJohn Forte  * 	Used by cmdparse for midify clis
3239*fcf3ce44SJohn Forte  *
3240*fcf3ce44SJohn Forte  *
3241*fcf3ce44SJohn Forte  * ****************************************************************************
3242*fcf3ce44SJohn Forte  */
3243*fcf3ce44SJohn Forte /*ARGSUSED*/
3244*fcf3ce44SJohn Forte static int
3245*fcf3ce44SJohn Forte modifyFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
3246*fcf3ce44SJohn Forte     void *addArgs)
3247*fcf3ce44SJohn Forte {
3248*fcf3ce44SJohn Forte 	int 					ret = 0;
3249*fcf3ce44SJohn Forte 
3250*fcf3ce44SJohn Forte 	switch (object) {
3251*fcf3ce44SJohn Forte 		case MPATH_SUPPORT:
3252*fcf3ce44SJohn Forte 			ret = modifyMpathSupport(operandLen, operand, options);
3253*fcf3ce44SJohn Forte 			break;
3254*fcf3ce44SJohn Forte 		case LOGICAL_UNIT:
3255*fcf3ce44SJohn Forte 			ret = modifyLogicalUnit(operandLen, operand, options);
3256*fcf3ce44SJohn Forte 			break;
3257*fcf3ce44SJohn Forte 		default:
3258*fcf3ce44SJohn Forte 			ret = 1;
3259*fcf3ce44SJohn Forte 			break;
3260*fcf3ce44SJohn Forte 	}
3261*fcf3ce44SJohn Forte 
3262*fcf3ce44SJohn Forte 
3263*fcf3ce44SJohn Forte 	return (ret);
3264*fcf3ce44SJohn Forte }
3265*fcf3ce44SJohn Forte 
3266*fcf3ce44SJohn Forte 
3267*fcf3ce44SJohn Forte /*
3268*fcf3ce44SJohn Forte  * ****************************************************************************
3269*fcf3ce44SJohn Forte  *
3270*fcf3ce44SJohn Forte  * enableFunc
3271*fcf3ce44SJohn Forte  * 	Used by cmdpars for enable clis
3272*fcf3ce44SJohn Forte  *
3273*fcf3ce44SJohn Forte  * ****************************************************************************
3274*fcf3ce44SJohn Forte  */
3275*fcf3ce44SJohn Forte /*ARGSUSED*/
3276*fcf3ce44SJohn Forte static int
3277*fcf3ce44SJohn Forte enableFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
3278*fcf3ce44SJohn Forte     void *addArgs)
3279*fcf3ce44SJohn Forte {
3280*fcf3ce44SJohn Forte 	int 					ret = 0;
3281*fcf3ce44SJohn Forte 
3282*fcf3ce44SJohn Forte 	switch (object) {
3283*fcf3ce44SJohn Forte 		case PATH:
3284*fcf3ce44SJohn Forte 			ret = enablePath(options);
3285*fcf3ce44SJohn Forte 			break;
3286*fcf3ce44SJohn Forte 		default:
3287*fcf3ce44SJohn Forte 			ret = 1;
3288*fcf3ce44SJohn Forte 			break;
3289*fcf3ce44SJohn Forte 	}
3290*fcf3ce44SJohn Forte 
3291*fcf3ce44SJohn Forte 	return (ret);
3292*fcf3ce44SJohn Forte }
3293*fcf3ce44SJohn Forte 
3294*fcf3ce44SJohn Forte 
3295*fcf3ce44SJohn Forte /*
3296*fcf3ce44SJohn Forte  * ****************************************************************************
3297*fcf3ce44SJohn Forte  *
3298*fcf3ce44SJohn Forte  * disableFunc
3299*fcf3ce44SJohn Forte  * 	Used by cmdpars for disable clis
3300*fcf3ce44SJohn Forte  *
3301*fcf3ce44SJohn Forte  * ****************************************************************************
3302*fcf3ce44SJohn Forte  */
3303*fcf3ce44SJohn Forte /*ARGSUSED*/
3304*fcf3ce44SJohn Forte static int
3305*fcf3ce44SJohn Forte disableFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
3306*fcf3ce44SJohn Forte     void *addArgs)
3307*fcf3ce44SJohn Forte {
3308*fcf3ce44SJohn Forte 	int 					ret = 0;
3309*fcf3ce44SJohn Forte 
3310*fcf3ce44SJohn Forte 	switch (object) {
3311*fcf3ce44SJohn Forte 		case PATH:
3312*fcf3ce44SJohn Forte 			ret = disablePath(options);
3313*fcf3ce44SJohn Forte 			break;
3314*fcf3ce44SJohn Forte 		default:
3315*fcf3ce44SJohn Forte 			ret = 1;
3316*fcf3ce44SJohn Forte 			break;
3317*fcf3ce44SJohn Forte 	}
3318*fcf3ce44SJohn Forte 
3319*fcf3ce44SJohn Forte 	return (ret);
3320*fcf3ce44SJohn Forte }
3321*fcf3ce44SJohn Forte 
3322*fcf3ce44SJohn Forte 
3323*fcf3ce44SJohn Forte /*
3324*fcf3ce44SJohn Forte  * ****************************************************************************
3325*fcf3ce44SJohn Forte  *
3326*fcf3ce44SJohn Forte  * failoverFunc
3327*fcf3ce44SJohn Forte  * 	Used by cmdpars for failover clis
3328*fcf3ce44SJohn Forte  *
3329*fcf3ce44SJohn Forte  * ****************************************************************************
3330*fcf3ce44SJohn Forte  */
3331*fcf3ce44SJohn Forte /*ARGSUSED*/
3332*fcf3ce44SJohn Forte static int
3333*fcf3ce44SJohn Forte failoverFunc(int operandLen, char *operand[], int object, cmdOptions_t *options,
3334*fcf3ce44SJohn Forte     void *addArgs)
3335*fcf3ce44SJohn Forte {
3336*fcf3ce44SJohn Forte 	int 					ret = 0;
3337*fcf3ce44SJohn Forte 
3338*fcf3ce44SJohn Forte 	switch (object) {
3339*fcf3ce44SJohn Forte 		case LOGICAL_UNIT:
3340*fcf3ce44SJohn Forte 			ret = failoverLogicalUnit(operand);
3341*fcf3ce44SJohn Forte 			break;
3342*fcf3ce44SJohn Forte 		default:
3343*fcf3ce44SJohn Forte 			ret = 1;
3344*fcf3ce44SJohn Forte 			break;
3345*fcf3ce44SJohn Forte 	}
3346*fcf3ce44SJohn Forte 
3347*fcf3ce44SJohn Forte 	return (ret);
3348*fcf3ce44SJohn Forte }
3349*fcf3ce44SJohn Forte 
3350*fcf3ce44SJohn Forte 
3351*fcf3ce44SJohn Forte /*
3352*fcf3ce44SJohn Forte  * ****************************************************************************
3353*fcf3ce44SJohn Forte  *
3354*fcf3ce44SJohn Forte  * overrideFunc
3355*fcf3ce44SJohn Forte  * 	Used by cmdpars for override clis
3356*fcf3ce44SJohn Forte  *
3357*fcf3ce44SJohn Forte  * ****************************************************************************
3358*fcf3ce44SJohn Forte  */
3359*fcf3ce44SJohn Forte /*ARGSUSED*/
3360*fcf3ce44SJohn Forte static int
3361*fcf3ce44SJohn Forte overrideFunc(int operandLen, char *operand[],
3362*fcf3ce44SJohn Forte 	int object, cmdOptions_t *options,
3363*fcf3ce44SJohn Forte     void *addArgs)
3364*fcf3ce44SJohn Forte {
3365*fcf3ce44SJohn Forte 	int 					ret = 0;
3366*fcf3ce44SJohn Forte 
3367*fcf3ce44SJohn Forte 	switch (object) {
3368*fcf3ce44SJohn Forte 		case PATH:
3369*fcf3ce44SJohn Forte 			ret = overridePath(options);
3370*fcf3ce44SJohn Forte 			break;
3371*fcf3ce44SJohn Forte 		default:
3372*fcf3ce44SJohn Forte 			ret = 1;
3373*fcf3ce44SJohn Forte 			break;
3374*fcf3ce44SJohn Forte 	}
3375*fcf3ce44SJohn Forte 
3376*fcf3ce44SJohn Forte 
3377*fcf3ce44SJohn Forte 	return (ret);
3378*fcf3ce44SJohn Forte }
3379*fcf3ce44SJohn Forte 
3380*fcf3ce44SJohn Forte 
3381*fcf3ce44SJohn Forte /*
3382*fcf3ce44SJohn Forte  * *************************************************************************
3383*fcf3ce44SJohn Forte  *
3384*fcf3ce44SJohn Forte  * main
3385*fcf3ce44SJohn Forte  *
3386*fcf3ce44SJohn Forte  * *************************************************************************
3387*fcf3ce44SJohn Forte  */
3388*fcf3ce44SJohn Forte int
3389*fcf3ce44SJohn Forte main(int argc, char *argv[])
3390*fcf3ce44SJohn Forte {
3391*fcf3ce44SJohn Forte 	synTables_t 			synTables;
3392*fcf3ce44SJohn Forte 	char 				versionString[VERSION_STRING_MAX_LEN];
3393*fcf3ce44SJohn Forte 	int 				ret;
3394*fcf3ce44SJohn Forte 	int 				funcRet;
3395*fcf3ce44SJohn Forte 	void 				*subcommandArgs = NULL;
3396*fcf3ce44SJohn Forte 
3397*fcf3ce44SJohn Forte 	/* set global command name */
3398*fcf3ce44SJohn Forte 	cmdName = getExecBasename(argv[0]);
3399*fcf3ce44SJohn Forte 
3400*fcf3ce44SJohn Forte 	(void) sprintf(versionString, "%2s.%2s",
3401*fcf3ce44SJohn Forte 	    VERSION_STRING_MAJOR, VERSION_STRING_MINOR);
3402*fcf3ce44SJohn Forte 	synTables.versionString = versionString;
3403*fcf3ce44SJohn Forte 	synTables.longOptionTbl = &longOptions[0];
3404*fcf3ce44SJohn Forte 	synTables.subcommandTbl = &subcommands[0];
3405*fcf3ce44SJohn Forte 	synTables.objectTbl = &objects[0];
3406*fcf3ce44SJohn Forte 	synTables.objectRulesTbl = &objectRules[0];
3407*fcf3ce44SJohn Forte 	synTables.optionRulesTbl = &optionRules[0];
3408*fcf3ce44SJohn Forte 
3409*fcf3ce44SJohn Forte 	ret = cmdParse(argc, argv, /* SUB_COMMAND_ISSUED, */ synTables,
3410*fcf3ce44SJohn Forte 	    subcommandArgs, &funcRet);
3411*fcf3ce44SJohn Forte 	if (ret == 1) {
3412*fcf3ce44SJohn Forte 		(void) fprintf(stdout, "%s %s(1M)\n",
3413*fcf3ce44SJohn Forte 		    getTextString(TEXT_MORE_INFO), cmdName);
3414*fcf3ce44SJohn Forte 		return (ERROR_CLI_FAILED);
3415*fcf3ce44SJohn Forte 	} else if (ret == -1) {
3416*fcf3ce44SJohn Forte 		perror(argv[0]);
3417*fcf3ce44SJohn Forte 		return (1);
3418*fcf3ce44SJohn Forte 	}
3419*fcf3ce44SJohn Forte 
3420*fcf3ce44SJohn Forte 	if (funcRet != 0) {
3421*fcf3ce44SJohn Forte 		(void) fprintf(stderr, "%s: %s\n",
3422*fcf3ce44SJohn Forte 		    argv[0], getTextString(TEXT_UNABLE_TO_COMPLETE));
3423*fcf3ce44SJohn Forte 		return (1);
3424*fcf3ce44SJohn Forte 	}
3425*fcf3ce44SJohn Forte 	return (0);
3426*fcf3ce44SJohn Forte 
3427*fcf3ce44SJohn Forte } /* end main */
3428