usr/src/cmd/mpathadm/mpathadm.c
changeset 10696 cd0f390dd9e2
parent 7916 0c19a39f2561
child 13687 72ce76fa37fb
equal deleted inserted replaced
10695:c2dc701391b4 10696:cd0f390dd9e2
    17  * information: Portions Copyright [yyyy] [name of copyright owner]
    17  * information: Portions Copyright [yyyy] [name of copyright owner]
    18  *
    18  *
    19  * CDDL HEADER END
    19  * CDDL HEADER END
    20  */
    20  */
    21 /*
    21 /*
    22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
    22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
    23  * Use is subject to license terms.
    23  * Use is subject to license terms.
    24  */
    24  */
    25 
    25 
    26 /*
    26 /*
    27  * mpathadm.c : MP API CLI program
    27  * mpathadm.c : MP API CLI program
   226 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
   226 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
   227 	MP_PLUGIN_PROPERTIES			pluginProps;
   227 	MP_PLUGIN_PROPERTIES			pluginProps;
   228 	MP_OID_LIST				*pPluginOidList;
   228 	MP_OID_LIST				*pPluginOidList;
   229 	boolean_t				shown = B_FALSE;
   229 	boolean_t				shown = B_FALSE;
   230 	/* number of plugins listed */
   230 	/* number of plugins listed */
   231 	int					i,
   231 	int					i, op;
   232 						op;
       
   233 
   232 
   234 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
   233 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
   235 	    != MP_STATUS_SUCCESS) {
   234 	    != MP_STATUS_SUCCESS) {
   236 		(void) fprintf(stderr, "%s: %s\n", cmdName,
   235 		(void) fprintf(stderr, "%s: %s\n", cmdName,
   237 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
   236 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
   274 						(void) printf("%s  %s\n",
   273 						(void) printf("%s  %s\n",
   275 						    getTextString(
   274 						    getTextString(
   276 						    TEXT_LB_MPATH_SUPPORT),
   275 						    TEXT_LB_MPATH_SUPPORT),
   277 						    pluginProps.fileName);
   276 						    pluginProps.fileName);
   278 					} else {
   277 					} else {
   279 					/* LINTED E_SEC_PRINTF_VAR_FMT */
   278 				/* begin back-up indentation */
   280 						(void) fprintf(stderr,
   279 				/* LINTED E_SEC_PRINTF_VAR_FMT */
   281 						    getTextString(
   280 				(void) fprintf(stderr, getTextString(
   282 				    ERR_CANT_FIND_MPATH_SUPPORT_WITH_NAME),
   281 				    ERR_CANT_FIND_MPATH_SUPPORT_WITH_NAME),
   283 						    operand[op]);
   282 				    operand[op]);
       
   283 				/* end back-up indentation */
   284 						(void) printf("\n");
   284 						(void) printf("\n");
   285 					}
   285 					}
   286 				}
   286 				}
   287 			}
   287 			}
   288 		}
   288 		}
   309 	MP_PLUGIN_PROPERTIES			pluginProps;
   309 	MP_PLUGIN_PROPERTIES			pluginProps;
   310 	MP_OID_LIST				*pPluginOidList;
   310 	MP_OID_LIST				*pPluginOidList;
   311 	MP_OID_LIST				*deviceOidListArray;
   311 	MP_OID_LIST				*deviceOidListArray;
   312 	MP_DEVICE_PRODUCT_PROPERTIES		devProps;
   312 	MP_DEVICE_PRODUCT_PROPERTIES		devProps;
   313 	boolean_t				bListIt = B_FALSE;
   313 	boolean_t				bListIt = B_FALSE;
   314 	int					op,
   314 	int					op, i, j;
   315 						i,
       
   316 						j;
       
   317 	MP_LOAD_BALANCE_TYPE 			lb;
   315 	MP_LOAD_BALANCE_TYPE 			lb;
   318 
   316 
   319 
   317 
   320 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList)) !=
   318 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList)) !=
   321 	    MP_STATUS_SUCCESS) {
   319 	    MP_STATUS_SUCCESS) {
   328 		    cmdName, getTextString(ERR_NO_MPATH_SUPPORT_LIST));
   326 		    cmdName, getTextString(ERR_NO_MPATH_SUPPORT_LIST));
   329 		return (ERROR_CLI_FAILED);
   327 		return (ERROR_CLI_FAILED);
   330 	}
   328 	}
   331 
   329 
   332 	for (op = 0; op < operandLen; op++) {
   330 	for (op = 0; op < operandLen; op++) {
   333 	    bListIt = B_FALSE;
   331 		bListIt = B_FALSE;
   334 
   332 
   335 		for (i = 0; i < pPluginOidList->oidCount; i++) {
   333 		for (i = 0; i < pPluginOidList->oidCount; i++) {
   336 
   334 
   337 			(void) memset(&pluginProps, 0,
   335 			(void) memset(&pluginProps, 0,
   338 			    sizeof (MP_PLUGIN_PROPERTIES));
   336 			    sizeof (MP_PLUGIN_PROPERTIES));
   375 			    sizeof (pluginProps.driverName));
   373 			    sizeof (pluginProps.driverName));
   376 			(void) printf("\n\t%s  ",
   374 			(void) printf("\n\t%s  ",
   377 			    getTextString(TEXT_LB_DEFAULT_LB));
   375 			    getTextString(TEXT_LB_DEFAULT_LB));
   378 			/* don't ignore load balance type none. */
   376 			/* don't ignore load balance type none. */
   379 			if (pluginProps.defaultloadBalanceType == 0) {
   377 			if (pluginProps.defaultloadBalanceType == 0) {
   380 			    (void) printf("%s",
   378 				(void) printf("%s",
   381 			    getTextString(TEXT_LBTYPE_NONE));
   379 				    getTextString(TEXT_LBTYPE_NONE));
   382 			} else {
   380 			} else {
   383 			    displayLoadBalanceString(
   381 				displayLoadBalanceString(
   384 			    pluginProps.defaultloadBalanceType);
   382 				    pluginProps.defaultloadBalanceType);
   385 			}
   383 			}
   386 			(void) printf("\n");
   384 			(void) printf("\n");
   387 
   385 
   388 
   386 
   389 			(void) printf("\t%s  \n",
   387 			(void) printf("\t%s  \n",
   390 			    getTextString(TEXT_LB_SUPPORTED_LB));
   388 			    getTextString(TEXT_LB_SUPPORTED_LB));
   391 			/* check each bit, display string if found set */
   389 			/* check each bit, display string if found set */
   392 			if (pluginProps.supportedLoadBalanceTypes == 0) {
   390 			if (pluginProps.supportedLoadBalanceTypes == 0) {
   393 				(void) printf("\t\t%s\n",
   391 				(void) printf("\t\t%s\n",
   394 					getTextString(TEXT_LBTYPE_NONE));
   392 				    getTextString(TEXT_LBTYPE_NONE));
   395 			} else {
   393 			} else {
   396 			    lb = 1;
   394 				lb = 1;
   397 			    do {
   395 				do {
   398 				if (0 != (lb &
   396 					if (0 != (lb & pluginProps.
   399 				    pluginProps.supportedLoadBalanceTypes)) {
   397 					    supportedLoadBalanceTypes)) {
   400 					(void) printf("\t\t");
   398 						(void) printf("\t\t");
   401 					displayLoadBalanceString(lb &
   399 						displayLoadBalanceString(lb &
   402 					pluginProps.supportedLoadBalanceTypes);
   400 						    pluginProps.
   403 					(void) printf("\n");
   401 						    supportedLoadBalanceTypes);
   404 				}
   402 						(void) printf("\n");
   405 				lb = lb<<1;
   403 					}
   406 			    } while (lb < 0x80000000);
   404 					lb = lb<<1;
       
   405 				} while (lb < 0x80000000);
   407 			}
   406 			}
   408 
   407 
   409 			(void) printf("\t%s  %s\n",
   408 			(void) printf("\t%s  %s\n",
   410 			    getTextString(TEXT_LB_ALLOWS_ACT_TPG),
   409 			    getTextString(TEXT_LB_ALLOWS_ACT_TPG),
   411 			    (MP_TRUE == pluginProps.canSetTPGAccess)?
   410 			    (MP_TRUE == pluginProps.canSetTPGAccess)?
   491 					break;
   490 					break;
   492 				}
   491 				}
   493 
   492 
   494 				for (j = 0; j < deviceOidListArray->oidCount;
   493 				for (j = 0; j < deviceOidListArray->oidCount;
   495 				    j++) {
   494 				    j++) {
   496 					(void) memset(&devProps, 0,
   495 				/* begin backup indentation */
   497 					sizeof (MP_DEVICE_PRODUCT_PROPERTIES));
   496 				(void) memset(&devProps, 0,
   498 
   497 				    sizeof (MP_DEVICE_PRODUCT_PROPERTIES));
       
   498 				/* end backup indentation */
   499 					if ((mpstatus =
   499 					if ((mpstatus =
   500 					    MP_GetDeviceProductProperties(\
   500 					    MP_GetDeviceProductProperties(\
   501 					    deviceOidListArray->oids[j],
   501 					    deviceOidListArray->oids[j],
   502 					    &devProps)) == MP_STATUS_SUCCESS) {
   502 					    &devProps)) == MP_STATUS_SUCCESS) {
   503 
   503 
   518 						    sizeof (devProps.revision));
   518 						    sizeof (devProps.revision));
   519 
   519 
   520 						(void) printf("\n\t\t%s\n",
   520 						(void) printf("\n\t\t%s\n",
   521 						    getTextString(
   521 						    getTextString(
   522 						    TEXT_LB_SUPPORTED_LB));
   522 						    TEXT_LB_SUPPORTED_LB));
   523 			if (devProps.supportedLoadBalanceTypes == 0) {
   523 		/* begin back-up indentation */
   524 				(void) printf("\t\t\t%s\n",
   524 		if (devProps.supportedLoadBalanceTypes == 0) {
   525 					getTextString(TEXT_LBTYPE_NONE));
   525 			(void) printf("\t\t\t%s\n",
   526 			} else {
   526 			    getTextString(TEXT_LBTYPE_NONE));
   527 			    lb = 1;
   527 		} else {
   528 			    do {
   528 			lb = 1;
       
   529 			do {
   529 				if (0 != (lb &
   530 				if (0 != (lb &
   530 				    devProps.supportedLoadBalanceTypes)) {
   531 				    devProps.supportedLoadBalanceTypes)) {
   531 					(void) printf("\t\t\t");
   532 					(void) printf("\t\t\t");
   532 					displayLoadBalanceString(lb &
   533 					displayLoadBalanceString(lb &
   533 					devProps.supportedLoadBalanceTypes);
   534 					    devProps.supportedLoadBalanceTypes);
   534 					(void) printf("\n");
   535 					(void) printf("\n");
   535 				}
   536 				}
   536 				lb = lb<<1;
   537 				lb = lb<<1;
   537 			    } while (lb < 0x80000000);
   538 			} while (lb < 0x80000000);
   538 			}
   539 		}
   539 
   540 		/* end back-up indentation */
   540 
       
   541 						(void) printf("\n");
   541 						(void) printf("\n");
   542 
   542 
   543 					} else {
   543 					} else {
   544 						(void) fprintf(stderr,
   544 						(void) fprintf(stderr,
   545 						    "%s:  %s\n", cmdName,
   545 						    "%s:  %s\n", cmdName,
   580  * ****************************************************************************
   580  * ****************************************************************************
   581  */
   581  */
   582 int
   582 int
   583 modifyMpathSupport(int operandLen, char *operand[], cmdOptions_t *options)
   583 modifyMpathSupport(int operandLen, char *operand[], cmdOptions_t *options)
   584 {
   584 {
   585 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
   585 	MP_STATUS		mpstatus = MP_STATUS_SUCCESS;
   586 	MP_PLUGIN_PROPERTIES			pluginProps;
   586 	MP_PLUGIN_PROPERTIES	pluginProps;
   587 	MP_OID_LIST				*pPluginOidList;
   587 	MP_OID_LIST		*pPluginOidList;
   588 	boolean_t				bFoundIt = B_FALSE;
   588 	boolean_t		bFoundIt = B_FALSE;
   589 	MP_OID					pluginOid;
   589 	MP_OID			pluginOid;
   590 	cmdOptions_t 				*optionList = options;
   590 	cmdOptions_t 		*optionList = options;
   591 	char					*cmdStr =
   591 	char			*cmdStr = getTextString(TEXT_UNKNOWN);
   592 						    getTextString(
   592 	int			op, i, lbValue;
   593 						    TEXT_UNKNOWN);
       
   594 	int					op,
       
   595 						i,
       
   596 						lbValue;
       
   597 
   593 
   598 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
   594 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
   599 	    != MP_STATUS_SUCCESS) {
   595 	    != MP_STATUS_SUCCESS) {
   600 		(void) fprintf(stderr, "%s: %s\n", cmdName,
   596 		(void) fprintf(stderr, "%s: %s\n", cmdName,
   601 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
   597 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
   643 			if (0 == strcasecmp(optionList->optarg,
   639 			if (0 == strcasecmp(optionList->optarg,
   644 			    getTextString(TEXT_ON))) {
   640 			    getTextString(TEXT_ON))) {
   645 				mpstatus =
   641 				mpstatus =
   646 				    MP_EnableAutoFailback(pluginOid);
   642 				    MP_EnableAutoFailback(pluginOid);
   647 			} else if (0 ==
   643 			} else if (0 ==
   648 				strcasecmp(optionList->optarg,
   644 			    strcasecmp(optionList->optarg,
   649 				    getTextString(TEXT_OFF))) {
   645 			    getTextString(TEXT_OFF))) {
   650 				mpstatus =
   646 				mpstatus =
   651 				    MP_DisableAutoFailback(pluginOid);
   647 				    MP_DisableAutoFailback(pluginOid);
   652 			} else {
   648 			} else {
   653 				/* LINTED E_SEC_PRINTF_VAR_FMT */
   649 				/* LINTED E_SEC_PRINTF_VAR_FMT */
   654 				(void) fprintf(stderr, getTextString(
   650 				(void) fprintf(stderr, getTextString(
   665 			if (0 == strcasecmp(optionList->optarg,
   661 			if (0 == strcasecmp(optionList->optarg,
   666 			    getTextString(TEXT_ON))) {
   662 			    getTextString(TEXT_ON))) {
   667 				mpstatus =
   663 				mpstatus =
   668 				    MP_EnableAutoProbing(pluginOid);
   664 				    MP_EnableAutoProbing(pluginOid);
   669 			} else if (0 ==
   665 			} else if (0 ==
   670 				strcasecmp(optionList->optarg,
   666 			    strcasecmp(optionList->optarg,
   671 				    getTextString(TEXT_OFF))) {
   667 			    getTextString(TEXT_OFF))) {
   672 				mpstatus =
   668 				mpstatus =
   673 				    MP_DisableAutoProbing(pluginOid);
   669 				    MP_DisableAutoProbing(pluginOid);
   674 			} else {
   670 			} else {
   675 				/* LINTED E_SEC_PRINTF_VAR_FMT */
   671 				/* LINTED E_SEC_PRINTF_VAR_FMT */
   676 				(void) fprintf(stderr, getTextString(
   672 				(void) fprintf(stderr, getTextString(
   736  * ****************************************************************************
   732  * ****************************************************************************
   737  */
   733  */
   738 int
   734 int
   739 listLogicalUnit(int operandLen, char *operand[], cmdOptions_t *options)
   735 listLogicalUnit(int operandLen, char *operand[], cmdOptions_t *options)
   740 {
   736 {
   741 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
   737 	MP_STATUS mpstatus = MP_STATUS_SUCCESS;
   742 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES	luProps;
   738 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES luProps;
   743 	MP_PLUGIN_PROPERTIES			pluginProps;
   739 	MP_PLUGIN_PROPERTIES pluginProps;
   744 	MP_TARGET_PORT_PROPERTIES		tportProps;
   740 	MP_TARGET_PORT_PROPERTIES tportProps;
   745 	MP_OID_LIST				*pPluginOidList,
   741 	MP_OID_LIST *pPluginOidList, *pLogicalUnitOidList,
   746 						*pLogicalUnitOidList,
   742 	    *pTpgOidListArray, *pTportOidListArray;
   747 						*pTpgOidListArray,
   743 	boolean_t bListIt = B_FALSE, bFoundOperand = B_FALSE,
   748 						*pTportOidListArray;
   744 	    *bFoundOption, bContinue = B_FALSE;
   749 	boolean_t				bListIt = B_FALSE,
   745 	MP_OID luOid;
   750 						bFoundOperand = B_FALSE,
   746 	cmdOptions_t *optionList = options;
   751 						*bFoundOption,
   747 	int opListCount = 0, i = 0, lu = 0, tpg = 0, opoffset = 0, j = 0,
   752 						bContinue = B_FALSE;
   748 	    opStart = 0, opEnd = 0, opIndex;
   753 	MP_OID					luOid;
       
   754 	cmdOptions_t 				*optionList = options;
       
   755 	int					opListCount = 0,
       
   756 						i = 0,
       
   757 						lu = 0,
       
   758 						tpg = 0,
       
   759 						opoffset = 0,
       
   760 						j = 0,
       
   761 						opStart = 0,
       
   762 						opEnd = 0,
       
   763 						opIndex;
       
   764 
   749 
   765 	/* count number of options */
   750 	/* count number of options */
   766 	for (; optionList->optval; optionList++) {
   751 	for (; optionList->optval; optionList++) {
   767 		opListCount++;
   752 		opListCount++;
   768 	}
   753 	}
   817 				    cmdName, getTextString(ERR_NO_LU_LIST));
   802 				    cmdName, getTextString(ERR_NO_LU_LIST));
   818 				return (mpstatus);
   803 				return (mpstatus);
   819 			}
   804 			}
   820 
   805 
   821 			for (lu = 0; lu < pLogicalUnitOidList->oidCount; lu++) {
   806 			for (lu = 0; lu < pLogicalUnitOidList->oidCount; lu++) {
   822 				/* get lu properties so we can check the name */
   807 			/* begin backup indentation */
   823 				(void) memset(&luProps, 0,
   808 			/* get lu properties so we can check the name */
   824 				sizeof (MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES));
   809 			(void) memset(&luProps, 0,
       
   810 			    sizeof (MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES));
       
   811 			/* end backup indentation */
   825 				mpstatus =
   812 				mpstatus =
   826 				    MP_GetMPLogicalUnitProperties(
   813 				    MP_GetMPLogicalUnitProperties(
   827 				    pLogicalUnitOidList->oids[lu],
   814 				    pLogicalUnitOidList->oids[lu],
   828 				    &luProps);
   815 				    &luProps);
   829 				if (mpstatus != MP_STATUS_SUCCESS) {
   816 				if (mpstatus != MP_STATUS_SUCCESS) {
   901 
   888 
   902 				for (lu = 0;
   889 				for (lu = 0;
   903 				    (lu < pLogicalUnitOidList->oidCount);
   890 				    (lu < pLogicalUnitOidList->oidCount);
   904 				    lu++) {
   891 				    lu++) {
   905 					bListIt = B_FALSE;
   892 					bListIt = B_FALSE;
   906 					/* get lu props & check the name */
   893 			/* begin backup indentation */
   907 					(void) memset(&luProps, 0,
   894 			/* get lu props & check the name */
   908 				sizeof (MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES));
   895 			(void) memset(&luProps, 0,
       
   896 			    sizeof (MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES));
       
   897 			/* end backup indentation */
   909 					mpstatus =
   898 					mpstatus =
   910 					    MP_GetMPLogicalUnitProperties(
   899 					    MP_GetMPLogicalUnitProperties(
   911 					    pLogicalUnitOidList->oids[lu],
   900 					    pLogicalUnitOidList->oids[lu],
   912 					    &luProps);
   901 					    &luProps);
   913 					if (mpstatus != MP_STATUS_SUCCESS) {
   902 					if (mpstatus != MP_STATUS_SUCCESS) {
   966 		    (NULL != pTpgOidListArray) &&
   955 		    (NULL != pTpgOidListArray) &&
   967 		    (tpg < pTpgOidListArray->oidCount) &&
   956 		    (tpg < pTpgOidListArray->oidCount) &&
   968 		    (B_FALSE == bListIt); tpg++) {
   957 		    (B_FALSE == bListIt); tpg++) {
   969 			mpstatus =
   958 			mpstatus =
   970 			    MP_GetTargetPortOidList(pTpgOidListArray->oids[tpg],
   959 			    MP_GetTargetPortOidList(pTpgOidListArray->oids[tpg],
   971 				&pTportOidListArray);
   960 			    &pTportOidListArray);
   972 			if (mpstatus != MP_STATUS_SUCCESS) {
   961 			if (mpstatus != MP_STATUS_SUCCESS) {
   973 				(void) fprintf(stderr, "%s:  %s\n",
   962 				(void) fprintf(stderr, "%s:  %s\n",
   974 				    cmdName,
   963 				    cmdName,
   975 				    getTextString(ERR_NO_ASSOC_TPORTS));
   964 				    getTextString(ERR_NO_ASSOC_TPORTS));
   976 				return (mpstatus);
   965 				return (mpstatus);
  1146 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES luProps)
  1135 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES luProps)
  1147 {
  1136 {
  1148 	MP_PATH_LOGICAL_UNIT_PROPERTIES		pathProps;
  1137 	MP_PATH_LOGICAL_UNIT_PROPERTIES		pathProps;
  1149 	MP_OID_LIST				*pPathOidListArray;
  1138 	MP_OID_LIST				*pPathOidListArray;
  1150 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  1139 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  1151 	int					numOperationalPaths,
  1140 	int					numOperationalPaths, pa;
  1152 						pa;
       
  1153 
  1141 
  1154 	(void) printf("\t");
  1142 	(void) printf("\t");
  1155 	displayArray(luProps.deviceFileName, sizeof (luProps.deviceFileName));
  1143 	displayArray(luProps.deviceFileName, sizeof (luProps.deviceFileName));
  1156 	(void) printf("\n");
  1144 	(void) printf("\n");
  1157 
  1145 
  1159 	    &pPathOidListArray);
  1147 	    &pPathOidListArray);
  1160 	if (mpstatus != MP_STATUS_SUCCESS) {
  1148 	if (mpstatus != MP_STATUS_SUCCESS) {
  1161 		/* LINTED E_SEC_PRINTF_VAR_FMT */
  1149 		/* LINTED E_SEC_PRINTF_VAR_FMT */
  1162 		(void) fprintf(stderr,
  1150 		(void) fprintf(stderr,
  1163 		    getTextString(ERR_NO_LU_PATH_INFO_WITH_MISSING_LU_STR),
  1151 		    getTextString(ERR_NO_LU_PATH_INFO_WITH_MISSING_LU_STR),
  1164 		getStringArray(luProps.deviceFileName,
  1152 		    getStringArray(luProps.deviceFileName,
  1165 		    sizeof (luProps.deviceFileName)));
  1153 		    sizeof (luProps.deviceFileName)));
  1166 		(void) fprintf(stderr, "\n");
  1154 		(void) fprintf(stderr, "\n");
  1167 		return (mpstatus);
  1155 		return (mpstatus);
  1168 	}
  1156 	}
  1169 	(void) printf("\t\t%s %d\n",
  1157 	(void) printf("\t\t%s %d\n",
  1211 showLogicalUnit(int operandLen, char *operand[])
  1199 showLogicalUnit(int operandLen, char *operand[])
  1212 {
  1200 {
  1213 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  1201 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  1214 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES	luProps;
  1202 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES	luProps;
  1215 	MP_PLUGIN_PROPERTIES			pluginProps;
  1203 	MP_PLUGIN_PROPERTIES			pluginProps;
  1216 	MP_OID					luOid,
  1204 	MP_OID					luOid, pluginOid;
  1217 						pluginOid;
       
  1218 
  1205 
  1219 	int					op;
  1206 	int					op;
  1220 
  1207 
  1221 	for (op = 0; op < operandLen; op++) {
  1208 	for (op = 0; op < operandLen; op++) {
  1222 		if (op > 0) {
  1209 		if (op > 0) {
  1290 {
  1277 {
  1291 	MP_PATH_LOGICAL_UNIT_PROPERTIES		pathProps;
  1278 	MP_PATH_LOGICAL_UNIT_PROPERTIES		pathProps;
  1292 	MP_TARGET_PORT_GROUP_PROPERTIES		tpgProps;
  1279 	MP_TARGET_PORT_GROUP_PROPERTIES		tpgProps;
  1293 	MP_TARGET_PORT_PROPERTIES 		tportProps;
  1280 	MP_TARGET_PORT_PROPERTIES 		tportProps;
  1294 	MP_INITIATOR_PORT_PROPERTIES 		initProps;
  1281 	MP_INITIATOR_PORT_PROPERTIES 		initProps;
  1295 	MP_OID_LIST				*pPathOidListArray,
  1282 	MP_OID_LIST	*pPathOidListArray, *pTPGOidListArray,
  1296 						*pTPGOidListArray,
  1283 	    *pTportOidListArray;
  1297 						*pTportOidListArray;
       
  1298 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  1284 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  1299 	boolean_t				showTportLabel = B_TRUE;
  1285 	boolean_t				showTportLabel = B_TRUE;
  1300 
  1286 
  1301 	int					pa,
  1287 	int					pa, tpg, tport;
  1302 						tpg,
       
  1303 						tport;
       
  1304 
  1288 
  1305 	(void) printf("%s  ", getTextString(TEXT_LB_LOGICAL_UNIT));
  1289 	(void) printf("%s  ", getTextString(TEXT_LB_LOGICAL_UNIT));
  1306 	displayArray(luProps.deviceFileName, sizeof (luProps.deviceFileName));
  1290 	displayArray(luProps.deviceFileName, sizeof (luProps.deviceFileName));
  1307 	(void) printf("\n");
  1291 	(void) printf("\n");
  1308 	(void) printf("\t%s  %s\n", getTextString(TEXT_LB_MPATH_SUPPORT),
  1292 	(void) printf("\t%s  %s\n", getTextString(TEXT_LB_MPATH_SUPPORT),
  1309 		pluginProps.fileName);
  1293 	    pluginProps.fileName);
  1310 
  1294 
  1311 	(void) printf("\t%s  ", getTextString(TEXT_LB_VENDOR));
  1295 	(void) printf("\t%s  ", getTextString(TEXT_LB_VENDOR));
  1312 	displayArray(luProps.vendor,
  1296 	displayArray(luProps.vendor,
  1313 	    sizeof (luProps.vendor));
  1297 	    sizeof (luProps.vendor));
  1314 	(void) printf("\n\t%s  ", getTextString(TEXT_LB_PRODUCT));
  1298 	(void) printf("\n\t%s  ", getTextString(TEXT_LB_PRODUCT));
  1465 					    getTextString(
  1449 					    getTextString(
  1466 					    TEXT_LB_ACCESS_STATE),
  1450 					    TEXT_LB_ACCESS_STATE),
  1467 					    getAccessStateStr(
  1451 					    getAccessStateStr(
  1468 					    tpgProps.accessState));
  1452 					    tpgProps.accessState));
  1469 					    /* display label for each tpg. */
  1453 					    /* display label for each tpg. */
  1470 					    (void) printf("\t\t%s\n",
  1454 					(void) printf("\t\t%s\n",
  1471 						getTextString(TEXT_TPORT_LIST));
  1455 					    getTextString(TEXT_TPORT_LIST));
  1472 				} else {
  1456 				} else {
  1473 					/* display label once for symmetric. */
  1457 					/* display label once for symmetric. */
  1474 					if (B_TRUE == showTportLabel) {
  1458 					if (B_TRUE == showTportLabel) {
  1475 						(void) printf("\t%s\n",
  1459 					/* begin back-up indentation */
  1476 						getTextString(TEXT_TPORT_LIST));
  1460 					(void) printf("\t%s\n",
  1477 						showTportLabel = B_FALSE;
  1461 					    getTextString(TEXT_TPORT_LIST));
       
  1462 					showTportLabel = B_FALSE;
       
  1463 					/* end back-up indentation */
  1478 					}
  1464 					}
  1479 				}
  1465 				}
  1480 
  1466 
  1481 				/* get target port info */
  1467 				/* get target port info */
  1482 				mpstatus = MP_GetTargetPortOidList(
  1468 				mpstatus = MP_GetTargetPortOidList(
  1494 		    sizeof (MP_TARGET_PORT_PROPERTIES));
  1480 		    sizeof (MP_TARGET_PORT_PROPERTIES));
  1495 		if ((mpstatus =
  1481 		if ((mpstatus =
  1496 		    MP_GetTargetPortProperties(pTportOidListArray->oids[tport],
  1482 		    MP_GetTargetPortProperties(pTportOidListArray->oids[tport],
  1497 		    &tportProps)) != MP_STATUS_SUCCESS) {
  1483 		    &tportProps)) != MP_STATUS_SUCCESS) {
  1498 			(void) fprintf(stderr, "%s:  %s",
  1484 			(void) fprintf(stderr, "%s:  %s",
  1499 			cmdName, getTextString(ERR_NO_PROPERTIES));
  1485 			    cmdName, getTextString(ERR_NO_PROPERTIES));
  1500 		} else {
  1486 		} else {
  1501 			if (MP_TRUE == luProps.asymmetric) {
  1487 			if (MP_TRUE == luProps.asymmetric) {
  1502 				(void) printf("\t\t\t%s  ",
  1488 				(void) printf("\t\t\t%s  ",
  1503 				getTextString(TEXT_LB_NAME));
  1489 				    getTextString(TEXT_LB_NAME));
  1504 				displayArray(tportProps.portID,
  1490 				displayArray(tportProps.portID,
  1505 					sizeof (tportProps.portID));
  1491 				    sizeof (tportProps.portID));
  1506 				(void) printf("\n\t\t\t%s  %d\n",
  1492 				(void) printf("\n\t\t\t%s  %d\n",
  1507 				getTextString(TEXT_LB_RELATIVE_ID),
  1493 				    getTextString(TEXT_LB_RELATIVE_ID),
  1508 				tportProps.relativePortID);
  1494 				    tportProps.relativePortID);
  1509 			} else {
  1495 			} else {
  1510 				(void) printf("\t\t%s  ",
  1496 				(void) printf("\t\t%s  ",
  1511 				getTextString(TEXT_LB_NAME));
  1497 				    getTextString(TEXT_LB_NAME));
  1512 				displayArray(tportProps.portID,
  1498 				displayArray(tportProps.portID,
  1513 					sizeof (tportProps.portID));
  1499 				    sizeof (tportProps.portID));
  1514 				(void) printf("\n\t\t%s  %d\n",
  1500 				(void) printf("\n\t\t%s  %d\n",
  1515 				getTextString(TEXT_LB_RELATIVE_ID),
  1501 				    getTextString(TEXT_LB_RELATIVE_ID),
  1516 				tportProps.relativePortID);
  1502 				    tportProps.relativePortID);
  1517 			}
  1503 			}
  1518 			/* insert blank line if not the last target port. */
  1504 			/* insert blank line if not the last target port. */
  1519 			if (!(tport == (pTportOidListArray->oidCount - 1))) {
  1505 			if (!(tport == (pTportOidListArray->oidCount - 1))) {
  1520 			    (void) printf("\n");
  1506 				(void) printf("\n");
  1521 			}
  1507 			}
  1522 		}
  1508 		}
  1523 	} /* for each target port */
  1509 	} /* for each target port */
  1524 /* end back-up indentation */
  1510 /* end back-up indentation */
  1525 
  1511 
  1549 modifyLogicalUnit(int operandLen, char *operand[], cmdOptions_t *options)
  1535 modifyLogicalUnit(int operandLen, char *operand[], cmdOptions_t *options)
  1550 {
  1536 {
  1551 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  1537 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  1552 	MP_OID					luOid;
  1538 	MP_OID					luOid;
  1553 	cmdOptions_t 				*optionList = options;
  1539 	cmdOptions_t 				*optionList = options;
  1554 	char					*cmdStr =
  1540 	char	*cmdStr = getTextString(TEXT_UNKNOWN);
  1555 						    getTextString(
       
  1556 						    TEXT_UNKNOWN);
       
  1557 	int					op;
  1541 	int					op;
  1558 
  1542 
  1559 	for (op = 0; op < operandLen; op++) {
  1543 	for (op = 0; op < operandLen; op++) {
  1560 		if (B_TRUE != getLogicalUnitOid(operand[op], &luOid)) {
  1544 		if (B_TRUE != getLogicalUnitOid(operand[op], &luOid)) {
  1561 			/* LINTED E_SEC_PRINTF_VAR_FMT */
  1545 			/* LINTED E_SEC_PRINTF_VAR_FMT */
  1578 				} else if (0 == strcasecmp(optionList->optarg,
  1562 				} else if (0 == strcasecmp(optionList->optarg,
  1579 				    getTextString(TEXT_OFF))) {
  1563 				    getTextString(TEXT_OFF))) {
  1580 					mpstatus =
  1564 					mpstatus =
  1581 					    MP_DisableAutoFailback(luOid);
  1565 					    MP_DisableAutoFailback(luOid);
  1582 				} else {
  1566 				} else {
  1583 					/* LINTED E_SEC_PRINTF_VAR_FMT */
  1567 				/* begin back-up indentation */
  1584 					(void) fprintf(stderr, getTextString(
  1568 				/* LINTED E_SEC_PRINTF_VAR_FMT */
       
  1569 				(void) fprintf(stderr, getTextString(
  1585 				    ERR_FAILED_TO_CHANGE_OPTION_WITH_REASON),
  1570 				    ERR_FAILED_TO_CHANGE_OPTION_WITH_REASON),
  1586 					    cmdStr,
  1571 				    cmdStr, getTextString(
  1587 					    getTextString(
  1572 				    TEXT_ILLEGAL_ARGUMENT));
  1588 					    TEXT_ILLEGAL_ARGUMENT));
  1573 				(void) printf("\n");
  1589 					(void) printf("\n");
  1574 				return (ERROR_CLI_FAILED);
  1590 					return (ERROR_CLI_FAILED);
  1575 				/* start back-up indentation */
  1591 				}
  1576 				}
  1592 				break;
  1577 				break;
  1593 			case 'p':
  1578 			case 'p':
  1594 				/* modify autoprobing */
  1579 				/* modify autoprobing */
  1595 				cmdStr = getTextString(TEXT_AUTO_PROBING);
  1580 				cmdStr = getTextString(TEXT_AUTO_PROBING);
  1596 				if (0 == strcasecmp(optionList->optarg,
  1581 				if (0 == strcasecmp(optionList->optarg,
  1597 				    getTextString(TEXT_ON))) {
  1582 				    getTextString(TEXT_ON))) {
  1598 					mpstatus =
  1583 					mpstatus =
  1599 					    MP_EnableAutoProbing(luOid);
  1584 					    MP_EnableAutoProbing(luOid);
  1600 				} else if (0 == strcasecmp(optionList->optarg,
  1585 				} else if (0 == strcasecmp(optionList->optarg,
  1601 					getTextString(TEXT_OFF))) {
  1586 				    getTextString(TEXT_OFF))) {
  1602 					mpstatus =
  1587 					mpstatus =
  1603 					    MP_DisableAutoProbing(luOid);
  1588 					    MP_DisableAutoProbing(luOid);
  1604 				} else {
  1589 				} else {
  1605 					/* LINTED E_SEC_PRINTF_VAR_FMT */
  1590 				/* begin back-up indentation */
  1606 					(void) fprintf(stderr, getTextString(
  1591 				/* LINTED E_SEC_PRINTF_VAR_FMT */
       
  1592 				(void) fprintf(stderr, getTextString(
  1607 				    ERR_FAILED_TO_CHANGE_OPTION_WITH_REASON),
  1593 				    ERR_FAILED_TO_CHANGE_OPTION_WITH_REASON),
  1608 					    cmdStr,
  1594 				    cmdStr, getTextString(
  1609 					    getTextString(
  1595 				    TEXT_ILLEGAL_ARGUMENT));
  1610 					    TEXT_ILLEGAL_ARGUMENT));
  1596 				(void) printf("\n");
  1611 					(void) printf("\n");
  1597 				return (ERROR_CLI_FAILED);
  1612 					return (ERROR_CLI_FAILED);
  1598 				/* end back-up indentation */
  1613 				}
  1599 				}
  1614 				break;
  1600 				break;
  1615 			case 'b':
  1601 			case 'b':
  1616 				/* modify loadbalance type */
  1602 				/* modify loadbalance type */
  1617 				cmdStr = getTextString(TEXT_LOAD_BALANCE);
  1603 				cmdStr = getTextString(TEXT_LOAD_BALANCE);
  1687 	/* get TPGs for this LUN */
  1673 	/* get TPGs for this LUN */
  1688 	mpstatus =
  1674 	mpstatus =
  1689 	    MP_GetAssociatedTPGOidList(luOid, &pTpgOidListArray);
  1675 	    MP_GetAssociatedTPGOidList(luOid, &pTpgOidListArray);
  1690 	if (mpstatus != MP_STATUS_SUCCESS) {
  1676 	if (mpstatus != MP_STATUS_SUCCESS) {
  1691 		(void) fprintf(stderr, "%s:  %s\n",
  1677 		(void) fprintf(stderr, "%s:  %s\n",
  1692 		cmdName, getTextString(ERR_NO_ASSOC_TPGS));
  1678 		    cmdName, getTextString(ERR_NO_ASSOC_TPGS));
  1693 		return (mpstatus);
  1679 		return (mpstatus);
  1694 	}
  1680 	}
  1695 
  1681 
  1696 	/* pick a TPG whose state is active or standby, and change it */
  1682 	/* pick a TPG whose state is active or standby, and change it */
  1697 	/* to opposite via MP_SetTPGAccessState */
  1683 	/* to opposite via MP_SetTPGAccessState */
  1707 			    cmdName, getTextString(ERR_NO_PROPERTIES));
  1693 			    cmdName, getTextString(ERR_NO_PROPERTIES));
  1708 			return (ERROR_CLI_FAILED);
  1694 			return (ERROR_CLI_FAILED);
  1709 		}
  1695 		}
  1710 		if (MP_FALSE == tpgProps.explicitFailover) {
  1696 		if (MP_FALSE == tpgProps.explicitFailover) {
  1711 			(void) fprintf(stderr, "%s:  %s\n",
  1697 			(void) fprintf(stderr, "%s:  %s\n",
  1712 			cmdName, getTextString(ERR_NO_FAILOVER_ALLOWED));
  1698 			    cmdName, getTextString(ERR_NO_FAILOVER_ALLOWED));
  1713 			return (ERROR_CLI_FAILED);
  1699 			return (ERROR_CLI_FAILED);
  1714 		}
  1700 		}
  1715 
  1701 
  1716 		/* find one that is standby */
  1702 		/* find one that is standby */
  1717 		if ((MP_ACCESS_STATE_STANDBY ==
  1703 		if ((MP_ACCESS_STATE_STANDBY ==
  1724 			tpgStatePair.desiredState =
  1710 			tpgStatePair.desiredState =
  1725 			    MP_ACCESS_STATE_ACTIVE;
  1711 			    MP_ACCESS_STATE_ACTIVE;
  1726 			mpstatus =
  1712 			mpstatus =
  1727 			    MP_SetTPGAccess(luOid, 1, &tpgStatePair);
  1713 			    MP_SetTPGAccess(luOid, 1, &tpgStatePair);
  1728 			if (MP_STATUS_SUCCESS != mpstatus) {
  1714 			if (MP_STATUS_SUCCESS != mpstatus) {
  1729 				/* LINTED E_SEC_PRINTF_VAR_FMT */
  1715 			/* begin back-up indentation */
  1730 				(void) fprintf(stderr, getTextString(
  1716 			/* LINTED E_SEC_PRINTF_VAR_FMT */
       
  1717 			(void) fprintf(stderr, getTextString(
  1731 			    ERR_FAILED_TO_FAILOVER_WITH_REASON),
  1718 			    ERR_FAILED_TO_FAILOVER_WITH_REASON),
  1732 			    getMpStatusStr(mpstatus));
  1719 			    getMpStatusStr(mpstatus));
  1733 				(void) printf("\n");
  1720 			(void) printf("\n");
  1734 				return (mpstatus);
  1721 			return (mpstatus);
       
  1722 			/* end back-up indentation */
  1735 			}
  1723 			}
  1736 		}
  1724 		}
  1737 
  1725 
  1738 
  1726 
  1739 	} /* for each tpg */
  1727 	} /* for each tpg */
  1763 getLogicalUnitOid(MP_CHAR *luFileName, MP_OID *pluOid)
  1751 getLogicalUnitOid(MP_CHAR *luFileName, MP_OID *pluOid)
  1764 {
  1752 {
  1765 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  1753 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  1766 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES	luProps;
  1754 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES	luProps;
  1767 	MP_PLUGIN_PROPERTIES			pluginProps;
  1755 	MP_PLUGIN_PROPERTIES			pluginProps;
  1768 	MP_OID_LIST				*pPluginOidList,
  1756 	MP_OID_LIST	*pPluginOidList, *pLogicalUnitOidList;
  1769 						*pLogicalUnitOidList;
       
  1770 	boolean_t				foundIt = B_FALSE;
  1757 	boolean_t				foundIt = B_FALSE;
  1771 
  1758 
  1772 	int					i,
  1759 	int					i, lu;
  1773 						lu;
       
  1774 
  1760 
  1775 	int 					fd1, fd2;
  1761 	int 					fd1, fd2;
  1776 	ddi_devid_t				devid1 = NULL, devid2 = NULL;
  1762 	ddi_devid_t				devid1, devid2;
  1777 
  1763 
  1778 	if (NULL == pluOid) {
  1764 	if (NULL == pluOid) {
  1779 		/* print some kind of error msg here - should never happen */
  1765 		/* print some kind of error msg here - should never happen */
  1780 		/* LINTED E_SEC_PRINTF_VAR_FMT */
  1766 		/* LINTED E_SEC_PRINTF_VAR_FMT */
  1781 		(void) fprintf(stderr, getTextString(ERR_MEMORY_ALLOCATION));
  1767 		(void) fprintf(stderr, getTextString(ERR_MEMORY_ALLOCATION));
  1786 	pluOid->objectSequenceNumber = 0;
  1772 	pluOid->objectSequenceNumber = 0;
  1787 	pluOid->objectType = 0;
  1773 	pluOid->objectType = 0;
  1788 	pluOid->ownerId = 0;
  1774 	pluOid->ownerId = 0;
  1789 
  1775 
  1790 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
  1776 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
  1791 		!= MP_STATUS_SUCCESS) {
  1777 	    != MP_STATUS_SUCCESS) {
  1792 		(void) fprintf(stderr, "%s: %s\n", cmdName,
  1778 		(void) fprintf(stderr, "%s: %s\n", cmdName,
  1793 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
  1779 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
  1794 		return (B_FALSE);
  1780 		return (B_FALSE);
  1795 	}
  1781 	}
  1796 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
  1782 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
  1797 		(void) fprintf(stderr, "%s: %s\n", cmdName,
  1783 		(void) fprintf(stderr, "%s: %s\n", cmdName,
  1798 		getTextString(ERR_NO_MPATH_SUPPORT_LIST));
  1784 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
  1799 		return (ERROR_CLI_FAILED);
  1785 		return (ERROR_CLI_FAILED);
  1800 	}
  1786 	}
  1801 	for (i = 0; i < pPluginOidList->oidCount; i++) {
  1787 	for (i = 0; i < pPluginOidList->oidCount; i++) {
  1802 
  1788 
  1803 		/* get properties so we can list the name */
  1789 		/* get properties so we can list the name */
  1804 		(void) memset(&pluginProps, 0, sizeof (MP_PLUGIN_PROPERTIES));
  1790 		(void) memset(&pluginProps, 0, sizeof (MP_PLUGIN_PROPERTIES));
  1805 		if ((mpstatus =
  1791 		if ((mpstatus =
  1806 		    MP_GetPluginProperties(pPluginOidList->oids[i],
  1792 		    MP_GetPluginProperties(pPluginOidList->oids[i],
  1807 		    &pluginProps)) != MP_STATUS_SUCCESS) {
  1793 		    &pluginProps)) != MP_STATUS_SUCCESS) {
  1808 				(void) fprintf(stderr, "%s:  %s\n",
  1794 			(void) fprintf(stderr, "%s:  %s\n",
  1809 				    cmdName, getTextString(ERR_NO_PROPERTIES));
  1795 			    cmdName, getTextString(ERR_NO_PROPERTIES));
  1810 				return (B_FALSE);
  1796 			return (B_FALSE);
  1811 		}
  1797 		}
  1812 
  1798 
  1813 		/* attempt to find this logical unit */
  1799 		/* attempt to find this logical unit */
  1814 		mpstatus = MP_GetMultipathLus(pPluginOidList->oids[i],
  1800 		mpstatus = MP_GetMultipathLus(pPluginOidList->oids[i],
  1815 		    &pLogicalUnitOidList);
  1801 		    &pLogicalUnitOidList);
  1832 				(void) fprintf(stderr, "%s:  %s\n",
  1818 				(void) fprintf(stderr, "%s:  %s\n",
  1833 				    cmdName, getTextString(ERR_NO_PROPERTIES));
  1819 				    cmdName, getTextString(ERR_NO_PROPERTIES));
  1834 				return (B_FALSE);
  1820 				return (B_FALSE);
  1835 			}
  1821 			}
  1836 
  1822 
  1837 			if (0 == strcmp(luFileName, luProps.deviceFileName)) {
  1823 			if (compareLUName(luFileName, luProps.deviceFileName)
       
  1824 			    == B_TRUE) {
  1838 				foundIt = B_TRUE;
  1825 				foundIt = B_TRUE;
  1839 			} else {
  1826 			} else {
  1840 				/* user input didn't match, try via devid */
  1827 				/* user input didn't match, try via devid */
  1841 				/*
  1828 				/*
  1842 				 * I don't see a reason to print the error for
  1829 				 * I don't see a reason to print the error for
  1843 				 * any of these since they'll get the error at
  1830 				 * any of these since they'll get the error at
  1844 				 * the end anyway
  1831 				 * the end anyway
  1845 				 */
  1832 				 */
  1846 
  1833 
  1847 				fd1 = fd2 = -1;
  1834 				fd1 = fd2 = -1;
       
  1835 				devid1 = devid2 = NULL;
  1848 				if (((fd1 = open(luFileName,
  1836 				if (((fd1 = open(luFileName,
  1849 					O_RDONLY|O_NDELAY)) >= 0) &&
  1837 				    O_RDONLY|O_NDELAY)) >= 0) &&
  1850 				    ((fd2 = open(luProps.deviceFileName,
  1838 				    ((fd2 = open(luProps.deviceFileName,
  1851 					O_RDONLY|O_NDELAY)) >= 0) &&
  1839 				    O_RDONLY|O_NDELAY)) >= 0) &&
  1852 				    (devid_get(fd1, &devid1) == 0) &&
  1840 				    (devid_get(fd1, &devid1) == 0) &&
  1853 				    (devid_get(fd2, &devid2) == 0) &&
  1841 				    (devid_get(fd2, &devid2) == 0) &&
  1854 				    ((NULL != devid1) && (NULL != devid2))) {
  1842 				    ((NULL != devid1) && (NULL != devid2))) {
  1855 					if (0 ==
  1843 					if (0 ==
  1856 					    (devid_compare(devid1, devid2))) {
  1844 					    (devid_compare(devid1, devid2))) {
  1903 int
  1891 int
  1904 listInitiatorPort(int operandLen, char *operand[])
  1892 listInitiatorPort(int operandLen, char *operand[])
  1905 {
  1893 {
  1906 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  1894 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  1907 	MP_INITIATOR_PORT_PROPERTIES 		initProps;
  1895 	MP_INITIATOR_PORT_PROPERTIES 		initProps;
  1908 	MP_OID_LIST				*pPluginOidList,
  1896 	MP_OID_LIST	*pPluginOidList, *pInitOidList;
  1909 						*pInitOidList;
       
  1910 	boolean_t				bListIt = B_FALSE;
  1897 	boolean_t				bListIt = B_FALSE;
  1911 	boolean_t				*foundOp;
  1898 	boolean_t				*foundOp;
  1912 
  1899 
  1913 	int					ol,
  1900 	int		ol, i, iport;
  1914 						i,
       
  1915 						iport;
       
  1916 
  1901 
  1917 	foundOp = malloc((sizeof (boolean_t)) * operandLen);
  1902 	foundOp = malloc((sizeof (boolean_t)) * operandLen);
  1918 	if (NULL == foundOp) {
  1903 	if (NULL == foundOp) {
  1919 		(void) fprintf(stdout, "%s\n",
  1904 		(void) fprintf(stdout, "%s\n",
  1920 		    getTextString(ERR_MEMORY_ALLOCATION));
  1905 		    getTextString(ERR_MEMORY_ALLOCATION));
  1924 	for (ol = 0; ol < operandLen; ol++) {
  1909 	for (ol = 0; ol < operandLen; ol++) {
  1925 		foundOp[ol] = B_FALSE;
  1910 		foundOp[ol] = B_FALSE;
  1926 	}
  1911 	}
  1927 
  1912 
  1928 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
  1913 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
  1929 		!= MP_STATUS_SUCCESS) {
  1914 	    != MP_STATUS_SUCCESS) {
  1930 		(void) fprintf(stderr, "%s: %s\n", cmdName,
  1915 		(void) fprintf(stderr, "%s: %s\n", cmdName,
  1931 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
  1916 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
  1932 		return (mpstatus);
  1917 		return (mpstatus);
  1933 	}
  1918 	}
  1934 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
  1919 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
  1946 			(void) fprintf(stderr,
  1931 			(void) fprintf(stderr,
  1947 			    getTextString(ERR_NO_INIT_PORT_LIST_WITH_REASON),
  1932 			    getTextString(ERR_NO_INIT_PORT_LIST_WITH_REASON),
  1948 			    getMpStatusStr(mpstatus));
  1933 			    getMpStatusStr(mpstatus));
  1949 			(void) printf("\n");
  1934 			(void) printf("\n");
  1950 		} else if ((NULL == pInitOidList) ||
  1935 		} else if ((NULL == pInitOidList) ||
  1951 			(pInitOidList->oidCount < 1)) {
  1936 		    (pInitOidList->oidCount < 1)) {
  1952 			(void) fprintf(stderr, "%s: %s\n", cmdName,
  1937 			(void) fprintf(stderr, "%s: %s\n", cmdName,
  1953 			    getTextString(ERR_NO_INIT_PORTS));
  1938 			    getTextString(ERR_NO_INIT_PORTS));
  1954 		} else {
  1939 		} else {
  1955 			for (iport = 0;
  1940 			for (iport = 0;
  1956 			    iport < pInitOidList->oidCount; iport ++) {
  1941 			    iport < pInitOidList->oidCount; iport ++) {
  2030 {
  2015 {
  2031 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  2016 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  2032 
  2017 
  2033 	(void) printf("%s  ", getTextString(TEXT_LB_INITATOR_PORT));
  2018 	(void) printf("%s  ", getTextString(TEXT_LB_INITATOR_PORT));
  2034 	displayArray(initProps.portID,
  2019 	displayArray(initProps.portID,
  2035 		sizeof (initProps.portID));
  2020 	    sizeof (initProps.portID));
  2036 	(void) printf("\n");
  2021 	(void) printf("\n");
  2037 
  2022 
  2038 	return (mpstatus);
  2023 	return (mpstatus);
  2039 
  2024 
  2040 }
  2025 }
  2054 int
  2039 int
  2055 showInitiatorPort(int operandLen, char *operand[])
  2040 showInitiatorPort(int operandLen, char *operand[])
  2056 {
  2041 {
  2057 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  2042 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  2058 	MP_INITIATOR_PORT_PROPERTIES 		initProps;
  2043 	MP_INITIATOR_PORT_PROPERTIES 		initProps;
  2059 	MP_OID_LIST				*pPluginOidList,
  2044 	MP_OID_LIST	*pPluginOidList, *pInitOidList;
  2060 						*pInitOidList;
  2045 	boolean_t	bListIt = B_FALSE, bFoundIt = B_FALSE;
  2061 	boolean_t				bListIt = B_FALSE,
  2046 	int		op, i, iport;
  2062 						bFoundIt = B_FALSE;
       
  2063 	int					op,
       
  2064 						i,
       
  2065 						iport;
       
  2066 
  2047 
  2067 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
  2048 	if ((mpstatus = MP_GetPluginOidList(&pPluginOidList))
  2068 		!= MP_STATUS_SUCCESS) {
  2049 	    != MP_STATUS_SUCCESS) {
  2069 		(void) fprintf(stderr, "%s: %s\n", cmdName,
  2050 		(void) fprintf(stderr, "%s: %s\n", cmdName,
  2070 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
  2051 		    getTextString(ERR_NO_MPATH_SUPPORT_LIST));
  2071 		return (mpstatus);
  2052 		return (mpstatus);
  2072 	}
  2053 	}
  2073 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
  2054 	if ((NULL == pPluginOidList) || (pPluginOidList->oidCount < 1)) {
  2105 					if ((mpstatus =
  2086 					if ((mpstatus =
  2106 					    MP_GetInitiatorPortProperties(
  2087 					    MP_GetInitiatorPortProperties(
  2107 					    pInitOidList->oids[iport],
  2088 					    pInitOidList->oids[iport],
  2108 					    &initProps))
  2089 					    &initProps))
  2109 					    != MP_STATUS_SUCCESS) {
  2090 					    != MP_STATUS_SUCCESS) {
  2110 						(void) fprintf(stderr,
  2091 					/* begin back-up indentation */
  2111 						    "%s: %s\n", cmdName,
  2092 					(void) fprintf(stderr,
       
  2093 					    "%s: %s\n", cmdName,
  2112 					    getTextString(ERR_NO_PROPERTIES));
  2094 					    getTextString(ERR_NO_PROPERTIES));
       
  2095 					/* end back-up indentation */
  2113 					} else {
  2096 					} else {
  2114 						if (0 == strcmp(operand[op],
  2097 						if (0 == strcmp(operand[op],
  2115 						    initProps.portID)) {
  2098 						    initProps.portID)) {
  2116 							bListIt = B_TRUE;
  2099 							bListIt = B_TRUE;
  2117 							bFoundIt = B_TRUE;
  2100 							bFoundIt = B_TRUE;
  2118 						}
  2101 						}
  2119 					}
  2102 					}
  2120 
  2103 
  2121 					if (B_TRUE == bListIt) {
  2104 					if (B_TRUE == bListIt) {
  2122 						mpstatus =
  2105 						mpstatus =
  2123 						showIndividualInitiatorPort(
  2106 						    showIndividualInitiatorPort(
  2124 						initProps);
  2107 						    initProps);
  2125 						if (0 != mpstatus) {
  2108 						if (0 != mpstatus) {
  2126 							return (mpstatus);
  2109 							return (mpstatus);
  2127 						}
  2110 						}
  2128 
  2111 
  2129 					} /* list It */
  2112 					} /* list It */
  2197 {
  2180 {
  2198 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  2181 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  2199 	MP_OID					pathOid;
  2182 	MP_OID					pathOid;
  2200 
  2183 
  2201 	cmdOptions_t 				*optionList = options;
  2184 	cmdOptions_t 				*optionList = options;
  2202 	boolean_t				bHaveInit = B_FALSE,
  2185 	boolean_t   bHaveInit = B_FALSE, bHaveTarg = B_FALSE, bHaveLu = B_FALSE;
  2203 						bHaveTarg = B_FALSE,
       
  2204 						bHaveLu = B_FALSE;
       
  2205 
  2186 
  2206 	for (; optionList->optval; optionList++) {
  2187 	for (; optionList->optval; optionList++) {
  2207 		switch (optionList->optval) {
  2188 		switch (optionList->optval) {
  2208 			case 'i':
  2189 			case 'i':
  2209 				/* have init port name */
  2190 				/* have init port name */
  2282 {
  2263 {
  2283 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  2264 	MP_STATUS				mpstatus = MP_STATUS_SUCCESS;
  2284 	MP_OID					pathOid;
  2265 	MP_OID					pathOid;
  2285 
  2266 
  2286 	cmdOptions_t 				*optionList = options;
  2267 	cmdOptions_t 				*optionList = options;
  2287 	boolean_t				bHaveInit = B_FALSE,
  2268 	boolean_t	bHaveInit = B_FALSE, bHaveTarg = B_FALSE,
  2288 						bHaveTarg = B_FALSE,
  2269 	    bHaveLu = B_FALSE;
  2289 						bHaveLu = B_FALSE;
       
  2290 
  2270 
  2291 	for (; optionList->optval; optionList++) {
  2271 	for (; optionList->optval; optionList++) {
  2292 		switch (optionList->optval) {
  2272 		switch (optionList->optval) {
  2293 			case 'i':
  2273 			case 'i':
  2294 				/* have init port name */
  2274 				/* have init port name */
  2469 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES 	luProps;
  2449 	MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES 	luProps;
  2470 	MP_PATH_LOGICAL_UNIT_PROPERTIES		pathProps;
  2450 	MP_PATH_LOGICAL_UNIT_PROPERTIES		pathProps;
  2471 	MP_INITIATOR_PORT_PROPERTIES		initProps;
  2451 	MP_INITIATOR_PORT_PROPERTIES		initProps;
  2472 	MP_TARGET_PORT_PROPERTIES		targProps;
  2452 	MP_TARGET_PORT_PROPERTIES		targProps;
  2473 
  2453 
  2474 	MP_OID_LIST				*pPluginOidList,
  2454 	MP_OID_LIST	*pPluginOidList, *pLogicalUnitOidList,
  2475 						*pLogicalUnitOidList,
  2455 	    *pathOidListArray;
  2476 						*pathOidListArray;
       
  2477 
  2456 
  2478 	boolean_t				bFoundIt = B_FALSE;
  2457 	boolean_t				bFoundIt = B_FALSE;
  2479 	MP_CHAR					initPortID[256];
  2458 	MP_CHAR					initPortID[256];
  2480 	MP_CHAR					targetPortID[256];
  2459 	MP_CHAR					targetPortID[256];
  2481 	MP_CHAR					luDeviceFileName[256];
  2460 	MP_CHAR					luDeviceFileName[256];
  2482 	boolean_t				bHaveTarg = B_FALSE,
  2461 	boolean_t	bHaveTarg = B_FALSE, bHaveLu = B_FALSE,
  2483 						bHaveLu = B_FALSE,
  2462 	    bHaveInit = B_FALSE;
  2484 						bHaveInit = B_FALSE;
       
  2485 
       
  2486 
       
  2487 	cmdOptions_t 				*optionList = options;
  2463 	cmdOptions_t 				*optionList = options;
  2488 
  2464 
  2489 	int					i,
  2465 	int					i, lu, pa;
  2490 						lu,
       
  2491 						pa;
       
  2492 	if (NULL == pPathOid) {
  2466 	if (NULL == pPathOid) {
  2493 		return (B_FALSE);
  2467 		return (B_FALSE);
  2494 	}
  2468 	}
  2495 
  2469 
  2496 	for (; optionList->optval; optionList++) {
  2470 	for (; optionList->optval; optionList++) {
  2548 			    cmdName, getTextString(ERR_NO_LU_LIST));
  2522 			    cmdName, getTextString(ERR_NO_LU_LIST));
  2549 			return (B_FALSE);
  2523 			return (B_FALSE);
  2550 		}
  2524 		}
  2551 
  2525 
  2552 		for (lu = 0; (lu < pLogicalUnitOidList->oidCount) &&
  2526 		for (lu = 0; (lu < pLogicalUnitOidList->oidCount) &&
  2553 			(B_FALSE == bFoundIt); lu++) {
  2527 		    (B_FALSE == bFoundIt); lu++) {
  2554 
  2528 
  2555 			/* get lu properties so we can check the name */
  2529 			/* get lu properties so we can check the name */
  2556 			(void) memset(&luProps, 0,
  2530 			(void) memset(&luProps, 0,
  2557 			    sizeof (MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES));
  2531 			    sizeof (MP_MULTIPATH_LOGICAL_UNIT_PROPERTIES));
  2558 			mpstatus =
  2532 			mpstatus =
  2561 			if (mpstatus != MP_STATUS_SUCCESS) {
  2535 			if (mpstatus != MP_STATUS_SUCCESS) {
  2562 				(void) fprintf(stderr, "%s:  %s\n",
  2536 				(void) fprintf(stderr, "%s:  %s\n",
  2563 				    cmdName, getTextString(ERR_NO_PROPERTIES));
  2537 				    cmdName, getTextString(ERR_NO_PROPERTIES));
  2564 				return (B_FALSE);
  2538 				return (B_FALSE);
  2565 			}
  2539 			}
  2566 			if (0 == strcmp(luDeviceFileName,
  2540 			if (compareLUName(luDeviceFileName,
  2567 			    luProps.deviceFileName)) {
  2541 			    luProps.deviceFileName) == B_TRUE) {
  2568 				/* get paths for this LU and search from here */
  2542 				/* get paths for this LU and search from here */
  2569 				mpstatus =
  2543 				mpstatus =
  2570 				    MP_GetAssociatedPathOidList(
  2544 				    MP_GetAssociatedPathOidList(
  2571 				    pLogicalUnitOidList->oids[lu],
  2545 				    pLogicalUnitOidList->oids[lu],
  2572 				    &pathOidListArray);
  2546 				    &pathOidListArray);
  2578 					(void) printf("\n");
  2552 					(void) printf("\n");
  2579 					return (B_FALSE);
  2553 					return (B_FALSE);
  2580 				}
  2554 				}
  2581 
  2555 
  2582 				for (pa = 0;
  2556 				for (pa = 0;
  2583 					(pa < pathOidListArray->oidCount) &&
  2557 				    (pa < pathOidListArray->oidCount) &&
  2584 					(B_FALSE == bFoundIt); pa++) {
  2558 				    (B_FALSE == bFoundIt); pa++) {
  2585 					mpstatus =
  2559 					mpstatus =
  2586 					    MP_GetPathLogicalUnitProperties
  2560 					    MP_GetPathLogicalUnitProperties
  2587 					    (pathOidListArray->oids[pa],
  2561 					    (pathOidListArray->oids[pa],
  2588 					    &pathProps);
  2562 					    &pathProps);
  2589 					if (mpstatus != MP_STATUS_SUCCESS) {
  2563 					if (mpstatus != MP_STATUS_SUCCESS) {
  2765 		case MP_LU_NAME_TYPE_VPD83_TYPE3:
  2739 		case MP_LU_NAME_TYPE_VPD83_TYPE3:
  2766 			typeString = getTextString(TEXT_NAME_TYPE_VPD83_TYPE3);
  2740 			typeString = getTextString(TEXT_NAME_TYPE_VPD83_TYPE3);
  2767 			break;
  2741 			break;
  2768 		case MP_LU_NAME_TYPE_DEVICE_SPECIFIC:
  2742 		case MP_LU_NAME_TYPE_DEVICE_SPECIFIC:
  2769 			typeString =
  2743 			typeString =
  2770 			getTextString(TEXT_NAME_TYPE_DEVICE_SPECIFIC);
  2744 			    getTextString(TEXT_NAME_TYPE_DEVICE_SPECIFIC);
  2771 			break;
  2745 			break;
  2772 		default:
  2746 		default:
  2773 			typeString = getTextString(TEXT_UNKNOWN);
  2747 			typeString = getTextString(TEXT_UNKNOWN);
  2774 			break;
  2748 			break;
  2775 	}
  2749 	}
  3201 		case INITIATOR_PORT:
  3175 		case INITIATOR_PORT:
  3202 			ret = listInitiatorPort(operandLen, operand);
  3176 			ret = listInitiatorPort(operandLen, operand);
  3203 			break;
  3177 			break;
  3204 		default:
  3178 		default:
  3205 			(void) fprintf(stderr, "%s: %s\n",
  3179 			(void) fprintf(stderr, "%s: %s\n",
  3206 		    cmdName, getTextString(TEXT_UNKNOWN_OBJECT));
  3180 			    cmdName, getTextString(TEXT_UNKNOWN_OBJECT));
  3207 			ret = 1;
  3181 			ret = 1;
  3208 			break;
  3182 			break;
  3209 	}
  3183 	}
  3210 
  3184 
  3211 	return (ret);
  3185 	return (ret);