summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsrivijitha dugganapalli <Srivijitha.Dugganapalli@Sun.COM>2010-02-18 12:37:30 -0700
committersrivijitha dugganapalli <Srivijitha.Dugganapalli@Sun.COM>2010-02-18 12:37:30 -0700
commit7b506e25917c371db526f76d85b9b1d17c8c5d39 (patch)
tree6d4d6a0b5b20187d26ecf83f5ca5d508cd316de8
parent20272c2e66d77f79ef35e7160584b5d098c3287f (diff)
downloadillumos-gate-7b506e25917c371db526f76d85b9b1d17c8c5d39.tar.gz
6896927 stmfGetViewEntryList() should return an empty list when no views are found
6901489 stmfadm delete-lu 600144F0D8EBC60000004B0009D002EA -k return 0, it should return non-zero 6908989 delete_lu() should check for length of the GUID passed in 6908988 deleteLuFunc() should check for length of the GUID passed in 6899423 addTargetGroupMemberFunc, addHostGroupMemberFunc don't count perm error 6901477 stmfSet(Get)LuProp with 65535 as prop return STMF_ERROR_NO_PROP insteat of STMF_ERROR_INVALID_PROP 6904251 stmfGetLuResource core dumped when invoked with NULL as hdl 6864263 The max length of LU alias is less than 255 chars
-rw-r--r--usr/src/cmd/sbdadm/sbdadm.c18
-rw-r--r--usr/src/cmd/stmfadm/stmfadm.c43
-rw-r--r--usr/src/common/cmdparse/cmdparse.h4
-rw-r--r--usr/src/lib/libstmf/common/stmf.c14
4 files changed, 47 insertions, 32 deletions
diff --git a/usr/src/cmd/sbdadm/sbdadm.c b/usr/src/cmd/sbdadm/sbdadm.c
index c1e62ff6d9..c0680816a5 100644
--- a/usr/src/cmd/sbdadm/sbdadm.c
+++ b/usr/src/cmd/sbdadm/sbdadm.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdlib.h>
@@ -290,6 +290,7 @@ delete_lu(int operandLen, char *operands[], cmdOptions_t *options,
boolean_t viewEntriesRemoved = B_FALSE;
boolean_t noLunFound = B_FALSE;
boolean_t views = B_FALSE;
+ boolean_t notValidHexNumber = B_FALSE;
char sGuid[GUID_INPUT + 1];
stmfViewEntryList *viewEntryList = NULL;
@@ -311,15 +312,18 @@ delete_lu(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;
break;
}
- sGuid[j] = tolower(operands[i][j]);
+ sGuid[j] = tolower(operands[i][j]);
}
- if (j != GUID_INPUT) {
+ if ((notValidHexNumber == B_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;
ret++;
continue;
}
@@ -369,13 +373,15 @@ delete_lu(int operandLen, char *operands[], cmdOptions_t *options,
(void) stmfRemoveViewEntry(&delGuid,
viewEntryList->ve[j].veIndex);
}
- viewEntriesRemoved = B_TRUE;
+ /* check if viewEntryList is empty */
+ if (viewEntryList->cnt != 0)
+ viewEntriesRemoved = B_TRUE;
stmfFreeMemory(viewEntryList);
- } else if (stmfRet != STMF_ERROR_NOT_FOUND) {
+ } else {
(void) fprintf(stderr, "%s: %s\n", cmdName,
gettext("unable to remove view entries\n"));
ret++;
- } /* No view entries to remove */
+ }
}
if (keepViews) {
stmfRet = stmfGetViewEntryList(&delGuid,
diff --git a/usr/src/cmd/stmfadm/stmfadm.c b/usr/src/cmd/stmfadm/stmfadm.c
index 045edfb50b..518ecac4b2 100644
--- a/usr/src/cmd/stmfadm/stmfadm.c
+++ b/usr/src/cmd/stmfadm/stmfadm.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -303,6 +303,7 @@ addHostGroupMemberFunc(int operandLen, char *operands[], cmdOptions_t *options,
case STMF_ERROR_PERM:
(void) fprintf(stderr, "%s: %s\n", cmdName,
gettext("permission denied"));
+ ret++;
break;
case STMF_ERROR_BUSY:
(void) fprintf(stderr, "%s: %s: %s\n", cmdName,
@@ -390,6 +391,7 @@ addTargetGroupMemberFunc(int operandLen, char *operands[],
case STMF_ERROR_PERM:
(void) fprintf(stderr, "%s: %s\n", cmdName,
gettext("permission denied"));
+ ret++;
break;
case STMF_ERROR_BUSY:
(void) fprintf(stderr, "%s: %s: %s\n", cmdName,
@@ -1323,6 +1325,7 @@ deleteLuFunc(int operandLen, char *operands[], cmdOptions_t *options,
boolean_t viewEntriesRemoved = B_FALSE;
boolean_t noLunFound = B_FALSE;
boolean_t views = B_FALSE;
+ boolean_t notValidHexNumber = B_FALSE;
char sGuid[GUID_INPUT + 1];
stmfViewEntryList *viewEntryList = NULL;
@@ -1344,15 +1347,19 @@ 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;
break;
}
sGuid[j] = tolower(operands[i][j]);
}
- if (j != GUID_INPUT) {
+ if ((notValidHexNumber == B_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;
+ ret++;
continue;
}
@@ -1401,13 +1408,16 @@ deleteLuFunc(int operandLen, char *operands[], cmdOptions_t *options,
(void) stmfRemoveViewEntry(&delGuid,
viewEntryList->ve[j].veIndex);
}
- viewEntriesRemoved = B_TRUE;
+ /* check if viewEntryList is empty */
+ if (viewEntryList->cnt != 0)
+ viewEntriesRemoved = B_TRUE;
stmfFreeMemory(viewEntryList);
- } else if (stmfRet != STMF_ERROR_NOT_FOUND) {
+ } else {
(void) fprintf(stderr, "%s: %s\n", cmdName,
gettext("unable to remove view entries\n"));
ret++;
- } /* No view entries to remove */
+ }
+
}
if (keepViews) {
stmfRet = stmfGetViewEntryList(&delGuid,
@@ -2004,9 +2014,6 @@ listLuFunc(int operandLen, char *operands[], cmdOptions_t *options, void *args)
if (stmfRet == STMF_STATUS_SUCCESS) {
(void) printf("%d",
viewEntryList->cnt);
- } else if (stmfRet ==
- STMF_ERROR_NOT_FOUND) {
- (void) printf("0");
} else {
(void) printf("unknown");
}
@@ -2722,10 +2729,6 @@ listViewFunc(int operandLen, char *operands[], cmdOptions_t *options,
(void) fprintf(stderr, "%s: %s: %s\n", cmdName,
sGuid, gettext("resource busy"));
break;
- case STMF_ERROR_NOT_FOUND:
- (void) fprintf(stderr, "%s: %s: %s\n", cmdName,
- sGuid, gettext("no views found"));
- break;
case STMF_ERROR_SERVICE_NOT_FOUND:
(void) fprintf(stderr, "%s: %s\n", cmdName,
gettext("STMF service not found"));
@@ -2746,6 +2749,12 @@ listViewFunc(int operandLen, char *operands[], cmdOptions_t *options,
return (1);
}
+ if (viewEntryList->cnt == 0) {
+ (void) fprintf(stderr, "%s: %s: %s\n", cmdName,
+ sGuid, gettext("no views found"));
+ return (1);
+ }
+
for (i = 0; i < outerLoop; i++) {
for (found = B_FALSE, j = 0; j < viewEntryList->cnt; j++) {
if (operandEntered) {
@@ -3263,10 +3272,6 @@ removeViewFunc(int operandLen, char *operands[], cmdOptions_t *options,
(void) fprintf(stderr, "%s: %s: %s\n", cmdName,
sGuid, gettext("resource busy"));
break;
- case STMF_ERROR_NOT_FOUND:
- (void) fprintf(stderr, "%s: %s: %s\n", cmdName,
- sGuid, gettext("no views found"));
- break;
case STMF_ERROR_SERVICE_NOT_FOUND:
(void) fprintf(stderr, "%s: %s\n", cmdName,
gettext("STMF service not found"));
@@ -3287,6 +3292,12 @@ removeViewFunc(int operandLen, char *operands[], cmdOptions_t *options,
return (1);
}
+ if (viewEntryList->cnt == 0) {
+ (void) fprintf(stderr, "%s: %s: %s\n", cmdName,
+ sGuid, gettext("no views found"));
+ return (1);
+ }
+
if (all) {
count = viewEntryList->cnt;
} else {
diff --git a/usr/src/common/cmdparse/cmdparse.h b/usr/src/common/cmdparse/cmdparse.h
index 63554a16a1..47dab55117 100644
--- a/usr/src/common/cmdparse/cmdparse.h
+++ b/usr/src/common/cmdparse/cmdparse.h
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -41,7 +41,7 @@ extern "C" {
#define OPERAND_OPTIONAL 0x10
/* maximum length of an option argument */
-#define MAXOPTARGLEN 256
+#define MAXOPTARGLEN 512
/* Following are used to express operand requirements */
diff --git a/usr/src/lib/libstmf/common/stmf.c b/usr/src/lib/libstmf/common/stmf.c
index f64396046b..204085b02d 100644
--- a/usr/src/lib/libstmf/common/stmf.c
+++ b/usr/src/lib/libstmf/common/stmf.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -2141,6 +2141,9 @@ stmfGetLuResource(stmfGuid *luGuid, luResource *hdl)
int ret = STMF_STATUS_SUCCESS;
stmfLogicalUnitProperties luProps;
+ if (hdl == NULL) {
+ return (STMF_ERROR_INVALID_ARG);
+ }
/* Check logical unit provider name to call correct dtype function */
if ((ret = stmfGetLogicalUnitProperties(luGuid, &luProps))
@@ -2824,7 +2827,7 @@ getDiskProp(luResourceImpl *hdl, uint32_t prop, char *propVal, size_t *propLen)
}
break;
default:
- ret = STMF_ERROR_NO_PROP;
+ ret = STMF_ERROR_INVALID_PROP;
break;
}
@@ -3021,7 +3024,7 @@ setDiskProp(luResourceImpl *hdl, uint32_t resourceProp, const char *propVal)
ret = STMF_ERROR_INVALID_PROP;
break;
default:
- ret = STMF_ERROR_NO_PROP;
+ ret = STMF_ERROR_INVALID_PROP;
break;
}
return (ret);
@@ -4826,11 +4829,6 @@ stmfGetViewEntryList(stmfGuid *lu, stmfViewEntryList **viewEntryList)
goto done;
}
- if (stmfIoctl.stmf_obuf_nentries == 0) {
- ret = STMF_ERROR_NOT_FOUND;
- goto done;
- }
-
listCnt = stmfIoctl.stmf_obuf_nentries;
/*