/*
* 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 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2012 Milan Jurik. All rights reserved.
*/
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <libintl.h>
#include <errno.h>
#include <string.h>
#include <assert.h>
#include <getopt.h>
#include <strings.h>
#include <ctype.h>
#include <libnvpair.h>
#include <locale.h>
#include <cmdparse.h>
#include <sys/stmf_defines.h>
#include <libstmf.h>
#include <sys/stmf_sbd_ioctl.h>
char *cmdName;
static char *getExecBasename(char *);
void *callData);
int print_lu_attr(stmfGuid *);
void print_attr_header();
"Size with <none>/k/m/g/t/p/e modifier" },
"Dont delete view entries related to the LU" },
{ NULL, 0, 0 }
};
"Full path of the file to initialize" },
OPERAND_MANDATORY_SINGLE, "GUID of the LU to deregister" },
OPERAND_MANDATORY_SINGLE, "filename of the LU to import" },
OPERAND_NONE, "List all the exported LUs" },
"Full path of the LU or GUID of a registered LU" },
};
/*ARGSUSED*/
int
{
int ret = 0;
if (ret != STMF_STATUS_SUCCESS) {
return (1);
}
case 's':
if (ret != STMF_STATUS_SUCCESS) {
gettext("size param invalid"));
(void) stmfFreeLuResource(hdl);
return (1);
}
break;
default:
gettext("unknown option"));
return (1);
}
}
if (ret != STMF_STATUS_SUCCESS) {
return (1);
}
switch (ret) {
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("invalid size"));
ret++;
break;
case STMF_ERROR_META_CREATION:
gettext("could not create meta file"));
ret++;
break;
default:
gettext("unknown error"));
ret++;
break;
}
if (ret != STMF_STATUS_SUCCESS) {
goto done;
}
(void) printf("Created the following LU:\n");
done:
(void) stmfFreeLuResource(hdl);
return (ret);
}
/*ARGSUSED*/
int
{
int ret = 0;
switch (ret) {
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;
gettext("invalid size"));
ret++;
break;
case STMF_ERROR_META_CREATION:
gettext("could not create meta file"));
ret++;
break;
default:
gettext("unknown error"));
ret++;
break;
}
if (ret != STMF_STATUS_SUCCESS) {
goto done;
}
(void) printf("Imported the following LU:\n");
done:
return (ret);
}
/*ARGSUSED*/
int
void *callData)
{
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 ((notValidHexNumber == B_TRUE) ||
gettext(" hexadecimal digits long"));
ret++;
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,
}
/* check if viewEntryList is empty */
if (viewEntryList->cnt != 0)
} else {
gettext("unable to remove view entries\n"));
ret++;
}
}
if (keepViews) {
if (stmfRet == STMF_STATUS_SUCCESS) {
}
}
gettext("not found"));
ret++;
}
}
return (ret);
}
/*ARGSUSED*/
int
void *callData)
{
int ret = 0;
int i;
if (operands[0][0] == '/') {
}
/* 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 's':
"size") != 0) {
return (1);
}
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;
default:
stmfRet);
ret++;
break;
}
return (ret);
}
/*ARGSUSED*/
int
{
int stmfRet;
int sbdLuCnt = 0;
int i;
!= 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);
}
&luProps);
if (stmfRet != STMF_STATUS_SUCCESS) {
gettext("list failed"));
return (1);
}
sbdLuCnt++;
}
}
if (sbdLuCnt == 0)
return (0);
&luProps);
if (stmfRet != STMF_STATUS_SUCCESS) {
gettext("list failed"));
return (1);
}
}
}
return (0);
}
void
{
(void) printf("\n");
(void) printf(" GUID DATA SIZE "
" SOURCE\n");
(void) printf("-------------------------------- -------------------"
" ----------------\n");
}
void
{
int i;
for (i = 0; i < 16; i++) {
(void) fprintf(f, "%02x", g[i]);
}
}
int
{
int stmfRet = 0;
int ret = 0;
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);
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 {
(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 {
(void) printf("<error retrieving property>\n");
ret++;
}
(void) stmfFreeLuResource(hdl);
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 *
{
/* 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) textdomain(TEXT_DOMAIN);
/* set global command name */
if (ret != 0) {
return (ret);
}
return (funcRet);
} /* end main */