00001
00002
00003
00004
00005
00006
00007
00008 #include "dataObjOpen.h"
00009 #include "dataObjOpenAndStat.h"
00010 #include "rodsLog.h"
00011 #include "objMetaOpr.h"
00012 #include "resource.h"
00013 #include "resource.h"
00014 #include "dataObjOpr.h"
00015 #include "physPath.h"
00016 #include "dataObjCreate.h"
00017 #include "dataObjLock.h"
00018
00019 #include "fileOpen.h"
00020 #include "subStructFileOpen.h"
00021 #include "rsGlobalExtern.h"
00022 #include "rcGlobalExtern.h"
00023 #include "reGlobalsExtern.h"
00024 #include "reDefines.h"
00025 #include "reDefines.h"
00026 #include "getRemoteZoneResc.h"
00027 #include "regReplica.h"
00028 #include "regDataObj.h"
00029 #include "dataObjClose.h"
00030 #include "dataObjRepl.h"
00031
00032
00033
00034 #include "eirods_resource_backport.h"
00035 #include "eirods_resource_redirect.h"
00036 #include "eirods_hierarchy_parser.h"
00037
00038 int
00039 rsDataObjOpen (rsComm_t *rsComm, dataObjInp_t *dataObjInp)
00040 {
00041 int status, l1descInx;
00042 int remoteFlag;
00043 rodsServerHost_t *rodsServerHost;
00044
00045 remoteFlag = getAndConnRemoteZone (rsComm, dataObjInp, &rodsServerHost,
00046 REMOTE_OPEN);
00047 if (remoteFlag < 0) {
00048 return (remoteFlag);
00049 } else if (remoteFlag == REMOTE_HOST) {
00050 openStat_t *openStat = NULL;
00051 status = rcDataObjOpenAndStat (rodsServerHost->conn, dataObjInp,
00052 &openStat);
00053 if (status < 0) return status;
00054 l1descInx = allocAndSetL1descForZoneOpr (status, dataObjInp,
00055 rodsServerHost, openStat);
00056 if (openStat != NULL) free (openStat);
00057 return (l1descInx);
00058 } else {
00059
00060
00061 if( getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW ) == NULL ) {
00062 std::string hier;
00063 eirods::error ret = eirods::resolve_resource_hierarchy( eirods::EIRODS_OPEN_OPERATION,
00064 rsComm, dataObjInp, hier );
00065 if( !ret.ok() ) {
00066 std::stringstream msg;
00067 msg << "rsDataObjOpen :: failed in eirods::resolve_resource_hierarchy for [";
00068 msg << dataObjInp->objPath << "]";
00069 eirods::log( PASSMSG( msg.str(), ret ) );
00070 return ret.code();
00071 }
00072
00073
00074
00075
00076 addKeyVal( &dataObjInp->condInput, RESC_HIER_STR_KW, hier.c_str() );
00077
00078 }
00079
00080 l1descInx = _rsDataObjOpen( rsComm, dataObjInp );
00081
00082 }
00083
00084 return (l1descInx);
00085 }
00086
00087
00088
00089
00090
00091 int
00092 _rsDataObjOpen (rsComm_t *rsComm, dataObjInp_t *dataObjInp)
00093 {
00094
00095 int status;
00096 dataObjInfo_t *dataObjInfoHead = NULL;
00097 dataObjInfo_t *otherDataObjInfo = NULL;
00098 dataObjInfo_t *nextDataObjInfo = NULL;
00099 dataObjInfo_t *tmpDataObjInfo;
00100 dataObjInfo_t *compDataObjInfo = NULL;
00101 dataObjInfo_t *cacheDataObjInfo = NULL;
00102 rescInfo_t *compRescInfo = NULL;
00103 int l1descInx;
00104 int writeFlag;
00105 int phyOpenFlag = DO_PHYOPEN;
00106 char *lockType = NULL;
00107 int lockFd = -1;
00108
00109 if (getValByKey (&dataObjInp->condInput, NO_OPEN_FLAG_KW) != NULL) {
00110 phyOpenFlag = DO_NOT_PHYOPEN;
00111 } else if (getValByKey (&dataObjInp->condInput, PHYOPEN_BY_SIZE_KW)
00112 != NULL) {
00113 phyOpenFlag = PHYOPEN_BY_SIZE;
00114 }
00115
00116
00117 lockType = getValByKey (&dataObjInp->condInput, LOCK_TYPE_KW);
00118 if (lockType != NULL) {
00119 lockFd = rsDataObjLock (rsComm, dataObjInp);
00120 if (lockFd > 0) {
00121
00122 rmKeyVal (&dataObjInp->condInput, LOCK_TYPE_KW);
00123 } else {
00124 rodsLogError (LOG_ERROR, lockFd,
00125 "_rsDataObjOpen: rsDataObjLock error for %s. lockType = %s",
00126 dataObjInp->objPath, lockType);
00127 return lockFd;
00128 }
00129 }
00130
00131
00132
00133 status = getDataObjInfoIncSpecColl (rsComm, dataObjInp, &dataObjInfoHead);
00134
00135 writeFlag = getWriteFlag (dataObjInp->openFlags);
00136
00137 if (status < 0) {
00138 if (dataObjInp->openFlags & O_CREAT && writeFlag > 0) {
00139 l1descInx = rsDataObjCreate (rsComm, dataObjInp);
00140 status = l1descInx;
00141 }
00142
00143
00144 if (lockFd >= 0) {
00145 if (status > 0) {
00146 L1desc[l1descInx].lockFd = lockFd;
00147 } else {
00148 rsDataObjUnlock (rsComm, dataObjInp, lockFd);
00149 }
00150 }
00151 return (status);
00152
00153 } else {
00154
00155 status = sortObjInfoForOpen (rsComm, &dataObjInfoHead, &dataObjInp->condInput, writeFlag);
00156 if (status < 0) {
00157 if (lockFd > 0)
00158 rsDataObjUnlock (rsComm, dataObjInp, lockFd);
00159 return status;
00160 }
00161
00162 status = applyPreprocRuleForOpen (rsComm, dataObjInp, &dataObjInfoHead);
00163 if (status < 0) {
00164 if (lockFd > 0)
00165 rsDataObjUnlock (rsComm, dataObjInp, lockFd);
00166 return status;
00167 }
00168 }
00169
00170 if (getStructFileType (dataObjInfoHead->specColl) >= 0) {
00171
00172 } else if (writeFlag > 0) {
00173
00174
00175 status = procDataObjOpenForWrite (rsComm, dataObjInp, &dataObjInfoHead, &cacheDataObjInfo, &compDataObjInfo, &compRescInfo);
00176 } else {
00177
00178
00179 }
00180
00181 if (status < 0) {
00182 if (lockFd > 0)
00183 rsDataObjUnlock (rsComm, dataObjInp, lockFd);
00184 freeAllDataObjInfo (dataObjInfoHead);
00185 return status;
00186 }
00187
00188
00189 std::string resc_class;
00190 eirods::error prop_err = eirods::get_resource_property<std::string>(
00191 dataObjInfoHead->rescInfo->rescName, "class", resc_class );
00192 if( prop_err.ok() ) {
00193 if( resc_class == "bundle" ) {
00194 status = stageBundledData (rsComm, &dataObjInfoHead);
00195 if (status < 0) {
00196 rodsLog (LOG_ERROR,
00197 "_rsDataObjOpen: stageBundledData of %s failed stat=%d",
00198 dataObjInfoHead->objPath, status);
00199 freeAllDataObjInfo (dataObjInfoHead);
00200 if (lockFd >= 0) rsDataObjUnlock (rsComm, dataObjInp, lockFd);
00201 return status;
00202 }
00203 }
00204 }
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217 tmpDataObjInfo = dataObjInfoHead;
00218
00219 while (tmpDataObjInfo != NULL) {
00220 nextDataObjInfo = tmpDataObjInfo->next;
00221 tmpDataObjInfo->next = NULL;
00222 #if 0 // JMC - legacy resource
00223 if (getRescClass (tmpDataObjInfo->rescInfo) == COMPOUND_CL) {
00224
00225 if (compDataObjInfo != tmpDataObjInfo) {
00226
00227 queDataObjInfo (&otherDataObjInfo, tmpDataObjInfo, 1, 1);
00228 }
00229 tmpDataObjInfo = nextDataObjInfo;
00230 continue;
00231 } else
00232 #endif // JMC - legacy resource
00233 if ( writeFlag > 0 && cacheDataObjInfo != NULL &&
00234 tmpDataObjInfo != cacheDataObjInfo) {
00235
00236 queDataObjInfo (&otherDataObjInfo, tmpDataObjInfo, 1, 1);
00237 tmpDataObjInfo = nextDataObjInfo;
00238 continue;
00239 }
00240
00241 status = l1descInx = _rsDataObjOpenWithObjInfo (rsComm, dataObjInp,phyOpenFlag, tmpDataObjInfo, cacheDataObjInfo);
00242
00243 if (status >= 0) {
00244 if (compDataObjInfo != NULL) {
00245 L1desc[l1descInx].replDataObjInfo = compDataObjInfo;
00246 } else if (compRescInfo != NULL) {
00247 L1desc[l1descInx].replRescInfo = compRescInfo;
00248 }
00249
00250 queDataObjInfo (&otherDataObjInfo, nextDataObjInfo, 0, 1);
00251 L1desc[l1descInx].otherDataObjInfo = otherDataObjInfo;
00252
00253 if (writeFlag > 0) {
00254 L1desc[l1descInx].openType = OPEN_FOR_WRITE_TYPE;
00255 } else {
00256 L1desc[l1descInx].openType = OPEN_FOR_READ_TYPE;
00257 }
00258
00259
00260 if (lockFd >= 0) {
00261 if (l1descInx >= 0) {
00262 L1desc[l1descInx].lockFd = lockFd;
00263 } else {
00264 rsDataObjUnlock (rsComm, dataObjInp, lockFd);
00265 }
00266 }
00267
00268 return (l1descInx);
00269
00270 }
00271
00272 tmpDataObjInfo = nextDataObjInfo;
00273 }
00274
00275 freeAllDataObjInfo (otherDataObjInfo);
00276
00277 return (status);
00278 }
00279
00280
00281
00282
00283
00284
00285
00286 int
00287 _rsDataObjOpenWithObjInfo (rsComm_t *rsComm, dataObjInp_t *dataObjInp,
00288 int phyOpenFlag, dataObjInfo_t *dataObjInfo, dataObjInfo_t *cacheDataObjInfo)
00289 {
00290 int replStatus;
00291 int status;
00292 int l1descInx;
00293 l1descInx = allocL1desc ();
00294
00295 if (l1descInx < 0) return l1descInx;
00296
00297 replStatus = dataObjInfo->replStatus | OPEN_EXISTING_COPY;
00298
00299
00300
00301
00302 fillL1desc (l1descInx, dataObjInp, dataObjInfo, replStatus, -1);
00303 if (dataObjInfo == cacheDataObjInfo &&
00304 getValByKey (&dataObjInp->condInput, PURGE_CACHE_KW) != NULL) {
00305 L1desc[l1descInx].purgeCacheFlag = 1;
00306 }
00307 if (phyOpenFlag == DO_NOT_PHYOPEN) {
00308
00309 status = 0;
00310 } else if (phyOpenFlag == PHYOPEN_BY_SIZE) {
00311
00312 if (getValByKey (&dataObjInp->condInput, DATA_INCLUDED_KW) != NULL
00313 && dataObjInfo->dataSize <= MAX_SZ_FOR_SINGLE_BUF) {
00314 status = 0;
00315 } else if (dataObjInfo->dataSize != UNKNOWN_FILE_SZ &&
00316 dataObjInfo->dataSize < MAX_SZ_FOR_SINGLE_BUF) {
00317 status = 0;
00318 } else {
00319 status = dataOpen (rsComm, l1descInx);
00320 }
00321 } else {
00322 status = dataOpen (rsComm, l1descInx);
00323 }
00324
00325 if (status < 0) {
00326 freeL1desc (l1descInx);
00327 return (status);
00328 } else {
00329 return (l1descInx);
00330 }
00331 }
00332
00333 int
00334 dataOpen (rsComm_t *rsComm, int l1descInx)
00335 {
00336 dataObjInfo_t *myDataObjInfo = L1desc[l1descInx].dataObjInfo;
00337 int status;
00338
00339
00340 status = l3Open (rsComm, l1descInx);
00341
00342 if (status <= 0) {
00343 rodsLog (LOG_NOTICE,
00344 "dataOpen: l3Open of %s failed, status = %d",
00345 myDataObjInfo->filePath, status);
00346 return (status);
00347 } else {
00348 L1desc[l1descInx].l3descInx = status;
00349 return (0);
00350 }
00351 }
00352
00353 int
00354 l3Open (rsComm_t *rsComm, int l1descInx)
00355 {
00356 dataObjInfo_t *dataObjInfo;
00357 int l3descInx;
00358 int mode, flags;
00359
00360 dataObjInfo = L1desc[l1descInx].dataObjInfo;
00361
00362 std::string location;
00363 eirods::error ret = eirods::get_loc_for_hier_string( dataObjInfo->rescHier, location );
00364 if( !ret.ok() ) {
00365 eirods::log( PASSMSG( "l3Open - failed in specColl open", ret ) );
00366 return -1;
00367 }
00368
00369 if (getStructFileType (dataObjInfo->specColl) >= 0) {
00370 subFile_t subFile;
00371 memset (&subFile, 0, sizeof (subFile));
00372 rstrcpy (subFile.subFilePath, dataObjInfo->subPath,MAX_NAME_LEN);
00373 rstrcpy (subFile.addr.hostAddr, location.c_str(), NAME_LEN );
00374 subFile.specColl = dataObjInfo->specColl;
00375 subFile.mode = getFileMode (L1desc[l1descInx].dataObjInp);
00376 subFile.flags = getFileFlags (l1descInx);
00377 l3descInx = rsSubStructFileOpen (rsComm, &subFile);
00378 } else {
00379 mode = getFileMode (L1desc[l1descInx].dataObjInp);
00380 flags = getFileFlags (l1descInx);
00381 l3descInx = _l3Open (rsComm, dataObjInfo, mode, flags);
00382 }
00383 return (l3descInx);
00384 }
00385
00386 int
00387 _l3Open (rsComm_t *rsComm, dataObjInfo_t *dataObjInfo, int mode, int flags)
00388 {
00389 int l3descInx;
00390 fileOpenInp_t fileOpenInp;
00391
00392 #if 0 // JMC legacy resource
00393 rescTypeInx = dataObjInfo->rescInfo->rescTypeInx;
00394
00395 switch (RescTypeDef[rescTypeInx].rescCat) {
00396 case FILE_CAT:
00397 #endif // JMC legacy resource
00398
00399
00400
00401 std::string location;
00402 eirods::error ret = eirods::get_loc_for_hier_string( dataObjInfo->rescHier, location );
00403 if( !ret.ok() ) {
00404 eirods::log( PASSMSG( "l3FilePutSingleBuf - failed in get_loc_for_hier_String", ret ) );
00405 return -1;
00406 }
00407
00408 memset (&fileOpenInp, 0, sizeof (fileOpenInp));
00409 rstrcpy( fileOpenInp.resc_name_, dataObjInfo->rescInfo->rescName, MAX_NAME_LEN );
00410 rstrcpy( fileOpenInp.resc_hier_, dataObjInfo->rescHier, MAX_NAME_LEN );
00411 rstrcpy( fileOpenInp.objPath, dataObjInfo->objPath, MAX_NAME_LEN );
00412 fileOpenInp.fileType = static_cast< fileDriverType_t >( -1 );
00413 rstrcpy (fileOpenInp.addr.hostAddr, location.c_str(), NAME_LEN);
00414 rstrcpy (fileOpenInp.fileName, dataObjInfo->filePath, MAX_NAME_LEN);
00415 fileOpenInp.mode = mode;
00416 fileOpenInp.flags = flags;
00417 fileOpenInp.in_pdmo = dataObjInfo->in_pdmo;
00418 l3descInx = rsFileOpen (rsComm, &fileOpenInp);
00419 #if 0 // JMC legacy resource
00420 break;
00421 default:
00422 rodsLog (LOG_NOTICE,
00423 "l3Open: rescCat type %d is not recognized",
00424 RescTypeDef[rescTypeInx].rescCat);
00425 l3descInx = SYS_INVALID_RESC_TYPE;
00426 break;
00427 }
00428 #endif // JMC legacy resource
00429 return (l3descInx);
00430 }
00431
00432
00433
00434
00435
00436 int
00437 l3OpenByHost (rsComm_t *rsComm, int rescTypeInx, int l3descInx, int flags)
00438 {
00439 fileOpenInp_t fileOpenInp;
00440 int newL3descInx;
00441
00442 #if 0 // JMC legacy resource
00443 switch (RescTypeDef[rescTypeInx].rescCat) {
00444 case FILE_CAT:
00445 #endif // JMC legacy resource
00446 memset (&fileOpenInp, 0, sizeof (fileOpenInp));
00447 fileOpenInp.fileType = static_cast< fileDriverType_t>( -1 );
00448 rstrcpy( fileOpenInp.resc_hier_, FileDesc[l3descInx].rescHier, MAX_NAME_LEN );
00449 rstrcpy (fileOpenInp.fileName, FileDesc[l3descInx].fileName, MAX_NAME_LEN);
00450 rstrcpy(fileOpenInp.objPath, FileDesc[l3descInx].objPath, MAX_NAME_LEN);
00451 fileOpenInp.mode = FileDesc[l3descInx].mode;
00452 fileOpenInp.flags = flags;
00453 newL3descInx = rsFileOpenByHost (rsComm, &fileOpenInp,
00454 FileDesc[l3descInx].rodsServerHost);
00455 #if 0 // JMC legacy resource
00456 break;
00457 default:
00458 rodsLog (LOG_NOTICE,
00459 "l3OpenByHost: rescCat type %d is not recognized",
00460 RescTypeDef[rescTypeInx].rescCat);
00461 l3descInx = SYS_INVALID_RESC_TYPE;
00462 break;
00463 }
00464 #endif // JMC legacy resource
00465 return (newL3descInx);
00466 }
00467
00468 int
00469 applyPreprocRuleForOpen (rsComm_t *rsComm, dataObjInp_t *dataObjInp,
00470 dataObjInfo_t **dataObjInfoHead)
00471 {
00472 int status;
00473 ruleExecInfo_t rei;
00474
00475 initReiWithDataObjInp (&rei, rsComm, dataObjInp);
00476 rei.doi = *dataObjInfoHead;
00477
00478 status = applyRule ("acPreprocForDataObjOpen", NULL, &rei, NO_SAVE_REI);
00479
00480 if (status < 0) {
00481 if (rei.status < 0) {
00482 status = rei.status;
00483 }
00484 rodsLog (LOG_ERROR,
00485 "applyPreprocRuleForOpen:acPreprocForDataObjOpen error for %s,stat=%d",
00486 dataObjInp->objPath, status);
00487 } else {
00488 *dataObjInfoHead = rei.doi;
00489 }
00490 return (status);
00491 }
00492
00493
00494
00495
00496 int
00497 createEmptyRepl (rsComm_t *rsComm, dataObjInp_t *dataObjInp,
00498 dataObjInfo_t **dataObjInfoHead)
00499 {
00500 int status;
00501 char *rescName;
00502 rescInfo_t *rescInfo;
00503 rescGrpInfo_t *tmpRescGrpInfo;
00504 regReplica_t regReplicaInp;
00505 rescGrpInfo_t *myRescGrpInfo = NULL;
00506 keyValPair_t *condInput = &dataObjInp->condInput;
00507 dataObjInfo_t *myDataObjInfo;
00508
00509 if ((rescName = getValByKey (condInput, DEST_RESC_NAME_KW)) == NULL &&
00510 (rescName = getValByKey (condInput, BACKUP_RESC_NAME_KW)) == NULL &&
00511 (rescName = getValByKey (condInput, DEF_RESC_NAME_KW)) == NULL) {
00512 return USER_NO_RESC_INPUT_ERR;
00513 }
00514
00515 status = getRescGrpForCreate (rsComm, dataObjInp, &myRescGrpInfo);
00516 if (status < 0 || myRescGrpInfo == NULL ) return status;
00517
00518 myDataObjInfo = (dataObjInfo_t*)malloc (sizeof (dataObjInfo_t));
00519 *myDataObjInfo = *(*dataObjInfoHead);
00520 tmpRescGrpInfo = myRescGrpInfo;
00521 while (tmpRescGrpInfo != NULL) {
00522 rescInfo = tmpRescGrpInfo->rescInfo;
00523 myDataObjInfo->rescInfo = rescInfo;
00524 rstrcpy (myDataObjInfo->rescName, rescInfo->rescName, NAME_LEN);
00525 rstrcpy (myDataObjInfo->rescGroupName, myRescGrpInfo->rescGroupName, NAME_LEN);
00526
00527 char* resc_hier = getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW );
00528 if( resc_hier ) {
00529 rstrcpy (myDataObjInfo->rescHier, resc_hier, MAX_NAME_LEN);
00530 } else {
00531 rodsLog( LOG_NOTICE, "createEmptyRepl :: using rescInfo->rescName for hier" );
00532 rstrcpy (myDataObjInfo->rescHier, rescInfo->rescName, MAX_NAME_LEN);
00533
00534 }
00535
00536
00537 status = getFilePathName (rsComm, myDataObjInfo, dataObjInp);
00538 if (status < 0) {
00539 tmpRescGrpInfo = tmpRescGrpInfo->next;
00540 continue;
00541 }
00542 status = l3CreateByObjInfo (rsComm, dataObjInp, myDataObjInfo);
00543 if (status < 0) {
00544 tmpRescGrpInfo = tmpRescGrpInfo->next;
00545 continue;
00546 }
00547
00548 _l3Close (rsComm, rescInfo->rescTypeInx, status);
00549
00550
00551 memset (®ReplicaInp, 0, sizeof (regReplicaInp));
00552 regReplicaInp.srcDataObjInfo = *dataObjInfoHead;
00553 regReplicaInp.destDataObjInfo = myDataObjInfo;
00554 if (getValByKey (&dataObjInp->condInput, IRODS_ADMIN_KW) != NULL) {
00555 addKeyVal (®ReplicaInp.condInput, IRODS_ADMIN_KW, "");
00556 }
00557 status = rsRegReplica (rsComm, ®ReplicaInp);
00558 clearKeyVal (®ReplicaInp.condInput);
00559
00560 break;
00561 }
00562
00563 freeAllRescGrpInfo (myRescGrpInfo);
00564
00565 if (status < 0) {
00566 free (myDataObjInfo);
00567 } else {
00568
00569 myDataObjInfo->next = *dataObjInfoHead;
00570 *dataObjInfoHead = myDataObjInfo;
00571 }
00572 return status;
00573 }
00574
00575
00576
00577 int
00578 procDataObjOpenForWrite (rsComm_t *rsComm, dataObjInp_t *dataObjInp,
00579 dataObjInfo_t **dataObjInfoHead, dataObjInfo_t **cacheDataObjInfo,
00580 dataObjInfo_t **compDataObjInfo, rescInfo_t **compRescInfo)
00581 {
00582 int status = 0;
00583 rescGrpInfo_t *myRescGrpInfo = NULL;
00584
00585
00586 status = requeDataObjInfoByDestResc ( dataObjInfoHead, &dataObjInp->condInput, 1, 1 );
00587
00588
00589 if (status < 0 && (*dataObjInfoHead)->specColl == NULL &&
00590 getValByKey (&dataObjInp->condInput, DEST_RESC_NAME_KW) != NULL) {
00591
00592 status = getRescGrpForCreate (rsComm, dataObjInp, &myRescGrpInfo);
00593 if (status < 0) return status;
00594 #if 0 // JMC - legacy resource
00595 if (getRescClass (myRescGrpInfo->rescInfo) == COMPOUND_CL) {
00596
00597
00598 status = getCacheDataInfoOfCompResc (rsComm, dataObjInp,
00599 *dataObjInfoHead, NULL, myRescGrpInfo, NULL,
00600 cacheDataObjInfo);
00601 if (status < 0) {
00602 rodsLogError (LOG_ERROR, status,
00603 "procDataObjForOpenWrite: getCacheDataInfo of %s failed",
00604 (*dataObjInfoHead)->objPath);
00605 freeAllRescGrpInfo (myRescGrpInfo);
00606 return status;
00607 } else {
00608
00609 *compRescInfo = myRescGrpInfo->rescInfo;
00610 }
00611 } else
00612 #endif // JMC - legacy resource
00613 {
00614
00615 status = createEmptyRepl (rsComm, dataObjInp, dataObjInfoHead);
00616 if (status < 0) {
00617 rodsLogError (LOG_ERROR, status,
00618 "procDataObjForOpenWrite: createEmptyRepl of %s failed",
00619 (*dataObjInfoHead)->objPath);
00620 freeAllRescGrpInfo (myRescGrpInfo);
00621 return status;
00622 }
00623 }
00624 } else {
00625
00626 status = 0;
00627 }
00628
00629 if (*compDataObjInfo != NULL) {
00630 dequeDataObjInfo (dataObjInfoHead, *compDataObjInfo);
00631 }
00632 freeAllRescGrpInfo (myRescGrpInfo);
00633 return status;
00634 }
00635
00636 #if 0 // JMC - legacy resource
00637
00638
00639
00640
00641
00642 int
00643 procDataObjOpenForExistObj (rsComm_t *rsComm, dataObjInp_t *dataObjInp,
00644 dataObjInfo_t **dataObjInfoHead, dataObjInfo_t **cacheDataObjInfo,
00645 dataObjInfo_t **compDataObjInfo, rescInfo_t **compRescInfo)
00646 {
00647 int status = 0;
00648 rescGrpInfo_t *myRescGrpInfo = NULL;
00649
00650 #if 0 // JMC - legacy resource
00651 if (getRescClass ((*dataObjInfoHead)->rescInfo) == COMPOUND_CL) {
00652
00653
00654 *compDataObjInfo = *dataObjInfoHead;
00655 status = stageAndRequeDataToCache (rsComm, dataObjInfoHead);
00656 if (status < 0 && status != SYS_COPY_ALREADY_IN_RESC) {
00657 rodsLogError (LOG_ERROR, status,
00658 "procDataObjOpenForExistObj:stageAndRequeDataToCache of %s failed",
00659 (*dataObjInfoHead)->objPath);
00660 return status;
00661 }
00662 *cacheDataObjInfo = *dataObjInfoHead;
00663 } else
00664 #endif // JMC - legacy resource
00665 if (getValByKey (&dataObjInp->condInput, PURGE_CACHE_KW) != NULL &&strlen ((*dataObjInfoHead)->rescGroupName) > 0) {
00666
00667
00668
00669 if( getRescInGrpByClass(rsComm, (*dataObjInfoHead)->rescGroupName, COMPOUND_CL, compRescInfo, &myRescGrpInfo) >= 0 ) {
00670
00671 status = getCacheDataInfoOfCompResc (rsComm, dataObjInp,*dataObjInfoHead, NULL, myRescGrpInfo, NULL,cacheDataObjInfo);
00672 if (status < 0) {
00673 rodsLogError (LOG_NOTICE, status,
00674 "procDataObjOpenForExistObj: getCacheDataInfo of %s failed",
00675 (*dataObjInfoHead)->objPath);
00676 } else {
00677 if (getDataObjByClass (*dataObjInfoHead, COMPOUND_CL,
00678 compDataObjInfo) >= 0) {
00679
00680 *compRescInfo = NULL;
00681 }
00682 }
00683 }
00684 }
00685 freeAllRescGrpInfo (myRescGrpInfo);
00686 return status;
00687 }
00688
00689 int
00690 procDataObjOpenForRead (rsComm_t *rsComm, dataObjInp_t *dataObjInp,
00691 dataObjInfo_t **dataObjInfoHead, dataObjInfo_t **cacheDataObjInfo,
00692 dataObjInfo_t **compDataObjInfo, rescInfo_t **compRescInfo)
00693 {
00694 int status = 0;
00695
00696 status = procDataObjOpenForExistObj (rsComm, dataObjInp, dataObjInfoHead,
00697 cacheDataObjInfo, compDataObjInfo, compRescInfo);
00698
00699 if (*compDataObjInfo != NULL) {
00700 dequeDataObjInfo (dataObjInfoHead, *compDataObjInfo);
00701 freeDataObjInfo (*compDataObjInfo);
00702 *compDataObjInfo = NULL;
00703 }
00704 *compRescInfo = NULL;
00705 return status;
00706 }
00707 #endif // JMC - legacy resource
00708