示例#1
0
/*
 * Create the XBSA Backup Copy Object.
 * BSACreateObject
 */
afs_int32
xbsa_WriteObjectBegin(struct butx_transactionInfo * info,
		      char *objectSpaceName, char *pathName, char *lGName,
		      afs_hyper_t estimatedSize, char *objectDescription,
		      char *objectInfo)
{
    int rc;
    int length;
    DataBlock dataBlock;

    if (debugLevel > 98) {
	printf
	    ("\nxbsa_WriteObjectBegin objectSpacename='%s' pathName='%s' lGName='%s' "
	     "estimatesSize='0x%x%08x objectDescription='%s' objectInfo='%s'\n",
	     GOODSTR(objectSpaceName), GOODSTR(pathName), GOODSTR(lGName),
	     hgethi(estimatedSize), hgetlo(estimatedSize),
	     GOODSTR(objectDescription), GOODSTR(objectInfo));
	printf
	    ("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n",
	     GOODSTR(info->serverName),
	     GOODSTR(info->objOwner.bsaObjectOwner),
	     GOODSTR(info->objOwner.appObjectOwner));
    }

    if (info->bsaHandle == 0) {
	/* We haven't initialized yet! */
	ELog(0,
	     "xbsa_WriteObjectBegin: No current handle, butx not initialized\n");
	return (BUTX_NOHANDLE);
    }

    if (objectSpaceName) {
	if (strlen(objectSpaceName) >= BSA_MAX_OSNAME) {
	    ELog(0,
		 "xbsa_WriteObjectBegin: The objectSpaceName is too long; size = %d; name = %s\n",
		 strlen(objectSpaceName), objectSpaceName);
	    return (BUTX_INVALIDOBJECTSPNAME);
	}
	strcpy(info->curObject.objName.objectSpaceName, objectSpaceName);
    } else {
	info->curObject.objName.objectSpaceName[0] = NULL;
    }

    if (pathName) {
	if (strlen(pathName) >= BSA_MAX_PATHNAME) {
	    ELog(0,
		 "xbsa_WriteObjectBegin: The pathName is too long; size = %d; name = %s\n",
		 strlen(pathName), pathName);
	    return (BUTX_INVALIDPATHNAME);
	}
	strcpy(info->curObject.objName.pathName, pathName);
    } else {
	info->curObject.objName.pathName[0] = NULL;
    }

    if (lGName) {
	if (strlen(lGName) >= BSA_MAX_LG_NAME) {
	    ELog(0,
		 "xbsa_WriteObjectBegin: The lGName is too long; size = %d; name = %s\n",
		 strlen(lGName), lGName);
	    return (BUTX_INVALIDLGNAME);
	}
	strcpy(info->curObject.lGName, lGName);
    } else {
	info->curObject.lGName[0] = NULL;
    }

    if (objectDescription) {
	if (((XBSA_GET_SERVER_TYPE(info->serverType) == XBSA_SERVER_TYPE_ADSM)
	     && (strlen(objectDescription) >= ADSM_MAX_DESC))
	    ||
	    ((XBSA_GET_SERVER_TYPE(info->serverType) != XBSA_SERVER_TYPE_ADSM)
	     && (strlen(objectDescription) >= BSA_MAX_DESC))) {
	    ELog(0,
		 "xbsa_WriteObjectBegin: The objectDescription is too long; size = %d; name = %s\n",
		 strlen(objectDescription), objectDescription);
	    return (BUTX_INVALIDOBJDESC);
	}
	strcpy(info->curObject.desc, objectDescription);
    } else {
	info->curObject.desc[0] = NULL;
    }

    if (objectInfo) {
	if (((XBSA_GET_SERVER_TYPE(info->serverType) == XBSA_SERVER_TYPE_ADSM)
	     && (strlen(objectInfo) >= ADSM_MAX_OBJINFO))
	    ||
	    ((XBSA_GET_SERVER_TYPE(info->serverType) != XBSA_SERVER_TYPE_ADSM)
	     && (strlen(objectInfo) >= BSA_MAX_OBJINFO))) {
	    ELog(0,
		 "xbsa_WriteObjectBegin: The objectInfo is too long; size = %d; name = %s\n",
		 strlen(objectInfo), objectInfo);
	    return (BUTX_INVALIDOBJINFO);
	}
	strcpy(info->curObject.objectInfo, objectInfo);
    } else {
	info->curObject.objectInfo[0] = NULL;
    }

    if (info->numObjects == info->maxObjects) {
	/* If we've used up Max Objects we must start a new transaction. */
	rc = (int)xbsa_EndTrans(info);
	if (rc != XBSA_SUCCESS) {
	    return (rc);
	}
	rc = (int)xbsa_BeginTrans(info);
	if (rc != XBSA_SUCCESS) {
	    return (rc);
	}
    }

    dataBlock.bufferLen = (BSA_UInt16) 0;
    dataBlock.numBytes = (BSA_UInt16) 0;
    dataBlock.bufferPtr = 0;

    info->curObject.Owner = info->objOwner;
    info->curObject.copyType = BSACopyType_BACKUP;
    info->curObject.size.left = hgethi(estimatedSize);
    info->curObject.size.right = hgetlo(estimatedSize);
    info->curObject.objectType = BSAObjectType_FILE;
    strcpy(info->curObject.resourceType, resourceType);

    rc = (int)XBSACreateObject(info->bsaHandle, &info->curObject, &dataBlock);
    if (rc != BSA_RC_SUCCESS) {
	ELog(0,
	     "xbsa_WriteObjectBegin: The XBSACreateObject call failed with %d\n",
	     rc);
	xbsa_error(rc, info);
	return (BUTX_CREATEOBJFAIL);
    }

    info->numObjects++;

    return (XBSA_SUCCESS);
}
示例#2
0
int
main(int argc, char *argv[])
{
    int rc;
    afs_status_t st = 0;
    rxdebugHandle_p handle;
    char *srvrName;
    long srvrPort;
    void *iterator;
    struct rx_debugPeer peer;
    afs_uint32 supportedValues;

    ParseArgs(argc, argv, &srvrName, &srvrPort);

    rc = afsclient_Init(&st);
    if (!rc) {
	fprintf(stderr, "afsclient_Init, status %d\n", st);
	exit(1);
    }

    rc = afsclient_RXDebugOpenPort(srvrName, srvrPort, &handle, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_RXDebugOpenPort, status %d\n", st);
	exit(1);
    }

    rc = util_RXDebugPeersBegin(handle, &iterator, &st);
    if (!rc) {
	fprintf(stderr, "util_RXDebugPeersBegin, status %d\n", st);
	exit(1);
    }

    while (util_RXDebugPeersNext(iterator, &peer, &supportedValues, &st)) {
	printf("\n");
	printf("host:            %u.%u.%u.%u\n", (peer.host >> 24) & 0xff,
	       (peer.host >> 16) & 0xff, (peer.host >> 8) & 0xff,
	       peer.host & 0xff);
	printf("port:            %u\n", peer.port);
	printf("ifMTU:           %u\n", peer.ifMTU);
	printf("idleWhen:        %u\n", peer.idleWhen);
	printf("refCount:        %u\n", peer.refCount);
	printf("burstSize:       %u\n", peer.burstSize);
	printf("burst:           %u\n", peer.burst);
	printf("burstWait:       %u.%06u\n", peer.burstWait.sec,
	       peer.burstWait.usec);
	printf("rtt:             %u\n", peer.rtt);
	printf("rtt_dev:         %u\n", peer.rtt_dev);
	printf("timeout:         %u.%06u\n", peer.timeout.sec,
	       peer.timeout.usec);
	printf("nSent:           %u\n", peer.nSent);
	printf("reSends:         %u\n", peer.reSends);
	printf("inPacketSkew:    %u\n", peer.inPacketSkew);
	printf("outPacketSkew:   %u\n", peer.outPacketSkew);
	printf("rateFlag:        %u\n", peer.rateFlag);
	printf("natMTU:          %u\n", peer.natMTU);
	printf("maxMTU:          %u\n", peer.maxMTU);
	printf("maxDgramPackets: %u\n", peer.maxDgramPackets);
	printf("ifDgramPackets:  %u\n", peer.ifDgramPackets);
	printf("MTU:             %u\n", peer.MTU);
	printf("cwind:           %u\n", peer.cwind);
	printf("nDgramPackets:   %u\n", peer.nDgramPackets);
	printf("congestSeq:      %u\n", peer.congestSeq);
	printf("bytesSent:       (%u.%u)\n", hgethi(peer.bytesSent),
	       hgetlo(peer.bytesSent));
	printf("bytesReceived:   (%u.%u)\n", hgethi(peer.bytesReceived),
	       hgetlo(peer.bytesReceived));
    }
    if (st != ADMITERATORDONE) {
	fprintf(stderr, "util_RXDebugPeersNext, status %d\n", st);
	exit(1);
    }
    printf("\n");

    rc = util_RXDebugPeersDone(iterator, &st);
    if (!rc) {
	fprintf(stderr, "util_RXDebugPeersDone, status %d\n", st);
	exit(1);
    }

    rc = afsclient_RXDebugClose(handle, &st);
    if (!rc) {
	fprintf(stderr, "afsclient_RXDebugClose, status %d\n", st);
	exit(1);
    }

    exit(0);
}