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