int bulkPutDirUtil( rcComm_t **myConn, char *srcDir, char *targColl, rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs, dataObjInp_t *dataObjOprInp, bulkOprInp_t *bulkOprInp, rodsRestart_t *rodsRestart ) { int status; bulkOprInfo_t bulkOprInfo; /* do large files first */ bzero( &bulkOprInfo, sizeof( bulkOprInfo ) ); bulkOprInfo.flags = BULK_OPR_LARGE_FILES; status = putDirUtil( myConn, srcDir, targColl, myRodsEnv, rodsArgs, dataObjOprInp, bulkOprInp, rodsRestart, &bulkOprInfo ); if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "bulkPutDirUtil: Large files bulkPut error for %s", srcDir ); return status; } /* now bulk put the small files */ bzero( &bulkOprInfo, sizeof( bulkOprInfo ) ); bulkOprInfo.flags = BULK_OPR_SMALL_FILES; rstrcpy( dataObjOprInp->objPath, targColl, MAX_NAME_LEN ); rstrcpy( bulkOprInp->objPath, targColl, MAX_NAME_LEN ); bulkOprInfo.bytesBuf.len = 0; bulkOprInfo.bytesBuf.buf = malloc( BULK_OPR_BUF_SIZE ); status = putDirUtil( myConn, srcDir, targColl, myRodsEnv, rodsArgs, dataObjOprInp, bulkOprInp, rodsRestart, &bulkOprInfo ); if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "bulkPutDirUtil: Small files bulkPut error for %s", srcDir ); return status; } if ( bulkOprInfo.count > 0 ) { status = sendBulkPut( *myConn, bulkOprInp, &bulkOprInfo, rodsArgs ); if ( status >= 0 ) { if ( rodsRestart->fd > 0 ) { rodsRestart->curCnt += bulkOprInfo.count; /* last entry. */ writeRestartFile( rodsRestart, bulkOprInfo.cachedTargPath ); } } else { rodsLogError( LOG_ERROR, status, "bulkPutDirUtil: tarAndBulkPut error for %s", bulkOprInfo.phyBunDir ); } clearBulkOprInfo( &bulkOprInfo ); if ( bulkOprInfo.bytesBuf.buf != NULL ) { free( bulkOprInfo.bytesBuf.buf ); bulkOprInfo.bytesBuf.buf = NULL; } } return status; }
int irods_file_open_( char *filename, char *mode ) { int i; int status; dataObjInp_t dataObjInp; char **outPath; char *cp1, *cp2; int nameLen; if ( debug ) { printf( "irods_file_open filename input:%s:\n", filename ); } /* Remove trailing blanks from the filename */ cp1 = filename; cp2 = cp1 + strlen( filename ) - 1; for ( ; *cp2 == ' ' && cp2 > cp1; cp2-- ) { } cp2++; if ( cp2 > cp1 ) { *cp2 = '\0'; } if ( debug ) printf( "irods_file_open filename w/o trailing blanks:%s:\n", filename ); if ( setupFlag == 0 ) { status = irods_connect_(); if ( status ) { return -1; } } memset( &dataObjInp, 0, sizeof( dataObjInp ) ); status = parseRodsPathStr( filename , &myRodsEnv, dataObjInp.objPath ); if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "irods_file_open" ); return -1; } /* Set the openFlags based on the input mode (incomplete * currently) // */ dataObjInp.openFlags = O_RDONLY; if ( strstr( mode, "WRITE" ) != NULL ) { dataObjInp.openFlags = O_RDWR; } /* may want a O_WRONLY mode too sometime */ status = rcDataObjOpen( Comm, &dataObjInp ); if ( status == CAT_NO_ROWS_FOUND && dataObjInp.openFlags == O_WRONLY ) { status = rcDataObjCreate( Comm, &dataObjInp ); } if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "irods_file_open" ); return -1; } return status; }
/* close a iFuse file */ int ifuseClose (iFuseDesc_t *desc) { int status; LOCK_STRUCT(*desc); status = _ifuseFlush(desc); if(status < 0) { rodsLogError(LOG_ERROR, status, "ifuseClose: flush of %s error", desc->localPath); } status = ifuseFileCacheClose(desc->fileCache); if(status < 0) { rodsLogError(LOG_ERROR, status, "ifuseClose: close of %s error", desc->localPath); } status = _freeIFuseDesc(desc); UNLOCK_STRUCT(*desc); if(status < 0) { rodsLogError(LOG_ERROR, status, "ifuseClose: free desc struct error", desc->localPath); } return status; }
int rsAcceptConn( rsComm_t *svrComm ) { socklen_t len = sizeof( svrComm->remoteAddr ); const int saved_socket_flags = fcntl( svrComm->sock, F_GETFL ); int status = fcntl( svrComm->sock, F_SETFL, saved_socket_flags | O_NONBLOCK ); if ( status < 0 ) { rodsLogError( LOG_NOTICE, status, "failed to set flags with nonblock on fnctl with status %d", status ); } const int newSock = accept( svrComm->sock, ( struct sockaddr * ) &svrComm->remoteAddr, &len ); status = fcntl( svrComm->sock, F_SETFL, saved_socket_flags ); if ( status < 0 ) { rodsLogError( LOG_NOTICE, status, "failed to revert flags on fnctl with status %d", status ); } if ( newSock < 0 ) { const int status = SYS_SOCK_ACCEPT_ERR - errno; rodsLogError( LOG_NOTICE, status, "rsAcceptConn: accept error for socket %d, status = %d", svrComm->sock, status ); return newSock; } rodsSetSockOpt( newSock, svrComm->windowSize ); return newSock; }
int renamePreloadedCache (const char *fromPath, const char *toPath) { int status; char fromiRODSPath[MAX_NAME_LEN]; char toiRODSPath[MAX_NAME_LEN]; status = _getiRODSPath(fromPath, fromiRODSPath); if(status < 0) { rodsLogError(LOG_ERROR, status, "renamePreloadedCache: _getiRODSPath error."); rodsLog (LOG_ERROR, "renamePreloadedCache: failed to get iRODS path - %s", fromPath); return status; } status = _getiRODSPath(toPath, toiRODSPath); if(status < 0) { rodsLogError(LOG_ERROR, status, "renamePreloadedCache: _getiRODSPath error."); rodsLog (LOG_ERROR, "renamePreloadedCache: failed to get iRODS path - %s", toPath); return status; } LOCK(PreloadLock); status = _renameCache(fromiRODSPath, toiRODSPath); UNLOCK(PreloadLock); return status; }
int mvUtil( rcComm_t *conn, rodsArguments_t *myRodsArgs, rodsPathInp_t *rodsPathInp ) { if ( rodsPathInp == NULL ) { return USER__NULL_INPUT_ERR; } dataObjCopyInp_t dataObjRenameInp; initCondForMv( &dataObjRenameInp ); int savedStatus = resolveRodsTarget( conn, rodsPathInp, MOVE_OPR ); if ( savedStatus < 0 ) { rodsLogError( LOG_ERROR, savedStatus, "mvUtil: resolveRodsTarget error, status = %d", savedStatus ); return savedStatus; } for ( int i = 0; i < rodsPathInp->numSrc; i++ ) { rodsPath_t * targPath = &rodsPathInp->targPath[i]; int status = mvObjUtil( conn, rodsPathInp->srcPath[i].outPath, targPath->outPath, targPath->objType, myRodsArgs, &dataObjRenameInp ); /* XXXX may need to return a global status */ if ( status < 0 && status != CAT_NO_ROWS_FOUND ) { rodsLogError( LOG_ERROR, status, "mvUtil: mv error for %s, status = %d", targPath->outPath, status ); savedStatus = status; } } return savedStatus; }
static int _completeDownload(const char *workPath, const char *cachePath, struct stat *stbuf) { int status; struct utimbuf amtime; if (workPath == NULL || cachePath == NULL || stbuf == NULL) { rodsLog (LOG_ERROR, "_completeDownload: input workPath or cachePath or stbuf is NULL"); return (SYS_INTERNAL_NULL_INPUT_ERR); } //amtime.actime = stbuf->st_atime; amtime.actime = convTime(getCurrentTime()); amtime.modtime = stbuf->st_mtime; // set last access time and modified time the same as the original file status = utime(workPath, &amtime); if(status < 0) { rodsLogError(LOG_ERROR, status, "_completeDownload: utime error."); return status; } // change the name status = rename(workPath, cachePath); if(status < 0) { rodsLogError(LOG_ERROR, status, "_completeDownload: rename error."); return status; } return (0); }
int moveToPreloadedDir (const char *path, const char *iRODSPath) { int status; char preloadCachePath[MAX_NAME_LEN]; if (path == NULL || iRODSPath == NULL) { rodsLog (LOG_ERROR, "moveToPreloadedDir: input path or iRODSPath is NULL"); return (SYS_INTERNAL_NULL_INPUT_ERR); } status = _getCachePath(iRODSPath, preloadCachePath); if(status < 0) { rodsLogError(LOG_ERROR, status, "moveToPreloadedDir: _getCachePath error."); rodsLog (LOG_ERROR, "moveToPreloadedDir: failed to get cache path - %s", path); return status; } // make dir prepareDir(preloadCachePath); // move the file status = rename(path, preloadCachePath); if(status < 0) { rodsLogError(LOG_ERROR, status, "moveToPreloadedDir: rename error."); return status; } return (0); }
int regUtil( rcComm_t *conn, rodsEnv *myRodsEnv, rodsArguments_t *myRodsArgs, rodsPathInp_t *rodsPathInp ) { if ( rodsPathInp == NULL ) { return USER__NULL_INPUT_ERR; } dataObjInp_t dataObjOprInp; initCondForReg( myRodsEnv, myRodsArgs, &dataObjOprInp ); int savedStatus = 0; for ( int i = 0; i < rodsPathInp->numSrc; i++ ) { rodsPath_t * destPath = &rodsPathInp->destPath[i]; /* iRODS path */ rodsPath_t * srcPath = &rodsPathInp->srcPath[i]; /* file Path */ getRodsObjType( conn, destPath ); if ( destPath->objState == EXIST_ST && myRodsArgs->force == False && myRodsArgs->mountCollection == False && myRodsArgs->regRepl != True ) { rodsLog( LOG_ERROR, "regUtil: iRODSPath %s already exist", destPath->outPath ); return CAT_NAME_EXISTS_AS_DATAOBJ; } int status = 0; if ( myRodsArgs->collection == False && myRodsArgs->checksum == True ) { status = rcChksumLocFile( srcPath->outPath, REG_CHKSUM_KW, &dataObjOprInp.condInput, myRodsArgs->hashValue ); if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "regUtil: rcChksumLocFile error for %s, status = %d", srcPath, status ); return status; } } else if ( myRodsArgs->collection == False && myRodsArgs->verifyChecksum == True ) { addKeyVal( &dataObjOprInp.condInput, VERIFY_CHKSUM_KW, "" ); } addKeyVal( &dataObjOprInp.condInput, FILE_PATH_KW, srcPath->outPath ); rstrcpy( dataObjOprInp.objPath, destPath->outPath, MAX_NAME_LEN ); status = rcPhyPathReg( conn, &dataObjOprInp ); /* XXXX may need to return a global status */ if ( status < 0 && status != CAT_NO_ROWS_FOUND ) { rodsLogError( LOG_ERROR, status, "regUtil: reg error for %s, status = %d", destPath->outPath, status ); savedStatus = status; } } return savedStatus; }
int irodsTruncate (const char *path, off_t size) { dataObjInp_t dataObjInp; int status; pathCache_t *tmpPathCache; iFuseConn_t *iFuseConn = NULL; rodsLog (LOG_DEBUG, "irodsTruncate: %s", path); if (matchAndLockPathCache ((char *) path, &tmpPathCache) == 1) { if(tmpPathCache->fileCache != NULL) { LOCK_STRUCT(*tmpPathCache->fileCache); if(tmpPathCache->fileCache->state == HAVE_NEWLY_CREATED_CACHE) { status = truncate (tmpPathCache->fileCache->fileCachePath, size); if (status >= 0) { updatePathCacheStatFromFileCache (tmpPathCache); UNLOCK_STRUCT(*(tmpPathCache->fileCache)); UNLOCK_STRUCT(*tmpPathCache); return (0); } } UNLOCK_STRUCT(*(tmpPathCache->fileCache)); } } UNLOCK_STRUCT(*tmpPathCache); memset (&dataObjInp, 0, sizeof (dataObjInp)); status = parseRodsPathStr ((char *) (path + 1) , &MyRodsEnv, dataObjInp.objPath); if (status < 0) { rodsLogError (LOG_ERROR, status, "irodsTruncate: parseRodsPathStr of %s error", path); /* use ENOTDIR for this type of error */ return -ENOTDIR; } dataObjInp.dataSize = size; getAndUseIFuseConn (&iFuseConn, &MyRodsEnv); RECONNECT_IF_NECESSARY(status, iFuseConn, rcDataObjTruncate (iFuseConn->conn, &dataObjInp)); if (status >= 0) { pathCache_t *tmpPathCache; if (matchAndLockPathCache ((char *) path, &tmpPathCache) == 1) { tmpPathCache->stbuf.st_size = size; } UNLOCK_STRUCT(*tmpPathCache); status = 0; } else { rodsLogError (LOG_ERROR, status, "irodsTruncate: rcDataObjTruncate of %s error", path); status = -ENOENT; } unuseIFuseConn (iFuseConn); return (status); }
/** * \fn rcExecMyRule( rcComm_t *conn, execMyRuleInp_t *execMyRuleInp, msParamArray_t **outParamArray ) * * \brief Execute my rule. * * \user client * * \ingroup rules * * \since 1.0 * * * \remark none * * \note none * * \param[in] conn - A rcComm_t connection handle to the server. * \param[in] execMyRuleInp * \param[out] outParamArray * * \return integer * \retval 0 on success. * \sideeffect none * \pre none * \post none * \sa none **/ int rcExecMyRule( rcComm_t *conn, execMyRuleInp_t *execMyRuleInp, msParamArray_t **outParamArray ) { int status = procApiRequest( conn, EXEC_MY_RULE_AN, execMyRuleInp, NULL, ( void ** )outParamArray, NULL ); while ( status == SYS_SVR_TO_CLI_MSI_REQUEST ) { /* it is a server request */ msParam_t *myParam = NULL, *putParam = NULL; if ( ( myParam = putParam = getMsParamByLabel( *outParamArray, CL_PUT_ACTION ) ) || ( myParam = getMsParamByLabel( *outParamArray, CL_GET_ACTION ) ) ) { //putParam is non-null if it's a put, null if it's a get dataObjInp_t * dataObjInp = ( dataObjInp_t * ) myParam->inOutStruct; char * locFilePath; char myDir[MAX_NAME_LEN], myFile[MAX_NAME_LEN]; // locFilePath should be the return of getValByKey if it exists, // otherwise use the filename from splitPathByKey if ( ( locFilePath = getValByKey( &dataObjInp->condInput, LOCAL_PATH_KW ) ) || ( ( status = splitPathByKey( dataObjInp->objPath, myDir, MAX_NAME_LEN, myFile, MAX_NAME_LEN, '/' ) ) >= 0 && ( locFilePath = ( char * ) myFile ) ) ) { status = putParam ? rcDataObjPut( conn, dataObjInp, locFilePath ) : rcDataObjGet( conn, dataObjInp, locFilePath ); rcOprComplete( conn, status ); } else { rodsLogError( LOG_ERROR, status, "rcExecMyRule: splitPathByKey for %s error", dataObjInp->objPath ); rcOprComplete( conn, USER_FILE_DOES_NOT_EXIST ); } clearKeyVal( &dataObjInp->condInput ); } else { rcOprComplete( conn, SYS_SVR_TO_CLI_MSI_NO_EXIST ); } /* free outParamArray */ clearMsParamArray( *outParamArray, 1 ); free( *outParamArray ); *outParamArray = NULL; /* read the reply from the earlier call */ status = branchReadAndProcApiReply( conn, EXEC_MY_RULE_AN, ( void ** )outParamArray, NULL ); if ( status < 0 ) { rodsLogError( LOG_DEBUG, status, "rcExecMyRule: readAndProcApiReply failed. status = %d", status ); } } return status; }
int phybunUtil (rcComm_t *conn, rodsEnv *myRodsEnv, rodsArguments_t *myRodsArgs, rodsPathInp_t *rodsPathInp) { int i; int status; int savedStatus = 0; rodsPath_t *collPath; structFileExtAndRegInp_t phyBundleCollInp; if (rodsPathInp == NULL) { return (USER__NULL_INPUT_ERR); } status = initCondForPhybunOpr (myRodsEnv, myRodsArgs, &phyBundleCollInp, rodsPathInp); if (status < 0) return status; for (i = 0; i < rodsPathInp->numSrc; i++) { collPath = &rodsPathInp->srcPath[i]; /* iRODS Collection */ getRodsObjType (conn, collPath); if (collPath->objType != COLL_OBJ_T) { rodsLogError (LOG_ERROR, status, "phybunUtil: input path %s is not a collection", collPath->outPath); return USER_INPUT_PATH_ERR; } rstrcpy (phyBundleCollInp.collection, collPath->outPath, MAX_NAME_LEN); status = rcPhyBundleColl (conn, &phyBundleCollInp); if (status < 0) { rodsLogError (LOG_ERROR, status, "phybunUtil: opr error for %s, status = %d", collPath->outPath, status); savedStatus = status; } } if (savedStatus < 0) { return (savedStatus); } else if (status == CAT_NO_ROWS_FOUND) { return (0); } else { return (status); } }
int irods_file_create_( char *filename ) { int i; int status; dataObjInp_t dataObjInp; char **outPath; char *cp1, *cp2; int nameLen; if ( debug ) { printf( "irods_file_create filename input:%s:\n", filename ); } /* Remove trailing blanks from the filename */ cp1 = filename; cp2 = cp1 + strlen( filename ) - 1; for ( ; *cp2 == ' ' && cp2 > cp1; cp2-- ) { } cp2++; if ( cp2 > cp1 ) { *cp2 = '\0'; } if ( debug ) printf( "irods_file_create filename w/o trailing blanks:%s:\n", filename ); if ( setupFlag == 0 ) { status = irods_connect_(); if ( status ) { return -1; } } memset( &dataObjInp, 0, sizeof( dataObjInp ) ); status = parseRodsPathStr( filename , &myRodsEnv, dataObjInp.objPath ); if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "irods_file_create" ); return -1; } dataObjInp.openFlags = O_RDWR; /* may want a O_WRONLY mode too sometime */ status = rcDataObjCreate( Comm, &dataObjInp ); if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "irods_file_open" ); return -1; } return status; }
// =-=-=-=-=-=-=- // JMC - backport 4590 int procDataObjOpenForWrite( rsComm_t *rsComm, dataObjInp_t *dataObjInp, dataObjInfo_t **dataObjInfoHead, dataObjInfo_t **compDataObjInfo ) { int status = 0; /* put the copy with destResc on top */ status = requeDataObjInfoByDestResc( dataObjInfoHead, &dataObjInp->condInput, 1, 1 ); /* status < 0 means there is no copy in the DEST_RESC */ if ( status < 0 && ( *dataObjInfoHead )->specColl == NULL && getValByKey( &dataObjInp->condInput, DEST_RESC_NAME_KW ) != NULL ) { /* we don't have a copy, so create an empty dataObjInfo */ status = createEmptyRepl( rsComm, dataObjInp, dataObjInfoHead ); if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "procDataObjForOpenWrite: createEmptyRepl of %s failed", ( *dataObjInfoHead )->objPath ); return status; } } else { /* The target data object exists */ status = 0; } if ( *compDataObjInfo != NULL ) { dequeDataObjInfo( dataObjInfoHead, *compDataObjInfo ); } return status; }
int ifuseConnect( iFuseConn_t *iFuseConn, rodsEnv *myRodsEnv ) { int status = 0; LOCK_STRUCT( *iFuseConn ); if ( iFuseConn->conn == NULL ) { rErrMsg_t errMsg; iFuseConn->conn = rcConnect( myRodsEnv->rodsHost, myRodsEnv->rodsPort, myRodsEnv->rodsUserName, myRodsEnv->rodsZone, NO_RECONN, &errMsg ); if ( iFuseConn->conn == NULL ) { /* try one more */ iFuseConn->conn = rcConnect( myRodsEnv->rodsHost, myRodsEnv->rodsPort, myRodsEnv->rodsUserName, myRodsEnv->rodsZone, NO_RECONN, &errMsg ); if ( iFuseConn->conn == NULL ) { rodsLogError( LOG_ERROR, errMsg.status, "ifuseConnect: rcConnect failure %s", errMsg.msg ); UNLOCK_STRUCT( *iFuseConn ); if ( errMsg.status < 0 ) { return errMsg.status; } else { return -1; } } } status = clientLogin( iFuseConn->conn ); if ( status != 0 ) { rcDisconnect( iFuseConn->conn ); iFuseConn->conn = NULL; } } UNLOCK_STRUCT( *iFuseConn ); return status; }
int isioSetup() { int status; rErrMsg_t errMsg; char *mySubName; char *myName; if (debug) printf("isioSetup\n"); status = getRodsEnv (&myRodsEnv); if (status < 0) { rodsLogError(LOG_ERROR, status, "isioSetup: getRodsEnv error."); } Comm = rcConnect (myRodsEnv.rodsHost, myRodsEnv.rodsPort, myRodsEnv.rodsUserName, myRodsEnv.rodsZone, 0, &errMsg); if (Comm == NULL) { myName = rodsErrorName(errMsg.status, &mySubName); rodsLog(LOG_ERROR, "rcConnect failure %s (%s) (%d) %s", myName, mySubName, errMsg.status, errMsg.msg); status = errMsg.status; return(status); } status = clientLogin(Comm); if (status==0) { setupFlag=1; } return(status); }
int irods_file_seek_( int *fd, long *offset, char *whence ) { openedDataObjInp_t seekParam; fileLseekOut_t* seekResult = NULL; int status; int myWhence = 0; if ( strstr( whence, "SEEK_SET" ) != NULL ) { myWhence = SEEK_SET; } if ( strstr( whence, "SEEK_CUR" ) != NULL ) { myWhence = SEEK_CUR; } if ( strstr( whence, "SEEK_END" ) != NULL ) { myWhence = SEEK_END; } if ( debug ) { printf( "irods_file_seek_: %d\n", *fd ); } memset( &seekParam, 0, sizeof( openedDataObjInp_t ) ); seekParam.l1descInx = *fd; seekParam.offset = *offset; seekParam.whence = myWhence; status = rcDataObjLseek( Comm, &seekParam, &seekResult ); if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "irods_file_seek_" ); } return status; }
/* perform the modify command to change the comment*/ int doModComment(rcComm_t *Conn, char *objPath, int numRepl, char *theComment) { int status; modDataObjMeta_t modDataObjMetaInp; keyValPair_t regParam; dataObjInfo_t dataObjInfo; memset (®Param, 0, sizeof (regParam)); addKeyVal (®Param, DATA_COMMENTS_KW, theComment); memset(&dataObjInfo, 0, sizeof(dataObjInfo)); rstrcpy(dataObjInfo.objPath, objPath, MAX_NAME_LEN); if (numRepl > 0) { dataObjInfo.replNum = numRepl; } else { addKeyVal(®Param, ALL_KW, theComment); } modDataObjMetaInp.regParam = ®Param; modDataObjMetaInp.dataObjInfo = &dataObjInfo; status = rcModDataObjMeta(Conn, &modDataObjMetaInp); if (status) { rodsLogError(LOG_ERROR, status, "rcModDataObjMeta failure"); } return(status); }
int branchReadAndProcApiReply( rcComm_t *conn, int apiNumber, void **outStruct, bytesBuf_t *outBsBBuf ) { int status = 0; int apiInx = 0; if ( conn == NULL ) { return ( USER__NULL_INPUT_ERR ); } apiInx = apiTableLookup( apiNumber ); if ( apiInx < 0 ) { rodsLog( LOG_ERROR, "branchReadAndProcApiReply: apiTableLookup of apiNum %d failed", apiNumber ); return ( apiInx ); } conn->apiInx = apiInx; status = readAndProcApiReply( conn, apiInx, outStruct, outBsBBuf ); if ( status < 0 ) { rodsLogError( LOG_DEBUG, status, "branchReadAndProcApiReply: readAndProcApiReply failed. status = %d", status ); } return ( status ); }
int chksumDataObjUtil (rcComm_t *conn, char *srcPath, rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs, dataObjInp_t *dataObjInp) { int status; struct timeval startTime, endTime; char *chksumStr = NULL; char myDir[MAX_NAME_LEN], myFile[MAX_NAME_LEN]; if (srcPath == NULL) { rodsLog (LOG_ERROR, "chksumDataObjUtil: NULL srcPath input"); return (USER__NULL_INPUT_ERR); } if (rodsArgs->verbose == True) { (void) gettimeofday(&startTime, (struct timezone *)0); } rstrcpy (dataObjInp->objPath, srcPath, MAX_NAME_LEN); status = rcDataObjChksum (conn, dataObjInp, &chksumStr); if (status < 0) { #if 0 if (status == CAT_NO_ROWS_FOUND && rodsArgs->resource == True) { if (rodsArgs->verbose == True) { printf ("%s does not exist in resource %s\n", dataObjInp->objPath, rodsArgs->resourceString); } return 0; } else { #endif ChksumCnt++; FailedChksumCnt++; rodsLogError (LOG_ERROR, status, "chksumDataObjUtil: rcDataObjChksum error for %s", dataObjInp->objPath); return status; #if 0 } #endif } else { ChksumCnt++; } splitPathByKey (dataObjInp->objPath, myDir, myFile, '/'); if (rodsArgs->silent == False) { printf (" %-30.30s %s\n", myFile, chksumStr); free (chksumStr); if (rodsArgs->verbose == True) { (void) gettimeofday(&endTime, (struct timezone *)0); printTiming (conn, dataObjInp->objPath, -1, NULL, &startTime, &endTime); } } return (status); }
int irodsMkdir (const char *path, mode_t mode) { collInp_t collCreateInp; int status; iFuseConn_t *iFuseConn = NULL; rodsLog (LOG_DEBUG, "irodsMkdir: %s", path); memset (&collCreateInp, 0, sizeof (collCreateInp)); status = parseRodsPathStr ((char *) (path + 1) , &MyRodsEnv, collCreateInp.collName); if (status < 0) { rodsLogError (LOG_ERROR, status, "irodsMkdir: parseRodsPathStr of %s error", path); /* use ENOTDIR for this type of error */ return -ENOTDIR; } getAndUseIFuseConn (&iFuseConn, &MyRodsEnv); status = rcCollCreate (iFuseConn->conn, &collCreateInp); if (status < 0) { if (isReadMsgError (status)) { ifuseReconnect (iFuseConn); status = rcCollCreate (iFuseConn->conn, &collCreateInp); } unuseIFuseConn (iFuseConn); if (status < 0) { rodsLogError (LOG_ERROR, status, "irodsMkdir: rcCollCreate of %s error", path); return -ENOENT; } #ifdef CACHE_FUSE_PATH } else { struct stat stbuf; uint mytime = time (0); bzero (&stbuf, sizeof (struct stat)); fillDirStat (&stbuf, mytime, mytime, mytime); pathExist ((char *) path, NULL, &stbuf, NULL); #endif unuseIFuseConn (iFuseConn); } return (0); }
int lsDataObjUtilLong (rcComm_t *conn, char *srcPath, rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs, genQueryInp_t *genQueryInp) { int status; genQueryOut_t *genQueryOut = NULL; char myColl[MAX_NAME_LEN], myData[MAX_NAME_LEN]; char condStr[MAX_NAME_LEN]; int queryFlags; queryFlags = setQueryFlag (rodsArgs); setQueryInpForData (queryFlags, genQueryInp); genQueryInp->maxRows = MAX_SQL_ROWS; memset (myColl, 0, MAX_NAME_LEN); memset (myData, 0, MAX_NAME_LEN); if ((status = splitPathByKey ( srcPath, myColl, myData, '/')) < 0) { rodsLogError (LOG_ERROR, status, "setQueryInpForLong: splitPathByKey for %s error, status = %d", srcPath, status); return (status); } snprintf (condStr, MAX_NAME_LEN, "='%s'", myColl); addInxVal (&genQueryInp->sqlCondInp, COL_COLL_NAME, condStr); snprintf (condStr, MAX_NAME_LEN, "='%s'", myData); addInxVal (&genQueryInp->sqlCondInp, COL_DATA_NAME, condStr); status = rcGenQuery (conn, genQueryInp, &genQueryOut); if (status < 0) { if (status == CAT_NO_ROWS_FOUND) { rodsLog (LOG_ERROR, "%s does not exist or user lacks access permission", srcPath); } else { rodsLogError (LOG_ERROR, status, "lsDataObjUtilLong: rcGenQuery error for %s", srcPath); } return (status); } printLsLong (conn, rodsArgs, genQueryOut); return (0); }
int irodsUnlink (const char *path) { dataObjInp_t dataObjInp; int status; iFuseConn_t *iFuseConn = NULL; rodsLog (LOG_DEBUG, "irodsUnlink: %s", path); memset (&dataObjInp, 0, sizeof (dataObjInp)); status = parseRodsPathStr ((char *) (path + 1) , &MyRodsEnv, dataObjInp.objPath); if (status < 0) { rodsLogError (LOG_ERROR, status, "irodsUnlink: parseRodsPathStr of %s error", path); /* use ENOTDIR for this type of error */ return -ENOTDIR; } addKeyVal (&dataObjInp.condInput, FORCE_FLAG_KW, ""); getAndUseIFuseConn (&iFuseConn, &MyRodsEnv); status = rcDataObjUnlink (iFuseConn->conn, &dataObjInp); if (status >= 0) { #ifdef CACHE_FUSE_PATH pathNotExist ((char *) path); #endif status = 0; } else { if (isReadMsgError (status)) { ifuseReconnect (iFuseConn); status = rcDataObjUnlink (iFuseConn->conn, &dataObjInp); } if (status < 0) { rodsLogError (LOG_ERROR, status, "irodsUnlink: rcDataObjUnlink of %s error", path); status = -ENOENT; } } unuseIFuseConn (iFuseConn); clearKeyVal (&dataObjInp.condInput); return (status); }
/* precond: lock desc */ int _ifuseRead(iFuseDesc_t *desc, char *buf, size_t size, off_t offset) { int status = ifuseFileCacheRead(desc->fileCache, buf, size, offset); if (status < 0) { rodsLogError(LOG_ERROR, status, "ifuseRead: read of %s error", desc->localPath); } return status; }
int myS3Error (int status, int irodsErrorCode) { if (status < 0) return status; rodsLogError (LOG_ERROR, irodsErrorCode, "myS3Error: error:%s", S3_get_status_name((S3Status) status)); return (irodsErrorCode - status); }
int irodsRmdir (const char *path) { collInp_t collInp; int status; iFuseConn_t *iFuseConn = NULL; rodsLog (LOG_DEBUG, "irodsRmdir: %s", path); memset (&collInp, 0, sizeof (collInp)); status = parseRodsPathStr ((char *) (path + 1) , &MyRodsEnv, collInp.collName); if (status < 0) { rodsLogError (LOG_ERROR, status, "irodsRmdir: parseRodsPathStr of %s error", path); /* use ENOTDIR for this type of error */ return -ENOTDIR; } addKeyVal (&collInp.condInput, FORCE_FLAG_KW, ""); getAndUseIFuseConn (&iFuseConn, &MyRodsEnv); RECONNECT_IF_NECESSARY(status, iFuseConn, rcRmColl (iFuseConn->conn, &collInp, 0)); if (status >= 0) { #ifdef CACHE_FUSE_PATH pathNotExist ((char *) path); #endif status = 0; } else { rodsLogError (LOG_ERROR, status, "irodsRmdir: rcRmColl of %s error", path); status = -ENOENT; } unuseIFuseConn (iFuseConn); clearKeyVal (&collInp.condInput); return (status); }
int readAggInfo (rsComm_t *rsComm, char *aggColl, keyValPair_t *condInput, ncAggInfo_t **ncAggInfo) { int status; dataObjInp_t dataObjInp; bytesBuf_t packedBBuf; portalOprOut_t *portalOprOut = NULL; bzero (&dataObjInp, sizeof (dataObjInp)); bzero (&packedBBuf, sizeof (packedBBuf)); if (condInput != NULL) replKeyVal (condInput, &dataObjInp.condInput); snprintf (dataObjInp.objPath, MAX_NAME_LEN, "%s/%s", aggColl, NC_AGG_INFO_FILE_NAME); dataObjInp.oprType = GET_OPR; status = rsDataObjGet (rsComm, &dataObjInp, &portalOprOut, &packedBBuf); clearKeyVal (&dataObjInp.condInput); if (portalOprOut != NULL) free (portalOprOut); if (status < 0) { if (status == CAT_NO_ROWS_FOUND) status = NETCDF_AGG_INFO_FILE_ERR; rodsLogError (LOG_ERROR, status, "readAggInfo: rsDataObjGet error for %s", dataObjInp.objPath); return status; } status = unpackStruct (packedBBuf.buf, (void **) ncAggInfo, "NcAggInfo_PI", RodsPackTable, XML_PROT); if (status < 0) { rodsLogError (LOG_ERROR, status, "readAggInfo: unpackStruct error for %s", dataObjInp.objPath); return NETCDF_AGG_INFO_FILE_ERR; } if (*ncAggInfo == NULL || (*ncAggInfo)->numFiles == 0) { rodsLog (LOG_ERROR, "readAggInfo: No ncAggInfo for %s", dataObjInp.objPath); return NETCDF_AGG_INFO_FILE_ERR; } return status; }
int tdsStageToCache (rsComm_t *rsComm, fileDriverType_t cacheFileType, int mode, int flags, char *urlPath, char *cacheFilename, rodsLong_t dataSize, keyValPair_t *condInput) { int status; int ncid = 0; ncInqInp_t ncInqInp; ncInqOut_t *ncInqOut = NULL; status = nc_open (urlPath, NC_NOWRITE, &ncid); if (status != NC_NOERR) { rodsLog (LOG_ERROR, "tdsStageToCache: nc_open %s error, status = %d, %s", urlPath, status, nc_strerror(status)); return (NETCDF_OPEN_ERR - status); } bzero (&ncInqInp, sizeof (ncInqInp)); ncInqInp.ncid = ncid; ncInqInp.paramType = NC_ALL_TYPE; ncInqInp.flags = NC_ALL_FLAG; status = _rsNcInq (rsComm, &ncInqInp, &ncInqOut); if (status < 0) { rodsLogError (LOG_ERROR, status, "tdsStageToCache: _rsNcInq error for %s", urlPath); return status; } status = dumpNcInqOutToNcFile (NULL, ncid, False, ncInqOut, cacheFilename); freeNcInqOut (&ncInqOut); if (status < 0) { rodsLogError (LOG_ERROR, status, "tdsStageToCache: dumpNcInqOutToNcFile error for %s", urlPath); } return status; }
int procApiRequest( rcComm_t *conn, int apiNumber, void *inputStruct, bytesBuf_t *inputBsBBuf, void **outStruct, bytesBuf_t *outBsBBuf ) { int status = 0; int apiInx = 0; if ( conn == NULL ) { return ( USER__NULL_INPUT_ERR ); } freeRError( conn->rError ); conn->rError = NULL; apiInx = apiTableLookup( apiNumber ); if ( apiInx < 0 ) { rodsLog( LOG_ERROR, "procApiRequest: apiTableLookup of apiNumber %d failed", apiNumber ); return ( apiInx ); } status = sendApiRequest( conn, apiInx, inputStruct, inputBsBBuf ); if ( status < 0 ) { rodsLogError( LOG_DEBUG, status, "procApiRequest: sendApiRequest failed. status = %d", status ); return ( status ); } conn->apiInx = apiInx; status = readAndProcApiReply( conn, apiInx, outStruct, outBsBBuf ); if ( status < 0 ) { rodsLogError( LOG_DEBUG, status, "procApiRequest: readAndProcApiReply failed. status = %d", status ); } return ( status ); }
int _svrSendCollOprStat( rsComm_t * rsComm, collOprStat_t * collOprStat ) { int myBuf; int status; status = sendAndProcApiReply( rsComm, rsComm->apiInx, SYS_SVR_TO_CLI_COLL_STAT, collOprStat, NULL ); if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "svrSendCollOprStat: sendAndProcApiReply failed. status = %d", status ); return status; } /* read 4 bytes */ status = myRead( rsComm->sock, &myBuf, sizeof( myBuf ), NULL, NULL ); if ( status < 0 ) { rodsLogError( LOG_ERROR, status, "svrSendCollOprStat: read handshake failed. status = %d", status ); } return ntohl( myBuf ); }