ClRcT clTestCheckpointWrite(ClCkptHdlT ckptHdl, ClUint32T numSections) { ClRcT rc = CL_OK; ClUint32T i = 0; ClCkptIOVectorElementT iov[numSections]; ClUint32T readIdx = 0; memset(iov, 0, numSections * sizeof(ClCkptIOVectorElementT)); for( i = 0; i < numSections; i++ ) { if( numSections != 1 ) { iov[i].sectionId.id = clHeapCalloc(1, 15); if( NULL == iov[i].sectionId.id ) { return CL_OK; } snprintf( (ClCharT *) iov[i].sectionId.id, 15, "section%d", i); iov[i].sectionId.idLen = strlen((ClCharT *) iov[i].sectionId.id) + 1; } iov[i].dataSize = 50; if( NULL != (iov[i].dataBuffer = clHeapCalloc(1, iov[i].dataSize)) ) { memset(iov[i].dataBuffer, 'a', iov[i].dataSize); } iov[i].readSize = 0; iov[i].dataOffset = 0; } rc = clCkptCheckpointWrite(ckptHdl, iov, numSections, &readIdx); if( CL_OK != rc ) { return rc; } for( i = 0; i < numSections; i++ ) { if( NULL != iov[i].sectionId.id ) { clHeapFree(iov[i].sectionId.id); clHeapFree(iov[i].dataBuffer); } } return CL_OK; }
ClRcT clLogMasterCompDataCheckpoint(ClLogMasterEoDataT *pMasterEoEntry, ClLogCompDataT *pCompData) { ClRcT rc = CL_OK; ClCkptIOVectorElementT ioVector[3] = {{{0}}}; ClUint32T numComps = pMasterEoEntry->numComps; ClUint32T compCnt = 0; ClUint32T dataSize = 0; ClUint8T *pDataBuffer = NULL; ClUint32T dataOffset = 0; ClUint32T errIdx = 0; ClUint32T versionCode = 0; CL_LOG_DEBUG_TRACE(("Enter")); rc = clLogMasterCompData2BufferGet(pCompData, &pDataBuffer, &dataSize); if( CL_OK != rc ) { return rc; } versionCode = CL_VERSION_CODE(CL_RELEASE_VERSION, CL_MAJOR_VERSION, CL_MINOR_VERSION); versionCode = htonl(versionCode); ++numComps; compCnt = htonl(numComps); ioVector[0].sectionId = gLogMasterCompDataSectionId; ioVector[0].dataBuffer = (ClUint8T*)&versionCode; ioVector[0].dataSize = sizeof(versionCode); ioVector[0].readSize = 0; ioVector[0].dataOffset = 0; ioVector[1].sectionId = gLogMasterCompDataSectionId; ioVector[1].dataBuffer = (ClUint8T *) &compCnt; ioVector[1].dataSize = sizeof(numComps); ioVector[1].readSize = 0; ioVector[1].dataOffset = sizeof(versionCode); ioVector[2].sectionId = gLogMasterCompDataSectionId; dataOffset = (pMasterEoEntry->numComps * CL_LOG_COMP_SEC_OFFSET) + sizeof(numComps) + sizeof(versionCode); ioVector[2].dataBuffer = pDataBuffer; ioVector[2].dataSize = dataSize; ioVector[2].readSize = 0; ioVector[2].dataOffset = dataOffset; rc = clCkptCheckpointWrite(pMasterEoEntry->hCkpt, ioVector, 3, &errIdx); if( (CL_OK != rc) && (CL_ERR_TRY_AGAIN != CL_GET_ERROR_CODE(rc)) ) { CL_LOG_DEBUG_ERROR(("clkCptCheckpointWrite(): rc[0x %x]", rc)); clHeapFree(pDataBuffer); return rc; } pMasterEoEntry->numComps = numComps; clHeapFree(pDataBuffer); CL_LOG_DEBUG_TRACE(("curr Comp Cnt: %d ", numComps)); CL_LOG_DEBUG_TRACE(("Exit")); return rc; }
SaAisErrorT saCkptCheckpointWrite( SaCkptCheckpointHandleT checkpointHandle, const SaCkptIOVectorElementT *pIoVector, SaUint32T numberOfElements, SaUint32T *erroneousVectorIndex) { ClRcT rc = CL_OK; SaAisErrorT safRc = SA_AIS_OK; ClCkptIOVectorElementT *pTempVec = NULL; ClCkptIOVectorElementT *pInVector = NULL; ClUint32T count = 0; /* * Validate the input parameters. */ if(pIoVector == NULL) return SA_AIS_ERR_INVALID_PARAM; /* * Copy the iovector in clovis format. */ pTempVec = (ClCkptIOVectorElementT *)pIoVector; if(pIoVector != NULL) { pInVector = (ClCkptIOVectorElementT *)clHeapAllocate( sizeof(ClCkptIOVectorElementT) * numberOfElements); memset(pInVector, '\0', sizeof(ClCkptIOVectorElementT) * numberOfElements); pTempVec = pInVector; for(count = 0; count < numberOfElements; count ++) { pInVector->sectionId.idLen = pIoVector->sectionId.idLen; pInVector->sectionId.id = (ClUint8T *) clHeapAllocate( pInVector->sectionId.idLen); if(pInVector->sectionId.id == NULL) { safRc = SA_AIS_ERR_NO_MEMORY; return safRc; } memset(pInVector->sectionId.id,'\0',pInVector->sectionId.idLen); memcpy(pInVector->sectionId.id, pIoVector->sectionId.id, pInVector->sectionId.idLen); pInVector->dataBuffer = (ClUint8T*)pIoVector->dataBuffer; pInVector->dataSize = pIoVector->dataSize; pInVector->dataOffset = pIoVector->dataOffset; pInVector->readSize = pIoVector->readSize; pInVector++; pIoVector++; } } /* * Call the corresponding ckpt client library function. */ rc = clCkptCheckpointWrite((ClCkptHdlT) checkpointHandle, pTempVec, (ClUint32T )numberOfElements, (ClUint32T *)erroneousVectorIndex); /* * Translate the clovis error type to SAF error type. */ clErrorTxlate(rc, &safRc); if(pTempVec != NULL) { pInVector = pTempVec; for(count = 0; count < numberOfElements; count++) { clHeapFree(pInVector->sectionId.id); pInVector++; } clHeapFree(pTempVec); } return safRc; }