コード例 #1
0
ファイル: objDesc.c プロジェクト: brandt/irods
int
fillL1desc (int l1descInx, dataObjInp_t *dataObjInp,
            dataObjInfo_t *dataObjInfo, int replStatus, rodsLong_t dataSize)
{
    keyValPair_t *condInput = NULL;
    char *tmpPtr;


    if (dataObjInp != NULL) {
        condInput = &dataObjInp->condInput;
#if 0
        if (getValByKey (&dataObjInp->condInput, REPL_DATA_OBJ_INP_KW) !=
                NULL) {
            L1desc[l1descInx].dataObjInp = malloc (sizeof (dataObjInp_t));
            replDataObjInp (dataObjInp, L1desc[l1descInx].dataObjInp);
            L1desc[l1descInx].dataObjInpReplFlag = 1;
        } else {
            L1desc[l1descInx].dataObjInp = dataObjInp;
        }
#else
        /* always repl the .dataObjInp */
        L1desc[l1descInx].dataObjInp = (dataObjInp_t*)malloc (sizeof (dataObjInp_t));
        replDataObjInp (dataObjInp, L1desc[l1descInx].dataObjInp);
        L1desc[l1descInx].dataObjInpReplFlag = 1;
#endif
    } else {
        /* XXXX this can be a problem in rsDataObjClose */
        L1desc[l1descInx].dataObjInp = NULL;
    }

    L1desc[l1descInx].dataObjInfo = dataObjInfo;
    if (dataObjInp != NULL) {
        L1desc[l1descInx].oprType = dataObjInp->oprType;
    }
    L1desc[l1descInx].replStatus = replStatus;
    L1desc[l1descInx].dataSize = dataSize;
    if (condInput != NULL && condInput->len > 0) {
        if ((tmpPtr = getValByKey (condInput, REG_CHKSUM_KW)) != NULL) {
            L1desc[l1descInx].chksumFlag = REG_CHKSUM;
            rstrcpy (L1desc[l1descInx].chksum, tmpPtr, NAME_LEN);
        } else if ((tmpPtr = getValByKey (condInput, VERIFY_CHKSUM_KW)) !=
                   NULL) {
            L1desc[l1descInx].chksumFlag = VERIFY_CHKSUM;
            rstrcpy (L1desc[l1descInx].chksum, tmpPtr, NAME_LEN);
        }
    }
#ifdef LOG_TRANSFERS
    (void)gettimeofday(&L1desc[l1descInx].openStartTime,
                       (struct timezone *)0);
#endif
    return (0);
}
コード例 #2
0
ファイル: objDesc.cpp プロジェクト: janiheikkinen/irods
int
allocAndSetL1descForZoneOpr( int remoteL1descInx, dataObjInp_t *dataObjInp,
                             rodsServerHost_t *remoteZoneHost, openStat_t *openStat ) {
    int l1descInx;
    dataObjInfo_t *dataObjInfo;

    l1descInx = allocL1desc();
    if ( l1descInx < 0 ) {
        return l1descInx;
    }
    L1desc[l1descInx].remoteL1descInx = remoteL1descInx;
    L1desc[l1descInx].oprType = REMOTE_ZONE_OPR;
    L1desc[l1descInx].remoteZoneHost = remoteZoneHost;
    /* always repl the .dataObjInp */
    L1desc[l1descInx].dataObjInp = ( dataObjInp_t* )malloc( sizeof( dataObjInp_t ) );
    replDataObjInp( dataObjInp, L1desc[l1descInx].dataObjInp );
    L1desc[l1descInx].dataObjInpReplFlag = 1;
    dataObjInfo = L1desc[l1descInx].dataObjInfo =
                      ( dataObjInfo_t* )malloc( sizeof( dataObjInfo_t ) );
    bzero( dataObjInfo, sizeof( dataObjInfo_t ) );
    rstrcpy( dataObjInfo->objPath, dataObjInp->objPath, MAX_NAME_LEN );

    if ( openStat != NULL ) {
        dataObjInfo->dataSize = openStat->dataSize;
        rstrcpy( dataObjInfo->dataMode, openStat->dataMode, SHORT_STR_LEN );
        rstrcpy( dataObjInfo->dataType, openStat->dataType, NAME_LEN );
        L1desc[l1descInx].l3descInx = openStat->l3descInx;
        L1desc[l1descInx].replStatus = openStat->replStatus;
    }

    return l1descInx;
}
コード例 #3
0
ファイル: objDesc.cpp プロジェクト: hurngchunlee/irods
int
fillL1desc( int l1descInx, dataObjInp_t *dataObjInp,
            dataObjInfo_t *dataObjInfo, int replStatus, rodsLong_t dataSize ) {
    keyValPair_t *condInput;
    char *tmpPtr;


    char* resc_hier = getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW );
    if ( dataObjInfo->rescHier[0] == '\0' && resc_hier ) {
        snprintf( dataObjInfo->rescHier, sizeof( dataObjInfo->rescHier ), "%s", resc_hier );
    }


    condInput = &dataObjInp->condInput;
    char* in_pdmo = getValByKey( condInput, IN_PDMO_KW );
    if ( in_pdmo != NULL ) {
        rstrcpy( L1desc[l1descInx].in_pdmo, in_pdmo, MAX_NAME_LEN );
    }
    else {
        rstrcpy( L1desc[l1descInx].in_pdmo, "", MAX_NAME_LEN );
    }

    if ( dataObjInp != NULL ) {
        /* always repl the .dataObjInp */
        L1desc[l1descInx].dataObjInp = ( dataObjInp_t* )malloc( sizeof( dataObjInp_t ) );
        replDataObjInp( dataObjInp, L1desc[l1descInx].dataObjInp );
        L1desc[l1descInx].dataObjInpReplFlag = 1;
    }
    else {
        /* XXXX this can be a problem in rsDataObjClose */
        L1desc[l1descInx].dataObjInp = NULL;
    }

    L1desc[l1descInx].dataObjInfo = dataObjInfo;
    if ( dataObjInp != NULL ) {
        L1desc[l1descInx].oprType = dataObjInp->oprType;
    }
    L1desc[l1descInx].replStatus = replStatus;
    L1desc[l1descInx].dataSize = dataSize;
    if ( condInput != NULL && condInput->len > 0 ) {
        if ( ( tmpPtr = getValByKey( condInput, REG_CHKSUM_KW ) ) != NULL ) {
            L1desc[l1descInx].chksumFlag = REG_CHKSUM;
            rstrcpy( L1desc[l1descInx].chksum, tmpPtr, NAME_LEN );
        }
        else if ( ( tmpPtr = getValByKey( condInput, VERIFY_CHKSUM_KW ) ) !=
                  NULL ) {
            L1desc[l1descInx].chksumFlag = VERIFY_CHKSUM;
            rstrcpy( L1desc[l1descInx].chksum, tmpPtr, NAME_LEN );
        }
    }
