summaryrefslogtreecommitdiff
path: root/usr/src/cmd
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2013-05-15 14:41:51 +0400
committerIgor Pashev <pashev.igor@gmail.com>2013-05-15 14:41:51 +0400
commit52f0af66b0b42d0bf03bd350c40272fd389cffb1 (patch)
treef929c53e361333056f8b91ca0a14457b04309cca /usr/src/cmd
parent4b587d510fc5e6d58d4b87327224bfe4e8b81c0a (diff)
downloadstmf-upstream/1.0.tar.gz
Portable versionupstream/1.0
Diffstat (limited to 'usr/src/cmd')
-rw-r--r--usr/src/cmd/stmfadm/stmfadm.c146
-rw-r--r--usr/src/cmd/stmfsvc/stmf.xml10
-rw-r--r--usr/src/cmd/stmfsvc/stmfsvc.c14
3 files changed, 87 insertions, 83 deletions
diff --git a/usr/src/cmd/stmfadm/stmfadm.c b/usr/src/cmd/stmfadm/stmfadm.c
index 0c98614..f9b8e60 100644
--- a/usr/src/cmd/stmfadm/stmfadm.c
+++ b/usr/src/cmd/stmfadm/stmfadm.c
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <stdio.h>
+#include <stdbool.h>
#include <strings.h>
#include <sys/types.h>
#include <unistd.h>
@@ -36,13 +37,14 @@
#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>
+#include "cmdparse.h"
+#include "libstmf.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 *);
@@ -243,7 +245,7 @@ subCommandProps_t subcommands[] = {
OPERAND_MANDATORY_MULTIPLE, OPERANDSTRING_GROUP_MEMBER, NULL},
{"remove-view", removeViewFunc, "la", "l", NULL,
OPERAND_OPTIONAL_MULTIPLE, OPERANDSTRING_VIEW_ENTRY, NULL},
- {NULL, 0, NULL, NULL, 0, NULL, 0, NULL, NULL}
+ {NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL}
};
/* globals */
@@ -613,9 +615,9 @@ addViewFunc(int operandLen, char *operands[], cmdOptions_t *options,
bzero(&viewEntry, sizeof (viewEntry));
/* init view entry structure */
- viewEntry.allHosts = B_TRUE;
- viewEntry.allTargets = B_TRUE;
- viewEntry.luNbrValid = B_FALSE;
+ viewEntry.allHosts = true;
+ viewEntry.allTargets = true;
+ viewEntry.luNbrValid = false;
/* check input length */
if (strlen(operands[0]) != GUID_INPUT) {
@@ -629,7 +631,7 @@ addViewFunc(int operandLen, char *operands[], cmdOptions_t *options,
switch (options->optval) {
/* logical unit number */
case 'n':
- viewEntry.luNbrValid = B_TRUE;
+ viewEntry.luNbrValid = true;
inputLuNbr = atoi(options->optarg);
if (inputLuNbr > MAX_LU_NBR) {
(void) fprintf(stderr, "%s: %d: %s\n",
@@ -643,13 +645,13 @@ addViewFunc(int operandLen, char *operands[], cmdOptions_t *options,
break;
/* host group */
case 'h':
- viewEntry.allHosts = B_FALSE;
+ viewEntry.allHosts = false;
bcopy(options->optarg, viewEntry.hostGroup,
strlen(options->optarg));
break;
/* target group */
case 't':
- viewEntry.allTargets = B_FALSE;
+ viewEntry.allTargets = false;
bcopy(options->optarg, viewEntry.targetGroup,
strlen(options->optarg));
break;
@@ -967,7 +969,7 @@ modifyLuFunc(int operandLen, char *operands[], cmdOptions_t *options,
char sGuid[GUID_INPUT + 1];
char *prop = NULL;
char *propVal = NULL;
- boolean_t fnameUsed = B_FALSE;
+ bool fnameUsed = false;
uint32_t propId;
cmdOptions_t *optionStart = options;
@@ -975,7 +977,7 @@ modifyLuFunc(int operandLen, char *operands[], cmdOptions_t *options,
for (; options->optval; options++) {
switch (options->optval) {
case 'f':
- fnameUsed = B_TRUE;
+ fnameUsed = true;
fname = operands[0];
break;
}
@@ -1327,11 +1329,11 @@ deleteLuFunc(int operandLen, char *operands[], cmdOptions_t *options,
int stmfRet;
unsigned int inGuid[sizeof (stmfGuid)];
stmfGuid delGuid;
- boolean_t keepViews = B_FALSE;
- boolean_t viewEntriesRemoved = B_FALSE;
- boolean_t noLunFound = B_FALSE;
- boolean_t views = B_FALSE;
- boolean_t notValidHexNumber = B_FALSE;
+ bool keepViews = false;
+ bool viewEntriesRemoved = false;
+ bool noLunFound = false;
+ bool views = false;
+ bool notValidHexNumber = false;
char sGuid[GUID_INPUT + 1];
stmfViewEntryList *viewEntryList = NULL;
@@ -1339,7 +1341,7 @@ deleteLuFunc(int operandLen, char *operands[], cmdOptions_t *options,
switch (options->optval) {
/* Keep views for logical unit */
case 'k':
- keepViews = B_TRUE;
+ keepViews = true;
break;
default:
(void) fprintf(stderr, "%s: %c: %s\n",
@@ -1353,18 +1355,18 @@ deleteLuFunc(int operandLen, char *operands[], cmdOptions_t *options,
for (i = 0; i < operandLen; i++) {
for (j = 0; j < GUID_INPUT; j++) {
if (!isxdigit(operands[i][j])) {
- notValidHexNumber = B_TRUE;
+ notValidHexNumber = true;
break;
}
sGuid[j] = tolower(operands[i][j]);
}
- if ((notValidHexNumber == B_TRUE) ||
+ if ((notValidHexNumber == true) ||
(strlen(operands[i]) != GUID_INPUT)) {
(void) fprintf(stderr, "%s: %s: %s%d%s\n",
cmdName, operands[i], gettext("must be "),
GUID_INPUT,
gettext(" hexadecimal digits long"));
- notValidHexNumber = B_FALSE;
+ notValidHexNumber = false;
ret++;
continue;
}
@@ -1387,7 +1389,7 @@ deleteLuFunc(int operandLen, char *operands[], cmdOptions_t *options,
case STMF_STATUS_SUCCESS:
break;
case STMF_ERROR_NOT_FOUND:
- noLunFound = B_TRUE;
+ noLunFound = true;
break;
case STMF_ERROR_BUSY:
(void) fprintf(stderr, "%s: %s\n", cmdName,
@@ -1416,7 +1418,7 @@ deleteLuFunc(int operandLen, char *operands[], cmdOptions_t *options,
}
/* check if viewEntryList is empty */
if (viewEntryList->cnt != 0)
- viewEntriesRemoved = B_TRUE;
+ viewEntriesRemoved = true;
stmfFreeMemory(viewEntryList);
} else {
(void) fprintf(stderr, "%s: %s\n", cmdName,
@@ -1429,7 +1431,7 @@ deleteLuFunc(int operandLen, char *operands[], cmdOptions_t *options,
stmfRet = stmfGetViewEntryList(&delGuid,
&viewEntryList);
if (stmfRet == STMF_STATUS_SUCCESS) {
- views = B_TRUE;
+ views = true;
stmfFreeMemory(viewEntryList);
}
}
@@ -1441,7 +1443,7 @@ deleteLuFunc(int operandLen, char *operands[], cmdOptions_t *options,
gettext("not found"));
ret++;
}
- noLunFound = viewEntriesRemoved = views = B_FALSE;
+ noLunFound = viewEntriesRemoved = views = false;
}
return (ret);
}
@@ -1650,9 +1652,9 @@ listHostGroupFunc(int operandLen, char *operands[], cmdOptions_t *options,
int ret = 0;
int stmfRet;
int i, j, outerLoop;
- boolean_t verbose = B_FALSE;
- boolean_t found = B_TRUE;
- boolean_t operandEntered;
+ bool verbose = false;
+ bool found = true;
+ bool operandEntered;
stmfGroupList *groupList;
stmfGroupProperties *groupProps;
wchar_t operandName[sizeof (stmfGroupName)];
@@ -1661,7 +1663,7 @@ listHostGroupFunc(int operandLen, char *operands[], cmdOptions_t *options,
for (; options->optval; options++) {
switch (options->optval) {
case 'v':
- verbose = B_TRUE;
+ verbose = true;
break;
default:
(void) fprintf(stderr, "%s: %c: %s\n",
@@ -1673,10 +1675,10 @@ listHostGroupFunc(int operandLen, char *operands[], cmdOptions_t *options,
if (operandLen > 0) {
outerLoop = operandLen;
- operandEntered = B_TRUE;
+ operandEntered = true;
} else {
outerLoop = 1;
- operandEntered = B_FALSE;
+ operandEntered = false;
}
stmfRet = stmfGetHostGroupList(&groupList);
@@ -1707,7 +1709,7 @@ listHostGroupFunc(int operandLen, char *operands[], cmdOptions_t *options,
}
for (i = 0; i < outerLoop; i++) {
- for (found = B_FALSE, j = 0; j < groupList->cnt; j++) {
+ for (found = false, j = 0; j < groupList->cnt; j++) {
(void) mbstowcs(groupNamePrint,
(char *)groupList->name[j],
sizeof (stmfGroupName) - 1);
@@ -1718,7 +1720,7 @@ listHostGroupFunc(int operandLen, char *operands[], cmdOptions_t *options,
operandName[sizeof (stmfGroupName) - 1] = 0;
if (wcscmp(operandName, groupNamePrint)
== 0) {
- found = B_TRUE;
+ found = true;
}
}
if ((found && operandEntered) || !operandEntered) {
@@ -1781,9 +1783,9 @@ listTargetGroupFunc(int operandLen, char *operands[], cmdOptions_t *options,
int ret = 0;
int stmfRet;
int i, j, outerLoop;
- boolean_t verbose = B_FALSE;
- boolean_t found = B_TRUE;
- boolean_t operandEntered;
+ bool verbose = false;
+ bool found = true;
+ bool operandEntered;
stmfGroupList *groupList;
stmfGroupProperties *groupProps;
wchar_t operandName[sizeof (stmfGroupName)];
@@ -1792,7 +1794,7 @@ listTargetGroupFunc(int operandLen, char *operands[], cmdOptions_t *options,
for (; options->optval; options++) {
switch (options->optval) {
case 'v':
- verbose = B_TRUE;
+ verbose = true;
break;
default:
(void) fprintf(stderr, "%s: %c: %s\n",
@@ -1804,10 +1806,10 @@ listTargetGroupFunc(int operandLen, char *operands[], cmdOptions_t *options,
if (operandLen > 0) {
outerLoop = operandLen;
- operandEntered = B_TRUE;
+ operandEntered = true;
} else {
outerLoop = 1;
- operandEntered = B_FALSE;
+ operandEntered = false;
}
stmfRet = stmfGetTargetGroupList(&groupList);
@@ -1838,7 +1840,7 @@ listTargetGroupFunc(int operandLen, char *operands[], cmdOptions_t *options,
}
for (i = 0; i < outerLoop; i++) {
- for (found = B_FALSE, j = 0; j < groupList->cnt; j++) {
+ for (found = false, j = 0; j < groupList->cnt; j++) {
(void) mbstowcs(groupNamePrint,
(char *)groupList->name[j],
sizeof (stmfGroupName) - 1);
@@ -1849,7 +1851,7 @@ listTargetGroupFunc(int operandLen, char *operands[], cmdOptions_t *options,
operandName[sizeof (stmfGroupName) - 1] = 0;
if (wcscmp(operandName, groupNamePrint)
== 0) {
- found = B_TRUE;
+ found = true;
}
}
if ((found && operandEntered) || !operandEntered) {
@@ -1889,25 +1891,25 @@ static int
listLuFunc(int operandLen, char *operands[], cmdOptions_t *options, void *args)
{
cmdOptions_t *optionList = options;
- boolean_t operandEntered;
+ bool operandEntered;
int i, j;
int ret = 0;
int stmfRet;
int outerLoop;
unsigned int inGuid[sizeof (stmfGuid)];
stmfGuid cmpGuid;
- boolean_t verbose = B_FALSE;
- boolean_t found;
+ bool verbose = false;
+ bool found;
char sGuid[GUID_INPUT + 1];
stmfGuidList *luList;
stmfLogicalUnitProperties luProps;
- boolean_t invalidInput = B_FALSE;
+ bool invalidInput = false;
stmfViewEntryList *viewEntryList;
for (; optionList->optval; optionList++) {
switch (optionList->optval) {
case 'v':
- verbose = B_TRUE;
+ verbose = true;
break;
}
}
@@ -1940,22 +1942,22 @@ listLuFunc(int operandLen, char *operands[], cmdOptions_t *options, void *args)
}
if (operandLen > 0) {
- operandEntered = B_TRUE;
+ operandEntered = true;
outerLoop = operandLen;
} else {
- operandEntered = B_FALSE;
+ operandEntered = false;
outerLoop = 1;
}
- for (invalidInput = B_FALSE, i = 0; i < outerLoop; i++) {
+ for (invalidInput = false, i = 0; i < outerLoop; i++) {
if (operandEntered) {
if (strlen(operands[i]) != GUID_INPUT) {
- invalidInput = B_TRUE;
+ invalidInput = true;
} else {
for (j = 0; j < GUID_INPUT; j++) {
if (!isxdigit(operands[i][j])) {
- invalidInput = B_TRUE;
+ invalidInput = true;
break;
}
}
@@ -1965,7 +1967,7 @@ listLuFunc(int operandLen, char *operands[], cmdOptions_t *options, void *args)
cmdName, operands[i], gettext("must be "),
GUID_INPUT,
gettext(" hexadecimal digits long"));
- invalidInput = B_FALSE;
+ invalidInput = false;
continue;
}
@@ -1986,11 +1988,11 @@ listLuFunc(int operandLen, char *operands[], cmdOptions_t *options, void *args)
}
}
- for (found = B_FALSE, j = 0; j < luList->cnt; j++) {
+ for (found = false, j = 0; j < luList->cnt; j++) {
if (operandEntered) {
if (bcmp(luList->guid[j].guid, cmpGuid.guid,
sizeof (stmfGuid)) == 0) {
- found = B_TRUE;
+ found = true;
}
}
if ((found && operandEntered) || !operandEntered) {
@@ -2452,7 +2454,7 @@ listStateFunc(int operandLen, char *operands[], cmdOptions_t *options,
{
int ret;
stmfState state;
- boolean_t aluaEnabled;
+ bool aluaEnabled;
uint32_t node;
if ((ret = getStmfState(&state)) != STMF_STATUS_SUCCESS)
@@ -2512,7 +2514,7 @@ listStateFunc(int operandLen, char *operands[], cmdOptions_t *options,
}
(void) printf("%-18s: ", "ALUA Status");
if (ret == STMF_STATUS_SUCCESS) {
- if (aluaEnabled == B_TRUE) {
+ if (aluaEnabled == true) {
(void) printf("enabled");
} else {
(void) printf("disabled");
@@ -2550,7 +2552,7 @@ listTargetFunc(int operandLen, char *operands[], cmdOptions_t *options,
int outerLoop;
stmfSessionList *sessionList;
stmfDevid devid;
- boolean_t operandEntered, found, verbose = B_FALSE;
+ bool operandEntered, found, verbose = false;
stmfDevidList *targetList;
wchar_t targetIdent[STMF_IDENT_LENGTH + 1];
stmfTargetProperties targetProps;
@@ -2587,17 +2589,17 @@ listTargetFunc(int operandLen, char *operands[], cmdOptions_t *options,
for (; optionList->optval; optionList++) {
switch (optionList->optval) {
case 'v':
- verbose = B_TRUE;
+ verbose = true;
break;
}
}
if (operandLen > 0) {
outerLoop = operandLen;
- operandEntered = B_TRUE;
+ operandEntered = true;
} else {
outerLoop = 1;
- operandEntered = B_FALSE;
+ operandEntered = false;
}
for (i = 0; i < outerLoop; i++) {
@@ -2605,11 +2607,11 @@ listTargetFunc(int operandLen, char *operands[], cmdOptions_t *options,
bzero(&devid, sizeof (devid));
(void) parseDevid(operands[i], &devid);
}
- for (found = B_FALSE, j = 0; j < targetList->cnt; j++) {
+ for (found = false, j = 0; j < targetList->cnt; j++) {
if (operandEntered) {
if (bcmp(&devid, &(targetList->devid[j]),
sizeof (devid)) == 0) {
- found = B_TRUE;
+ found = true;
}
}
if ((found && operandEntered) || !operandEntered) {
@@ -2676,8 +2678,8 @@ listViewFunc(int operandLen, char *operands[], cmdOptions_t *options,
int ret = 0;
int stmfRet;
int i, j, outerLoop;
- boolean_t found = B_TRUE;
- boolean_t operandEntered;
+ bool found = true;
+ bool operandEntered;
uint16_t outputLuNbr;
wchar_t groupName[sizeof (stmfGroupName)];
char sGuid[GUID_INPUT + 1];
@@ -2707,10 +2709,10 @@ listViewFunc(int operandLen, char *operands[], cmdOptions_t *options,
if (operandLen > 0) {
outerLoop = operandLen;
- operandEntered = B_TRUE;
+ operandEntered = true;
} else {
outerLoop = 1;
- operandEntered = B_FALSE;
+ operandEntered = false;
}
for (i = 0; i < 32; i++)
@@ -2761,11 +2763,11 @@ listViewFunc(int operandLen, char *operands[], cmdOptions_t *options,
}
for (i = 0; i < outerLoop; i++) {
- for (found = B_FALSE, j = 0; j < viewEntryList->cnt; j++) {
+ for (found = false, j = 0; j < viewEntryList->cnt; j++) {
if (operandEntered) {
if (atoi(operands[i]) ==
viewEntryList->ve[j].veIndex) {
- found = B_TRUE;
+ found = true;
}
}
if ((found && operandEntered) || !operandEntered) {
@@ -3301,8 +3303,8 @@ removeViewFunc(int operandLen, char *operands[], cmdOptions_t *options,
char *endPtr;
uint32_t veNbr;
int i;
- boolean_t all = B_FALSE;
- boolean_t luInput = B_FALSE;
+ bool all = false;
+ bool luInput = false;
int ret = 0;
int stmfRet;
@@ -3319,11 +3321,11 @@ removeViewFunc(int operandLen, char *operands[], cmdOptions_t *options,
return (1);
}
bcopy(options->optarg, sGuid, GUID_INPUT);
- luInput = B_TRUE;
+ luInput = true;
break;
case 'a':
/* removing all view entries for this GUID */
- all = B_TRUE;
+ all = true;
break;
default:
(void) fprintf(stderr, "%s: %c: %s\n",
@@ -3495,7 +3497,7 @@ main(int argc, char *argv[])
void *subcommandArgs = NULL;
(void) setlocale(LC_ALL, "");
- (void) textdomain(TEXT_DOMAIN);
+ textdomain(PACKAGE);
/* set global command name */
cmdName = getExecBasename(argv[0]);
diff --git a/usr/src/cmd/stmfsvc/stmf.xml b/usr/src/cmd/stmfsvc/stmf.xml
index b3119da..110afc9 100644
--- a/usr/src/cmd/stmfsvc/stmf.xml
+++ b/usr/src/cmd/stmfsvc/stmf.xml
@@ -1,5 +1,5 @@
<?xml version='1.0'?>
-<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
+<!DOCTYPE service_bundle SYSTEM '/usr/share/xml/schema/smf/service_bundle.dtd.1'>
<!--
@@ -40,7 +40,7 @@ Service manifests for SCSI Target Mode Framework
type='service'
version='1'>
- <create_default_instance enabled='false' />
+ <create_default_instance enabled='true' />
<single_instance/>
@@ -65,7 +65,7 @@ Service manifests for SCSI Target Mode Framework
/>
</method_context>
</exec_method>
-
+
<exec_method
type='method'
name='stop'
@@ -109,8 +109,8 @@ Service manifests for SCSI Target Mode Framework
<documentation>
<manpage title='stmf' section='7D'
manpath='/usr/share/man' />
- <manpage title='stmfadm' section='1M'
- manpath='/usr/share /man' />
+ <manpage title='stmfadm' section='8'
+ manpath='/usr/share/man' />
</documentation>
</template>
diff --git a/usr/src/cmd/stmfsvc/stmfsvc.c b/usr/src/cmd/stmfsvc/stmfsvc.c
index 814ebc2..d440a5d 100644
--- a/usr/src/cmd/stmfsvc/stmfsvc.c
+++ b/usr/src/cmd/stmfsvc/stmfsvc.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <stdio.h>
+#include <stdbool.h>
#include <strings.h>
#include <sys/types.h>
#include <unistd.h>
@@ -33,12 +34,13 @@
#include <string.h>
#include <assert.h>
#include <getopt.h>
-#include <cmdparse.h>
-#include <libstmf.h>
#include <signal.h>
#include <pthread.h>
#include <locale.h>
+#include "cmdparse.h"
+#include "libstmf.h"
+
static int svcStart(int, char **, cmdOptions_t *, void *);
static int svcStop(int, char **, cmdOptions_t *, void *);
static int online();
@@ -90,7 +92,7 @@ svcStop(int operandLen, char *operands[], cmdOptions_t *options,
int stmfRet;
int ret = 0;
stmfState state;
- boolean_t serviceOffline = B_FALSE;
+ bool serviceOffline = false;
struct timespec rqtp;
bzero(&rqtp, sizeof (rqtp));
@@ -127,7 +129,7 @@ svcStop(int operandLen, char *operands[], cmdOptions_t *options,
break;
}
if (state.operationalState == STMF_SERVICE_STATE_OFFLINE) {
- serviceOffline = B_TRUE;
+ serviceOffline = true;
} else {
(void) nanosleep(&rqtp, NULL);
}
@@ -199,7 +201,7 @@ online()
int stmfRet;
int ret = 0;
stmfState state;
- boolean_t serviceOnline = B_FALSE;
+ bool serviceOnline = false;
struct timespec rqtp;
bzero(&rqtp, sizeof (rqtp));
@@ -236,7 +238,7 @@ online()
break;
}
if (state.operationalState == STMF_SERVICE_STATE_ONLINE) {
- serviceOnline = B_TRUE;
+ serviceOnline = true;
} else {
(void) nanosleep(&rqtp, NULL);
}