int allocAndSetL1descForZoneOpr( int remoteL1descInx, dataObjInp_t *dataObjInp, rodsServerHost_t *remoteZoneHost, openStat_t *openStat ) { int l1descInx; dataObjInfo_t *dataObjInfo; l1descInx = allocL1desc(); if ( l1descInx < 0 ) { return l1descInx; } L1desc[l1descInx].remoteL1descInx = remoteL1descInx; L1desc[l1descInx].oprType = REMOTE_ZONE_OPR; L1desc[l1descInx].remoteZoneHost = remoteZoneHost; /* always repl the .dataObjInp */ L1desc[l1descInx].dataObjInp = ( dataObjInp_t* )malloc( sizeof( dataObjInp_t ) ); replDataObjInp( dataObjInp, L1desc[l1descInx].dataObjInp ); L1desc[l1descInx].dataObjInpReplFlag = 1; dataObjInfo = L1desc[l1descInx].dataObjInfo = ( dataObjInfo_t* )malloc( sizeof( dataObjInfo_t ) ); bzero( dataObjInfo, sizeof( dataObjInfo_t ) ); rstrcpy( dataObjInfo->objPath, dataObjInp->objPath, MAX_NAME_LEN ); if ( openStat != NULL ) { dataObjInfo->dataSize = openStat->dataSize; rstrcpy( dataObjInfo->dataMode, openStat->dataMode, SHORT_STR_LEN ); rstrcpy( dataObjInfo->dataType, openStat->dataType, NAME_LEN ); L1desc[l1descInx].l3descInx = openStat->l3descInx; L1desc[l1descInx].replStatus = openStat->replStatus; } return l1descInx; }
int specCollSubCreate( rsComm_t *rsComm, dataObjInp_t *dataObjInp ) { int status; int l1descInx; dataObjInfo_t *dataObjInfo = NULL; status = resolvePathInSpecColl( rsComm, dataObjInp->objPath, WRITE_COLL_PERM, 0, &dataObjInfo ); if ( dataObjInfo == NULL ) { // JMC cppcheck rodsLog( LOG_ERROR, "specCollSubCreate :: dataObjInp is null" ); return status; } if ( status >= 0 ) { rodsLog( LOG_ERROR, "specCollSubCreate: phyPath %s already exist", dataObjInfo->filePath ); freeDataObjInfo( dataObjInfo ); return ( SYS_COPY_ALREADY_IN_RESC ); } else if ( status != SYS_SPEC_COLL_OBJ_NOT_EXIST ) { return ( status ); } l1descInx = allocL1desc(); if ( l1descInx < 0 ) { return l1descInx; } dataObjInfo->replStatus = NEWLY_CREATED_COPY; fillL1desc( l1descInx, dataObjInp, dataObjInfo, NEWLY_CREATED_COPY, dataObjInp->dataSize ); if ( getValByKey( &dataObjInp->condInput, NO_OPEN_FLAG_KW ) == NULL ) { status = dataCreate( rsComm, l1descInx ); if ( status < 0 ) { freeL1desc( l1descInx ); return ( status ); } } return l1descInx; }
int _rsDataObjCreateWithRescInfo( rsComm_t* rsComm, dataObjInp_t* dataObjInp, rescInfo_t* rescInfo, char* rescGroupName ) { dataObjInfo_t *dataObjInfo; int l1descInx; int status; l1descInx = allocL1desc(); if ( l1descInx < 0 ) { return l1descInx; } dataObjInfo = ( dataObjInfo_t* )malloc( sizeof( dataObjInfo_t ) ); initDataObjInfoWithInp( dataObjInfo, dataObjInp ); // =-=-=-=-=-=-=- // honor the purge flag if ( getValByKey( &dataObjInp->condInput, PURGE_CACHE_KW ) != NULL ) { // JMC - backport 4537 L1desc[l1descInx].purgeCacheFlag = 1; } dataObjInfo->rescInfo = new rescInfo_t; memcpy( dataObjInfo->rescInfo, rescInfo, sizeof( rescInfo_t ) ); rstrcpy( dataObjInfo->rescName, rescInfo->rescName, NAME_LEN ); rstrcpy( dataObjInfo->rescGroupName, rescGroupName, NAME_LEN ); char* resc_hier = getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW ); if ( resc_hier ) { rstrcpy( dataObjInfo->rescHier, resc_hier, MAX_NAME_LEN ); } else { rstrcpy( dataObjInfo->rescHier, rescInfo->rescName, MAX_NAME_LEN ); // in kw else } dataObjInfo->replStatus = NEWLY_CREATED_COPY; // JMC - backport 4754 fillL1desc( l1descInx, dataObjInp, dataObjInfo, NEWLY_CREATED_COPY, dataObjInp->dataSize ); status = getFilePathName( rsComm, dataObjInfo, L1desc[l1descInx].dataObjInp ); if ( status < 0 ) { freeL1desc( l1descInx ); return ( status ); } /* output of _rsDataObjCreate - filePath stored in * dataObjInfo struct */ if ( getValByKey( &dataObjInp->condInput, NO_OPEN_FLAG_KW ) != NULL ) { /* don't actually physically open the file */ status = 0; } else { status = dataObjCreateAndReg( rsComm, l1descInx ); } if ( status < 0 ) { freeL1desc( l1descInx ); return ( status ); } else { return ( l1descInx ); } }
int _rsDataObjOpenWithObjInfo( rsComm_t *rsComm, dataObjInp_t *dataObjInp, int phyOpenFlag, dataObjInfo_t *dataObjInfo ) { // JMC - backport 4537 int replStatus; int status; int l1descInx; l1descInx = allocL1desc(); if ( l1descInx < 0 ) { return l1descInx; } // kv pasthru copyKeyVal( &dataObjInp->condInput, &dataObjInfo->condInput ); replStatus = dataObjInfo->replStatus | OPEN_EXISTING_COPY; /* the size was set to -1 because we don't know the target size. * For copy and replicate, the calling routine should modify this * dataSize */ fillL1desc( l1descInx, dataObjInp, dataObjInfo, replStatus, -1 ); if ( getValByKey( &dataObjInp->condInput, PURGE_CACHE_KW ) != NULL ) { L1desc[l1descInx].purgeCacheFlag = 1; } if ( phyOpenFlag == DO_NOT_PHYOPEN ) { /* don't actually physically open the file */ status = 0; } else if ( phyOpenFlag == PHYOPEN_BY_SIZE ) { int single_buff_sz; try { single_buff_sz = irods::get_advanced_setting<const int>(irods::CFG_MAX_SIZE_FOR_SINGLE_BUFFER) * 1024 * 1024; } catch ( const irods::exception& e ) { irods::log(e); return e.code(); } /* open for put or get. May do "dataInclude" */ if ( getValByKey( &dataObjInp->condInput, DATA_INCLUDED_KW ) != NULL && dataObjInfo->dataSize <= single_buff_sz ) { status = 0; } else if ( dataObjInfo->dataSize != UNKNOWN_FILE_SZ && dataObjInfo->dataSize <= single_buff_sz ) { status = 0; } else { status = dataOpen( rsComm, l1descInx ); } } else { status = dataOpen( rsComm, l1descInx ); } if ( status < 0 ) { freeL1desc( l1descInx ); return status; } else { return l1descInx; } }
int rsNcOpenGroup( rsComm_t *rsComm, ncOpenInp_t *ncOpenGroupInp, int **ncid ) { int remoteFlag; rodsServerHost_t *rodsServerHost; int status; dataObjInfo_t *dataObjInfo = NULL; int rl1descInx, l1descInx, myncid; int rootNcid; if ( getValByKey( &ncOpenGroupInp->condInput, NATIVE_NETCDF_CALL_KW ) != NULL ) { /* just all 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_inq_grp_full_ncid( ncOpenGroupInp->rootNcid, ncOpenGroupInp->objPath, &myncid ); if ( status == NC_NOERR ) { *ncid = ( int * ) malloc( sizeof( int ) ); *( *ncid ) = myncid; return 0; } else { rodsLog( LOG_ERROR, "rsNcOpenGroup: nc_open %s error, status = %d, %s", ncOpenGroupInp->objPath, status, nc_strerror( status ) ); return ( NETCDF_OPEN_ERR + status ); } } rl1descInx = ncOpenGroupInp->rootNcid; l1desc_t& my_desc = irods::get_l1desc( rl1descInx ); if ( rl1descInx < 2 || rl1descInx >= NUM_L1_DESC ) { rodsLog( LOG_ERROR, "rsNcClose: rl1descInx %d out of range", rl1descInx ); return ( SYS_FILE_DESC_OUT_OF_RANGE ); } if ( my_desc.inuseFlag != FD_INUSE ) { return BAD_INPUT_DESC_INDEX; } if ( my_desc.remoteZoneHost != NULL ) { ncOpenInp_t myNcOpenGroupInp; bzero( &myNcOpenGroupInp, sizeof( myNcOpenGroupInp ) ); rstrcpy( myNcOpenGroupInp.objPath, ncOpenGroupInp->objPath, MAX_NAME_LEN ); myNcOpenGroupInp.rootNcid = my_desc.remoteL1descInx; status = rcNcOpenGroup( my_desc.remoteZoneHost->conn, &myNcOpenGroupInp, &myncid ); if ( status < 0 ) { rodsLog( LOG_ERROR, "rsNcOpenGroup: _rcNcOpenGroup %s error, status = %d", ncOpenGroupInp->objPath, status ); return ( status ); } l1descInx = allocAndSetL1descForZoneOpr( myncid, my_desc.dataObjInp, my_desc.remoteZoneHost, NULL ); } else { /* local zone */ rootNcid = my_desc.l3descInx; remoteFlag = resoAndConnHostByDataObjInfo( rsComm, my_desc.dataObjInfo, &rodsServerHost ); if ( remoteFlag < 0 ) { return ( remoteFlag ); } else if ( remoteFlag == LOCAL_HOST ) { status = nc_inq_grp_full_ncid( rootNcid, ncOpenGroupInp->objPath, &myncid ); if ( status != NC_NOERR ) { rodsLog( LOG_ERROR, "rsNcOpenGroup: nc_inq_grp_full_ncid %s err, stat = %d, %s", ncOpenGroupInp->objPath, status, nc_strerror( status ) ); return ( NETCDF_OPEN_ERR + status ); } } else { /* execute it remotely */ ncOpenInp_t myNcOpenGroupInp; bzero( &myNcOpenGroupInp, sizeof( myNcOpenGroupInp ) ); rstrcpy( myNcOpenGroupInp.objPath, ncOpenGroupInp->objPath, MAX_NAME_LEN ); myNcOpenGroupInp.rootNcid = rootNcid; addKeyVal( &myNcOpenGroupInp.condInput, NATIVE_NETCDF_CALL_KW, "" ); status = rcNcOpenGroup( rodsServerHost->conn, &myNcOpenGroupInp, &myncid ); clearKeyVal( &myNcOpenGroupInp.condInput ); if ( status < 0 ) { rodsLog( LOG_ERROR, "rsNcOpenGroup: rcNcOpenGroup %s error, status = %d", myNcOpenGroupInp.objPath, status ); return ( status ); } } l1descInx = allocL1desc(); l1desc_t& new_desc = irods::get_l1desc( l1descInx ); new_desc.dataObjInfo = dataObjInfo = ( dataObjInfo_t * ) calloc( 1, sizeof( dataObjInfo_t ) ); rstrcpy( dataObjInfo->objPath, ncOpenGroupInp->objPath, MAX_NAME_LEN ); new_desc.l3descInx = myncid; } my_desc.oprType = NC_OPEN_GROUP; *ncid = ( int * ) malloc( sizeof( int ) ); *( *ncid ) = l1descInx; return 0; }