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