00001
00002
00003
00004
00005
00006
00007
00008 #include "phyPathReg.h"
00009 #include "rodsLog.h"
00010 #include "icatDefines.h"
00011 #include "objMetaOpr.h"
00012 #include "dataObjOpr.h"
00013 #include "collection.h"
00014 #include "specColl.h"
00015 #include "resource.h"
00016 #include "physPath.h"
00017 #include "rsGlobalExtern.h"
00018 #include "rcGlobalExtern.h"
00019 #include "reGlobalsExtern.h"
00020 #include "miscServerFunct.h"
00021 #include "apiHeaderAll.h"
00022
00023
00024
00025 #include "eirods_resource_backport.h"
00026 #include "eirods_resource_redirect.h"
00027 #include "eirods_hierarchy_parser.h"
00028
00029
00030
00031 #include <iostream>
00032
00033
00034
00035
00036 static pathnamePatterns_t *ExcludePatterns = NULL;
00037
00038
00039 pathnamePatterns_t *
00040 readPathnamePatternsFromFile(rsComm_t *rsComm, char *filename, char* );
00041
00042
00043
00044
00045
00046 int
00047 phyPathRegNoChkPerm (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp)
00048 {
00049 int status;
00050
00051 addKeyVal (&phyPathRegInp->condInput, NO_CHK_FILE_PERM_KW, "");
00052
00053 status = irsPhyPathReg (rsComm, phyPathRegInp);
00054 return (status);
00055 }
00056
00057 int
00058 rsPhyPathReg (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp)
00059 {
00060 int status;
00061
00062 if (getValByKey (&phyPathRegInp->condInput, NO_CHK_FILE_PERM_KW) != NULL &&
00063 rsComm->proxyUser.authInfo.authFlag < LOCAL_PRIV_USER_AUTH) {
00064 return SYS_NO_API_PRIV;
00065 }
00066
00067 status = irsPhyPathReg (rsComm, phyPathRegInp);
00068 return (status);
00069 }
00070
00071 int
00072 irsPhyPathReg (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp)
00073 {
00074 int status;
00075 rescGrpInfo_t *rescGrpInfo = NULL;
00076 rodsServerHost_t *rodsServerHost = NULL;
00077 int remoteFlag;
00078
00079 rodsHostAddr_t addr;
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 char* coll_type = getValByKey( &phyPathRegInp->condInput, COLLECTION_TYPE_KW );
00091
00092 if( coll_type && strcmp( coll_type, UNMOUNT_STR ) == 0) {
00093 status = unmountFileDir (rsComm, phyPathRegInp);
00094 return (status);
00095
00096 } else if ( coll_type != NULL && strcmp ( coll_type, LINK_POINT_STR) == 0) {
00097 status = linkCollReg (rsComm, phyPathRegInp);
00098 return (status);
00099
00100 }
00101
00102
00103
00104
00105
00106 int local = LOCAL_HOST;
00107 rodsServerHost_t* host = 0;
00108 std::string hier;
00109 char* tmp_hier = getValByKey( &phyPathRegInp->condInput, RESC_HIER_STR_KW );
00110 if( NULL == tmp_hier ) {
00111 eirods::error ret = eirods::resource_redirect( eirods::EIRODS_CREATE_OPERATION, rsComm,
00112 phyPathRegInp, hier, host, local );
00113 if( !ret.ok() ) {
00114 std::stringstream msg;
00115 msg << "failed in eirods::resource_redirect for [";
00116 msg << phyPathRegInp->objPath << "]";
00117 eirods::log( PASSMSG( msg.str(), ret ) );
00118 return ret.code();
00119 }
00120
00121
00122
00123 addKeyVal( &phyPathRegInp->condInput, RESC_HIER_STR_KW, hier.c_str() );
00124
00125 } else {
00126 hier = tmp_hier;
00127 }
00128
00129
00130
00131 if( coll_type && (strcmp( coll_type, HAAW_STRUCT_FILE_STR) == 0 ||
00132 strcmp ( coll_type, TAR_STRUCT_FILE_STR) == 0)) {
00133 status = structFileReg (rsComm, phyPathRegInp);
00134 return (status);
00135 }
00136
00137
00138
00139
00140 eirods::hierarchy_parser parser;
00141 parser.set_string( hier );
00142 std::string resc_name;
00143 parser.first_resc( resc_name );
00144
00145 rescGrpInfo = new rescGrpInfo_t;
00146 rescGrpInfo->rescInfo = new rescInfo_t;
00147 eirods::error err = eirods::get_resc_grp_info( resc_name, *rescGrpInfo );
00148 if( !err.ok() ) {
00149 eirods::log( PASS( err ) );
00150 delete rescGrpInfo->rescInfo;
00151 delete rescGrpInfo;
00152 return -1;
00153 }
00154
00155 std::string last_resc;
00156 parser.last_resc( last_resc );
00157
00158 std::string location;
00159 eirods::error ret = eirods::get_resource_property< std::string >(
00160 last_resc,
00161 eirods::RESOURCE_LOCATION,
00162 location );
00163 if( !ret.ok() ) {
00164 eirods::log( PASSMSG( "failed in get_resource_property", ret ) );
00165 delete rescGrpInfo->rescInfo;
00166 delete rescGrpInfo;
00167 return -1;
00168 }
00169
00170 memset (&addr, 0, sizeof (addr));
00171 rstrcpy (addr.hostAddr, location.c_str(), LONG_NAME_LEN);
00172 remoteFlag = resolveHost (&addr, &rodsServerHost);
00173
00174 if (remoteFlag == LOCAL_HOST) {
00175 status = _rsPhyPathReg (rsComm, phyPathRegInp, rescGrpInfo, rodsServerHost );
00176
00177 } else if (remoteFlag == REMOTE_HOST) {
00178 status = remotePhyPathReg (rsComm, phyPathRegInp, rodsServerHost);
00179
00180 } else {
00181 if (remoteFlag < 0) {
00182 delete rescGrpInfo->rescInfo;
00183 delete rescGrpInfo;
00184 return (remoteFlag);
00185 } else {
00186 rodsLog (LOG_ERROR,
00187 "rsPhyPathReg: resolveHost returned unrecognized value %d",
00188 remoteFlag);
00189 delete rescGrpInfo->rescInfo;
00190 delete rescGrpInfo;
00191 return (SYS_UNRECOGNIZED_REMOTE_FLAG);
00192 }
00193 }
00194
00195 delete rescGrpInfo->rescInfo;
00196 delete rescGrpInfo;
00197 return (status);
00198 }
00199
00200 int
00201 remotePhyPathReg (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp,
00202 rodsServerHost_t *rodsServerHost)
00203 {
00204 int status;
00205
00206 if (rodsServerHost == NULL) {
00207 rodsLog (LOG_ERROR,
00208 "remotePhyPathReg: Invalid rodsServerHost");
00209 return SYS_INVALID_SERVER_HOST;
00210 }
00211
00212 if ((status = svrToSvrConnect (rsComm, rodsServerHost)) < 0) {
00213 return status;
00214 }
00215
00216 status = rcPhyPathReg (rodsServerHost->conn, phyPathRegInp);
00217
00218 if (status < 0) {
00219 rodsLog (LOG_ERROR,
00220 "remotePhyPathReg: rcPhyPathReg failed for %s",
00221 phyPathRegInp->objPath);
00222 }
00223
00224 return (status);
00225 }
00226
00227 int
00228 _rsPhyPathReg (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp,
00229 rescGrpInfo_t *rescGrpInfo, rodsServerHost_t *rodsServerHost)
00230 {
00231 int status = 0;
00232 fileOpenInp_t chkNVPathPermInp;
00233 char *tmpFilePath = 0;
00234 char filePath[MAX_NAME_LEN];
00235 dataObjInfo_t dataObjInfo;
00236 char *tmpStr = NULL;
00237 int chkType = 0;
00238 char *excludePatternFile = 0;
00239
00240 if ((tmpFilePath = getValByKey (&phyPathRegInp->condInput, FILE_PATH_KW))== NULL) {
00241 rodsLog( LOG_ERROR,"_rsPhyPathReg: No filePath input for %s",
00242 phyPathRegInp->objPath );
00243 return (SYS_INVALID_FILE_PATH);
00244 } else {
00245
00246 rstrcpy (filePath, tmpFilePath, MAX_NAME_LEN);
00247 }
00248
00249
00250 memset (&dataObjInfo, 0, sizeof (dataObjInfo));
00251 rstrcpy (dataObjInfo.objPath, phyPathRegInp->objPath, MAX_NAME_LEN);
00252 rstrcpy (dataObjInfo.filePath, filePath, MAX_NAME_LEN);
00253 dataObjInfo.rescInfo = new rescInfo_t;
00254 memcpy( dataObjInfo.rescInfo, rescGrpInfo->rescInfo, sizeof( rescInfo_t ) );
00255 rstrcpy (dataObjInfo.rescName, rescGrpInfo->rescInfo->rescName, NAME_LEN);
00256
00257 char* resc_hier = getValByKey( &phyPathRegInp->condInput, RESC_HIER_STR_KW );
00258 if( resc_hier ) {
00259 rstrcpy (dataObjInfo.rescHier, resc_hier, MAX_NAME_LEN);
00260 } else {
00261 rodsLog( LOG_NOTICE, "_rsPhyPathReg :: RESC_HIER_STR_KW is NULL" );
00262 return -1;
00263 }
00264
00265 if( getValByKey (&phyPathRegInp->condInput, NO_CHK_FILE_PERM_KW) == NULL &&
00266 (chkType = getchkPathPerm (rsComm, phyPathRegInp, &dataObjInfo)) != NO_CHK_PATH_PERM) {
00267
00268 memset (&chkNVPathPermInp, 0, sizeof (chkNVPathPermInp));
00269
00270 rstrcpy (chkNVPathPermInp.fileName, filePath, MAX_NAME_LEN);
00271 chkNVPathPermInp.fileType = static_cast< fileDriverType_t>( -1 );
00272
00273
00274
00275 std::string location;
00276 eirods::error ret = eirods::get_loc_for_hier_string( resc_hier, location );
00277 if( !ret.ok() ) {
00278 eirods::log( PASSMSG( "failed in get_loc_for_hier_String", ret ) );
00279 return -1;
00280 }
00281
00282 rstrcpy (chkNVPathPermInp.addr.hostAddr, location.c_str(), NAME_LEN );
00283 status = chkFilePathPerm (rsComm, &chkNVPathPermInp, rodsServerHost,chkType);
00284
00285 if (status < 0) {
00286 rodsLog (LOG_ERROR,
00287 "_rsPhyPathReg: chkFilePathPerm error for %s",
00288 phyPathRegInp->objPath);
00289 return (SYS_NO_PATH_PERMISSION);
00290 }
00291 } else {
00292 status = 0;
00293 }
00294
00295 if (getValByKey (&phyPathRegInp->condInput, COLLECTION_KW) != NULL) {
00296 excludePatternFile = getValByKey(&phyPathRegInp->condInput, EXCLUDE_FILE_KW);
00297 if (excludePatternFile != NULL) {
00298 ExcludePatterns = readPathnamePatternsFromFile(rsComm,
00299 excludePatternFile,
00300 resc_hier);
00301 }
00302
00303 status = dirPathReg (rsComm, phyPathRegInp, filePath, rescGrpInfo->rescInfo);
00304 if (excludePatternFile != NULL) {
00305 freePathnamePatterns(ExcludePatterns);
00306 ExcludePatterns = NULL;
00307 }
00308
00309 } else if ((tmpStr = getValByKey (&phyPathRegInp->condInput, COLLECTION_TYPE_KW)) != NULL && strcmp (tmpStr, MOUNT_POINT_STR) == 0) {
00310
00311 status = mountFileDir (rsComm, phyPathRegInp, filePath, rescGrpInfo->rescInfo);
00312
00313 } else {
00314 if (getValByKey (&phyPathRegInp->condInput, REG_REPL_KW) != NULL) {
00315 status = filePathRegRepl (rsComm, phyPathRegInp, filePath, rescGrpInfo->rescInfo);
00316
00317 } else {
00318 status = filePathReg (rsComm, phyPathRegInp, filePath,rescGrpInfo->rescInfo);
00319 }
00320 }
00321
00322 return (status);
00323 }
00324
00325 int
00326 filePathRegRepl (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp, char *filePath,
00327 rescInfo_t *rescInfo)
00328 {
00329 dataObjInfo_t destDataObjInfo, *dataObjInfoHead = NULL;
00330 regReplica_t regReplicaInp;
00331 char *rescGroupName = NULL;
00332 int status;
00333
00334 status = getDataObjInfo (rsComm, phyPathRegInp, &dataObjInfoHead,
00335 ACCESS_READ_OBJECT, 0);
00336
00337 if (status < 0) {
00338 rodsLog (LOG_ERROR,
00339 "filePathRegRepl: getDataObjInfo for %s", phyPathRegInp->objPath);
00340 return (status);
00341 }
00342 status = sortObjInfoForOpen (rsComm, &dataObjInfoHead, NULL, 0);
00343 if (status < 0 || NULL == dataObjInfoHead ) return status;
00344
00345 destDataObjInfo = *dataObjInfoHead;
00346 rstrcpy (destDataObjInfo.filePath, filePath, MAX_NAME_LEN);
00347 destDataObjInfo.rescInfo = new rescInfo_t;
00348 memcpy( destDataObjInfo.rescInfo, rescInfo, sizeof( rescInfo_t ) );
00349 rstrcpy (destDataObjInfo.rescName, rescInfo->rescName, NAME_LEN);
00350 if ((rescGroupName = getValByKey (&phyPathRegInp->condInput,
00351 RESC_GROUP_NAME_KW)) != NULL) {
00352 rstrcpy (destDataObjInfo.rescGroupName, rescGroupName, NAME_LEN);
00353 }
00354 memset (®ReplicaInp, 0, sizeof (regReplicaInp));
00355 regReplicaInp.srcDataObjInfo = dataObjInfoHead;
00356 regReplicaInp.destDataObjInfo = &destDataObjInfo;
00357 if (getValByKey (&phyPathRegInp->condInput, SU_CLIENT_USER_KW) != NULL) {
00358 addKeyVal (®ReplicaInp.condInput, SU_CLIENT_USER_KW, "");
00359 addKeyVal (®ReplicaInp.condInput, IRODS_ADMIN_KW, "");
00360 } else if (getValByKey (&phyPathRegInp->condInput,
00361 IRODS_ADMIN_KW) != NULL) {
00362 addKeyVal (®ReplicaInp.condInput, IRODS_ADMIN_KW, "");
00363 }
00364 status = rsRegReplica (rsComm, ®ReplicaInp);
00365 clearKeyVal (®ReplicaInp.condInput);
00366 freeAllDataObjInfo (dataObjInfoHead);
00367
00368 return status;
00369 }
00370
00371 int
00372 filePathReg (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp, char *filePath,
00373 rescInfo_t *rescInfo)
00374 {
00375 dataObjInfo_t dataObjInfo;
00376 int status;
00377 char *rescGroupName = NULL;
00378 char *chksum;
00379
00380 initDataObjInfoWithInp (&dataObjInfo, phyPathRegInp);
00381 if ((rescGroupName = getValByKey (&phyPathRegInp->condInput,
00382 RESC_GROUP_NAME_KW)) != NULL) {
00383 rstrcpy (dataObjInfo.rescGroupName, rescGroupName, NAME_LEN);
00384 }
00385 dataObjInfo.replStatus = NEWLY_CREATED_COPY;
00386 dataObjInfo.rescInfo = new rescInfo_t;
00387 memcpy( dataObjInfo.rescInfo, rescInfo, sizeof( rescInfo_t ) );
00388 rstrcpy (dataObjInfo.rescName, rescInfo->rescName, NAME_LEN);
00389
00390 char* resc_hier = getValByKey( &phyPathRegInp->condInput, RESC_HIER_STR_KW );
00391 if( !resc_hier ) {
00392 rodsLog( LOG_NOTICE, "filePathReg - RESC_HIER_STR_KW is NULL" );
00393 return -1;
00394 }
00395
00396 rstrcpy (dataObjInfo.rescHier, resc_hier, MAX_NAME_LEN);
00397
00398 if (dataObjInfo.dataSize <= 0 &&
00399 (dataObjInfo.dataSize = getSizeInVault (rsComm, &dataObjInfo)) < 0 &&
00400 dataObjInfo.dataSize != UNKNOWN_FILE_SZ) {
00401 status = (int) dataObjInfo.dataSize;
00402 rodsLog (LOG_ERROR,
00403 "filePathReg: getSizeInVault for %s failed, status = %d",
00404 dataObjInfo.objPath, status);
00405 return (status);
00406 }
00407
00408 if ((chksum = getValByKey (&phyPathRegInp->condInput,
00409 REG_CHKSUM_KW)) != NULL) {
00410 rstrcpy (dataObjInfo.chksum, chksum, NAME_LEN);
00411 }
00412 else if ((chksum = getValByKey (&phyPathRegInp->condInput,
00413 VERIFY_CHKSUM_KW)) != NULL) {
00414 status = _dataObjChksum (rsComm, &dataObjInfo, &chksum);
00415 if (status < 0) {
00416 rodsLog (LOG_ERROR,
00417 "rodsPathReg: _dataObjChksum for %s failed, status = %d",
00418 dataObjInfo.objPath, status);
00419 return (status);
00420 }
00421 rstrcpy (dataObjInfo.chksum, chksum, NAME_LEN);
00422 }
00423
00424 status = svrRegDataObj (rsComm, &dataObjInfo);
00425 if (status < 0) {
00426 rodsLog (LOG_ERROR,
00427 "filePathReg: rsRegDataObj for %s failed, status = %d",
00428 dataObjInfo.objPath, status);
00429 } else {
00430 ruleExecInfo_t rei;
00431 initReiWithDataObjInp (&rei, rsComm, phyPathRegInp);
00432 rei.doi = &dataObjInfo;
00433 rei.status = status;
00434 rei.status = applyRule ("acPostProcForFilePathReg", NULL, &rei,
00435 NO_SAVE_REI);
00436 }
00437
00438 return (status);
00439 }
00440
00441 int
00442 dirPathReg (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp, char *filePath,
00443 rescInfo_t *rescInfo )
00444 {
00445 collInp_t collCreateInp;
00446 fileOpendirInp_t fileOpendirInp;
00447 fileClosedirInp_t fileClosedirInp;
00448 int status;
00449 int dirFd;
00450 dataObjInp_t subPhyPathRegInp;
00451 fileReaddirInp_t fileReaddirInp;
00452 rodsDirent_t *rodsDirent = NULL;
00453 rodsObjStat_t *rodsObjStatOut = NULL;
00454 int forceFlag;
00455
00456 char* resc_hier = getValByKey( &phyPathRegInp->condInput, RESC_HIER_STR_KW );
00457 if( !resc_hier ) {
00458 rodsLog( LOG_NOTICE, "dirPathReg - RESC_HIER_STR_KW is NULL" );
00459 return -1;
00460 }
00461
00462
00463
00464 std::string location;
00465 eirods::error ret = eirods::get_loc_for_hier_string( resc_hier, location );
00466 if( !ret.ok() ) {
00467 eirods::log( PASSMSG( "failed in get_loc_for_hier_String", ret ) );
00468 return -1;
00469 }
00470
00471 status = collStat (rsComm, phyPathRegInp, &rodsObjStatOut);
00472 if (status < 0 || NULL == rodsObjStatOut ) {
00473 memset (&collCreateInp, 0, sizeof (collCreateInp));
00474 rstrcpy (collCreateInp.collName, phyPathRegInp->objPath,
00475 MAX_NAME_LEN);
00476
00477
00478 addKeyVal (&collCreateInp.condInput, TRANSLATED_PATH_KW, "");
00479
00480
00481 status = rsCollCreate (rsComm, &collCreateInp);
00482 clearKeyVal (&collCreateInp.condInput);
00483 if (status < 0 ) return status;
00484 } else if (rodsObjStatOut->specColl != NULL) {
00485 freeRodsObjStat (rodsObjStatOut);
00486 rodsLog (LOG_ERROR,
00487 "mountFileDir: %s already mounted", phyPathRegInp->objPath);
00488 return (SYS_MOUNT_MOUNTED_COLL_ERR);
00489 }
00490 freeRodsObjStat (rodsObjStatOut);
00491
00492 memset (&fileOpendirInp, 0, sizeof (fileOpendirInp));
00493
00494 rstrcpy (fileOpendirInp.dirName, filePath, MAX_NAME_LEN);
00495 fileOpendirInp.fileType = static_cast< fileDriverType_t >( -1 );
00496 rstrcpy (fileOpendirInp.addr.hostAddr, location.c_str(), NAME_LEN);
00497 rstrcpy (fileOpendirInp.objPath, phyPathRegInp->objPath, MAX_NAME_LEN);
00498 rstrcpy (fileOpendirInp.resc_hier_, resc_hier, MAX_NAME_LEN);
00499
00500 dirFd = rsFileOpendir (rsComm, &fileOpendirInp);
00501 if (dirFd < 0) {
00502 rodsLog (LOG_ERROR,
00503 "dirPathReg: rsFileOpendir for %s error, status = %d",
00504 filePath, dirFd);
00505 return (dirFd);
00506 }
00507
00508 fileReaddirInp.fileInx = dirFd;
00509
00510 if (getValByKey (&phyPathRegInp->condInput, FORCE_FLAG_KW) != NULL) {
00511 forceFlag = 1;
00512 } else {
00513 forceFlag = 0;
00514 }
00515
00516 while ((status = rsFileReaddir (rsComm, &fileReaddirInp, &rodsDirent))>= 0) {
00517
00518 fileStatInp_t fileStatInp;
00519 rodsStat_t *myStat = NULL;
00520
00521 if (strlen (rodsDirent->d_name) == 0) break;
00522
00523 if (strcmp (rodsDirent->d_name, ".") == 0 ||
00524 strcmp (rodsDirent->d_name, "..") == 0) {
00525 free (rodsDirent);
00526 continue;
00527 }
00528
00529 subPhyPathRegInp = *phyPathRegInp;
00530 snprintf (subPhyPathRegInp.objPath, MAX_NAME_LEN, "%s/%s",
00531 phyPathRegInp->objPath, rodsDirent->d_name);
00532
00533 if (matchPathname(ExcludePatterns, rodsDirent->d_name, filePath)) {
00534 continue;
00535 }
00536
00537 memset (&fileStatInp, 0, sizeof (fileStatInp));
00538
00539 snprintf (fileStatInp.fileName, MAX_NAME_LEN, "%s/%s", filePath, rodsDirent->d_name);
00540 rstrcpy(fileStatInp.objPath, subPhyPathRegInp.objPath, MAX_NAME_LEN);
00541 fileStatInp.fileType = fileOpendirInp.fileType;
00542 fileStatInp.addr = fileOpendirInp.addr;
00543 rstrcpy (fileStatInp.rescHier, resc_hier, MAX_NAME_LEN);
00544
00545
00546 status = rsFileStat (rsComm, &fileStatInp, &myStat);
00547
00548 if (status != 0) {
00549 rodsLog (LOG_ERROR,
00550 "dirPathReg: rsFileStat failed for %s, status = %d",
00551 fileStatInp.fileName, status);
00552 free (rodsDirent);
00553 return (status);
00554 }
00555
00556 if ((myStat->st_mode & S_IFREG) != 0) {
00557 if (forceFlag > 0) {
00558
00559 if (isData (rsComm, subPhyPathRegInp.objPath, NULL) >= 0) {
00560 free (myStat);
00561 free (rodsDirent);
00562 continue;
00563 }
00564 }
00565 subPhyPathRegInp.dataSize = myStat->st_size;
00566 if (getValByKey (&phyPathRegInp->condInput, REG_REPL_KW) != NULL) {
00567 status = filePathRegRepl (rsComm, &subPhyPathRegInp,
00568 fileStatInp.fileName, rescInfo);
00569 } else {
00570 addKeyVal (&subPhyPathRegInp.condInput, FILE_PATH_KW,
00571 fileStatInp.fileName);
00572 status = filePathReg (rsComm, &subPhyPathRegInp,
00573 fileStatInp.fileName, rescInfo);
00574 }
00575 } else if ((myStat->st_mode & S_IFDIR) != 0) {
00576 status = dirPathReg (rsComm, &subPhyPathRegInp,
00577 fileStatInp.fileName, rescInfo);
00578 }
00579 free (myStat);
00580 free (rodsDirent);
00581 }
00582
00583 if (status == -1) {
00584 status = 0;
00585 }
00586
00587 fileClosedirInp.fileInx = dirFd;
00588 rsFileClosedir (rsComm, &fileClosedirInp);
00589
00590 return (status);
00591 }
00592
00593 int mountFileDir( rsComm_t* rsComm,
00594 dataObjInp_t* phyPathRegInp,
00595 char* filePath,
00596 rescInfo_t* rescInfo ) {
00597 collInp_t collCreateInp;
00598 int status;
00599 fileStatInp_t fileStatInp;
00600 rodsStat_t *myStat = NULL;
00601 rodsObjStat_t *rodsObjStatOut = NULL;
00602
00603 char* resc_hier = getValByKey( &phyPathRegInp->condInput, RESC_HIER_STR_KW );
00604 if( !resc_hier ) {
00605 rodsLog( LOG_NOTICE, "mountFileDir - RESC_HIER_STR_KW is NULL" );
00606 return -1;
00607 }
00608
00609
00610
00611 std::string location;
00612 eirods::error ret = eirods::get_loc_for_hier_string( resc_hier, location );
00613 if( !ret.ok() ) {
00614 eirods::log( PASSMSG( "failed in get_loc_for_hier_String", ret ) );
00615 return -1;
00616 }
00617
00618 if (rsComm->clientUser.authInfo.authFlag < LOCAL_PRIV_USER_AUTH ) {
00619 rodsLog( LOG_NOTICE, "mountFileDir - insufficient privilege" );
00620 return(CAT_INSUFFICIENT_PRIVILEGE_LEVEL);
00621 }
00622
00623 status = collStat (rsComm, phyPathRegInp, &rodsObjStatOut);
00624 if (status < 0 || NULL == rodsObjStatOut ) {
00625 rodsLog( LOG_NOTICE, "mountFileDir collstat failed." );
00626 return status;
00627 }
00628
00629 if (rodsObjStatOut->specColl != NULL) {
00630 freeRodsObjStat (rodsObjStatOut);
00631 rodsLog (LOG_ERROR,
00632 "mountFileDir: %s already mounted", phyPathRegInp->objPath);
00633 return (SYS_MOUNT_MOUNTED_COLL_ERR);
00634 }
00635 freeRodsObjStat (rodsObjStatOut);
00636
00637 if (isCollEmpty (rsComm, phyPathRegInp->objPath) == False) {
00638 rodsLog (LOG_ERROR,
00639 "mountFileDir: collection %s not empty", phyPathRegInp->objPath);
00640 return (SYS_COLLECTION_NOT_EMPTY);
00641 }
00642
00643 memset (&fileStatInp, 0, sizeof (fileStatInp));
00644
00645 rstrcpy (fileStatInp.fileName, filePath, MAX_NAME_LEN);
00646 rstrcpy (fileStatInp.objPath, phyPathRegInp->objPath, MAX_NAME_LEN);
00647 fileStatInp.fileType = static_cast< fileDriverType_t >( -1 );
00648 rstrcpy (fileStatInp.addr.hostAddr, location.c_str(), NAME_LEN);
00649 rstrcpy (fileStatInp.rescHier, resc_hier, MAX_NAME_LEN);
00650
00651
00652 status = rsFileStat (rsComm, &fileStatInp, &myStat);
00653
00654 if (status < 0) {
00655 fileMkdirInp_t fileMkdirInp;
00656
00657 rodsLog (LOG_NOTICE,
00658 "mountFileDir: rsFileStat failed for %s, status = %d, create it",
00659 fileStatInp.fileName, status);
00660 memset (&fileMkdirInp, 0, sizeof (fileMkdirInp));
00661 rstrcpy (fileMkdirInp.dirName, filePath, MAX_NAME_LEN);
00662 rstrcpy (fileMkdirInp.rescHier, resc_hier, MAX_NAME_LEN);
00663 fileMkdirInp.fileType = static_cast<fileDriverType_t>(-1);
00664 fileMkdirInp.mode = getDefDirMode ();
00665 rstrcpy (fileMkdirInp.addr.hostAddr, location.c_str(), NAME_LEN);
00666 status = rsFileMkdir (rsComm, &fileMkdirInp);
00667 if (status < 0) {
00668 return (status);
00669 }
00670 } else if ((myStat->st_mode & S_IFDIR) == 0) {
00671 rodsLog (LOG_ERROR,
00672 "mountFileDir: phyPath %s is not a directory",
00673 fileStatInp.fileName);
00674 free (myStat);
00675 return (USER_FILE_DOES_NOT_EXIST);
00676 }
00677
00678 free (myStat);
00679
00680
00681 memset (&collCreateInp, 0, sizeof (collCreateInp));
00682 rstrcpy (collCreateInp.collName, phyPathRegInp->objPath, MAX_NAME_LEN);
00683 addKeyVal (&collCreateInp.condInput, COLLECTION_TYPE_KW, MOUNT_POINT_STR);
00684
00685 addKeyVal (&collCreateInp.condInput, COLLECTION_INFO1_KW, filePath);
00686 addKeyVal (&collCreateInp.condInput, COLLECTION_INFO2_KW, resc_hier);
00687
00688
00689
00690 status = rsModColl (rsComm, &collCreateInp);
00691
00692 if (status < 0) {
00693 rodsLog( LOG_NOTICE, "mountFileDir rsModColl < 0." );
00694 status = rsRegColl (rsComm, &collCreateInp);
00695 }
00696
00697 if (status >= 0) {
00698 rodsLog( LOG_NOTICE, "mountFileDir rsModColl > 0." );
00699
00700 char outLogPath[MAX_NAME_LEN];
00701 int status1;
00702
00703 if (getLogPathFromPhyPath (filePath, rescInfo, outLogPath) >= 0 &&
00704 strcmp (outLogPath, phyPathRegInp->objPath) != 0) {
00705
00706 if (isColl (rsComm, outLogPath, NULL) >= 0) {
00707 modAccessControlInp_t modAccessControl;
00708
00709
00710
00711 bzero (&modAccessControl, sizeof (modAccessControl));
00712 modAccessControl.accessLevel = "read";
00713 modAccessControl.userName = rsComm->clientUser.userName;
00714 modAccessControl.zone = rsComm->clientUser.rodsZone;
00715 modAccessControl.path = phyPathRegInp->objPath;
00716 status1 = rsModAccessControl(rsComm, &modAccessControl);
00717 if (status1 < 0) {
00718 rodsLog (LOG_NOTICE,
00719 "mountFileDir: rsModAccessControl err for %s, stat = %d",
00720 phyPathRegInp->objPath, status1);
00721 }
00722 }
00723 }
00724 }
00725
00726 rodsLog( LOG_NOTICE, "mountFileDir return status." );
00727 return (status);
00728 }
00729
00730 int
00731 unmountFileDir (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp)
00732 {
00733 int status;
00734 collInp_t modCollInp;
00735 rodsObjStat_t *rodsObjStatOut = NULL;
00736
00737 status = collStat (rsComm, phyPathRegInp, &rodsObjStatOut);
00738 if (status < 0 || NULL == rodsObjStatOut ) {
00739 return status;
00740 } else if (rodsObjStatOut->specColl == NULL) {
00741 freeRodsObjStat (rodsObjStatOut);
00742 rodsLog (LOG_ERROR,
00743 "unmountFileDir: %s not mounted", phyPathRegInp->objPath);
00744 return (SYS_COLL_NOT_MOUNTED_ERR);
00745 }
00746
00747 if (getStructFileType (rodsObjStatOut->specColl) >= 0) {
00748
00749 status = _rsSyncMountedColl (rsComm, rodsObjStatOut->specColl,
00750 PURGE_STRUCT_FILE_CACHE);
00751 #if 0
00752 if (status < 0) {
00753 freeRodsObjStat (rodsObjStatOut);
00754 return (status);
00755 }
00756 #endif
00757 }
00758
00759 freeRodsObjStat (rodsObjStatOut);
00760
00761 memset (&modCollInp, 0, sizeof (modCollInp));
00762 rstrcpy (modCollInp.collName, phyPathRegInp->objPath, MAX_NAME_LEN);
00763 addKeyVal (&modCollInp.condInput, COLLECTION_TYPE_KW,
00764 "NULL_SPECIAL_VALUE");
00765 addKeyVal (&modCollInp.condInput, COLLECTION_INFO1_KW, "NULL_SPECIAL_VALUE");
00766 addKeyVal (&modCollInp.condInput, COLLECTION_INFO2_KW, "NULL_SPECIAL_VALUE");
00767
00768 status = rsModColl (rsComm, &modCollInp);
00769
00770 return (status);
00771 }
00772
00773 int
00774 structFileReg (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp)
00775 {
00776 collInp_t collCreateInp;
00777 int status;
00778 dataObjInfo_t *dataObjInfo = NULL;
00779 char *structFilePath = NULL;
00780 dataObjInp_t dataObjInp;
00781 char *collType;
00782 int len;
00783 rodsObjStat_t *rodsObjStatOut = NULL;
00784 specCollCache_t *specCollCache = NULL;
00785 rescInfo_t *rescInfo = NULL;
00786 #if 0
00787
00788 if (rsComm->clientUser.authInfo.authFlag < LOCAL_PRIV_USER_AUTH)
00789 return(CAT_INSUFFICIENT_PRIVILEGE_LEVEL);
00790 #endif
00791 if ((structFilePath = getValByKey (&phyPathRegInp->condInput, FILE_PATH_KW))
00792 == NULL) {
00793 rodsLog (LOG_ERROR,
00794 "structFileReg: No structFilePath input for %s",
00795 phyPathRegInp->objPath);
00796 return (SYS_INVALID_FILE_PATH);
00797 }
00798
00799 collType = getValByKey (&phyPathRegInp->condInput, COLLECTION_TYPE_KW);
00800 if (collType == NULL) {
00801 rodsLog (LOG_ERROR,
00802 "structFileReg: Bad COLLECTION_TYPE_KW for structFilePath %s",
00803 dataObjInp.objPath);
00804 return (SYS_INTERNAL_NULL_INPUT_ERR);
00805 }
00806
00807 len = strlen (phyPathRegInp->objPath);
00808 if (strncmp (structFilePath, phyPathRegInp->objPath, len) == 0 &&
00809 (structFilePath[len] == '\0' || structFilePath[len] == '/')) {
00810 rodsLog (LOG_ERROR,
00811 "structFileReg: structFilePath %s inside collection %s",
00812 structFilePath, phyPathRegInp->objPath);
00813 return (SYS_STRUCT_FILE_INMOUNTED_COLL);
00814 }
00815
00816
00817
00818 if (getSpecCollCache (rsComm, structFilePath, 0, &specCollCache) >= 0) {
00819 rodsLog (LOG_ERROR,
00820 "structFileReg: structFilePath %s is in a mounted path",
00821 structFilePath);
00822 return (SYS_STRUCT_FILE_INMOUNTED_COLL);
00823 }
00824
00825 status = collStat (rsComm, phyPathRegInp, &rodsObjStatOut);
00826 if (status < 0 || NULL == rodsObjStatOut ) return status;
00827
00828 if (rodsObjStatOut->specColl != NULL) {
00829 freeRodsObjStat (rodsObjStatOut);
00830 rodsLog (LOG_ERROR,
00831 "structFileReg: %s already mounted", phyPathRegInp->objPath);
00832 return (SYS_MOUNT_MOUNTED_COLL_ERR);
00833 }
00834
00835 freeRodsObjStat (rodsObjStatOut);
00836
00837 if (isCollEmpty (rsComm, phyPathRegInp->objPath) == False) {
00838 rodsLog (LOG_ERROR,
00839 "structFileReg: collection %s not empty", phyPathRegInp->objPath);
00840 return (SYS_COLLECTION_NOT_EMPTY);
00841 }
00842
00843 memset (&dataObjInp, 0, sizeof (dataObjInp));
00844 rstrcpy (dataObjInp.objPath, structFilePath, sizeof (dataObjInp));
00845
00846 dataObjInp.openFlags = O_WRONLY;
00847 status = getDataObjInfoIncSpecColl (rsComm, &dataObjInp, &dataObjInfo);
00848 if (status < 0 || NULL == dataObjInfo) {
00849 int myStatus;
00850
00851 dataObjInp.condInput = phyPathRegInp->condInput;
00852
00853 rmKeyVal (&dataObjInp.condInput, FILE_PATH_KW);
00854 myStatus = rsDataObjCreate (rsComm, &dataObjInp);
00855 if (myStatus < 0 ) {
00856 rodsLog (LOG_ERROR,
00857 "structFileReg: Problem with open/create structFilePath %s, status = %d",
00858 dataObjInp.objPath, status);
00859 return (status);
00860 } else {
00861 openedDataObjInp_t dataObjCloseInp;
00862 bzero (&dataObjCloseInp, sizeof (dataObjCloseInp));
00863 rescInfo = L1desc[myStatus].dataObjInfo->rescInfo;
00864 dataObjCloseInp.l1descInx = myStatus;
00865 rsDataObjClose (rsComm, &dataObjCloseInp);
00866 }
00867 } else {
00868 rescInfo = dataObjInfo->rescInfo;
00869 }
00870
00871 char* tmp_hier = getValByKey( &phyPathRegInp->condInput, RESC_HIER_STR_KW );
00872 if( !tmp_hier ) {
00873 rodsLog( LOG_ERROR, "structFileReg - RESC_HIER_STR_KW is NULL" );
00874 return -1;
00875 }
00876 #if 0 // JMC - no longer necessary
00877 if (!structFileSupport (rsComm, phyPathRegInp->objPath,
00878 collType, tmp_hier)) {
00879 rodsLog (LOG_ERROR,
00880 "structFileReg: structFileDriver type %s does not exist for %s",
00881 collType, dataObjInp.objPath);
00882 return (SYS_NOT_SUPPORTED);
00883 }
00884 #endif // JMC - no longer necessary
00885
00886
00887
00888 memset (&collCreateInp, 0, sizeof (collCreateInp));
00889 rstrcpy (collCreateInp.collName, phyPathRegInp->objPath, MAX_NAME_LEN);
00890 addKeyVal (&collCreateInp.condInput, COLLECTION_TYPE_KW, collType);
00891
00892
00893 addKeyVal (&collCreateInp.condInput, COLLECTION_INFO1_KW,
00894 dataObjInp.objPath);
00895
00896
00897 status = rsModColl (rsComm, &collCreateInp);
00898
00899 if (status < 0) {
00900 status = rsRegColl (rsComm, &collCreateInp);
00901 }
00902
00903 return (status);
00904 }
00905
00906 int
00907 structFileSupport (rsComm_t *rsComm, char *collection, char *collType,
00908 char* resc_hier )
00909 {
00910 rodsStat_t *myStat = NULL;
00911 int status;
00912 subFile_t subFile;
00913 specColl_t specColl;
00914
00915 if (rsComm == NULL || collection == NULL || collType == NULL ||
00916 resc_hier == NULL) return 0;
00917
00918 memset (&subFile, 0, sizeof (subFile));
00919 memset (&specColl, 0, sizeof (specColl));
00920
00921 subFile.specColl = &specColl;
00922 rstrcpy (specColl.collection, collection, MAX_NAME_LEN);
00923 specColl.collClass = STRUCT_FILE_COLL;
00924 if (strcmp (collType, HAAW_STRUCT_FILE_STR) == 0) {
00925 specColl.type = HAAW_STRUCT_FILE_T;
00926 } else if (strcmp (collType, TAR_STRUCT_FILE_STR) == 0) {
00927 specColl.type = TAR_STRUCT_FILE_T;
00928 } else {
00929 return (0);
00930 }
00931
00932
00933
00934 std::string location;
00935 eirods::error ret = eirods::get_loc_for_hier_string( resc_hier, location );
00936 if( !ret.ok() ) {
00937 eirods::log( PASSMSG( "failed in get_loc_for_hier_String", ret ) );
00938 return -1;
00939 }
00940
00941 eirods::hierarchy_parser parser;
00942 parser.set_string( resc_hier );
00943 std::string first_resc;
00944 parser.first_resc( first_resc );
00945
00946 snprintf (specColl.objPath, MAX_NAME_LEN, "%s/myFakeFile",collection);
00947 rstrcpy (specColl.resource, first_resc.c_str(), NAME_LEN);
00948 rstrcpy (specColl.rescHier, resc_hier, NAME_LEN);
00949 rstrcpy (specColl.phyPath, "/fakeDir1/fakeDir2/myFakeStructFile", MAX_NAME_LEN );
00950 rstrcpy (subFile.subFilePath, "/fakeDir1/fakeDir2/myFakeFile", MAX_NAME_LEN);
00951 rstrcpy (subFile.addr.hostAddr, location.c_str(), NAME_LEN);
00952
00953 status = rsSubStructFileStat (rsComm, &subFile, &myStat);
00954
00955 if (status == SYS_NOT_SUPPORTED)
00956 return (0);
00957 else
00958 return (1);
00959 }
00960
00961 int
00962 linkCollReg (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp)
00963 {
00964 collInp_t collCreateInp;
00965 int status;
00966 char *linkPath = NULL;
00967 char *collType;
00968 int len;
00969 rodsObjStat_t *rodsObjStatOut = NULL;
00970 specCollCache_t *specCollCache = NULL;
00971
00972 if ((linkPath = getValByKey (&phyPathRegInp->condInput, FILE_PATH_KW))
00973 == NULL) {
00974 rodsLog (LOG_ERROR,
00975 "linkCollReg: No linkPath input for %s",
00976 phyPathRegInp->objPath);
00977 return (SYS_INVALID_FILE_PATH);
00978 }
00979
00980 collType = getValByKey (&phyPathRegInp->condInput, COLLECTION_TYPE_KW);
00981 if (collType == NULL || strcmp (collType, LINK_POINT_STR) != 0) {
00982 rodsLog (LOG_ERROR,
00983 "linkCollReg: Bad COLLECTION_TYPE_KW for linkPath %s",
00984 phyPathRegInp->objPath);
00985 return (SYS_INTERNAL_NULL_INPUT_ERR);
00986 }
00987
00988 if (phyPathRegInp->objPath[0] != '/' || linkPath[0] != '/') {
00989 rodsLog (LOG_ERROR,
00990 "linkCollReg: linkPath %s or collection %s not absolute path",
00991 linkPath, phyPathRegInp->objPath);
00992 return (SYS_COLL_LINK_PATH_ERR);
00993 }
00994
00995 len = strlen (phyPathRegInp->objPath);
00996 if (strncmp (linkPath, phyPathRegInp->objPath, len) == 0 &&
00997 linkPath[len] == '/') {
00998 rodsLog (LOG_ERROR,
00999 "linkCollReg: linkPath %s inside collection %s",
01000 linkPath, phyPathRegInp->objPath);
01001 return (SYS_COLL_LINK_PATH_ERR);
01002 }
01003
01004 len = strlen (linkPath);
01005 if (strncmp (phyPathRegInp->objPath, linkPath, len) == 0 &&
01006 phyPathRegInp->objPath[len] == '/') {
01007 rodsLog (LOG_ERROR,
01008 "linkCollReg: collection %s inside linkPath %s",
01009 linkPath, phyPathRegInp->objPath);
01010 return (SYS_COLL_LINK_PATH_ERR);
01011 }
01012
01013 if (getSpecCollCache (rsComm, linkPath, 0, &specCollCache) >= 0 &&
01014 specCollCache->specColl.collClass != LINKED_COLL) {
01015 rodsLog (LOG_ERROR,
01016 "linkCollReg: linkPath %s is in a spec coll path",
01017 linkPath);
01018 return (SYS_COLL_LINK_PATH_ERR);
01019 }
01020
01021 status = collStat (rsComm, phyPathRegInp, &rodsObjStatOut);
01022 if (status < 0) {
01023
01024 collInp_t collCreateInp;
01025 memset (&collCreateInp, 0, sizeof (collCreateInp));
01026 rstrcpy (collCreateInp.collName, phyPathRegInp->objPath, MAX_NAME_LEN);
01027 status = rsRegColl (rsComm, &collCreateInp);
01028 if (status < 0) {
01029 rodsLog (LOG_ERROR,
01030 "linkCollReg: rsRegColl error for %s, status = %d",
01031 collCreateInp.collName, status);
01032 return status;
01033 }
01034 status = collStat (rsComm, phyPathRegInp, &rodsObjStatOut);
01035 if (status < 0 ) return status;
01036
01037 }
01038
01039 if ( rodsObjStatOut &&
01040 rodsObjStatOut->specColl != NULL &&
01041 rodsObjStatOut->specColl->collClass != LINKED_COLL) {
01042 freeRodsObjStat (rodsObjStatOut);
01043 rodsLog (LOG_ERROR,
01044 "linkCollReg: link collection %s in a spec coll path",
01045 phyPathRegInp->objPath);
01046 return (SYS_COLL_LINK_PATH_ERR);
01047 }
01048
01049 freeRodsObjStat (rodsObjStatOut);
01050
01051 if (isCollEmpty (rsComm, phyPathRegInp->objPath) == False) {
01052 rodsLog (LOG_ERROR,
01053 "linkCollReg: collection %s not empty", phyPathRegInp->objPath);
01054 return (SYS_COLLECTION_NOT_EMPTY);
01055 }
01056
01057
01058
01059 memset (&collCreateInp, 0, sizeof (collCreateInp));
01060 rstrcpy (collCreateInp.collName, phyPathRegInp->objPath, MAX_NAME_LEN);
01061 addKeyVal (&collCreateInp.condInput, COLLECTION_TYPE_KW, collType);
01062
01063
01064 addKeyVal (&collCreateInp.condInput, COLLECTION_INFO1_KW,
01065 linkPath);
01066
01067
01068 status = rsModColl (rsComm, &collCreateInp);
01069
01070 if (status < 0) {
01071 status = rsRegColl (rsComm, &collCreateInp);
01072 }
01073
01074 return (status);
01075 }
01076
01077 pathnamePatterns_t *
01078 readPathnamePatternsFromFile(rsComm_t *rsComm, char *filename, char* resc_hier )
01079 {
01080 int status;
01081 rodsStat_t *stbuf;
01082 fileStatInp_t fileStatInp;
01083 bytesBuf_t fileReadBuf;
01084 fileOpenInp_t fileOpenInp;
01085 fileReadInp_t fileReadInp;
01086 fileCloseInp_t fileCloseInp;
01087 int buf_len, fd;
01088 pathnamePatterns_t *pp;
01089
01090 if (rsComm == NULL || filename == NULL || resc_hier == NULL) {
01091 return NULL;
01092 }
01093
01094
01095
01096
01097 std::string location;
01098 eirods::error ret = eirods::get_loc_for_hier_string( resc_hier, location );
01099 if( !ret.ok() ) {
01100 eirods::log( PASSMSG( "failed in get_loc_for_hier_String", ret ) );
01101 return NULL;
01102 }
01103
01104 memset(&fileStatInp, 0, sizeof(fileStatInp));
01105 rstrcpy(fileStatInp.fileName, filename, MAX_NAME_LEN);
01106
01107 rstrcpy(fileStatInp.addr.hostAddr, location.c_str(), NAME_LEN);
01108 status = rsFileStat(rsComm, &fileStatInp, &stbuf);
01109 if (status != 0) {
01110 if (status != UNIX_FILE_STAT_ERR - ENOENT) {
01111 rodsLog(LOG_DEBUG, "readPathnamePatternsFromFile: can't stat %s. status = %d",
01112 fileStatInp.fileName, status);
01113 }
01114 return NULL;
01115 }
01116 buf_len = stbuf->st_size;
01117 free(stbuf);
01118
01119 memset(&fileOpenInp, 0, sizeof(fileOpenInp));
01120 rstrcpy(fileOpenInp.fileName, filename, MAX_NAME_LEN);
01121
01122 rstrcpy(fileOpenInp.addr.hostAddr, location.c_str(), NAME_LEN);
01123 fileOpenInp.flags = O_RDONLY;
01124 fd = rsFileOpen(rsComm, &fileOpenInp);
01125 if (fd < 0) {
01126 rodsLog(LOG_NOTICE,
01127 "readPathnamePatternsFromFile: can't open %s for reading. status = %d",
01128 fileOpenInp.fileName, fd);
01129 return NULL;
01130 }
01131
01132 memset(&fileReadBuf, 0, sizeof(fileReadBuf));
01133 fileReadBuf.buf = malloc(buf_len);
01134 if (fileReadBuf.buf == NULL) {
01135 rodsLog(LOG_NOTICE, "readPathnamePatternsFromFile: could not malloc buffer");
01136 return NULL;
01137 }
01138
01139 memset(&fileReadInp, 0, sizeof(fileReadInp));
01140 fileReadInp.fileInx = fd;
01141 fileReadInp.len = buf_len;
01142 status = rsFileRead(rsComm, &fileReadInp, &fileReadBuf);
01143
01144 memset(&fileCloseInp, 0, sizeof(fileCloseInp));
01145 fileCloseInp.fileInx = fd;
01146 rsFileClose(rsComm, &fileCloseInp);
01147
01148 if (status < 0) {
01149 rodsLog(LOG_NOTICE, "readPathnamePatternsFromFile: could not read %s. status = %d",
01150 fileOpenInp.fileName, status);
01151 free(fileReadBuf.buf);
01152 return NULL;
01153 }
01154
01155 pp = readPathnamePatterns((char*)fileReadBuf.buf, buf_len);
01156
01157 return pp;
01158 }
01159
01160