int _rsProcStat (rsComm_t *rsComm, procStatInp_t *procStatInp, genQueryOut_t **procStatOut) { int status; rodsServerHost_t *rodsServerHost; int remoteFlag; rodsHostAddr_t addr; procStatInp_t myProcStatInp; char *tmpStr; if (getValByKey (&procStatInp->condInput, ALL_KW) != NULL) { status = _rsProcStatAll (rsComm, procStatInp, procStatOut); return status; } if (getValByKey (&procStatInp->condInput, EXEC_LOCALLY_KW) != NULL) { status = localProcStat (rsComm, procStatInp, procStatOut); return status; } bzero (&addr, sizeof (addr)); bzero (&myProcStatInp, sizeof (myProcStatInp)); if (*procStatInp->addr != '\0') { /* given input addr */ rstrcpy (addr.hostAddr, procStatInp->addr, LONG_NAME_LEN); remoteFlag = resolveHost (&addr, &rodsServerHost); } else if ((tmpStr = getValByKey (&procStatInp->condInput, RESC_NAME_KW)) != NULL) { rescGrpInfo_t *rescGrpInfo = NULL; status = _getRescInfo (rsComm, tmpStr, &rescGrpInfo); if (status < 0) { rodsLog (LOG_ERROR, "_rsProcStat: _getRescInfo of %s error. stat = %d", tmpStr, status); return status; } rstrcpy (procStatInp->addr, rescGrpInfo->rescInfo->rescLoc, NAME_LEN); rodsServerHost = (rodsServerHost_t*)rescGrpInfo->rescInfo->rodsServerHost; if (rodsServerHost == NULL) { remoteFlag = SYS_INVALID_SERVER_HOST; } else { remoteFlag = rodsServerHost->localFlag; } } else { /* do the IES server */ remoteFlag = getRcatHost (MASTER_RCAT, NULL, &rodsServerHost); } if (remoteFlag < 0) { rodsLog (LOG_ERROR, "_rsProcStat: getRcatHost() failed. erro=%d", remoteFlag); return (remoteFlag); } else if (remoteFlag == REMOTE_HOST) { addKeyVal (&myProcStatInp.condInput, EXEC_LOCALLY_KW, ""); status = remoteProcStat (rsComm, &myProcStatInp, procStatOut, rodsServerHost); rmKeyVal (&myProcStatInp.condInput, EXEC_LOCALLY_KW); } else { status = localProcStat (rsComm, procStatInp, procStatOut); } return status; }
/** * \fn msiPropertiesRemove( msParam_t *listParam, msParam_t* keywordParam, ruleExecInfo_t *rei ) * * \brief Remove a property from the list. * * \module properties * * \since pre-2.1 * * \author David R. Nadeau / University of California, San Diego * \date 2007 * * \usage See clients/icommands/test/rules3.0/ * * \param[in,out] listParam - a KeyValPair_MS_T, the property list to be removed from * \param[in] keywordParam - a STR_MS_T, a keyword to remove * \param[in,out] rei - The RuleExecInfo structure that is automatically * handled by the rule engine. The user does not include rei as a * parameter in the rule invocation. * * \DolVarDependence none * \DolVarModified none * \iCatAttrDependence none * \iCatAttrModified none * \sideeffect property list changed * * \return integer * \retval 0 on success * \pre none * \post none * \sa none **/ int msiPropertiesRemove( msParam_t *listParam, msParam_t* keywordParam, ruleExecInfo_t *rei ) { RE_TEST_MACRO( " Calling msiPropertiesRemove" ); /* Check parameters */ if ( strcmp( listParam->type, KeyValPair_MS_T ) != 0 ) return USER_PARAM_TYPE_ERR; if ( strcmp( keywordParam->type, STR_MS_T ) != 0 ) return USER_PARAM_TYPE_ERR; /* Remove entry */ rmKeyVal( (keyValPair_t*)listParam->inOutStruct, (char*)keywordParam->inOutStruct ); return 0; }
int _rsProcStatAll (rsComm_t *rsComm, procStatInp_t *procStatInp, genQueryOut_t **procStatOut) { rodsServerHost_t *tmpRodsServerHost; procStatInp_t myProcStatInp; int status; genQueryOut_t *singleProcStatOut = NULL; int savedStatus = 0; bzero (&myProcStatInp, sizeof (myProcStatInp)); tmpRodsServerHost = ServerHostHead; while (tmpRodsServerHost != NULL) { if (getHostStatusByRescInfo (tmpRodsServerHost) == INT_RESC_STATUS_UP) { /* don't do down resc */ if (tmpRodsServerHost->localFlag == LOCAL_HOST) { setLocalSrvAddr (myProcStatInp.addr); status = localProcStat (rsComm, &myProcStatInp, &singleProcStatOut); } else { rstrcpy (myProcStatInp.addr, tmpRodsServerHost->hostName->name, NAME_LEN); addKeyVal (&myProcStatInp.condInput, EXEC_LOCALLY_KW, ""); status = remoteProcStat (rsComm, &myProcStatInp, &singleProcStatOut, tmpRodsServerHost); rmKeyVal (&myProcStatInp.condInput, EXEC_LOCALLY_KW); } if (status < 0) { savedStatus = status; } if (singleProcStatOut != NULL) { if (*procStatOut == NULL) { *procStatOut = singleProcStatOut; } else { catGenQueryOut (*procStatOut, singleProcStatOut, MAX_PROC_STAT_CNT); freeGenQueryOut (&singleProcStatOut); } singleProcStatOut = NULL; } } tmpRodsServerHost = tmpRodsServerHost->next; } return savedStatus; }
int sendBulkPut( rcComm_t *conn, bulkOprInp_t *bulkOprInp, bulkOprInfo_t *bulkOprInfo, rodsArguments_t *rodsArgs ) { struct timeval startTime, endTime; int status = 0; if ( bulkOprInfo == NULL || bulkOprInfo->count <= 0 ) { return 0; } if ( rodsArgs->verbose == True ) { ( void ) gettimeofday( &startTime, ( struct timezone * )0 ); } /* send it */ if ( bulkOprInfo->bytesBuf.buf != NULL ) { status = rcBulkDataObjPut( conn, bulkOprInp, &bulkOprInfo->bytesBuf ); } /* reset the row count */ bulkOprInp->attriArray.rowCnt = 0; if ( bulkOprInfo->forceFlagAdded == 1 ) { rmKeyVal( &bulkOprInp->condInput, FORCE_FLAG_KW ); bulkOprInfo->forceFlagAdded = 0; } if ( status >= 0 ) { if ( rodsArgs->verbose == True ) { printf( "Bulk upload %d files.\n", bulkOprInfo->count ); ( void ) gettimeofday( &endTime, ( struct timezone * )0 ); printTiming( conn, bulkOprInfo->cachedTargPath, bulkOprInfo->size, bulkOprInfo->cachedTargPath, &startTime, &endTime ); } if ( gGuiProgressCB != NULL ) { rstrcpy( conn->operProgress.curFileName, bulkOprInfo->cachedTargPath, MAX_NAME_LEN ); conn->operProgress.totalNumFilesDone += bulkOprInfo->count; conn->operProgress.totalFileSizeDone += bulkOprInfo->size; gGuiProgressCB( &conn->operProgress ); } } return status; }
int collStatAllKinds( rsComm_t *rsComm, dataObjInp_t *dataObjInp, rodsObjStat_t **rodsObjStatOut ) { int status; *rodsObjStatOut = NULL; addKeyVal( &dataObjInp->condInput, SEL_OBJ_TYPE_KW, "collection" ); status = _rsObjStat( rsComm, dataObjInp, rodsObjStatOut ); rmKeyVal( &dataObjInp->condInput, SEL_OBJ_TYPE_KW ); if ( status >= 0 ) { if ( ( *rodsObjStatOut )->objType != COLL_OBJ_T ) { status = OBJ_PATH_DOES_NOT_EXIST; } } if ( status < 0 && *rodsObjStatOut != NULL ) { freeRodsObjStat( *rodsObjStatOut ); *rodsObjStatOut = NULL; } return status; }
int rsDataObjCreate( rsComm_t *rsComm, dataObjInp_t *dataObjInp ) { int l1descInx; int status; rodsObjStat_t *rodsObjStatOut = NULL; int remoteFlag; rodsServerHost_t *rodsServerHost; specCollCache_t *specCollCache = NULL; char *lockType = NULL; // JMC - backport 4604 int lockFd = -1; // JMC - backport 4604 resolveLinkedPath( rsComm, dataObjInp->objPath, &specCollCache, &dataObjInp->condInput ); remoteFlag = getAndConnRemoteZone( rsComm, dataObjInp, &rodsServerHost, REMOTE_CREATE ); if ( remoteFlag < 0 ) { return ( remoteFlag ); } else if ( remoteFlag == REMOTE_HOST ) { openStat_t *openStat = NULL; addKeyVal( &dataObjInp->condInput, CROSS_ZONE_CREATE_KW, "" ); status = rcDataObjCreateAndStat( rodsServerHost->conn, dataObjInp, &openStat ); /* rm it to avoid confusion */ rmKeyVal( &dataObjInp->condInput, CROSS_ZONE_CREATE_KW ); if ( status < 0 ) { return status; } l1descInx = allocAndSetL1descForZoneOpr( status, dataObjInp, rodsServerHost, openStat ); if ( openStat != NULL ) { free( openStat ); } return ( l1descInx ); } // =-=-=-=-=-=-=- // working on the "home zone", determine if we need to redirect to a different // server in this zone for this operation. if there is a RESC_HIER_STR_KW then // we know that the redirection decision has already been made char* resc_hier = getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW ); if ( NULL == resc_hier ) { std::string hier; irods::error ret = irods::resolve_resource_hierarchy( irods::CREATE_OPERATION, rsComm, dataObjInp, hier ); if ( !ret.ok() ) { std::stringstream msg; msg << "failed in irods::resolve_resource_hierarchy for ["; msg << dataObjInp->objPath << "]"; irods::log( PASSMSG( msg.str(), ret ) ); return ret.code(); } // =-=-=-=-=-=-=- // we resolved the redirect and have a host, set the hier str for subsequent // api calls, etc. addKeyVal( &dataObjInp->condInput, RESC_HIER_STR_KW, hier.c_str() ); } // if keyword // =-=-=-=-=-=-=- // JMC - backport 4604 lockType = getValByKey( &dataObjInp->condInput, LOCK_TYPE_KW ); if ( lockType != NULL ) { lockFd = rsDataObjLock( rsComm, dataObjInp ); if ( lockFd >= 0 ) { /* rm it so it won't be done again causing deadlock */ rmKeyVal( &dataObjInp->condInput, LOCK_TYPE_KW ); } else { rodsLogError( LOG_ERROR, lockFd, "rsDataObjCreate: rsDataObjLock error for %s. lockType = %s", dataObjInp->objPath, lockType ); return lockFd; } } // =-=-=-=-=-=-=- // Gets here means local zone operation stat dataObj addKeyVal( &dataObjInp->condInput, SEL_OBJ_TYPE_KW, "dataObj" ); status = rsObjStat( rsComm, dataObjInp, &rodsObjStatOut ); if ( rodsObjStatOut != NULL && rodsObjStatOut->objType == COLL_OBJ_T ) { if ( lockFd >= 0 ) { rsDataObjUnlock( rsComm, dataObjInp, lockFd ); // JMC - backport 4604 } return ( USER_INPUT_PATH_ERR ); } if ( rodsObjStatOut != NULL && rodsObjStatOut->specColl != NULL && rodsObjStatOut->specColl->collClass == LINKED_COLL ) { /* should not be here because if has been translated */ if ( lockFd >= 0 ) { rsDataObjUnlock( rsComm, dataObjInp, lockFd ); // JMC - backport 4604 } return SYS_COLL_LINK_PATH_ERR; } if ( rodsObjStatOut == NULL || ( rodsObjStatOut->objType == UNKNOWN_OBJ_T && rodsObjStatOut->specColl == NULL ) ) { /* does not exist. have to create one */ /* use L1desc[l1descInx].replStatus & OPEN_EXISTING_COPY instead */ /* newly created. take out FORCE_FLAG since it could be used by put */ /* rmKeyVal (&dataObjInp->condInput, FORCE_FLAG_KW); */ l1descInx = _rsDataObjCreate( rsComm, dataObjInp ); } else if ( rodsObjStatOut->specColl != NULL && rodsObjStatOut->objType == UNKNOWN_OBJ_T ) { /* newly created. take out FORCE_FLAG since it could be used by put */ /* rmKeyVal (&dataObjInp->condInput, FORCE_FLAG_KW); */ l1descInx = specCollSubCreate( rsComm, dataObjInp ); } else { /* dataObj exist */ if ( getValByKey( &dataObjInp->condInput, FORCE_FLAG_KW ) != NULL ) { dataObjInp->openFlags |= O_TRUNC | O_RDWR; // =-=-=-=-=-=-=- // re-determine the resource hierarchy since this is an open instead of a create std::string hier; irods::error ret = irods::resolve_resource_hierarchy( irods::WRITE_OPERATION, rsComm, dataObjInp, hier ); if ( !ret.ok() ) { std::stringstream msg; msg << __FUNCTION__; msg << " :: failed in irods::resolve_resource_hierarchy for ["; msg << dataObjInp->objPath << "]"; irods::log( PASSMSG( msg.str(), ret ) ); return ret.code(); } // =-=-=-=-=-=-=- // we resolved the redirect and have a host, set the hier str for subsequent // api calls, etc. addKeyVal( &dataObjInp->condInput, RESC_HIER_STR_KW, hier.c_str() ); std::string top_resc; irods::hierarchy_parser parser; parser.set_string( hier ); parser.first_resc( top_resc ); addKeyVal( &dataObjInp->condInput, DEST_RESC_NAME_KW, top_resc.c_str() ); l1descInx = _rsDataObjOpen( rsComm, dataObjInp ); } else { l1descInx = OVERWRITE_WITHOUT_FORCE_FLAG; } } if ( rodsObjStatOut != NULL ) { freeRodsObjStat( rodsObjStatOut ); } // =-=-=-=-=-=-=- // JMC - backport 4604 if ( lockFd >= 0 ) { if ( l1descInx >= 0 ) { L1desc[l1descInx].lockFd = lockFd; } else { rsDataObjUnlock( rsComm, dataObjInp, lockFd ); } } // =-=-=-=-=-=-=- return ( l1descInx ); }
int getUtil (rcComm_t **myConn, rodsEnv *myRodsEnv, rodsArguments_t *myRodsArgs, rodsPathInp_t *rodsPathInp) { int i; int status; int savedStatus = 0; rodsPath_t *targPath; dataObjInp_t dataObjOprInp; rodsRestart_t rodsRestart; rcComm_t *conn = *myConn; if (rodsPathInp == NULL) { return (USER__NULL_INPUT_ERR); } if (myRodsArgs->ticket == True) { if (myRodsArgs->ticketString == NULL) { rodsLog (LOG_ERROR, "initCondForPut: NULL ticketString error"); return (USER__NULL_INPUT_ERR); } else { setSessionTicket(conn, myRodsArgs->ticketString); } } initCondForGet (conn, myRodsEnv, myRodsArgs, &dataObjOprInp, &rodsRestart); if (rodsPathInp->resolved == False) { status = resolveRodsTarget (conn, myRodsEnv, rodsPathInp, 1); if (status < 0) { rodsLogError (LOG_ERROR, status, "getUtil: resolveRodsTarget"); return (status); } rodsPathInp->resolved = True; } /* initialize the progress struct */ if (gGuiProgressCB != NULL) { bzero (&conn->operProgress, sizeof (conn->operProgress)); for (i = 0; i < rodsPathInp->numSrc; i++) { targPath = &rodsPathInp->targPath[i]; if (targPath->objType == LOCAL_FILE_T) { conn->operProgress.totalNumFiles++; if (rodsPathInp->srcPath[i].size > 0) { conn->operProgress.totalFileSize += rodsPathInp->srcPath[i].size; } } else { getCollSizeForProgStat (conn, rodsPathInp->srcPath[i].outPath, &conn->operProgress); } } } if (conn->fileRestart.flags == FILE_RESTART_ON) { fileRestartInfo_t *info; status = readLfRestartFile (conn->fileRestart.infoFile, &info); if (status >= 0) { status = lfRestartGetWithInfo (conn, info); if (status >= 0) { /* save info so we know what got restarted and what not to * delete in setStateForResume */ rstrcpy (conn->fileRestart.info.objPath, info->objPath, MAX_NAME_LEN); rstrcpy (conn->fileRestart.info.fileName, info->fileName, MAX_NAME_LEN); conn->fileRestart.info.status = FILE_RESTARTED; printf ("%s was restarted successfully\n", conn->fileRestart.info.objPath); unlink (conn->fileRestart.infoFile); } if (info != NULL) free (info); } } for (i = 0; i < rodsPathInp->numSrc; i++) { targPath = &rodsPathInp->targPath[i]; if (rodsPathInp->srcPath[i].rodsObjStat != NULL && rodsPathInp->srcPath[i].rodsObjStat->specColl != NULL) { dataObjOprInp.specColl = rodsPathInp->srcPath[i].rodsObjStat->specColl; } else { dataObjOprInp.specColl = NULL; } if (targPath->objType == LOCAL_FILE_T) { rmKeyVal (&dataObjOprInp.condInput, TRANSLATED_PATH_KW); status = getDataObjUtil (conn, rodsPathInp->srcPath[i].outPath, targPath->outPath, rodsPathInp->srcPath[i].size, rodsPathInp->srcPath[i].objMode, myRodsEnv, myRodsArgs, &dataObjOprInp); } else if (targPath->objType == LOCAL_DIR_T) { setStateForRestart (conn, &rodsRestart, targPath, myRodsArgs); /* The path given by collEnt.collName from rclReadCollection * has already been translated */ addKeyVal (&dataObjOprInp.condInput, TRANSLATED_PATH_KW, ""); status = getCollUtil (myConn, rodsPathInp->srcPath[i].outPath, targPath->outPath, myRodsEnv, myRodsArgs, &dataObjOprInp, &rodsRestart); #if 0 if (rodsRestart.fd > 0 && status < 0) { close (rodsRestart.fd); return (status); } #endif } else { /* should not be here */ rodsLog (LOG_ERROR, "getUtil: invalid get dest objType %d for %s", targPath->objType, targPath->outPath); return (USER_INPUT_PATH_ERR); } /* XXXX may need to return a global status */ if (status < 0) { rodsLogError (LOG_ERROR, status, "getUtil: get error for %s", targPath->outPath); savedStatus = status; break; } } if (rodsRestart.fd > 0) { close (rodsRestart.fd); } if (savedStatus < 0) { status = savedStatus; } else if (status == CAT_NO_ROWS_FOUND) { status = 0; } if (status < 0 && myRodsArgs->retries == True) { int reconnFlag; /* this is recursive. Only do it the first time */ myRodsArgs->retries = False; if (myRodsArgs->reconnect == True) { reconnFlag = RECONN_TIMEOUT; } else { reconnFlag = NO_RECONN; } while (myRodsArgs->retriesValue > 0) { rErrMsg_t errMsg; bzero (&errMsg, sizeof (errMsg)); status = rcReconnect (myConn, myRodsEnv->rodsHost, myRodsEnv, reconnFlag); if (status < 0) { rodsLogError (LOG_ERROR, status, "getUtil: rcReconnect error for %s", targPath->outPath); return status; } status = getUtil (myConn, myRodsEnv, myRodsArgs, rodsPathInp); if (status >= 0) { printf ("Retry get successful\n"); break; } else { rodsLogError (LOG_ERROR, status, "getUtil: retry getUtil error"); } myRodsArgs->retriesValue--; } } return status; }
int rsGenQuery( rsComm_t *rsComm, genQueryInp_t *genQueryInp, genQueryOut_t **genQueryOut ) { rodsServerHost_t *rodsServerHost; int status; char *zoneHint; zoneHint = getZoneHintForGenQuery( genQueryInp ); std::string zone_hint_str; if ( zoneHint ) { zone_hint_str = zoneHint; } status = getAndConnRcatHost( rsComm, SLAVE_RCAT, zoneHint, &rodsServerHost ); if ( status < 0 ) { return status; } // =-=-=-=-=-=-=- // handle non-irods connections if ( !zone_hint_str.empty() ) { irods::error ret = proc_query_terms_for_non_irods_server( zone_hint_str, genQueryInp ); if ( !ret.ok() ) { irods::log( PASS( ret ) ); } } if ( rodsServerHost->localFlag == LOCAL_HOST ) { #ifdef RODS_CAT status = _rsGenQuery( rsComm, genQueryInp, genQueryOut ); #else rodsLog( LOG_NOTICE, "rsGenQuery error. RCAT is not configured on this host" ); return SYS_NO_RCAT_SERVER_ERR; #endif } else { // =-=-=-=-=-=-=- // strip disable strict acl flag if the agent conn flag is missing char* dis_kw = getValByKey( &genQueryInp->condInput, DISABLE_STRICT_ACL_KW ); if ( dis_kw ) { irods::server_properties& props = irods::server_properties::getInstance(); props.capture_if_needed(); std::string svr_sid; irods::error err = props.get_property< std::string >( irods::AGENT_CONN_KW, svr_sid ); if ( !err.ok() ) { rmKeyVal( &genQueryInp->condInput, DISABLE_STRICT_ACL_KW ); } } // if dis_kw status = rcGenQuery( rodsServerHost->conn, genQueryInp, genQueryOut ); } if ( status < 0 && status != CAT_NO_ROWS_FOUND ) { rodsLog( LOG_NOTICE, "rsGenQuery: rcGenQuery failed, status = %d", status ); } return status; }
int _rsDataObjOpen( rsComm_t *rsComm, dataObjInp_t *dataObjInp, dataObjInfo_t *dataObjInfoHead ) { int status = 0; int phyOpenFlag = DO_PHYOPEN; if ( getValByKey( &dataObjInp->condInput, NO_OPEN_FLAG_KW ) != NULL ) { phyOpenFlag = DO_NOT_PHYOPEN; } else if ( getValByKey( &dataObjInp->condInput, PHYOPEN_BY_SIZE_KW ) != NULL ) { phyOpenFlag = PHYOPEN_BY_SIZE; } // =-=-=-=-=-=-=- // JMC - backport 4604 char * lockType = getValByKey( &dataObjInp->condInput, LOCK_TYPE_KW ); int lockFd = -1; // JMC - backport 4604 if ( lockType != NULL ) { lockFd = irods::server_api_call( DATA_OBJ_LOCK_AN, rsComm, dataObjInp, NULL, ( void** ) NULL, NULL ); if ( lockFd > 0 ) { /* rm it so it won't be done again causing deadlock */ rmKeyVal( &dataObjInp->condInput, LOCK_TYPE_KW ); } else { rodsLogError( LOG_ERROR, lockFd, "_rsDataObjOpen: lock error for %s. lockType = %s", dataObjInp->objPath, lockType ); return lockFd; } } int writeFlag = getWriteFlag( dataObjInp->openFlags ); // check earlier attempt at resolving resource hierarchy if (!getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW)) { int l1descInx = 0; if ( dataObjInp->openFlags & O_CREAT && writeFlag > 0 ) { l1descInx = rsDataObjCreate( rsComm, dataObjInp ); status = l1descInx; // JMC - backport 4604 } // =-=-=-=-=-=-=- // JMC - backport 4604 if ( lockFd >= 0 ) { if ( status > 0 ) { L1desc[l1descInx].lockFd = lockFd; } else { char fd_string[NAME_LEN]; snprintf( fd_string, sizeof( fd_string ), "%-d", lockFd ); addKeyVal( &dataObjInp->condInput, LOCK_FD_KW, fd_string ); irods::server_api_call( DATA_OBJ_UNLOCK_AN, rsComm, dataObjInp, NULL, ( void** ) NULL, NULL ); } } return status; } else { ////// /* screen out any stale copies */ status = sortObjInfoForOpen( &dataObjInfoHead, &dataObjInp->condInput, writeFlag ); if ( status < 0 ) { // JMC - backport 4604 if ( lockFd > 0 ) { char fd_string[NAME_LEN]; snprintf( fd_string, sizeof( fd_string ), "%-d", lockFd ); addKeyVal( &dataObjInp->condInput, LOCK_FD_KW, fd_string ); irods::server_api_call( DATA_OBJ_UNLOCK_AN, rsComm, dataObjInp, NULL, ( void** ) NULL, NULL ); } std::stringstream msg; msg << __FUNCTION__; msg << " - Unable to select a data obj info matching the resource hierarchy from the keywords."; irods::log( ERROR( status, msg.str() ) ); return status; } ////// status = applyPreprocRuleForOpen( rsComm, dataObjInp, &dataObjInfoHead ); if ( status < 0 ) { // JMC - backport 4604 if ( lockFd > 0 ) { char fd_string[NAME_LEN]; snprintf( fd_string, sizeof( fd_string ), "%-d", lockFd ); addKeyVal( &dataObjInp->condInput, LOCK_FD_KW, fd_string ); irods::server_api_call( DATA_OBJ_UNLOCK_AN, rsComm, dataObjInp, NULL, ( void** ) NULL, NULL ); } return status; } } dataObjInfo_t * compDataObjInfo = NULL; if ( getStructFileType( dataObjInfoHead->specColl ) >= 0 ) { /* special coll. Nothing to do */ } else if ( writeFlag > 0 ) { // JMC :: had to reformat this code to find a missing { // :: i seriously hope its in the right place... status = procDataObjOpenForWrite( rsComm, dataObjInp, &dataObjInfoHead, &compDataObjInfo ); } if ( status < 0 ) { if ( lockFd > 0 ) { char fd_string[NAME_LEN]; snprintf( fd_string, sizeof( fd_string ), "%-d", lockFd ); addKeyVal( &dataObjInp->condInput, LOCK_FD_KW, fd_string ); irods::server_api_call( DATA_OBJ_UNLOCK_AN, rsComm, dataObjInp, NULL, ( void** ) NULL, NULL ); } freeAllDataObjInfo( dataObjInfoHead ); return status; } std::string resc_class; irods::error prop_err = irods::get_resource_property<std::string>( dataObjInfoHead->rescId, "class", resc_class ); if ( prop_err.ok() ) { if ( resc_class == "bundle" ) { status = stageBundledData( rsComm, &dataObjInfoHead ); if ( status < 0 ) { rodsLog( LOG_ERROR, "_rsDataObjOpen: stageBundledData of %s failed stat=%d", dataObjInfoHead->objPath, status ); freeAllDataObjInfo( dataObjInfoHead ); if ( lockFd >= 0 ) { char fd_string[NAME_LEN]; snprintf( fd_string, sizeof( fd_string ), "%-d", lockFd ); addKeyVal( &dataObjInp->condInput, LOCK_FD_KW, fd_string ); irods::server_api_call( DATA_OBJ_UNLOCK_AN, rsComm, dataObjInp, NULL, ( void** ) NULL, NULL ); } return status; } } } /* If compDataObjInfo != NULL, an existing COMPOUND_CL DataObjInfo exist. * Need to replicate to * this DataObjInfo in rsdataObjClose. * For read, compDataObjInfo should be NULL. */ dataObjInfo_t * tmpDataObjInfo = dataObjInfoHead; while ( tmpDataObjInfo != NULL ) { dataObjInfo_t * nextDataObjInfo = tmpDataObjInfo->next; tmpDataObjInfo->next = NULL; int l1descInx = status = _rsDataObjOpenWithObjInfo( rsComm, dataObjInp, phyOpenFlag, tmpDataObjInfo ); if ( l1descInx >= 0 ) { if ( compDataObjInfo != NULL ) { L1desc[l1descInx].replDataObjInfo = compDataObjInfo; } dataObjInfo_t *otherDataObjInfo = NULL; queDataObjInfo( &otherDataObjInfo, nextDataObjInfo, 0, 1 ); // JMC - backport 4542 L1desc[l1descInx].otherDataObjInfo = otherDataObjInfo; // JMC - backport 4542 if ( writeFlag > 0 ) { L1desc[l1descInx].openType = OPEN_FOR_WRITE_TYPE; } else { L1desc[l1descInx].openType = OPEN_FOR_READ_TYPE; } if ( lockFd >= 0 ) { L1desc[l1descInx].lockFd = lockFd; } return l1descInx; } // if l1descInx >= 0 tmpDataObjInfo = nextDataObjInfo; } // while return status; } // BAD
int ncUtil (rcComm_t *conn, rodsEnv *myRodsEnv, rodsArguments_t *myRodsArgs, rodsPathInp_t *rodsPathInp) { int i; int status; int savedStatus = 0; ncOpenInp_t ncOpenInp; ncVarSubset_t ncVarSubset; if (rodsPathInp == NULL) { return (USER__NULL_INPUT_ERR); } initCondForNcOper (myRodsEnv, myRodsArgs, &ncOpenInp, &ncVarSubset); for (i = 0; i < rodsPathInp->numSrc; i++) { if (rodsPathInp->srcPath[i].objType == UNKNOWN_OBJ_T) { getRodsObjType (conn, &rodsPathInp->srcPath[i]); if (rodsPathInp->srcPath[i].objState == NOT_EXIST_ST) { rodsLog (LOG_ERROR, "ncUtil: srcPath %s does not exist", rodsPathInp->srcPath[i].outPath); savedStatus = USER_INPUT_PATH_ERR; continue; } } if (rodsPathInp->srcPath[i].objType == DATA_OBJ_T) { if (myRodsArgs->agginfo == True) { rodsLog (LOG_ERROR, "ncUtil: %s is not a collection for --agginfo", rodsPathInp->srcPath[i].outPath); continue; } rmKeyVal (&ncOpenInp.condInput, TRANSLATED_PATH_KW); status = ncOperDataObjUtil (conn, rodsPathInp->srcPath[i].outPath, myRodsEnv, myRodsArgs, &ncOpenInp, &ncVarSubset); } else if (rodsPathInp->srcPath[i].objType == COLL_OBJ_T) { /* The path given by collEnt.collName from rclReadCollection * has already been translated */ addKeyVal (&ncOpenInp.condInput, TRANSLATED_PATH_KW, ""); if (myRodsArgs->agginfo == True) { if (myRodsArgs->longOption==True) { /* list the content of .aggInfo file */ status = catAggInfo (conn, rodsPathInp->srcPath[i].outPath); } else { status = setAggInfo (conn, rodsPathInp->srcPath[i].outPath, myRodsEnv, myRodsArgs, &ncOpenInp); } } else if (myRodsArgs->recursive == True) { status = ncOperCollUtil (conn, rodsPathInp->srcPath[i].outPath, myRodsEnv, myRodsArgs, &ncOpenInp, &ncVarSubset); } else { /* assume it is an aggr collection */ status = ncOperDataObjUtil (conn, rodsPathInp->srcPath[i].outPath, myRodsEnv, myRodsArgs, &ncOpenInp, &ncVarSubset); } } else { /* should not be here */ rodsLog (LOG_ERROR, "ncUtil: invalid nc objType %d for %s", rodsPathInp->srcPath[i].objType, rodsPathInp->srcPath[i].outPath); return (USER_INPUT_PATH_ERR); } /* XXXX may need to return a global status */ if (status < 0) { rodsLogError (LOG_ERROR, status, "ncUtil: nc error for %s, status = %d", rodsPathInp->srcPath[i].outPath, status); savedStatus = status; } } if (savedStatus < 0) { return (savedStatus); } else if (status == CAT_NO_ROWS_FOUND) { return (0); } else { return (status); } }
int cpUtil( rcComm_t *conn, rodsEnv *myRodsEnv, rodsArguments_t *myRodsArgs, rodsPathInp_t *rodsPathInp ) { if ( rodsPathInp == NULL ) { return USER__NULL_INPUT_ERR; } int savedStatus = resolveRodsTarget( conn, rodsPathInp, 1 ); if ( savedStatus < 0 ) { rodsLogError( LOG_ERROR, savedStatus, "cpUtil: resolveRodsTarget error, status = %d", savedStatus ); return savedStatus; } dataObjCopyInp_t dataObjCopyInp; rodsRestart_t rodsRestart; initCondForCp( myRodsEnv, myRodsArgs, &dataObjCopyInp, &rodsRestart ); /* initialize the progress struct */ if ( gGuiProgressCB != NULL ) { bzero( &conn->operProgress, sizeof( conn->operProgress ) ); for ( int i = 0; i < rodsPathInp->numSrc; i++ ) { rodsPath_t * targPath = &rodsPathInp->targPath[i]; if ( targPath->objType == DATA_OBJ_T ) { conn->operProgress.totalNumFiles++; if ( rodsPathInp->srcPath[i].size > 0 ) { conn->operProgress.totalFileSize += rodsPathInp->srcPath[i].size; } } else { getCollSizeForProgStat( conn, rodsPathInp->srcPath[i].outPath, &conn->operProgress ); } } } for ( int i = 0; i < rodsPathInp->numSrc; i++ ) { rodsPath_t * targPath = &rodsPathInp->targPath[i]; if ( rodsPathInp->srcPath[i].rodsObjStat != NULL && rodsPathInp->srcPath[i].rodsObjStat->specColl != NULL ) { dataObjCopyInp.srcDataObjInp.specColl = rodsPathInp->srcPath[i].rodsObjStat->specColl; } int status = 0; if ( targPath->objType == DATA_OBJ_T ) { rmKeyVal( &dataObjCopyInp.srcDataObjInp.condInput, TRANSLATED_PATH_KW ); status = cpFileUtil( conn, rodsPathInp->srcPath[i].outPath, targPath->outPath, rodsPathInp->srcPath[i].size, myRodsArgs, &dataObjCopyInp ); } else if ( targPath->objType == COLL_OBJ_T ) { setStateForRestart( &rodsRestart, targPath, myRodsArgs ); addKeyVal( &dataObjCopyInp.srcDataObjInp.condInput, TRANSLATED_PATH_KW, "" ); status = cpCollUtil( conn, rodsPathInp->srcPath[i].outPath, targPath->outPath, myRodsEnv, myRodsArgs, &dataObjCopyInp, &rodsRestart ); if ( rodsRestart.fd > 0 && status < 0 ) { close( rodsRestart.fd ); return status; } if ( dataObjCopyInp.srcDataObjInp.specColl != NULL && dataObjCopyInp.srcDataObjInp.specColl->collClass == STRUCT_FILE_COLL ) { dataObjCopyInp.srcDataObjInp.specColl = NULL; status = cpCollUtil( conn, rodsPathInp->srcPath[i].outPath, targPath->outPath, myRodsEnv, myRodsArgs, &dataObjCopyInp, &rodsRestart ); } } else { /* should not be here */ rodsLog( LOG_ERROR, "cpUtil: invalid cp dest objType %d for %s", targPath->objType, targPath->outPath ); return USER_INPUT_PATH_ERR; } /* XXXX may need to return a global status */ if ( status < 0 && status != CAT_NO_ROWS_FOUND && status != SYS_SPEC_COLL_OBJ_NOT_EXIST ) { rodsLogError( LOG_ERROR, status, "cpUtil: cp error for %s, status = %d", targPath->outPath, status ); savedStatus = status; } } if ( rodsRestart.fd > 0 ) { close( rodsRestart.fd ); } return savedStatus; }
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; } }
int rsyncFileToDataUtil (rcComm_t *conn, rodsPath_t *srcPath, rodsPath_t *targPath, rodsEnv *myRodsEnv, rodsArguments_t *myRodsArgs, dataObjInp_t *dataObjOprInp) { int status; struct timeval startTime, endTime; int putFlag = 0; int syncFlag = 0; char *chksum; if (srcPath == NULL || targPath == NULL) { rodsLog (LOG_ERROR, "rsyncFileToDataUtil: NULL srcPath or targPath input"); return (USER__NULL_INPUT_ERR); } /* check the age */ if (myRodsArgs->age == True) { #ifndef windows_platform struct stat statbuf; status = stat (srcPath->outPath, &statbuf); #else struct irodsntstat statbuf; status = iRODSNt_stat(srcPath->outPath, &statbuf); #endif if (status < 0) { rodsLog (LOG_ERROR, "rsyncFileToDataUtil: stat error for %s, errno = %d\n", srcPath->outPath, errno); return (USER_INPUT_PATH_ERR); } if (ageExceeded (myRodsArgs->agevalue, statbuf.st_mtime, myRodsArgs->verbose, srcPath->outPath, srcPath->size)) return 0; } if (myRodsArgs->verbose == True) { (void) gettimeofday(&startTime, (struct timezone *)0); bzero (&conn->transStat, sizeof (transStat_t)); } if (targPath->objState == NOT_EXIST_ST) { putFlag = 1; } else if (myRodsArgs->sizeFlag == True) { /* sync by size */ if (targPath->size != srcPath->size) { putFlag = 1; } } else if (strlen (targPath->chksum) > 0) { /* src has a checksum value */ status = rcChksumLocFile (srcPath->outPath, RSYNC_CHKSUM_KW, &dataObjOprInp->condInput, extractHashFunction3(myRodsArgs)); if (status < 0) { rodsLogError (LOG_ERROR, status, "rsyncFileToDataUtil: rcChksumLocFile error for %s, status = %d", srcPath->outPath, status); return (status); } else { chksum = getValByKey (&dataObjOprInp->condInput, RSYNC_CHKSUM_KW); if (strcmp (chksum, targPath->chksum) != 0) { if (myRodsArgs->verifyChecksum == True) { addKeyVal (&dataObjOprInp->condInput, VERIFY_CHKSUM_KW, chksum); } putFlag = 1; } } } else { /* exist but no chksum */ status = rcChksumLocFile (srcPath->outPath, RSYNC_CHKSUM_KW, &dataObjOprInp->condInput, extractHashFunction3(myRodsArgs)); if (status < 0) { rodsLogError (LOG_ERROR, status, "rsyncFileToDataUtil: rcChksumLocFile error for %s, status = %d", srcPath->outPath, status); return (status); } else { chksum = getValByKey (&dataObjOprInp->condInput, RSYNC_CHKSUM_KW); if (myRodsArgs->verifyChecksum == True) { addKeyVal (&dataObjOprInp->condInput, VERIFY_CHKSUM_KW, chksum); } syncFlag = 1; } } if (putFlag + syncFlag > 0) { rstrcpy (dataObjOprInp->objPath, targPath->outPath, MAX_NAME_LEN); dataObjOprInp->dataSize = srcPath->size; dataObjOprInp->openFlags = O_WRONLY; } if (putFlag == 1) { /* only do the sync if no -l option specified */ if ( myRodsArgs->longOption != True ) { status = rcDataObjPut (conn, dataObjOprInp, srcPath->outPath); } else { status = 0; printf ("%s %lld N\n", srcPath->outPath, srcPath->size); } rmKeyVal (&dataObjOprInp->condInput, RSYNC_CHKSUM_KW); } else if (syncFlag == 1) { addKeyVal (&dataObjOprInp->condInput, RSYNC_DEST_PATH_KW, srcPath->outPath); addKeyVal (&dataObjOprInp->condInput, RSYNC_MODE_KW, IRODS_TO_LOCAL); /* only do the sync if no -l option specified */ if ( myRodsArgs->longOption != True ) { status = rcDataObjRsync (conn, dataObjOprInp); } else { status = 0; printf ("%s %lld N\n", srcPath->outPath, srcPath->size); } rmKeyVal (&dataObjOprInp->condInput, RSYNC_DEST_PATH_KW); rmKeyVal (&dataObjOprInp->condInput, RSYNC_MODE_KW); } else { status = 0; } if (status >= 0 && myRodsArgs->verbose == True) { if (putFlag > 0 || (syncFlag > 0 && status == SYS_RSYNC_TARGET_MODIFIED)) { (void) gettimeofday(&endTime, (struct timezone *)0); printTiming (conn, srcPath->outPath, srcPath->size, targPath->outPath, &startTime, &endTime); } else { printNoSync (srcPath->outPath, srcPath->size, "a match"); } } return (status); }
int chksumUtil (rcComm_t *conn, rodsEnv *myRodsEnv, rodsArguments_t *myRodsArgs, rodsPathInp_t *rodsPathInp) { int i; int status; int savedStatus = 0; collInp_t collInp; dataObjInp_t dataObjInp; if (rodsPathInp == NULL) { return (USER__NULL_INPUT_ERR); } status = initCondForChksum (myRodsEnv, myRodsArgs, &dataObjInp, &collInp); if (status < 0) { return (status); } for (i = 0; i < rodsPathInp->numSrc; i++) { if (rodsPathInp->srcPath[i].objType == UNKNOWN_OBJ_T) { getRodsObjType (conn, &rodsPathInp->srcPath[i]); if (rodsPathInp->srcPath[i].objState == NOT_EXIST_ST) { rodsLog (LOG_ERROR, "chksumUtil: srcPath %s does not exist", rodsPathInp->srcPath[i].outPath); savedStatus = USER_INPUT_PATH_ERR; continue; } } if (rodsPathInp->srcPath[i].objType == DATA_OBJ_T) { rmKeyVal (&dataObjInp.condInput, TRANSLATED_PATH_KW); status = chksumDataObjUtil (conn, rodsPathInp->srcPath[i].outPath, myRodsEnv, myRodsArgs, &dataObjInp); } else if (rodsPathInp->srcPath[i].objType == COLL_OBJ_T) { /* The path given by collEnt.collName from rclReadCollection * has already been translated */ addKeyVal (&dataObjInp.condInput, TRANSLATED_PATH_KW, ""); status = chksumCollUtil (conn, rodsPathInp->srcPath[i].outPath, myRodsEnv, myRodsArgs, &dataObjInp, &collInp); } else { /* should not be here */ rodsLog (LOG_ERROR, "chksumUtil: invalid chksum objType %d for %s", rodsPathInp->srcPath[i].objType, rodsPathInp->srcPath[i].outPath); return (USER_INPUT_PATH_ERR); } /* XXXX may need to return a global status */ if (status < 0) { rodsLogError (LOG_ERROR, status, "chksumUtil: chksum error for %s, status = %d", rodsPathInp->srcPath[i].outPath, status); savedStatus = status; } } printf ("Total checksum performed = %d, Failed checksum = %d\n", ChksumCnt, FailedChksumCnt); if (savedStatus < 0) { return (savedStatus); } else if (status == CAT_NO_ROWS_FOUND) { return (0); } else { return (status); } }
int rsyncUtil (rcComm_t *conn, rodsEnv *myRodsEnv, rodsArguments_t *myRodsArgs, rodsPathInp_t *rodsPathInp) { int i; int status; int savedStatus = 0; rodsPath_t *srcPath, *targPath; dataObjInp_t dataObjOprInp; dataObjCopyInp_t dataObjCopyInp; if (rodsPathInp == NULL) { return (USER__NULL_INPUT_ERR); } status = resolveRodsTarget (conn, myRodsEnv, rodsPathInp, RSYNC_OPR); if (status < 0) { rodsLogError (LOG_ERROR, status, "rsyncUtil: resolveRodsTarget"); return (status); } if (rodsPathInp->srcPath[0].objType <= COLL_OBJ_T && rodsPathInp->targPath[0].objType <= COLL_OBJ_T) { initCondForIrodsToIrodsRsync (myRodsEnv, myRodsArgs, &dataObjCopyInp); } else { initCondForRsync (myRodsEnv, myRodsArgs, &dataObjOprInp); } for (i = 0; i < rodsPathInp->numSrc; i++) { int srcType, targType; targPath = &rodsPathInp->targPath[i]; srcPath = &rodsPathInp->srcPath[i]; srcType = srcPath->objType; targType = targPath->objType; if (srcPath->objState != EXIST_ST) { rodsLog (LOG_ERROR, "rsyncUtil: Source path %s does not exist"); return USER_INPUT_PATH_ERR; } if (srcPath->objType <= COLL_OBJ_T && srcPath->rodsObjStat != NULL && rodsPathInp->srcPath[i].rodsObjStat->specColl != NULL) { dataObjOprInp.specColl = dataObjCopyInp.srcDataObjInp.specColl = srcPath->rodsObjStat->specColl; } else { dataObjOprInp.specColl = dataObjCopyInp.srcDataObjInp.specColl = NULL; } if (srcType == DATA_OBJ_T && targType == LOCAL_FILE_T) { rmKeyVal (&dataObjOprInp.condInput, TRANSLATED_PATH_KW); status = rsyncDataToFileUtil (conn, srcPath, targPath, myRodsEnv, myRodsArgs, &dataObjOprInp); } else if (srcType == LOCAL_FILE_T && targType == DATA_OBJ_T) { if (isPathSymlink (myRodsArgs, srcPath->outPath) > 0) continue; dataObjOprInp.createMode = rodsPathInp->srcPath[i].objMode; #ifdef FILESYSTEM_META getFileMetaFromPath(rodsPathInp->srcPath[i].outPath, &dataObjOprInp.condInput); #endif status = rsyncFileToDataUtil (conn, srcPath, targPath, myRodsEnv, myRodsArgs, &dataObjOprInp); } else if (srcType == DATA_OBJ_T && targType == DATA_OBJ_T) { rmKeyVal (&dataObjCopyInp.srcDataObjInp.condInput, TRANSLATED_PATH_KW); addKeyVal (&dataObjCopyInp.destDataObjInp.condInput, REG_CHKSUM_KW, ""); status = rsyncDataToDataUtil (conn, srcPath, targPath, myRodsEnv, myRodsArgs, &dataObjCopyInp); } else if (srcType == COLL_OBJ_T && targType == LOCAL_DIR_T) { /* The path given by collEnt.collName from rclReadCollection * has already been translated */ addKeyVal (&dataObjOprInp.condInput, TRANSLATED_PATH_KW, ""); status = rsyncCollToDirUtil (conn, srcPath, targPath, myRodsEnv, myRodsArgs, &dataObjOprInp); if (status >= 0 && dataObjOprInp.specColl != NULL && dataObjOprInp.specColl->collClass == STRUCT_FILE_COLL) { dataObjOprInp.specColl = NULL; status = rsyncCollToDirUtil (conn, srcPath, targPath, myRodsEnv, myRodsArgs, &dataObjOprInp); } } else if (srcType == LOCAL_DIR_T && targType == COLL_OBJ_T) { status = rsyncDirToCollUtil (conn, srcPath, targPath, myRodsEnv, myRodsArgs, &dataObjOprInp); } else if (srcType == COLL_OBJ_T && targType == COLL_OBJ_T) { addKeyVal (&dataObjCopyInp.srcDataObjInp.condInput, TRANSLATED_PATH_KW, ""); addKeyVal (&dataObjCopyInp.destDataObjInp.condInput, REG_CHKSUM_KW, ""); status = rsyncCollToCollUtil (conn, srcPath, targPath, myRodsEnv, myRodsArgs, &dataObjCopyInp); if (status >= 0 && dataObjOprInp.specColl != NULL && dataObjCopyInp.srcDataObjInp.specColl->collClass == STRUCT_FILE_COLL) { dataObjCopyInp.srcDataObjInp.specColl = NULL; status = rsyncCollToCollUtil (conn, srcPath, targPath, myRodsEnv, myRodsArgs, &dataObjCopyInp); } } else { /* should not be here */ rodsLog (LOG_ERROR, "rsyncUtil: invalid srcType %d and targType %d combination for %s", srcType, targType, targPath->outPath); return (USER_INPUT_PATH_ERR); } /* XXXX may need to return a global status */ if (status < 0) { rodsLogError (LOG_ERROR, status, "rsyncUtil: rsync error for %s", targPath->outPath); savedStatus = status; } } if (savedStatus < 0) { return (savedStatus); } else if (status == CAT_NO_ROWS_FOUND || status == SYS_SPEC_COLL_OBJ_NOT_EXIST) { return (0); } else { return (status); } }
int structFileReg (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp) { collInp_t collCreateInp; int status; dataObjInfo_t *dataObjInfo = NULL; char *structFilePath = NULL; dataObjInp_t dataObjInp; char *collType; int len; rodsObjStat_t *rodsObjStatOut = NULL; specCollCache_t *specCollCache = NULL; rescInfo_t *rescInfo = NULL; #if 0 /* fixed */ /* make it a privileged call for now */ if (rsComm->clientUser.authInfo.authFlag < LOCAL_PRIV_USER_AUTH) return(CAT_INSUFFICIENT_PRIVILEGE_LEVEL); #endif if ((structFilePath = getValByKey (&phyPathRegInp->condInput, FILE_PATH_KW)) == NULL) { rodsLog (LOG_ERROR, "structFileReg: No structFilePath input for %s", phyPathRegInp->objPath); return (SYS_INVALID_FILE_PATH); } collType = getValByKey (&phyPathRegInp->condInput, COLLECTION_TYPE_KW); if (collType == NULL) { rodsLog (LOG_ERROR, "structFileReg: Bad COLLECTION_TYPE_KW for structFilePath %s", dataObjInp.objPath); return (SYS_INTERNAL_NULL_INPUT_ERR); } len = strlen (phyPathRegInp->objPath); if (strncmp (structFilePath, phyPathRegInp->objPath, len) == 0 && (structFilePath[len] == '\0' || structFilePath[len] == '/')) { rodsLog (LOG_ERROR, "structFileReg: structFilePath %s inside collection %s", structFilePath, phyPathRegInp->objPath); return (SYS_STRUCT_FILE_INMOUNTED_COLL); } /* see if the struct file is in spec coll */ if (getSpecCollCache (rsComm, structFilePath, 0, &specCollCache) >= 0) { rodsLog (LOG_ERROR, "structFileReg: structFilePath %s is in a mounted path", structFilePath); return (SYS_STRUCT_FILE_INMOUNTED_COLL); } status = collStat (rsComm, phyPathRegInp, &rodsObjStatOut); if (status < 0) return status; if (rodsObjStatOut->specColl != NULL) { freeRodsObjStat (rodsObjStatOut); rodsLog (LOG_ERROR, "structFileReg: %s already mounted", phyPathRegInp->objPath); return (SYS_MOUNT_MOUNTED_COLL_ERR); } freeRodsObjStat (rodsObjStatOut); if (isCollEmpty (rsComm, phyPathRegInp->objPath) == False) { rodsLog (LOG_ERROR, "structFileReg: collection %s not empty", phyPathRegInp->objPath); return (SYS_COLLECTION_NOT_EMPTY); } memset (&dataObjInp, 0, sizeof (dataObjInp)); rstrcpy (dataObjInp.objPath, structFilePath, sizeof (dataObjInp)); /* user need to have write permission */ dataObjInp.openFlags = O_WRONLY; status = getDataObjInfoIncSpecColl (rsComm, &dataObjInp, &dataObjInfo); if (status < 0) { int myStatus; /* try to make one */ dataObjInp.condInput = phyPathRegInp->condInput; /* have to remove FILE_PATH_KW because getFullPathName will use it */ rmKeyVal (&dataObjInp.condInput, FILE_PATH_KW); myStatus = rsDataObjCreate (rsComm, &dataObjInp); if (myStatus < 0) { rodsLog (LOG_ERROR, "structFileReg: Problem with open/create structFilePath %s, status = %d", dataObjInp.objPath, status); return (status); } else { openedDataObjInp_t dataObjCloseInp; bzero (&dataObjCloseInp, sizeof (dataObjCloseInp)); rescInfo = L1desc[myStatus].dataObjInfo->rescInfo; dataObjCloseInp.l1descInx = myStatus; rsDataObjClose (rsComm, &dataObjCloseInp); } } else { rescInfo = dataObjInfo->rescInfo; } if (!structFileSupport (rsComm, phyPathRegInp->objPath, collType, rescInfo)) { rodsLog (LOG_ERROR, "structFileReg: structFileDriver type %s does not exist for %s", collType, dataObjInp.objPath); return (SYS_NOT_SUPPORTED); } /* mk the collection */ memset (&collCreateInp, 0, sizeof (collCreateInp)); rstrcpy (collCreateInp.collName, phyPathRegInp->objPath, MAX_NAME_LEN); addKeyVal (&collCreateInp.condInput, COLLECTION_TYPE_KW, collType); /* have to use dataObjInp.objPath because structFile path was removed */ addKeyVal (&collCreateInp.condInput, COLLECTION_INFO1_KW, dataObjInp.objPath); /* try to mod the coll first */ status = rsModColl (rsComm, &collCreateInp); if (status < 0) { /* try to create it */ status = rsRegColl (rsComm, &collCreateInp); } 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; }
int replUtil( rcComm_t *conn, rodsEnv *myRodsEnv, rodsArguments_t *myRodsArgs, rodsPathInp_t *rodsPathInp ) { int i = 0; int status = 0; int savedStatus = 0; dataObjInp_t dataObjInp; rodsRestart_t rodsRestart; if ( rodsPathInp == NULL ) { return ( USER__NULL_INPUT_ERR ); } initCondForRepl( myRodsEnv, myRodsArgs, &dataObjInp, &rodsRestart ); for ( i = 0; i < rodsPathInp->numSrc; i++ ) { if ( rodsPathInp->srcPath[i].objType == UNKNOWN_OBJ_T ) { getRodsObjType( conn, &rodsPathInp->srcPath[i] ); if ( rodsPathInp->srcPath[i].objState == NOT_EXIST_ST ) { rodsLog( LOG_ERROR, "replUtil: srcPath %s does not exist", rodsPathInp->srcPath[i].outPath ); savedStatus = USER_INPUT_PATH_ERR; continue; } } } /* initialize the progress struct */ if ( gGuiProgressCB != NULL ) { bzero( &conn->operProgress, sizeof( conn->operProgress ) ); for ( i = 0; i < rodsPathInp->numSrc; i++ ) { if ( rodsPathInp->srcPath[i].objType == DATA_OBJ_T ) { conn->operProgress.totalNumFiles++; if ( rodsPathInp->srcPath[i].size > 0 ) { conn->operProgress.totalFileSize += rodsPathInp->srcPath[i].size; } } else if ( rodsPathInp->srcPath[i].objType == COLL_OBJ_T ) { getCollSizeForProgStat( conn, rodsPathInp->srcPath[i].outPath, &conn->operProgress ); } } } for ( i = 0; i < rodsPathInp->numSrc; i++ ) { if ( rodsPathInp->srcPath[i].objType == DATA_OBJ_T ) { rmKeyVal( &dataObjInp.condInput, TRANSLATED_PATH_KW ); status = replDataObjUtil( conn, rodsPathInp->srcPath[i].outPath, rodsPathInp->srcPath[i].size, myRodsEnv, myRodsArgs, &dataObjInp ); } else if ( rodsPathInp->srcPath[i].objType == COLL_OBJ_T ) { setStateForRestart( conn, &rodsRestart, &rodsPathInp->srcPath[i], myRodsArgs ); addKeyVal( &dataObjInp.condInput, TRANSLATED_PATH_KW, "" ); status = replCollUtil( conn, rodsPathInp->srcPath[i].outPath, myRodsEnv, myRodsArgs, &dataObjInp, &rodsRestart ); if ( rodsRestart.fd > 0 && status < 0 ) { close( rodsRestart.fd ); return ( status ); } } else { /* should not be here */ rodsLog( LOG_ERROR, "replUtil: invalid repl objType %d for %s", rodsPathInp->srcPath[i].objType, rodsPathInp->srcPath[i].outPath ); return ( USER_INPUT_PATH_ERR ); } /* XXXX may need to return a global status */ if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "replUtil: repl error for %s, status = %d", rodsPathInp->srcPath[i].outPath, status ); savedStatus = status; } } if ( savedStatus < 0 ) { return ( savedStatus ); } else if ( status == CAT_NO_ROWS_FOUND ) { return ( 0 ); } else { return ( status ); } }
int rsQueryDataObjInCollReCur( rsComm_t *rsComm, char *collection, genQueryInp_t *genQueryInp, genQueryOut_t **genQueryOut, char *accessPerm, int singleFlag ) { char collQCond[MAX_NAME_LEN * 2]; int status = 0; char accStr[LONG_NAME_LEN]; if ( genQueryInp == NULL || collection == NULL || genQueryOut == NULL ) { return USER__NULL_INPUT_ERR; } memset( genQueryInp, 0, sizeof( genQueryInp_t ) ); genAllInCollQCond( collection, collQCond ); addInxVal( &genQueryInp->sqlCondInp, COL_COLL_NAME, collQCond ); addInxIval( &genQueryInp->selectInp, COL_D_DATA_ID, 1 ); addInxIval( &genQueryInp->selectInp, COL_COLL_NAME, 1 ); addInxIval( &genQueryInp->selectInp, COL_DATA_NAME, 1 ); if ( singleFlag == 0 ) { addInxIval( &genQueryInp->selectInp, COL_DATA_REPL_NUM, 1 ); addInxIval( &genQueryInp->selectInp, COL_D_RESC_NAME, 1 ); addInxIval( &genQueryInp->selectInp, COL_D_DATA_PATH, 1 ); } addInxIval( &genQueryInp->selectInp, COL_D_RESC_HIER, 1 ); if ( accessPerm != NULL ) { snprintf( accStr, LONG_NAME_LEN, "%s", rsComm->clientUser.userName ); addKeyVal( &genQueryInp->condInput, USER_NAME_CLIENT_KW, accStr ); snprintf( accStr, LONG_NAME_LEN, "%s", rsComm->clientUser.rodsZone ); addKeyVal( &genQueryInp->condInput, RODS_ZONE_CLIENT_KW, accStr ); snprintf( accStr, LONG_NAME_LEN, "%s", accessPerm ); addKeyVal( &genQueryInp->condInput, ACCESS_PERMISSION_KW, accStr ); /* have to set it to 1 because it only check the first one */ genQueryInp->maxRows = 1; status = rsGenQuery( rsComm, genQueryInp, genQueryOut ); rmKeyVal( &genQueryInp->condInput, USER_NAME_CLIENT_KW ); rmKeyVal( &genQueryInp->condInput, RODS_ZONE_CLIENT_KW ); rmKeyVal( &genQueryInp->condInput, ACCESS_PERMISSION_KW ); } else { genQueryInp->maxRows = MAX_SQL_ROWS; status = trySpecificQueryDataObjInCollReCur( rsComm, collection, genQueryOut ); if ( status < 0 && status != CAT_NO_ROWS_FOUND ) { rodsLog( LOG_NOTICE, "Note: DataObjInCollReCur specific-Query failed (not defined?), running standard query, status=%d", status ); /* remove the level 0 error msg added by the specific-query failure */ status = freeRErrorContent( &rsComm->rError ); /* fall back to the general-query call which used before this specific-query was added (post 3.3.1) */ genQueryInp->maxRows = MAX_SQL_ROWS; status = rsGenQuery( rsComm, genQueryInp, genQueryOut ); } } return status; }
int rsNcCreate( rsComm_t *rsComm, ncOpenInp_t *ncCreateInp, int **ncid ) { int remoteFlag; rodsServerHost_t *rodsServerHost; specCollCache_t *specCollCache = NULL; int status; dataObjInp_t dataObjInp; int l1descInx, myncid; if ( getValByKey( &ncCreateInp->condInput, NATIVE_NETCDF_CALL_KW ) != NULL ) { /* just do nc_open with objPath as file nc file path */ /* must to be called internally */ if ( rsComm->proxyUser.authInfo.authFlag < REMOTE_PRIV_USER_AUTH ) { return( CAT_INSUFFICIENT_PRIVILEGE_LEVEL ); } status = nc_create( ncCreateInp->objPath, ncCreateInp->mode, &myncid ); if ( status == NC_NOERR ) { *ncid = ( int * ) malloc( sizeof( int ) ); *( *ncid ) = myncid; return 0; } else { rodsLog( LOG_ERROR, "rsNccreate: nc_create %s error, status = %d, %s", ncCreateInp->objPath, status, nc_strerror( status ) ); return ( NETCDF_OPEN_ERR + status ); } } bzero( &dataObjInp, sizeof( dataObjInp ) ); rstrcpy( dataObjInp.objPath, ncCreateInp->objPath, MAX_NAME_LEN ); replKeyVal( &ncCreateInp->condInput, &dataObjInp.condInput ); resolveLinkedPath( rsComm, dataObjInp.objPath, &specCollCache, &dataObjInp.condInput ); remoteFlag = getAndConnRemoteZone( rsComm, &dataObjInp, &rodsServerHost, REMOTE_OPEN ); if ( remoteFlag < 0 ) { return ( remoteFlag ); } else if ( remoteFlag == LOCAL_HOST ) { addKeyVal( &dataObjInp.condInput, NO_OPEN_FLAG_KW, "" ); l1descInx = _rsDataObjCreate( rsComm, &dataObjInp ); clearKeyVal( &dataObjInp.condInput ); if ( l1descInx < 0 ) { return l1descInx; } l1desc_t& my_desc = irods::get_l1desc( l1descInx ); remoteFlag = resoAndConnHostByDataObjInfo( rsComm, my_desc.dataObjInfo, &rodsServerHost ); if ( remoteFlag < 0 ) { return ( remoteFlag ); } else if ( remoteFlag == LOCAL_HOST ) { status = nc_create( my_desc.dataObjInfo->filePath, ncCreateInp->mode, &myncid ); if ( status != NC_NOERR ) { rodsLog( LOG_ERROR, "rsNcCreate: nc_open %s error, status = %d, %s", ncCreateInp->objPath, status, nc_strerror( status ) ); freeL1desc( l1descInx ); return ( NETCDF_CREATE_ERR + status ); } } else { /* execute it remotely with dataObjInfo->filePath */ ncOpenInp_t myNcCreateInp; bzero( &myNcCreateInp, sizeof( myNcCreateInp ) ); rstrcpy( myNcCreateInp.objPath, my_desc.dataObjInfo->filePath, MAX_NAME_LEN ); addKeyVal( &myNcCreateInp.condInput, NATIVE_NETCDF_CALL_KW, "" ); status = rcNcCreate( rodsServerHost->conn, &myNcCreateInp, &myncid ); clearKeyVal( &myNcCreateInp.condInput ); if ( status < 0 ) { rodsLog( LOG_ERROR, "rsNcCreate: _rcNcCreate %s error, status = %d", myNcCreateInp.objPath, status ); freeL1desc( l1descInx ); return ( status ); } } my_desc.l3descInx = myncid; /* need to reg here since NO_OPEN_FLAG_KW does not do it */ if ( my_desc.dataObjInfo->specColl == NULL ) { status = svrRegDataObj( rsComm, my_desc.dataObjInfo ); if ( status < 0 ) { ncCloseInp_t myNcCloseInp; bzero( &myNcCloseInp, sizeof( myNcCloseInp ) ); myNcCloseInp.ncid = l1descInx; irods::server_api_call ( NC_CLOSE_AN, rsComm, &myNcCloseInp ); l3Unlink( rsComm, my_desc.dataObjInfo ); rodsLog( LOG_ERROR, "rsNcCreate: svrRegDataObj for %s failed, status = %d", my_desc.dataObjInfo->objPath, status ); freeL1desc( l1descInx ); return ( NETCDF_CREATE_ERR + status ); } } } else { addKeyVal( &dataObjInp.condInput, CROSS_ZONE_CREATE_KW, "" ); status = rcNcCreate( rodsServerHost->conn, ncCreateInp, &myncid ); /* rm it to avoid confusion */ rmKeyVal( &dataObjInp.condInput, CROSS_ZONE_CREATE_KW ); if ( status < 0 ) { rodsLog( LOG_ERROR, "rsNcCreate: _rcNcCreate %s error, status = %d", ncCreateInp->objPath, status ); return ( status ); } l1descInx = allocAndSetL1descForZoneOpr( myncid, &dataObjInp, rodsServerHost, NULL ); } l1desc_t& my_desc = irods::get_l1desc( l1descInx ); my_desc.oprType = NC_CREATE; *ncid = ( int * ) malloc( sizeof( int ) ); *( *ncid ) = l1descInx; return 0; }
int phymvUtil( rcComm_t *conn, rodsEnv *myRodsEnv, rodsArguments_t *myRodsArgs, rodsPathInp_t *rodsPathInp ) { int i = 0; int status = 0; int savedStatus = 0; dataObjInp_t dataObjInp; if ( rodsPathInp == NULL ) { return ( USER__NULL_INPUT_ERR ); } initCondForPhymv( myRodsEnv, myRodsArgs, &dataObjInp ); for ( i = 0; i < rodsPathInp->numSrc; i++ ) { if ( rodsPathInp->srcPath[i].objType == UNKNOWN_OBJ_T ) { getRodsObjType( conn, &rodsPathInp->srcPath[i] ); if ( rodsPathInp->srcPath[i].objState == NOT_EXIST_ST ) { rodsLog( LOG_ERROR, "phymvUtil: srcPath %s does not exist", rodsPathInp->srcPath[i].outPath ); savedStatus = USER_INPUT_PATH_ERR; continue; } } if ( rodsPathInp->srcPath[i].objType == DATA_OBJ_T ) { rmKeyVal( &dataObjInp.condInput, TRANSLATED_PATH_KW ); status = phymvDataObjUtil( conn, rodsPathInp->srcPath[i].outPath, myRodsEnv, myRodsArgs, &dataObjInp ); } else if ( rodsPathInp->srcPath[i].objType == COLL_OBJ_T ) { addKeyVal( &dataObjInp.condInput, TRANSLATED_PATH_KW, "" ); status = phymvCollUtil( conn, rodsPathInp->srcPath[i].outPath, myRodsEnv, myRodsArgs, &dataObjInp ); } else { /* should not be here */ rodsLog( LOG_ERROR, "phymvUtil: invalid phymv objType %d for %s", rodsPathInp->srcPath[i].objType, rodsPathInp->srcPath[i].outPath ); return ( USER_INPUT_PATH_ERR ); } /* XXXX may need to return a global status */ if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "phymvUtil: phymv error for %s, status = %d", rodsPathInp->srcPath[i].outPath, status ); savedStatus = status; } } if ( savedStatus < 0 ) { return ( savedStatus ); } else if ( status == CAT_NO_ROWS_FOUND ) { return ( 0 ); } else { return ( status ); } }
int rsyncDataToDataUtil (rcComm_t *conn, rodsPath_t *srcPath, rodsPath_t *targPath, rodsEnv *myRodsEnv, rodsArguments_t *myRodsArgs, dataObjCopyInp_t *dataObjCopyInp) { int status; struct timeval startTime, endTime; int syncFlag = 0; int cpFlag = 0; if (srcPath == NULL || targPath == NULL) { rodsLog (LOG_ERROR, "rsyncDataToDataUtil: NULL srcPath or targPath input"); return (USER__NULL_INPUT_ERR); } /* check the age */ if (myRodsArgs->age == True) { if (srcPath->rodsObjStat != NULL) { if (ageExceeded (myRodsArgs->agevalue, atoi (srcPath->rodsObjStat->modifyTime), myRodsArgs->verbose, srcPath->outPath, srcPath->size)) return 0; } } if (myRodsArgs->verbose == True) { (void) gettimeofday(&startTime, (struct timezone *)0); bzero (&conn->transStat, sizeof (transStat_t)); } if (targPath->objState == NOT_EXIST_ST) { cpFlag = 1; } else if (myRodsArgs->sizeFlag == True) { /* sync by size */ if (targPath->size != srcPath->size) { cpFlag = 1; } } else if (strlen (srcPath->chksum) > 0 && strlen (targPath->chksum) > 0) { /* src and trg has a checksum value */ if (strcmp (targPath->chksum, srcPath->chksum) != 0) { cpFlag = 1; } } else { syncFlag = 1; } if (cpFlag == 1) { rstrcpy (dataObjCopyInp->srcDataObjInp.objPath, srcPath->outPath, MAX_NAME_LEN); dataObjCopyInp->srcDataObjInp.dataSize = srcPath->size; rstrcpy (dataObjCopyInp->destDataObjInp.objPath, targPath->outPath, MAX_NAME_LEN); /* only do the sync if no -l option specified */ if ( myRodsArgs->longOption != True ) { status = rcDataObjCopy (conn, dataObjCopyInp); } else { status = 0; printf ("%s %lld N\n", srcPath->outPath, srcPath->size); } } else if (syncFlag == 1) { dataObjInp_t *dataObjOprInp = &dataObjCopyInp->destDataObjInp; rstrcpy (dataObjOprInp->objPath, srcPath->outPath, MAX_NAME_LEN); dataObjOprInp->dataSize = srcPath->size; addKeyVal (&dataObjOprInp->condInput, RSYNC_DEST_PATH_KW, targPath->outPath); addKeyVal (&dataObjOprInp->condInput, RSYNC_MODE_KW, IRODS_TO_IRODS); /* only do the sync if no -l option specified */ if ( myRodsArgs->longOption != True ) { status = rcDataObjRsync (conn, dataObjOprInp); } else { status = 0; printf ("%s %lld N\n", srcPath->outPath, srcPath->size); } rmKeyVal (&dataObjOprInp->condInput, RSYNC_MODE_KW); rmKeyVal (&dataObjOprInp->condInput, RSYNC_DEST_PATH_KW); } else { status = 0; } if (status >= 0 && myRodsArgs->verbose == True) { if (cpFlag > 0 || (syncFlag > 0 && status == SYS_RSYNC_TARGET_MODIFIED)) { (void) gettimeofday(&endTime, (struct timezone *)0); printTiming (conn, srcPath->outPath, srcPath->size, targPath->outPath, &startTime, &endTime); } else { printNoSync (srcPath->outPath, srcPath->size, "a match"); } } return (status); }