Ejemplo n.º 1
0
static int
stmfGetLogicalUnitProperties002()
{
	int stmfRet;
	int ret = 0;
	stmfGuid zeroGuid;
	stmfLogicalUnitProperties luProps;

	bzero(&zeroGuid, sizeof (zeroGuid));
	/*
	 * temporary fix to populate byte 0 with non-zero
	 * since driver checks this byte for 0
	 */
	zeroGuid.guid[0] = 1;
	stmfRet = stmfGetLogicalUnitProperties(&zeroGuid, &luProps);
	if (stmfRet != STMF_ERROR_NOT_FOUND) {
		ret = 2;
	}

	return (ret);
}
Ejemplo n.º 2
0
static int
stmfAddViewEntry003()
{
    int ret = 0;
    int i;
    boolean_t foundA = B_FALSE, foundB = B_FALSE;
    stmfViewEntry viewEntry;
    stmfGuidList *luList;
    stmfGuid guidA, guidB;
    stmfLogicalUnitProperties luProps;
    char sbdadmDeleteLuA[MAXPATHLEN];
    char sbdadmDeleteLuB[MAXPATHLEN];
    char guidAsciiBufA[33];
    char guidAsciiBufB[33];
    int stmfRet;

    bzero(&viewEntry, sizeof (viewEntry));
    (void) system("touch /tmp/stmfAddViewEntryA.lu");
    (void) system("touch /tmp/stmfAddViewEntryB.lu");
    (void) system("sbdadm create-lu -s 10g /tmp/stmfAddViewEntryA.lu");
    (void) system("sbdadm create-lu -s 10g /tmp/stmfAddViewEntryB.lu");
    stmfRet = stmfGetLogicalUnitList(&luList);
    if (stmfRet != STMF_STATUS_SUCCESS) {
        ret = 1;
        goto cleanup1;
    }

    for (i = 0; i < luList->cnt; i++) {
        stmfRet = stmfGetLogicalUnitProperties(&(luList->guid[i]),
                                               &luProps);
        if (strncmp(luProps.alias, "/tmp/stmfAddViewEntryA.lu",
                    sizeof (luProps.alias)) == 0) {
            foundA = B_TRUE;
            bcopy(&luList->guid[i], &guidA, sizeof (guidA));
        }
        if (strncmp(luProps.alias, "/tmp/stmfAddViewEntryB.lu",
                    sizeof (luProps.alias)) == 0) {
            foundB = B_TRUE;
            bcopy(&luList->guid[i], &guidB, sizeof (guidB));
        }
    }
    if (!foundA || !foundB) {
        ret = 1;
        goto cleanup1;
    }

    guidToAscii(&guidA, guidAsciiBufA);
    guidToAscii(&guidB, guidAsciiBufB);

    (void) snprintf(sbdadmDeleteLuA, sizeof (sbdadmDeleteLuA), "%s %s",
                    "sbdadm delete-lu", guidAsciiBufA);

    (void) snprintf(sbdadmDeleteLuB, sizeof (sbdadmDeleteLuA), "%s %s",
                    "sbdadm delete-lu", guidAsciiBufB);

    viewEntry.allHosts = B_TRUE;
    viewEntry.allTargets = B_TRUE;
    viewEntry.luNbrValid = B_TRUE;
    viewEntry.luNbr[0] = 232 >> 8;
    viewEntry.luNbr[1] = 232 & 0xff;

    stmfRet = stmfAddViewEntry(&guidA, &viewEntry);
    if (stmfRet != STMF_STATUS_SUCCESS) {
        ret = 1;
        goto cleanup2;
    }

    stmfRet = stmfAddViewEntry(&guidB, &viewEntry);
    if (stmfRet != STMF_ERROR_LUN_IN_USE) {
        ret = 2;
        goto cleanup2;
    }

cleanup3:
    (void) stmfRemoveViewEntry(&guidA, 0);
cleanup2:
    (void) system(sbdadmDeleteLuA);
    (void) system(sbdadmDeleteLuB);
cleanup1:
    (void) system("rm /tmp/stmfAddViewEntryA.lu");
    (void) system("rm /tmp/stmfAddViewEntryB.lu");
    return (ret);
}
Ejemplo n.º 3
0
/*ARGSUSED*/
int
list_lus(int argc, char *argv[], cmdOptions_t *options, void *callData)
{
    int stmfRet;
    stmfGuidList *luList;
    stmfLogicalUnitProperties luProps;
    int sbdLuCnt = 0;
    int i;

    if ((stmfRet = stmfGetLogicalUnitList(&luList))
            != STMF_STATUS_SUCCESS) {
        switch (stmfRet) {
        case STMF_ERROR_SERVICE_NOT_FOUND:
            (void) fprintf(stderr, "%s: %s\n", cmdName,
                           gettext("STMF service not found"));
            break;
        case STMF_ERROR_BUSY:
            (void) fprintf(stderr, "%s: %s\n", cmdName,
                           gettext("resource busy"));
            break;
        case STMF_ERROR_PERM:
            (void) fprintf(stderr, "%s: %s\n", cmdName,
                           gettext("permission denied"));
            break;
        case STMF_ERROR_SERVICE_DATA_VERSION:
            (void) fprintf(stderr, "%s: %s\n", cmdName,
                           gettext("STMF service version incorrect"));
            break;
        default:
            (void) fprintf(stderr, "%s: %s\n", cmdName,
                           gettext("list failed"));
            break;
        }
        return (1);
    }

    for (i = 0; i < luList->cnt; i++) {
        stmfRet = stmfGetLogicalUnitProperties(&luList->guid[i],
                                               &luProps);
        if (stmfRet != STMF_STATUS_SUCCESS) {
            (void) fprintf(stderr, "%s: %s\n", cmdName,
                           gettext("list failed"));
            return (1);
        }
        if (strcmp(luProps.providerName, "sbd") == 0) {
            sbdLuCnt++;
        }
    }


    if (sbdLuCnt == 0)
        return (0);

    (void) printf("\nFound %d LU(s)\n", sbdLuCnt);
    print_attr_header();

    for (i = 0; i < luList->cnt; i++) {
        stmfRet = stmfGetLogicalUnitProperties(&luList->guid[i],
                                               &luProps);
        if (stmfRet != STMF_STATUS_SUCCESS) {
            (void) fprintf(stderr, "%s: %s\n", cmdName,
                           gettext("list failed"));
            return (1);
        }
        if (strcmp(luProps.providerName, "sbd") == 0) {
            (void) print_lu_attr(&luList->guid[i]);
        }
    }
    return (0);
}
Ejemplo n.º 4
0
static int
stmfRemoveViewEntry001()
{
	int ret = 0;
	int i;
	boolean_t found = B_FALSE;
	stmfViewEntry viewEntry;
	stmfGuidList *luList;
	stmfLogicalUnitProperties luProps;
	stmfViewEntryList *viewEntryList;
	char sbdadmDeleteLu[MAXPATHLEN];
	char guidAsciiBuf[33];
	int stmfRet;

	bzero(&viewEntry, sizeof (viewEntry));
	(void) system("touch /tmp/stmfRemoveViewEntry.lu");
	(void) system("sbdadm create-lu -s 10g /tmp/stmfRemoveViewEntry.lu");
	stmfRet = stmfGetLogicalUnitList(&luList);
	if (stmfRet != STMF_STATUS_SUCCESS) {
		ret = 1;
		goto cleanup1;
	}

	for (i = 0; i < luList->cnt; i++) {
		stmfRet = stmfGetLogicalUnitProperties(&(luList->guid[i]),
		    &luProps);
		if (strncmp(luProps.alias, "/tmp/stmfRemoveViewEntry.lu",
		    sizeof (luProps.alias)) == 0) {
			found = B_TRUE;
			break;
		}
	}
	if (!found) {
		ret = 2;
		goto cleanup1;
	}

	guidToAscii(&luList->guid[i], guidAsciiBuf);

	(void) snprintf(sbdadmDeleteLu, sizeof (sbdadmDeleteLu), "%s %s",
	    "sbdadm delete-lu", guidAsciiBuf);

	viewEntry.allHosts = B_TRUE;
	viewEntry.allTargets = B_TRUE;
	viewEntry.luNbrValid = B_FALSE;

	stmfRet = stmfAddViewEntry(&(luList->guid[i]), &viewEntry);
	if (stmfRet != STMF_STATUS_SUCCESS) {
		ret = 3;
		goto cleanup2;
	}

	stmfRet = stmfGetViewEntryList(&(luList->guid[i]), &viewEntryList);
	if (stmfRet != STMF_STATUS_SUCCESS) {
		ret = 4;
		goto cleanup2;
	}

	if (viewEntryList->cnt > 0) {
		if ((viewEntryList->ve[0].allHosts != B_TRUE) ||
		    (viewEntryList->ve[0].allTargets != B_TRUE)) {
			ret = 5;
			goto cleanup2;
		}
		if (viewEntryList->ve[0].luNbrValid != B_TRUE) {
			ret = 6;
			goto cleanup2;
		}
	}

	stmfRet = stmfRemoveViewEntry(&(luList->guid[i]),
	    viewEntryList->ve[0].veIndex);
	if (stmfRet != STMF_STATUS_SUCCESS) {
		ret = 7;
		goto cleanup2;
	}

	stmfFreeMemory(viewEntryList);

	stmfRet = stmfGetViewEntryList(&(luList->guid[i]), &viewEntryList);
	if (stmfRet != STMF_ERROR_NOT_FOUND) {
		ret = 8;
		goto cleanup2;
	}

cleanup2:
	(void) system(sbdadmDeleteLu);
cleanup1:
	(void) system("rm /tmp/stmfRemoveViewEntry.lu");
	return (ret);
}