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