#ifdef LOG_TRANSFERS
    ( void )gettimeofday( &L1desc[l1descInx].openStartTime,
                          ( struct timezone * )0 );
#endif
    return 0;
}
コード例 #4
0
ファイル: rsDataObjRsync.cpp プロジェクト: QuarkDoe/irods
int
rsRsyncDataToData( rsComm_t *rsComm, dataObjInp_t *dataObjInp ) {
    int status;
    char *srcChksumStr = NULL;
    char *destChksumStr = NULL;
    dataObjCopyInp_t dataObjCopyInp;
    char *destObjPath;
    transferStat_t *transStat = NULL;

    /* always have the FORCE flag on */
    addKeyVal( &dataObjInp->condInput, FORCE_FLAG_KW, "" );

    destObjPath = getValByKey( &dataObjInp->condInput, RSYNC_DEST_PATH_KW );
    if ( destObjPath == NULL ) {
        rodsLog( LOG_ERROR,
                 "rsRsyncDataToData: RSYNC_DEST_PATH_KW input is missing for %s",
                 dataObjInp->objPath );
        return USER_RSYNC_NO_MODE_INPUT_ERR;
    }

    memset( &dataObjCopyInp, 0, sizeof( dataObjCopyInp ) );
    rstrcpy( dataObjCopyInp.srcDataObjInp.objPath, dataObjInp->objPath,
             MAX_NAME_LEN );
    dataObjCopyInp.srcDataObjInp.dataSize = dataObjInp->dataSize;
    replDataObjInp( dataObjInp, &dataObjCopyInp.destDataObjInp );
    rstrcpy( dataObjCopyInp.destDataObjInp.objPath, destObjPath,
             MAX_NAME_LEN );
    // we need the destination resource hierarchy to vote on the write
    rmKeyVal( &dataObjCopyInp.destDataObjInp.condInput, RESC_HIER_STR_KW );

    /* use rsDataObjChksum because the path could in in remote zone */
    status = rsDataObjChksum( rsComm, &dataObjCopyInp.srcDataObjInp,
                              &srcChksumStr );

    if ( status < 0 &&
            ( status != CAT_NO_ACCESS_PERMISSION || srcChksumStr == NULL ) ) {
        /* XXXXX CAT_NO_ACCESS_PERMISSION mean the chksum was calculated but
         * cannot be registered. But the chksum value is OK.
         */
        rodsLog( LOG_ERROR,
                 "rsRsyncDataToData: _rsDataObjChksum error for %s, status = %d",
                 dataObjCopyInp.srcDataObjInp.objPath, status );
        clearKeyVal( &dataObjCopyInp.srcDataObjInp.condInput );
        return status;
    }

    /* use rsDataObjChksum because the path could in in remote zone */
    status = rsDataObjChksum( rsComm, &dataObjCopyInp.destDataObjInp,
                              &destChksumStr );

    if ( status < 0 && status != CAT_NO_ACCESS_PERMISSION &&
            status != CAT_NO_ROWS_FOUND ) {
        rodsLog( LOG_ERROR,
                 "rsRsyncDataToData: _rsDataObjChksum error for %s, status = %d",
                 dataObjCopyInp.destDataObjInp.objPath, status );
        free( srcChksumStr );
        free( destChksumStr );
        clearKeyVal( &dataObjCopyInp.srcDataObjInp.condInput );
        clearKeyVal( &dataObjCopyInp.destDataObjInp.condInput );
        return status;
    }

    if ( destChksumStr != NULL && strcmp( srcChksumStr, destChksumStr ) == 0 ) {
        free( srcChksumStr );
        free( destChksumStr );
        clearKeyVal( &dataObjCopyInp.destDataObjInp.condInput );
        clearKeyVal( &dataObjCopyInp.srcDataObjInp.condInput );
        return 0;
    }

    addKeyVal( &dataObjCopyInp.destDataObjInp.condInput, REG_CHKSUM_KW,
               srcChksumStr );
    status = rsDataObjCopy( rsComm, &dataObjCopyInp, &transStat );
    free( transStat );
    free( srcChksumStr );
    free( destChksumStr );
    clearKeyVal( &dataObjCopyInp.destDataObjInp.condInput );
    clearKeyVal( &dataObjCopyInp.srcDataObjInp.condInput );

    if ( status >= 0 ) {
        return SYS_RSYNC_TARGET_MODIFIED;
    }
    else {
        return status;
    }
}
コード例 #5
0
ファイル: objDesc.cpp プロジェクト: irods/irods
int
fillL1desc( int l1descInx, dataObjInp_t *dataObjInp,
            dataObjInfo_t *dataObjInfo, int replStatus, rodsLong_t dataSize ) {
    keyValPair_t *condInput;
    char *tmpPtr;

    // Initialize the bytesWritten to -1 rather than 0.  If this is negative then we
    // know no bytes have been written.  This is so that zero length files can be handled
    // similarly to non-zero length files.
    L1desc[l1descInx].bytesWritten = -1;

    char* resc_hier = getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW );
    if ( dataObjInfo->rescHier[0] == '\0' && resc_hier ) {
        snprintf( dataObjInfo->rescHier, sizeof( dataObjInfo->rescHier ), "%s", resc_hier );
    }


    condInput = &dataObjInp->condInput;
    char* in_pdmo = getValByKey( condInput, IN_PDMO_KW );
    if ( in_pdmo != NULL ) {
        rstrcpy( L1desc[l1descInx].in_pdmo, in_pdmo, MAX_NAME_LEN );
    }
    else {
        rstrcpy( L1desc[l1descInx].in_pdmo, "", MAX_NAME_LEN );
    }

    const auto open_type{getValByKey(condInput, OPEN_TYPE_KW)};
    if (open_type) {
        L1desc[l1descInx].openType = std::atoi(open_type);
    }

    if ( dataObjInp != NULL ) {
        /* always repl the .dataObjInp */
        L1desc[l1descInx].dataObjInp = ( dataObjInp_t* )malloc( sizeof( dataObjInp_t ) );
        replDataObjInp( dataObjInp, L1desc[l1descInx].dataObjInp );
        L1desc[l1descInx].dataObjInpReplFlag = 1;
    }
    else {
        /* XXXX this can be a problem in rsDataObjClose */
        L1desc[l1descInx].dataObjInp = NULL;
    }

    L1desc[l1descInx].dataObjInfo = dataObjInfo;
    if ( dataObjInp != NULL ) {
        L1desc[l1descInx].oprType = dataObjInp->oprType;
    }
    L1desc[l1descInx].replStatus = replStatus;
    L1desc[l1descInx].dataSize = dataSize;
    if ( condInput != NULL && condInput->len > 0 ) {
        if ( ( tmpPtr = getValByKey( condInput, REG_CHKSUM_KW ) ) != NULL ) {
            L1desc[l1descInx].chksumFlag = REG_CHKSUM;
            rstrcpy( L1desc[l1descInx].chksum, tmpPtr, NAME_LEN );
        }
        else if ( ( tmpPtr = getValByKey( condInput, VERIFY_CHKSUM_KW ) ) !=
                  NULL ) {
            L1desc[l1descInx].chksumFlag = VERIFY_CHKSUM;
            rstrcpy( L1desc[l1descInx].chksum, tmpPtr, NAME_LEN );
        }
    }

    return 0;
}
コード例 #6
0
ファイル: rsDataObjRsync.c プロジェクト: UPPMAX/irods
int
rsRsyncFileToData (rsComm_t *rsComm, dataObjInp_t *dataObjInp)
{
    int status;
    char *fileChksumStr = NULL;
     char *dataObjChksumStr = NULL;
    dataObjInfo_t *dataObjInfoHead = NULL;

    fileChksumStr = getValByKey (&dataObjInp->condInput, RSYNC_CHKSUM_KW);

    if (fileChksumStr == NULL) {
        rodsLog (LOG_ERROR,
          "rsRsyncFileToData: RSYNC_CHKSUM_KW input is missing");
        return (CHKSUM_EMPTY_IN_STRUCT_ERR);
    }

    status = _rsDataObjChksum (rsComm, dataObjInp, &dataObjChksumStr,
      &dataObjInfoHead);

    if (status < 0 && status != CAT_NO_ACCESS_PERMISSION && 
      status != CAT_NO_ROWS_FOUND) {
        /* XXXXX CAT_NO_ACCESS_PERMISSION mean the chksum was calculated but
         * cannot be registered. But the chksum value is OK.
         */
        rodsLog (LOG_ERROR,
          "rsRsyncFileToData: _rsDataObjChksum of %s error. status = %d",
          dataObjInp->objPath, status);
    }

    freeAllDataObjInfo (dataObjInfoHead);

    if (dataObjChksumStr != NULL &&
      strcmp (dataObjChksumStr, fileChksumStr) == 0) {
	free (dataObjChksumStr);
	return (0);
    }
    return SYS_SVR_TO_CLI_PUT_ACTION;
#if 0
    msParamArray_t *myMsParamArray;
    dataObjInp_t *myDataObjInp;

    myMsParamArray = malloc (sizeof (msParamArray_t));
    memset (myMsParamArray, 0, sizeof (msParamArray_t));
    /* have to get its own dataObjInp_t */
    myDataObjInp = malloc (sizeof (dataObjInp_t));
    replDataObjInp (dataObjInp, myDataObjInp);
    addKeyVal (&myDataObjInp->condInput, REG_CHKSUM_KW, fileChksumStr);

    status = addMsParam (myMsParamArray, CL_PUT_ACTION, DataObjInp_MS_T,
      (void *) myDataObjInp, NULL);

    if (status < 0) {
        rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, status,
          "rsRsyncDataToFile: addMsParam error. status = %d", status);
        return (status);
    }

    /* tell the client to do the put */
    status = sendAndRecvBranchMsg (rsComm, rsComm->apiInx,
     SYS_SVR_TO_CLI_MSI_REQUEST, (void *) myMsParamArray, NULL);

    return (status);
#endif
}