stmfadm.c revision fdcc480a6215c1e81d58d8e7af8c84fd6f1faa50
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#include <unistd.h>
#include <wchar.h>
#include <libintl.h>
#include <errno.h>
#include <time.h>
#include <string.h>
#include <assert.h>
#include <getopt.h>
#include <cmdparse.h>
#include <stmfadm.h>
#include <libstmf.h>
#include <signal.h>
#include <pthread.h>
#include <locale.h>
static int addHostGroupMemberFunc(int, char **, cmdOptions_t *, void *);
static int addTargetGroupMemberFunc(int, char **, cmdOptions_t *, void *);
static int addViewFunc(int, char **, cmdOptions_t *, void *);
static int createHostGroupFunc(int, char **, cmdOptions_t *, void *);
static int createLuFunc(int, char **, cmdOptions_t *, void *);
static int modifyLuFunc(int, char **, cmdOptions_t *, void *);
static int importLuFunc(int, char **, cmdOptions_t *, void *);
static int deleteLuFunc(int, char **, cmdOptions_t *, void *);
static int createTargetGroupFunc(int, char **, cmdOptions_t *, void *);
static int deleteHostGroupFunc(int, char **, cmdOptions_t *, void *);
static int deleteTargetGroupFunc(int, char **, cmdOptions_t *, void *);
static int listLuFunc(int, char **, cmdOptions_t *, void *);
static int listTargetFunc(int, char **, cmdOptions_t *, void *);
static int listViewFunc(int, char **, cmdOptions_t *, void *);
static int listHostGroupFunc(int, char **, cmdOptions_t *, void *);
static int listStateFunc(int, char **, cmdOptions_t *, void *);
static int listTargetGroupFunc(int, char **, cmdOptions_t *, void *);
static int offlineTargetFunc(int, char **, cmdOptions_t *, void *);
static int offlineLuFunc(int, char **, cmdOptions_t *, void *);
static int onlineTargetFunc(int, char **, cmdOptions_t *, void *);
static int onlineLuFunc(int, char **, cmdOptions_t *, void *);
static int onlineOfflineTarget(char *, int);
static int onlineOfflineLu(char *, int);
static int removeHostGroupMemberFunc(int, char **, cmdOptions_t *, void *);
static int removeTargetGroupMemberFunc(int, char **, cmdOptions_t *, void *);
static int removeViewFunc(int, char **, cmdOptions_t *, void *);
static char *getExecBasename(char *);
static int checkHexUpper(char *);
static int checkIscsiName(wchar_t *);
static void printTargetProps(stmfTargetProperties *);
static void printSessionProps(stmfSessionList *);
static int setLuPropFromInput(luResource, char *);
static int convertCharToPropId(char *, uint32_t *);
/*
* MAJOR - This should only change when there is an incompatible change made
* to the interfaces or the output.
*
* MINOR - This should change whenever there is a new command or new feature
* with no incompatible change.
*/
#define VERSION_STRING_MAJOR "1"
#define VERSION_STRING_MINOR "0"
#define MAX_DEVID_INPUT 256
#define GUID_INPUT 32
#define MAX_LU_NBR 16383
#define ONLINE_LU 0
#define OFFLINE_LU 1
#define ONLINE_TARGET 2
#define OFFLINE_TARGET 3
#define PROPS_FORMAT " %-18s: "
#define VIEW_FORMAT " %-13s: "
#define LVL3_FORMAT " %s"
#define LVL4_FORMAT " %s"
/* SCSI Name String length definitions */
#define SNS_EUI_16 16
#define SNS_EUI_24 24
#define SNS_EUI_32 32
#define SNS_NAA_16 16
#define SNS_NAA_32 32
#define SNS_WWN_16 16
#define SNS_IQN_223 223
/* LU Property strings */
#define GUID "GUID"
#define ALIAS "ALIAS"
#define VID "VID"
#define PID "PID"
#define META_FILE "META"
#define WRITE_PROTECT "WP"
#define WRITEBACK_CACHE_DISABLE "WCD"
#define COMPANY_ID "OUI"
#define BLOCK_SIZE "BLK"
#define SERIAL_NUMBER "SERIAL"
#define MGMT_URL "MGMT-URL"
#define HOST_ID "HOST-ID"
#define MODIFY_HELP "\n"\
"Description: Modify properties of a logical unit. \n" \
"Valid properties for -p, --lu-prop are: \n" \
" alias - alias for logical unit (up to 255 chars)\n" \
" mgmt-url - Management URL address\n" \
" wcd - write cache disabled (true, false)\n" \
" wp - write protect (true, false)\n\n" \
"-f alters the meaning of the operand to be a file name\n" \
"rather than a LU name. This allows for modification\n" \
"of a logical unit that is not yet imported into stmf\n"
#define CREATE_HELP "\n"\
"Description: Create a logical unit. \n" \
"Valid properties for -p, --lu-prop are: \n" \
" alias - alias for logical unit (up to 255 chars)\n" \
" blk - block size in bytes in 2^n\n" \
" guid - 32 ascii hex characters in NAA format \n" \
" host-id - host identifier to be used for GUID generation \n" \
" 8 ascii hex characters\n" \
" meta - separate meta data file name\n" \
" mgmt-url - Management URL address\n" \
" oui - organizational unique identifier\n" \
" 6 ascii hex characters of valid format\n" \
" pid - product identifier (up to 16 chars)\n" \
" serial - serial number (up to 252 chars)\n" \
" vid - vendor identifier (up to 8 chars)\n" \
" wcd - write cache disabled (true, false)\n" \
" wp - write protect (true, false)\n"
#define ADD_VIEW_HELP "\n"\
"Description: Add a view entry to a logical unit. \n" \
"A view entry is comprised of three elements; the \n" \
"logical unit number, the target group name and the\n" \
"host group name. These three elements combine together\n" \
"to form a view for a given COMSTAR logical unit.\n" \
"This view is realized by a client, a SCSI initiator,\n" \
"via a REPORT LUNS command. \n"
/* tables set up based on cmdparse instructions */
/* add new options here */
optionTbl_t longOptions[] = {
{NULL, 0, 0, 0}
};
/*
* Add new subcommands here
*/
subCommandProps_t subcommands[] = {
"lu file", CREATE_HELP},
};
/* globals */
char *cmdName;
/*
* addHostGroupMemberFunc
*
* Add members to a host group
*
*/
/*ARGSUSED*/
static int
void *args)
{
int i;
int ret = 0;
int stmfRet;
stmfGroupName groupName = {0};
/* host group name */
case 'g':
sizeof (stmfGroupName) - 1);
break;
default:
gettext("unknown option"));
return (1);
}
}
for (i = 0; i < operandLen; i++) {
gettext("unrecognized device id"));
ret++;
continue;
}
switch (stmfRet) {
case STMF_STATUS_SUCCESS:
break;
case STMF_ERROR_EXISTS:
ret++;
break;
ret++;
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
break;
case STMF_ERROR_BUSY:
ret++;
break;
gettext("STMF service not found"));
ret++;
break;
gettext("STMF service version incorrect"));
ret++;
break;
default:
ret++;
break;
}
}
return (ret);
}
/*
* addTargetGroupMemberFunc
*
* Add members to a target group
*
*/
/*ARGSUSED*/
static int
{
int i;
int ret = 0;
int stmfRet;
stmfGroupName groupName = {0};
/* target group name */
case 'g':
sizeof (stmfGroupName) - 1);
break;
default:
gettext("unknown option"));
return (1);
}
}
for (i = 0; i < operandLen; i++) {
gettext("unrecognized device id"));
ret++;
continue;
}
switch (stmfRet) {
case STMF_STATUS_SUCCESS:
break;
case STMF_ERROR_EXISTS:
ret++;
break;
ret++;
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
break;
case STMF_ERROR_BUSY:
ret++;
break;
gettext("STMF service not found"));
ret++;
break;
gettext("STMF service must be offline"));
ret++;
break;
gettext("STMF service version incorrect"));
ret++;
break;
default:
ret++;
break;
}
}
return (ret);
}
/*
* parseDevid
*
* Converts char * input to a stmfDevid
*
* input - this should be in the following format with either a
* wwn. iqn. or eui. representation.
* A name string of the format:
* iqn.<iSCSI name> (iSCSI iqn)
* eui.<WWN> (iSCSI eui name)
*
* devid - pointer to stmfDevid structure allocated by the caller.
*
* Returns:
* 0 on success
* non-zero on failure
*/
static int
{
/* convert to wcs */
/*
* Check for known scsi name string formats
* If one is found, we're done
* If not, then it's a failure to parse
*/
return (0);
}
return (-1);
}
/*
* checkScsiNameString
*
* Validates known SCSI name string formats and converts to stmfDevid
* format
*
* input - input SCSI name string
* devid - pointer to stmfDevid structure allocated by the caller
* on successful return, contains the devid based on input
*
* returns:
* 0 on success
* -1 on failure
*/
static int
{
int mbStringLen;
int len;
int i;
/*
* Convert to multi-byte string
*
* This is used for either eui or naa formats
*/
cmdName, "Insufficient memory\n");
return (-1);
}
return (-1);
}
/*
* check for iqn format
*/
return (-1);
}
for (i = 0; i < len; i++) {
}
return (-1);
}
return (-1);
return (-1);
}
return (-1);
return (-1);
}
} else {
return (-1);
}
/*
* We have a validated name string.
* Go ahead and set the length and copy it.
*/
return (0);
}
/*
* Checks whether the entire string is in hex and converts to upper
*/
static int
checkHexUpper(char *input)
{
int i;
continue;
}
return (-1);
}
return (0);
}
/*
* checkIscsiName
*
* Purpose: Basic string checking on name
*/
static int
{
int i;
for (i = 0; input[i] != 0; i++) {
return (-1);
}
}
return (0);
}
/*
* addViewFunc
*
* Adds a view entry to a logical unit
*
*/
/*ARGSUSED*/
static int
void *args)
{
int ret = 0;
int stmfRet;
int i;
/* init view entry structure */
/* check input length */
gettext(" hexadecimal digits"));
return (1);
}
/* logical unit number */
case 'n':
if (inputLuNbr > MAX_LU_NBR) {
gettext("Logical unit number"
" must be less than 16384"));
return (1);
}
break;
/* host group */
case 'h':
break;
/* target group */
case 't':
break;
default:
gettext("unknown option"));
return (1);
}
}
/* convert to lower case for scan */
for (i = 0; i < 32; i++)
sGuid[i] = 0;
for (i = 0; i < sizeof (stmfGuid); i++) {
}
/* add the view entry */
switch (stmfRet) {
case STMF_STATUS_SUCCESS:
break;
case STMF_ERROR_EXISTS:
ret++;
break;
case STMF_ERROR_BUSY:
ret++;
break;
gettext("STMF service not found"));
ret++;
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
ret++;
break;
case STMF_ERROR_LUN_IN_USE:
gettext("LUN already in use"));
ret++;
break;
case STMF_ERROR_VE_CONFLICT:
gettext("view entry exists"));
ret++;
break;
case STMF_ERROR_CONFIG_NONE:
gettext("STMF service is not initialized"));
ret++;
break;
gettext("STMF service version incorrect"));
ret++;
break;
case STMF_ERROR_INVALID_HG:
gettext("invalid host group"));
ret++;
break;
case STMF_ERROR_INVALID_TG:
gettext("invalid target group"));
ret++;
break;
default:
ret++;
break;
}
return (ret);
}
/*
* createHostGroupFunc
*
* Create a host group
*
*/
/*ARGSUSED*/
static int
{
int ret = 0;
int stmfRet;
stmfGroupName groupName = {0};
sizeof (stmfGroupName) - 1);
/* call create group */
switch (stmfRet) {
case STMF_STATUS_SUCCESS:
break;
case STMF_ERROR_EXISTS:
ret++;
break;
case STMF_ERROR_BUSY:
ret++;
break;
gettext("STMF service not found"));
ret++;
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
ret++;
break;
gettext("STMF service version incorrect"));
ret++;
break;
default:
ret++;
break;
}
return (ret);
}
/*
* createLuFunc
*
* Create a logical unit
*
*/
/*ARGSUSED*/
static int
void *args)
{
int ret = 0;
int stmfRet = 0;
char guidAsciiBuf[33];
if (stmfRet != STMF_STATUS_SUCCESS) {
return (1);
}
case 'p':
if (ret != 0) {
(void) stmfFreeLuResource(hdl);
return (1);
}
break;
case 's':
if (stmfRet != STMF_STATUS_SUCCESS) {
gettext("size param invalid"));
(void) stmfFreeLuResource(hdl);
return (1);
}
break;
default:
gettext("unknown option"));
return (1);
}
}
if (stmfRet != STMF_STATUS_SUCCESS) {
return (1);
}
switch (stmfRet) {
case STMF_STATUS_SUCCESS:
break;
case STMF_ERROR_BUSY:
case STMF_ERROR_LU_BUSY:
gettext("resource busy"));
ret++;
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
ret++;
break;
case STMF_ERROR_FILE_IN_USE:
ret++;
break;
gettext("invalid block size"));
ret++;
break;
case STMF_ERROR_GUID_IN_USE:
gettext("guid in use"));
ret++;
break;
gettext("meta file error"));
ret++;
break;
gettext("data file error"));
ret++;
break;
gettext("file size invalid"));
ret++;
break;
gettext("invalid size"));
ret++;
break;
case STMF_ERROR_META_CREATION:
gettext("could not create meta file"));
ret++;
break;
gettext("could not set write cache"));
ret++;
break;
default:
gettext("unknown error"));
ret++;
break;
}
if (ret != 0) {
goto done;
}
"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X"
"%02X%02X%02X%02X%02X%02X",
done:
(void) stmfFreeLuResource(hdl);
return (ret);
}
/*
* createLuFunc
*
* Create a logical unit
*
*/
/*ARGSUSED*/
static int
void *args)
{
int ret = 0;
int i;
case 'f':
break;
}
}
/* check input length */
gettext(" hexadecimal digits"));
return (1);
}
if (!fnameUsed) {
/* convert to lower case for scan */
for (i = 0; i < 32; i++)
sGuid[i] = 0;
"%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x",
for (i = 0; i < sizeof (stmfGuid); i++) {
}
}
case 'p':
if (ret != 0) {
gettext("invalid property specified"),
prop);
return (1);
}
propId != STMF_LU_PROP_MGMT_URL) {
gettext("invalid property specifier"
"- prop=val\n"));
return (1);
}
"", prop);
} else {
}
if (ret != 0) {
return (1);
}
break;
case 's':
"size") != 0) {
return (1);
}
break;
case 'f':
break;
default:
gettext("unknown option"));
return (1);
}
}
return (ret);
}
static int
const char *propString)
{
int ret = 0;
int stmfRet = 0;
if (!fname) {
} else {
propVal);
}
switch (stmfRet) {
case STMF_STATUS_SUCCESS:
break;
case STMF_ERROR_BUSY:
case STMF_ERROR_LU_BUSY:
gettext("resource busy"));
ret++;
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
ret++;
break;
gettext("invalid block size"));
ret++;
break;
case STMF_ERROR_GUID_IN_USE:
gettext("guid in use"));
ret++;
break;
gettext("meta file error"));
ret++;
break;
gettext("data file error"));
ret++;
break;
gettext("file size invalid"));
ret++;
break;
gettext("invalid size"));
ret++;
break;
case STMF_ERROR_META_CREATION:
gettext("could not create meta file"));
ret++;
break;
case STMF_ERROR_INVALID_PROP:
gettext("invalid property for modify"));
ret++;
break;
gettext("could not set write cache"));
ret++;
break;
gettext("cannot modify while in standby mode"));
ret++;
break;
default:
stmfRet);
ret++;
break;
}
return (ret);
}
/*
* importLuFunc
*
* Create a logical unit
*
*/
/*ARGSUSED*/
static int
void *args)
{
int stmfRet = 0;
int ret = 0;
char guidAsciiBuf[33];
switch (stmfRet) {
case STMF_STATUS_SUCCESS:
break;
case STMF_ERROR_BUSY:
case STMF_ERROR_LU_BUSY:
gettext("resource busy"));
ret++;
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
ret++;
break;
case STMF_ERROR_FILE_IN_USE:
ret++;
break;
case STMF_ERROR_GUID_IN_USE:
gettext("guid in use"));
ret++;
break;
gettext("meta file error"));
ret++;
break;
gettext("data file error"));
ret++;
break;
case STMF_ERROR_META_CREATION:
gettext("could not create meta file"));
ret++;
break;
gettext("could not set write cache"));
ret++;
break;
default:
gettext("unknown error"));
ret++;
break;
}
if (ret != STMF_STATUS_SUCCESS) {
goto done;
}
"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X"
"%02X%02X%02X%02X%02X%02X",
done:
return (ret);
}
static int
{
int ret = 0;
gettext("invalid property specifier - prop=val\n"));
return (1);
}
if (ret != 0) {
return (1);
}
if (ret != STMF_STATUS_SUCCESS) {
switch (ret) {
break;
case STMF_ERROR_INVALID_ARG:
break;
default:
break;
}
return (1);
}
return (0);
}
static int
{
} else {
return (1);
}
return (0);
}
/*
* deleteLuFunc
*
* Delete a logical unit
*
*/
/*ARGSUSED*/
static int
void *args)
{
int i, j;
int ret = 0;
int stmfRet;
/* Keep views for logical unit */
case 'k':
break;
default:
gettext("unknown option"));
return (1);
}
}
for (i = 0; i < operandLen; i++) {
for (j = 0; j < GUID_INPUT; j++) {
break;
}
}
if (j != GUID_INPUT) {
gettext(" hexadecimal digits long"));
continue;
}
sGuid[j] = 0;
"%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x",
for (j = 0; j < sizeof (stmfGuid); j++) {
}
switch (stmfRet) {
case STMF_STATUS_SUCCESS:
break;
case STMF_ERROR_NOT_FOUND:
noLunFound = B_TRUE;
break;
case STMF_ERROR_BUSY:
gettext("resource busy"));
ret++;
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
ret++;
break;
default:
gettext("unknown error"));
ret++;
break;
}
if (!keepViews) {
if (stmfRet == STMF_STATUS_SUCCESS) {
for (j = 0; j < viewEntryList->cnt; j++) {
(void) stmfRemoveViewEntry(&delGuid,
}
} else if (stmfRet != STMF_ERROR_NOT_FOUND) {
gettext("unable to remove view entries\n"));
ret++;
} /* No view entries to remove */
}
if (keepViews) {
if (stmfRet == STMF_STATUS_SUCCESS) {
}
}
gettext("not found"));
ret++;
}
}
return (ret);
}
/*
* createTargetGroupFunc
*
* Create a target group
*
*/
/*ARGSUSED*/
static int
void *args)
{
int ret = 0;
int stmfRet;
stmfGroupName groupName = {0};
sizeof (stmfGroupName) - 1);
/* call create group */
switch (stmfRet) {
case STMF_STATUS_SUCCESS:
break;
case STMF_ERROR_EXISTS:
ret++;
break;
case STMF_ERROR_BUSY:
ret++;
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
ret++;
break;
gettext("STMF service not found"));
ret++;
break;
gettext("STMF service version incorrect"));
ret++;
break;
default:
ret++;
break;
}
return (ret);
}
/*
* deleteHostGroupFunc
*
* Delete a host group
*
*/
/*ARGSUSED*/
static int
{
int ret = 0;
int stmfRet;
stmfGroupName groupName = {0};
sizeof (stmfGroupName) - 1);
/* call delete group */
switch (stmfRet) {
case STMF_STATUS_SUCCESS:
break;
case STMF_ERROR_NOT_FOUND:
ret++;
break;
case STMF_ERROR_BUSY:
ret++;
break;
gettext("STMF service not found"));
ret++;
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
ret++;
break;
case STMF_ERROR_GROUP_IN_USE:
gettext("group is in use by existing view entry"));
ret++;
break;
gettext("STMF service version incorrect"));
ret++;
break;
default:
ret++;
break;
}
return (ret);
}
/*
* deleteTargetGroupFunc
*
* Delete a target group
*
*/
/*ARGSUSED*/
static int
void *args)
{
int ret = 0;
int stmfRet;
stmfGroupName groupName = {0};
sizeof (stmfGroupName) - 1);
/* call delete group */
switch (stmfRet) {
case STMF_STATUS_SUCCESS:
break;
case STMF_ERROR_NOT_FOUND:
ret++;
break;
case STMF_ERROR_BUSY:
ret++;
break;
gettext("STMF service not found"));
ret++;
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
ret++;
break;
case STMF_ERROR_GROUP_IN_USE:
gettext("group is in use by existing view entry"));
ret++;
break;
gettext("STMF service version incorrect"));
ret++;
break;
default:
ret++;
break;
}
return (ret);
}
/*
* listHostGroupFunc
*
* Lists the specified host groups or all if none are specified
*
*/
/*ARGSUSED*/
static int
void *args)
{
int ret = 0;
int stmfRet;
int i, j, outerLoop;
case 'v':
break;
default:
gettext("unknown option"));
return (1);
}
}
if (operandLen > 0) {
} else {
outerLoop = 1;
}
if (stmfRet != STMF_STATUS_SUCCESS) {
switch (stmfRet) {
case STMF_ERROR_BUSY:
gettext("resource busy"));
break;
gettext("STMF service not found"));
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
break;
gettext("STMF service version incorrect"));
break;
default:
gettext("unknown error"));
break;
}
return (1);
}
for (i = 0; i < outerLoop; i++) {
(void) mbstowcs(groupNamePrint,
sizeof (stmfGroupName) - 1);
if (operandEntered) {
sizeof (stmfGroupName) - 1);
== 0) {
}
}
(void) printf("Host Group: %ws\n",
if (verbose) {
if (stmfRet != STMF_STATUS_SUCCESS) {
return (1);
}
}
if (found && operandEntered) {
break;
}
}
}
if (operandEntered && !found) {
ret = 1;
}
}
return (ret);
}
/*
* printGroupProps
*
* Prints group members for target or host groups
*
*/
static void
{
int i;
for (i = 0; i < groupProps->cnt; i++) {
sizeof (groupProps->name[0].ident));
}
}
/*
* listTargetGroupFunc
*
* Lists the specified target groups or all if none are specified
*
*/
/*ARGSUSED*/
static int
void *args)
{
int ret = 0;
int stmfRet;
int i, j, outerLoop;
case 'v':
break;
default:
gettext("unknown option"));
return (1);
}
}
if (operandLen > 0) {
} else {
outerLoop = 1;
}
if (stmfRet != STMF_STATUS_SUCCESS) {
switch (stmfRet) {
case STMF_ERROR_BUSY:
gettext("resource busy"));
break;
gettext("STMF service not found"));
break;
gettext("STMF service version incorrect"));
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
break;
default:
gettext("unknown error"));
break;
}
return (1);
}
for (i = 0; i < outerLoop; i++) {
(void) mbstowcs(groupNamePrint,
sizeof (stmfGroupName) - 1);
if (operandEntered) {
sizeof (stmfGroupName) - 1);
== 0) {
}
}
(void) printf("Target Group: %ws\n",
if (verbose) {
if (stmfRet != STMF_STATUS_SUCCESS) {
return (1);
}
}
if (found && operandEntered) {
break;
}
}
}
if (operandEntered && !found) {
ret = 1;
}
}
return (ret);
}
/*
* listLuFunc
*
* List the logical units and optionally the properties
*
*/
/*ARGSUSED*/
static int
{
int i, j;
int ret = 0;
int stmfRet;
int outerLoop;
switch (optionList->optval) {
case 'v':
break;
}
}
!= STMF_STATUS_SUCCESS) {
switch (stmfRet) {
gettext("STMF service not found"));
break;
case STMF_ERROR_BUSY:
gettext("resource busy"));
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
break;
gettext("STMF service version incorrect"));
break;
default:
gettext("list failed"));
break;
}
return (1);
}
if (operandLen > 0) {
} else {
outerLoop = 1;
}
if (operandEntered) {
} else {
for (j = 0; j < GUID_INPUT; j++) {
break;
}
}
}
if (invalidInput) {
gettext(" hexadecimal digits long"));
continue;
}
for (j = 0; j < GUID_INPUT; j++) {
}
sGuid[j] = 0;
"%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x",
for (j = 0; j < sizeof (stmfGuid); j++) {
}
}
if (operandEntered) {
sizeof (stmfGuid)) == 0) {
}
}
(void) printf("LU Name: ");
(void) printf("\n");
if (verbose) {
if (stmfRet == STMF_STATUS_SUCCESS) {
} else {
cmdName);
stderr);
gettext(" get properties "
"failed"));
}
(void) printf(PROPS_FORMAT,
"View Entry Count");
if (stmfRet == STMF_STATUS_SUCCESS) {
(void) printf("%d",
viewEntryList->cnt);
} else if (stmfRet ==
(void) printf("0");
} else {
(void) printf("unknown");
}
(void) printf("\n");
}
if (found && operandEntered) {
break;
}
}
}
if (operandEntered && !found) {
ret = 1;
}
}
return (ret);
}
static void
{
int i;
for (i = 0; i < 16; i++) {
}
}
static int
{
int stmfRet;
int ret = 0;
char propVal[MAXNAMELEN];
!= STMF_STATUS_SUCCESS) {
switch (stmfRet) {
case STMF_ERROR_BUSY:
gettext("resource busy"));
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
break;
case STMF_ERROR_NOT_FOUND:
/* No error here */
return (0);
break;
default:
gettext("get extended properties failed"));
break;
}
return (1);
}
&propValSize);
if (stmfRet == STMF_STATUS_SUCCESS) {
} else if (stmfRet == STMF_ERROR_NO_PROP) {
(void) printf("not set\n");
} else if (stmfRet == STMF_ERROR_NO_PROP_STANDBY) {
(void) printf("prop unavailable in standby\n");
} else {
(void) printf("<error retrieving property>\n");
ret++;
}
&propValSize);
if (stmfRet == STMF_STATUS_SUCCESS) {
} else if (stmfRet == STMF_ERROR_NO_PROP) {
(void) printf("not set\n");
} else if (stmfRet == STMF_ERROR_NO_PROP_STANDBY) {
(void) printf("prop unavailable in standby\n");
} else {
(void) printf("<error retrieving property>\n");
ret++;
}
&propValSize);
if (stmfRet == STMF_STATUS_SUCCESS) {
} else if (stmfRet == STMF_ERROR_NO_PROP) {
(void) printf("not set\n");
} else if (stmfRet == STMF_ERROR_NO_PROP_STANDBY) {
(void) printf("prop unavailable in standby\n");
} else {
(void) printf("<error retrieving property>\n");
ret++;
}
&propValSize);
if (stmfRet == STMF_STATUS_SUCCESS) {
} else if (stmfRet == STMF_ERROR_NO_PROP) {
(void) printf("not set\n");
} else if (stmfRet == STMF_ERROR_NO_PROP_STANDBY) {
(void) printf("prop unavailable in standby\n");
} else {
(void) printf("<error retrieving property>\n");
ret++;
}
&propValSize);
if (stmfRet == STMF_STATUS_SUCCESS) {
} else if (stmfRet == STMF_ERROR_NO_PROP) {
(void) printf("not set\n");
} else if (stmfRet == STMF_ERROR_NO_PROP_STANDBY) {
(void) printf("prop unavailable in standby\n");
} else {
(void) printf("<error retrieving property>\n");
ret++;
}
&propValSize);
if (stmfRet == STMF_STATUS_SUCCESS) {
} else if (stmfRet == STMF_ERROR_NO_PROP) {
(void) printf("not set\n");
} else if (stmfRet == STMF_ERROR_NO_PROP_STANDBY) {
(void) printf("prop unavailable in standby\n");
} else {
(void) printf("<error retrieving property>\n");
ret++;
}
&propValSize);
if (stmfRet == STMF_STATUS_SUCCESS) {
} else if (stmfRet == STMF_ERROR_NO_PROP) {
(void) printf("not set\n");
} else if (stmfRet == STMF_ERROR_NO_PROP_STANDBY) {
(void) printf("prop unavailable in standby\n");
} else {
(void) printf("<error retrieving property>\n");
ret++;
}
&propValSize);
if (stmfRet == STMF_STATUS_SUCCESS) {
} else if (stmfRet == STMF_ERROR_NO_PROP) {
(void) printf("not set\n");
} else if (stmfRet == STMF_ERROR_NO_PROP_STANDBY) {
(void) printf("prop unavailable in standby\n");
} else {
(void) printf("<error retrieving property>\n");
ret++;
}
&propValSize);
if (stmfRet == STMF_STATUS_SUCCESS) {
(void) printf("%s\n",
} else if (stmfRet == STMF_ERROR_NO_PROP) {
(void) printf("not set\n");
} else if (stmfRet == STMF_ERROR_NO_PROP_STANDBY) {
(void) printf("prop unavailable in standby\n");
} else {
(void) printf("<error retrieving property>\n");
ret++;
}
&propValSize);
if (stmfRet == STMF_STATUS_SUCCESS) {
(void) printf("%s\n",
} else if (stmfRet == STMF_ERROR_NO_PROP) {
(void) printf("not set\n");
} else if (stmfRet == STMF_ERROR_NO_PROP_STANDBY) {
(void) printf("prop unavailable in standby\n");
} else {
(void) printf("<error retrieving property>\n");
ret++;
}
&propValSize);
if (stmfRet == STMF_STATUS_SUCCESS) {
STMF_ACCESS_ACTIVE_TO_STANDBY) == 0) {
STMF_ACCESS_STANDBY_TO_ACTIVE) == 0) {
} else {
}
} else if (stmfRet == STMF_ERROR_NO_PROP) {
(void) printf("not set\n");
} else {
(void) printf("<error retrieving property>\n");
ret++;
}
done:
(void) stmfFreeLuResource(hdl);
return (ret);
}
/*
* printLuProps
*
* Prints the properties for a logical unit
*
*/
static void
{
case STMF_LOGICAL_UNIT_ONLINE:
(void) printf("Online");
break;
(void) printf("Offline");
break;
(void) printf("Onlining");
break;
(void) printf("Offlining");
break;
(void) printf("unregistered");
sizeof (luProps->providerName));
break;
default:
(void) printf("unknown");
break;
}
(void) printf("\n");
if (luProps->providerName[0] != 0) {
} else {
(void) printf("unknown");
}
(void) printf("\n");
} else {
(void) printf("-");
}
(void) printf("\n");
}
/*
* printTargetProps
*
* Prints the properties for a target
*
*/
static void
{
switch (targetProps->status) {
case STMF_TARGET_PORT_ONLINE:
(void) printf("Online");
break;
case STMF_TARGET_PORT_OFFLINE:
(void) printf("Offline");
break;
(void) printf("Onlining");
break;
(void) printf("Offlining");
break;
default:
(void) printf("unknown");
break;
}
(void) printf("\n");
if (targetProps->providerName[0] != 0) {
}
(void) printf("\n");
if (targetProps->alias[0] != 0) {
} else {
(void) printf("-");
}
(void) printf("\n");
switch (targetProps->protocol) {
break;
case STMF_PROTOCOL_ISCSI:
break;
case STMF_PROTOCOL_SRP:
break;
case STMF_PROTOCOL_SAS:
break;
default:
break;
}
(void) printf("\n");
}
/*
* printSessionProps
*
* Prints the session data
*
*/
static void
{
int i;
char *cTime;
for (i = 0; i < sessionList->cnt; i++) {
initiator[STMF_IDENT_LENGTH] = 0;
} else {
(void) printf("-");
}
(void) printf("\n");
} else {
(void) printf("unknown\n");
}
}
}
static int
{
int ret;
switch (ret) {
case STMF_STATUS_SUCCESS:
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
break;
gettext("STMF service not found"));
break;
case STMF_ERROR_BUSY:
gettext("resource busy"));
break;
gettext("STMF service version incorrect"));
break;
default:
break;
}
return (ret);
}
/*
* listStateFunc
*
* List the operational and config state of the stmf service
*
*/
/*ARGSUSED*/
static int
void *args)
{
int ret;
return (ret);
switch (state.operationalState) {
(void) printf("online");
break;
(void) printf("offline");
break;
(void) printf("onlining");
break;
(void) printf("offlining");
break;
default:
(void) printf("unknown");
break;
}
(void) printf("\n");
switch (state.configState) {
case STMF_CONFIG_STATE_NONE:
(void) printf("uninitialized");
break;
case STMF_CONFIG_STATE_INIT:
(void) printf("initializing");
break;
(void) printf("initialized");
break;
default:
(void) printf("unknown");
break;
}
(void) printf("\n");
switch (ret) {
case STMF_STATUS_SUCCESS:
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
break;
case STMF_ERROR_BUSY:
gettext("resource busy"));
break;
default:
break;
}
if (ret == STMF_STATUS_SUCCESS) {
if (aluaEnabled == B_TRUE) {
(void) printf("enabled");
} else {
(void) printf("disabled");
}
} else {
(void) printf("unknown");
}
(void) printf("\n");
if (ret == STMF_STATUS_SUCCESS) {
} else {
(void) printf("unknown");
}
(void) printf("\n");
return (ret);
}
/*
* listTargetFunc
*
* list the targets and optionally their properties
*
*/
/*ARGSUSED*/
static int
void *args)
{
int ret = 0;
int stmfRet;
int i, j;
int outerLoop;
switch (stmfRet) {
case STMF_ERROR_NOT_FOUND:
ret = 0;
break;
gettext("STMF service offline"));
break;
case STMF_ERROR_BUSY:
gettext("resource busy"));
break;
gettext("STMF service version incorrect"));
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
break;
default:
gettext("unknown error"));
break;
}
return (1);
}
switch (optionList->optval) {
case 'v':
break;
}
}
if (operandLen > 0) {
} else {
outerLoop = 1;
}
for (i = 0; i < outerLoop; i++) {
if (operandEntered) {
}
if (operandEntered) {
sizeof (devid)) == 0) {
}
}
(void) mbstowcs(targetIdent,
(char *)targetList->devid[j].ident,
targetIdent[STMF_IDENT_LENGTH] = 0;
if (verbose) {
&(targetList->devid[j]),
&targetProps);
if (stmfRet == STMF_STATUS_SUCCESS) {
} else {
cmdName);
gettext(" get properties"
" failed"));
}
&(targetList->devid[j]),
&sessionList);
if (stmfRet == STMF_STATUS_SUCCESS) {
} else {
cmdName);
gettext(" get session info"
" failed"));
}
}
if (found && operandEntered) {
break;
}
}
}
if (operandEntered && !found) {
operands[i], "not found");
ret = 1;
}
}
return (ret);
}
/*
* listViewFunc
*
* list the view entries for the specified logical unit
*
*/
/*ARGSUSED*/
static int
void *args)
{
int ret = 0;
int stmfRet;
int i, j, outerLoop;
case 'l':
"%s: %s: %s%d%s\n",
gettext(" hexadecimal digits"
" long"));
return (1);
}
break;
default:
gettext("unknown option"));
return (1);
}
}
if (operandLen > 0) {
} else {
outerLoop = 1;
}
for (i = 0; i < 32; i++)
sGuid[i] = 0;
for (i = 0; i < sizeof (stmfGuid); i++) {
}
!= STMF_STATUS_SUCCESS) {
switch (stmfRet) {
case STMF_ERROR_BUSY:
break;
case STMF_ERROR_NOT_FOUND:
break;
gettext("STMF service not found"));
break;
gettext("STMF service version incorrect"));
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
break;
default:
break;
}
return (1);
}
for (i = 0; i < outerLoop; i++) {
if (operandEntered) {
}
}
(void) printf("View Entry: %d\n",
(void) printf("All\n");
} else {
sizeof (stmfGroupName) - 1);
= 0;
}
(void) printf("All\n");
} else {
sizeof (stmfGroupName) - 1);
= 0;
}
if (found && operandEntered) {
break;
}
}
}
if (operandEntered && !found) {
ret = 1;
}
}
return (ret);
}
/*
* onlineOfflineLu
*
* Purpose: Online or offline a logical unit
*
* lu - logical unit to online or offline
*
* state - ONLINE_LU
* OFFLINE_LU
*/
static int
{
int i;
int ret = 0;
gettext("hexadecimal digits long"));
return (1);
}
for (i = 0; i < 32; i++)
sGuid[i] = 0;
for (i = 0; i < sizeof (stmfGuid); i++) {
}
} else if (state == OFFLINE_LU) {
}
if (ret != STMF_STATUS_SUCCESS) {
switch (ret) {
case STMF_ERROR_PERM:
gettext("permission denied"));
break;
gettext("STMF service not found"));
break;
case STMF_ERROR_NOT_FOUND:
break;
gettext("STMF service version incorrect"));
break;
default:
gettext("unknown error"));
break;
}
}
return (ret);
}
/*
* onlineLuFunc
*
* Purpose: Online a logical unit
*
*/
/*ARGSUSED*/
static int
void *args)
{
int ret;
if (ret != STMF_STATUS_SUCCESS)
return (ret);
gettext("STMF service is offline"));
return (1);
}
}
/*
* offlineLuFunc
*
* Purpose: Offline a logical unit
*
*/
/*ARGSUSED*/
static int
void *args)
{
}
/*
* onlineOfflineTarget
*
* Purpose: Online or offline a target
*
* target - target to online or offline
*
* state - ONLINE_TARGET
* OFFLINE_TARGET
*/
static int
{
int ret = 0;
return (1);
}
if (state == ONLINE_TARGET) {
} else if (state == OFFLINE_TARGET) {
}
if (ret != STMF_STATUS_SUCCESS) {
switch (ret) {
case STMF_ERROR_PERM:
gettext("permission denied"));
break;
gettext("STMF service not found"));
break;
case STMF_ERROR_NOT_FOUND:
break;
gettext("STMF service version incorrect"));
break;
default:
gettext("unknown error"));
break;
}
}
return (ret);
}
/*
* onlineTargetFunc
*
* Purpose: Online a target
*
*/
/*ARGSUSED*/
static int
void *args)
{
int ret;
if (ret != STMF_STATUS_SUCCESS)
return (ret);
gettext("STMF service is offline"));
return (1);
}
}
/*
* offlineTargetFunc
*
* Purpose: Offline a target
*
*/
/*ARGSUSED*/
static int
void *args)
{
}
/*ARGSUSED*/
static int
{
int i;
int ret = 0;
int stmfRet;
stmfGroupName groupName = {0};
case 'g':
sizeof (stmfGroupName) - 1);
break;
default:
gettext("unknown option"));
return (1);
}
}
for (i = 0; i < operandLen; i++) {
gettext("unrecognized device id"));
ret++;
continue;
}
switch (stmfRet) {
case STMF_STATUS_SUCCESS:
break;
ret++;
break;
ret++;
break;
case STMF_ERROR_BUSY:
operands[i], "resource busy");
ret++;
break;
gettext("STMF service not found"));
ret++;
break;
gettext("STMF service version incorrect"));
ret++;
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
ret++;
break;
default:
ret++;
break;
}
}
return (ret);
}
/*
* removeTargetGroupMemberFunc
*
* Removes one or more members from a target group
*
*/
/*ARGSUSED*/
static int
{
int i;
int ret = 0;
int stmfRet;
stmfGroupName groupName = {0};
case 'g':
sizeof (stmfGroupName) - 1);
break;
default:
gettext("unknown option"));
return (1);
}
}
for (i = 0; i < operandLen; i++) {
gettext("unrecognized device id"));
ret++;
continue;
}
switch (stmfRet) {
case STMF_STATUS_SUCCESS:
break;
ret++;
break;
ret++;
break;
case STMF_ERROR_BUSY:
ret++;
break;
gettext("STMF service not found"));
ret++;
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
ret++;
break;
gettext("STMF service version incorrect"));
ret++;
break;
case STMF_ERROR_TG_ONLINE:
gettext("STMF target must be offline"));
ret++;
break;
default:
ret++;
break;
}
}
return (ret);
}
/*
* removeViewFunc
*
* Removes one or more view entries from a logical unit
*
*/
/*ARGSUSED*/
static int
void *args)
{
char *endPtr;
int i;
int ret = 0;
int stmfRet;
/* Note: 'l' is required */
case 'l':
"%s: %s: %s %d %s\n",
gettext("hexadecimal digits long"));
return (1);
}
break;
case 'a':
/* removing all view entries for this GUID */
break;
default:
"unknown option");
return (1);
}
}
if (!all && operandLen == 0) {
gettext("no view entries specified"));
return (1);
}
if (!luInput) {
gettext("logical unit (-l) not specified"));
return (1);
}
for (i = 0; i < 32; i++)
sGuid[i] = 0;
for (i = 0; i < sizeof (stmfGuid); i++) {
}
!= STMF_STATUS_SUCCESS) {
switch (stmfRet) {
case STMF_ERROR_BUSY:
break;
case STMF_ERROR_NOT_FOUND:
break;
gettext("STMF service not found"));
break;
gettext("STMF service version incorrect"));
break;
case STMF_ERROR_PERM:
gettext("permission denied"));
break;
default:
break;
}
return (1);
}
if (all) {
} else {
count = operandLen;
}
for (i = 0; i < count; i++) {
if (all) {
} else {
continue;
}
}
switch (stmfRet) {
case STMF_STATUS_SUCCESS:
break;
case STMF_ERROR_NOT_FOUND:
gettext("not found"));
ret++;
break;
case STMF_ERROR_BUSY:
ret++;
break;
gettext("STMF service not found"));
ret++;
break;
case STMF_ERROR_CONFIG_NONE:
gettext("STMF service is not initialized"));
ret++;
break;
gettext("STMF service version incorrect"));
ret++;
break;
default:
gettext("unknown error"));
ret++;
break;
}
}
return (ret);
}
/*
* input:
* execFullName - exec name of program (argv[0])
*
* (changed name to lowerCamelCase to keep consistent with this file)
*
* Returns:
* command name portion of execFullName
*/
static char *
getExecBasename(char *execFullname)
{
char *lastSlash, *execBasename;
/* guard against '/' at end of command invocation */
for (;;) {
break;
} else {
if (*execBasename == '\0') {
*lastSlash = '\0';
continue;
}
break;
}
}
return (execBasename);
}
int
{
int ret;
int funcRet;
void *subcommandArgs = NULL;
(void) textdomain(TEXT_DOMAIN);
/* set global command name */
if (ret != 0) {
return (ret);
}
return (funcRet);
} /* end main */