int rcDataObjGet( rcComm_t *conn, dataObjInp_t *dataObjInp, char *locFilePath ) { int status; portalOprOut_t *portalOprOut = NULL; bytesBuf_t dataObjOutBBuf; #ifndef windows_platform struct stat statbuf; #else struct irodsntstat statbuf; #endif if ( strcmp( locFilePath, STDOUT_FILE_NAME ) == 0 ) { /* no parallel I/O if pipe to stdout */ dataObjInp->numThreads = NO_THREADING; } #ifndef windows_platform else if ( stat( locFilePath, &statbuf ) >= 0 ) #else else if ( iRODSNt_stat( locFilePath, &statbuf ) >= 0 ) #endif { /* local file exists */ if ( getValByKey( &dataObjInp->condInput, FORCE_FLAG_KW ) == NULL ) { return ( OVERWRITE_WITHOUT_FORCE_FLAG ); } } status = _rcDataObjGet( conn, dataObjInp, &portalOprOut, &dataObjOutBBuf ); if ( status < 0 ) { if ( portalOprOut != NULL ) { free( portalOprOut ); } return ( status ); } if ( status == 0 || dataObjOutBBuf.len > 0 ) { /* data included */ /**** Removed by Raja as this can cause problems when the data sizes are different - say when post processing is done....Dec 2 2010 if (dataObjInp->dataSize > 0 && dataObjInp->dataSize != dataObjOutBBuf.len) { rodsLog (LOG_NOTICE, "putFile: totalWritten %lld dataSize %lld mismatch", dataObjOutBBuf.len, dataObjInp->dataSize); return (SYS_COPY_LEN_ERR); } ****/ status = getIncludeFile( conn, &dataObjOutBBuf, locFilePath ); free( dataObjOutBBuf.buf ); } else if ( getUdpPortFromPortList( &portalOprOut->portList ) != 0 ) { int veryVerbose; /* rbudp transfer */ /* some sanity check */ if ( portalOprOut->numThreads != 1 ) { rcOprComplete( conn, SYS_INVALID_PORTAL_OPR ); free( portalOprOut ); return ( SYS_INVALID_PORTAL_OPR ); } conn->transStat.numThreads = portalOprOut->numThreads; if ( getValByKey( &dataObjInp->condInput, VERY_VERBOSE_KW ) != NULL ) { printf( "From server: NumThreads=%d, addr:%s, port:%d, cookie=%d\n", portalOprOut->numThreads, portalOprOut->portList.hostAddr, portalOprOut->portList.portNum, portalOprOut->portList.cookie ); veryVerbose = 2; } else { veryVerbose = 0; } // =-=-=-=-=-=-=- // if a secret has been negotiated then we must be using // encryption. given that RBUDP is not supported in an // encrypted capacity this is considered an error if ( irods::CS_NEG_USE_SSL == conn->negotiation_results ) { rodsLog( LOG_ERROR, "getFileToPortal: Encryption is not supported with RBUDP" ); return SYS_INVALID_PORTAL_OPR; } status = getFileToPortalRbudp( portalOprOut, locFilePath, 0, dataObjInp->dataSize, veryVerbose, 0 ); /* just send a complete msg */ if ( status < 0 ) { rcOprComplete( conn, status ); } else { status = rcOprComplete( conn, portalOprOut->l1descInx ); } } else { if ( portalOprOut->numThreads <= 0 ) { status = getFile( conn, portalOprOut->l1descInx, locFilePath, dataObjInp->objPath, dataObjInp->dataSize ); } else { if ( getValByKey( &dataObjInp->condInput, VERY_VERBOSE_KW ) != NULL ) { printf( "From server: NumThreads=%d, addr:%s, port:%d, cookie=%d\n", portalOprOut->numThreads, portalOprOut->portList.hostAddr, portalOprOut->portList.portNum, portalOprOut->portList.cookie ); } /* some sanity check */ if ( portalOprOut->numThreads >= 20 * DEF_NUM_TRAN_THR ) { rcOprComplete( conn, SYS_INVALID_PORTAL_OPR ); free( portalOprOut ); return ( SYS_INVALID_PORTAL_OPR ); } conn->transStat.numThreads = portalOprOut->numThreads; status = getFileFromPortal( conn, portalOprOut, locFilePath, dataObjInp->objPath, dataObjInp->dataSize ); } /* just send a complete msg */ if ( status < 0 ) { rcOprComplete( conn, status ); } else { status = rcOprComplete( conn, portalOprOut->l1descInx ); } } if ( status >= 0 && conn->fileRestart.info.numSeg > 0 ) { /* file restart */ clearLfRestartFile( &conn->fileRestart ); } if ( getValByKey( &dataObjInp->condInput, VERIFY_CHKSUM_KW ) != NULL ) { if ( portalOprOut == NULL || strlen( portalOprOut->chksum ) == 0 ) { rodsLog( LOG_ERROR, "rcDataObjGet: VERIFY_CHKSUM_KW set but no chksum from server" ); } else { status = verifyChksumLocFile( locFilePath, portalOprOut->chksum, NULL ); if ( status == USER_CHKSUM_MISMATCH ) { rodsLogError( LOG_ERROR, status, "rcDataObjGet: chksum mismatch error for %s, status = %d", locFilePath, status ); if ( portalOprOut != NULL ) { free( portalOprOut ); } return ( status ); } else if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "rcDataObjGet: chksumLocFile error for %s, status = %d", locFilePath, status ); if ( portalOprOut != NULL ) { free( portalOprOut ); } return ( status ); } } } if ( portalOprOut != NULL ) { free( portalOprOut ); } return ( status ); }
int rcDataObjPut( rcComm_t *conn, dataObjInp_t *dataObjInp, char *locFilePath ) { int status; portalOprOut_t *portalOprOut = NULL; bytesBuf_t dataObjInpBBuf; if ( dataObjInp->dataSize <= 0 ) { dataObjInp->dataSize = getFileSize( locFilePath ); if ( dataObjInp->dataSize < 0 ) { return USER_FILE_DOES_NOT_EXIST; } } memset( &conn->transStat, 0, sizeof( transStat_t ) ); memset( &dataObjInpBBuf, 0, sizeof( dataObjInpBBuf ) ); rodsEnv env; getRodsEnv( &env ); int single_buff_sz = env.irodsMaxSizeForSingleBuffer * 1024 * 1024; if ( getValByKey( &dataObjInp->condInput, DATA_INCLUDED_KW ) != NULL ) { if ( dataObjInp->dataSize > single_buff_sz ) { rmKeyVal( &dataObjInp->condInput, DATA_INCLUDED_KW ); } else { status = fillBBufWithFile( conn, &dataObjInpBBuf, locFilePath, dataObjInp->dataSize ); if ( status < 0 ) { rodsLog( LOG_NOTICE, "rcDataObjPut: fileBBufWithFile error for %s", locFilePath ); return status; } } } else if ( dataObjInp->dataSize < single_buff_sz ) { addKeyVal( &dataObjInp->condInput, DATA_INCLUDED_KW, "" ); status = fillBBufWithFile( conn, &dataObjInpBBuf, locFilePath, dataObjInp->dataSize ); if ( status < 0 ) { rodsLog( LOG_NOTICE, "rcDataObjPut: fileBBufWithFile error for %s", locFilePath ); return status; } } dataObjInp->oprType = PUT_OPR; status = _rcDataObjPut( conn, dataObjInp, &dataObjInpBBuf, &portalOprOut ); clearBBuf( &dataObjInpBBuf ); if ( status < 0 || getValByKey( &dataObjInp->condInput, DATA_INCLUDED_KW ) != NULL ) { if ( portalOprOut != NULL ) { free( portalOprOut ); } return status; } if ( portalOprOut->numThreads <= 0 ) { status = putFile( conn, portalOprOut->l1descInx, locFilePath, dataObjInp->objPath, dataObjInp->dataSize ); } else if ( getUdpPortFromPortList( &portalOprOut->portList ) != 0 ) { int veryVerbose; /* rbudp transfer */ /* some sanity check */ if ( portalOprOut->numThreads != 1 ) { rcOprComplete( conn, SYS_INVALID_PORTAL_OPR ); free( portalOprOut ); return SYS_INVALID_PORTAL_OPR; } conn->transStat.numThreads = portalOprOut->numThreads; if ( getValByKey( &dataObjInp->condInput, VERY_VERBOSE_KW ) != NULL ) { printf( "From server: NumThreads=%d, addr:%s, port:%d, cookie=%d\n", portalOprOut->numThreads, portalOprOut->portList.hostAddr, portalOprOut->portList.portNum, portalOprOut->portList.cookie ); veryVerbose = 2; } else { veryVerbose = 0; } if ( irods::CS_NEG_USE_SSL == conn->negotiation_results ) { // =-=-=-=-=-=-=- // if a secret has been negotiated then we must be using // encryption. given that RBUDP is not supported in an // encrypted capacity this is considered an error rodsLog( LOG_ERROR, "putFileToPortal: Encryption is not supported with RBUDP" ); return SYS_INVALID_PORTAL_OPR; } else { status = putFileToPortalRbudp( portalOprOut, locFilePath, -1, veryVerbose, 0, 0 ); } } else { if ( getValByKey( &dataObjInp->condInput, VERY_VERBOSE_KW ) != NULL ) { printf( "From server: NumThreads=%d, addr:%s, port:%d, cookie=%d\n", portalOprOut->numThreads, portalOprOut->portList.hostAddr, portalOprOut->portList.portNum, portalOprOut->portList.cookie ); } /* some sanity check */ rodsEnv env; getRodsEnv( &env ); if ( portalOprOut->numThreads >= 20 * env.irodsDefaultNumberTransferThreads ) { rcOprComplete( conn, SYS_INVALID_PORTAL_OPR ); free( portalOprOut ); return SYS_INVALID_PORTAL_OPR; } conn->transStat.numThreads = portalOprOut->numThreads; status = putFileToPortal( conn, portalOprOut, locFilePath, dataObjInp->objPath, dataObjInp->dataSize ); } /* just send a complete msg */ if ( status < 0 ) { rcOprComplete( conn, status ); } else { status = rcOprComplete( conn, portalOprOut->l1descInx ); } free( portalOprOut ); if ( status >= 0 && conn->fileRestart.info.numSeg > 0 ) { /* file restart */ clearLfRestartFile( &conn->fileRestart ); } return status; }