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
00266 if( getValByKey (&phyPathRegInp->condInput, NO_CHK_FILE_PERM_KW) == NULL &&
00267 (chkType = getchkPathPerm (rsComm, phyPathRegInp, &dataObjInfo)) != NO_CHK_PATH_PERM) {
00268
00269 memset (&chkNVPathPermInp, 0, sizeof (chkNVPathPermInp));
00270
00271 rstrcpy (chkNVPathPermInp.fileName, filePath, MAX_NAME_LEN);
00272 chkNVPathPermInp.fileType = static_cast< fileDriverType_t>( -1 );
00273
00274
00275
00276 std::string location;
00277 eirods::error ret = eirods::get_loc_for_hier_string( resc_hier, location );
00278 if( !ret.ok() ) {
00279 eirods::log( PASSMSG( "failed in get_loc_for_hier_String", ret ) );
00280 return -1;
00281 }
00282
00283 rstrcpy (chkNVPathPermInp.addr.hostAddr, location.c_str(), NAME_LEN );
00284 status = chkFilePathPerm (rsComm, &chkNVPathPermInp, rodsServerHost,chkType);
00285
00286 if (status < 0) {
00287 rodsLog (LOG_ERROR,
00288 "_rsPhyPathReg: chkFilePathPerm error for %s",
00289 phyPathRegInp->objPath);
00290 return (SYS_NO_PATH_PERMISSION);
00291 }
00292 } else {
00293 status = 0;
00294 }
00295
00296 if (getValByKey (&phyPathRegInp->condInput, COLLECTION_KW) != NULL) {
00297 excludePatternFile = getValByKey(&phyPathRegInp->condInput, EXCLUDE_FILE_KW);
00298 if (excludePatternFile != NULL) {
00299 ExcludePatterns = readPathnamePatternsFromFile(rsComm,
00300 excludePatternFile,
00301 resc_hier);
00302 }
00303
00304 status = dirPathReg (rsComm, phyPathRegInp, filePath, rescGrpInfo->rescInfo);
00305 if (excludePatternFile != NULL) {
00306 freePathnamePatterns(ExcludePatterns);
00307 ExcludePatterns = NULL;
00308 }
00309
00310 } else if ((tmpStr = getValByKey (&phyPathRegInp->condInput, COLLECTION_TYPE_KW)) != NULL && strcmp (tmpStr, MOUNT_POINT_STR) == 0) {
00311
00312 status = mountFileDir (rsComm, phyPathRegInp, filePath, rescGrpInfo->rescInfo);
00313
00314 } else {
00315 if (getValByKey (&phyPathRegInp->condInput, REG_REPL_KW) != NULL) {
00316 status = filePathRegRepl (rsComm, phyPathRegInp, filePath, rescGrpInfo->rescInfo);
00317
00318 } else {
00319 status = filePathReg (rsComm, phyPathRegInp, filePath,rescGrpInfo->rescInfo);
00320 }
00321 }
00322
00323 return (status);
00324 }
00325
00326 int
00327 filePathRegRepl (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp, char *filePath,
00328 rescInfo_t *rescInfo)
00329 {
00330 dataObjInfo_t destDataObjInfo, *dataObjInfoHead = NULL;
00331 regReplica_t regReplicaInp;
00332 char *rescGroupName = NULL;
00333 int status;
00334
00335 status = getDataObjInfo( rsComm, phyPathRegInp, &dataObjInfoHead,
00336 ACCESS_READ_OBJECT, 0 );
00337 if (status < 0) {
00338 rodsLog (LOG_ERROR,
00339 "filePathRegRepl: getDataObjInfo for %s", phyPathRegInp->objPath);
00340 return (status);
00341 }
00342
00343 status = sortObjInfoForOpen (rsComm, &dataObjInfoHead, &phyPathRegInp->condInput, 0);
00344 if (status < 0 ) {
00345
00346
00347
00348
00349 if( NULL == dataObjInfoHead ) {
00350 return status;
00351 }
00352 }
00353 destDataObjInfo = *dataObjInfoHead;
00354 rstrcpy (destDataObjInfo.filePath, filePath, MAX_NAME_LEN);
00355 destDataObjInfo.rescInfo = new rescInfo_t;
00356 memcpy( destDataObjInfo.rescInfo, rescInfo, sizeof( rescInfo_t ) );
00357 rstrcpy (destDataObjInfo.rescName, rescInfo->rescName, NAME_LEN);
00358 if ((rescGroupName = getValByKey (&phyPathRegInp->condInput,
00359 RESC_GROUP_NAME_KW)) != NULL) {
00360 rstrcpy (destDataObjInfo.rescGroupName, rescGroupName, NAME_LEN);
00361 }
00362 memset (®ReplicaInp, 0, sizeof (regReplicaInp));
00363 regReplicaInp.srcDataObjInfo = dataObjInfoHead;
00364 regReplicaInp.destDataObjInfo = &destDataObjInfo;
00365 if (getValByKey (&phyPathRegInp->condInput, SU_CLIENT_USER_KW) != NULL) {
00366 addKeyVal (®ReplicaInp.condInput, SU_CLIENT_USER_KW, "");
00367 addKeyVal (®ReplicaInp.condInput, IRODS_ADMIN_KW, "");
00368 } else if (getValByKey (&phyPathRegInp->condInput,
00369 IRODS_ADMIN_KW) != NULL) {
00370 addKeyVal (®ReplicaInp.condInput, IRODS_ADMIN_KW, "");
00371 }
00372 status = rsRegReplica (rsComm, ®ReplicaInp);
00373 clearKeyVal (®ReplicaInp.condInput);
00374 freeAllDataObjInfo (dataObjInfoHead);
00375
00376 return status;
00377 }
00378
00379 int
00380 filePathReg (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp, char *filePath,
00381 rescInfo_t *rescInfo)
00382 {
00383 dataObjInfo_t dataObjInfo;
00384 int status;
00385 char *rescGroupName = NULL;
00386 char *chksum = NULL;
00387
00388 initDataObjInfoWithInp (&dataObjInfo, phyPathRegInp);
00389 if ((rescGroupName = getValByKey (&phyPathRegInp->condInput,
00390 RESC_GROUP_NAME_KW)) != NULL) {
00391 rstrcpy (dataObjInfo.rescGroupName, rescGroupName, NAME_LEN);
00392 }
00393 dataObjInfo.replStatus = NEWLY_CREATED_COPY;
00394 dataObjInfo.rescInfo = new rescInfo_t;
00395 memcpy( dataObjInfo.rescInfo, rescInfo, sizeof( rescInfo_t ) );
00396 rstrcpy (dataObjInfo.rescName, rescInfo->rescName, NAME_LEN);
00397
00398 char* resc_hier = getValByKey( &phyPathRegInp->condInput, RESC_HIER_STR_KW );
00399 if( !resc_hier ) {
00400 rodsLog( LOG_NOTICE, "filePathReg - RESC_HIER_STR_KW is NULL" );
00401 return -1;
00402 }
00403
00404 rstrcpy (dataObjInfo.rescHier, resc_hier, MAX_NAME_LEN);
00405
00406 if (dataObjInfo.dataSize <= 0 &&
00407 (dataObjInfo.dataSize = getSizeInVault (rsComm, &dataObjInfo)) < 0 &&
00408 dataObjInfo.dataSize != UNKNOWN_FILE_SZ) {
00409 status = (int) dataObjInfo.dataSize;
00410 rodsLog (LOG_ERROR,
00411 "filePathReg: getSizeInVault for %s failed, status = %d",
00412 dataObjInfo.objPath, status);
00413 return (status);
00414 }
00415
00416 if ((chksum = getValByKey (&phyPathRegInp->condInput,
00417 REG_CHKSUM_KW)) != NULL) {
00418 rstrcpy (dataObjInfo.chksum, chksum, NAME_LEN);
00419 }
00420 else if ((chksum = getValByKey (&phyPathRegInp->condInput,
00421 VERIFY_CHKSUM_KW)) != NULL) {
00422 status = _dataObjChksum (rsComm, &dataObjInfo, &chksum);
00423 if (status < 0) {
00424 rodsLog (LOG_ERROR,
00425 "rodsPathReg: _dataObjChksum for %s failed, status = %d",
00426 dataObjInfo.objPath, status);
00427 return (status);
00428 }
00429 rstrcpy (dataObjInfo.chksum, chksum, NAME_LEN);
00430 }
00431
00432 status = svrRegDataObj (rsComm, &dataObjInfo);
00433 if (status < 0) {
00434 rodsLog (LOG_ERROR,
00435 "filePathReg: rsRegDataObj for %s failed, status = %d",
00436 dataObjInfo.objPath, status);
00437 } else {
00438 ruleExecInfo_t rei;
00439 initReiWithDataObjInp (&rei, rsComm, phyPathRegInp);
00440 rei.doi = &dataObjInfo;
00441 rei.status = status;
00442 rei.status = applyRule ("acPostProcForFilePathReg", NULL, &rei,
00443 NO_SAVE_REI);
00444 }
00445
00446 return (status);
00447 }
00448
00449 int
00450 dirPathReg (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp, char *filePath,
00451 rescInfo_t *rescInfo )
00452 {
00453 collInp_t collCreateInp;
00454 fileOpendirInp_t fileOpendirInp;
00455 fileClosedirInp_t fileClosedirInp;
00456 int status;
00457 int dirFd;
00458 dataObjInp_t subPhyPathRegInp;
00459 fileReaddirInp_t fileReaddirInp;
00460 rodsDirent_t *rodsDirent = NULL;
00461 rodsObjStat_t *rodsObjStatOut = NULL;
00462 int forceFlag;
00463
00464 char* resc_hier = getValByKey( &phyPathRegInp->condInput, RESC_HIER_STR_KW );
00465 if( !resc_hier ) {
00466 rodsLog( LOG_NOTICE, "dirPathReg - RESC_HIER_STR_KW is NULL" );
00467 return -1;
00468 }
00469
00470
00471
00472 std::string location;
00473 eirods::error ret = eirods::get_loc_for_hier_string( resc_hier, location );
00474 if( !ret.ok() ) {
00475 eirods::log( PASSMSG( "failed in get_loc_for_hier_String", ret ) );
00476 return -1;
00477 }
00478
00479 status = collStat (rsComm, phyPathRegInp, &rodsObjStatOut);
00480 if (status < 0 || NULL == rodsObjStatOut ) {
00481 memset (&collCreateInp, 0, sizeof (collCreateInp));
00482 rstrcpy (collCreateInp.collName, phyPathRegInp->objPath,
00483 MAX_NAME_LEN);
00484
00485
00486 addKeyVal (&collCreateInp.condInput, TRANSLATED_PATH_KW, "");
00487
00488
00489 status = rsCollCreate (rsComm, &collCreateInp);
00490 clearKeyVal (&collCreateInp.condInput);
00491 if (status < 0 ) return status;
00492 } else if (rodsObjStatOut->specColl != NULL) {
00493 freeRodsObjStat (rodsObjStatOut);
00494 rodsLog (LOG_ERROR,
00495 "mountFileDir: %s already mounted", phyPathRegInp->objPath);
00496 return (SYS_MOUNT_MOUNTED_COLL_ERR);
00497 }
00498 freeRodsObjStat (rodsObjStatOut);
00499
00500 memset (&fileOpendirInp, 0, sizeof (fileOpendirInp));
00501
00502 rstrcpy (fileOpendirInp.dirName, filePath, MAX_NAME_LEN);
00503 fileOpendirInp.fileType = static_cast< fileDriverType_t >( -1 );
00504 rstrcpy (fileOpendirInp.addr.hostAddr, location.c_str(), NAME_LEN);
00505 rstrcpy (fileOpendirInp.objPath, phyPathRegInp->objPath, MAX_NAME_LEN);
00506 rstrcpy (fileOpendirInp.resc_hier_, resc_hier, MAX_NAME_LEN);
00507
00508 dirFd = rsFileOpendir (rsComm, &fileOpendirInp);
00509 if (dirFd < 0) {
00510 rodsLog (LOG_ERROR,
00511 "dirPathReg: rsFileOpendir for %s error, status = %d",
00512 filePath, dirFd);
00513 return (dirFd);
00514 }
00515
00516 fileReaddirInp.fileInx = dirFd;
00517
00518 if (getValByKey (&phyPathRegInp->condInput, FORCE_FLAG_KW) != NULL) {
00519 forceFlag = 1;
00520 } else {
00521 forceFlag = 0;
00522 }
00523
00524 while ((status = rsFileReaddir (rsComm, &fileReaddirInp, &rodsDirent))>= 0) {
00525
00526 fileStatInp_t fileStatInp;
00527 rodsStat_t *myStat = NULL;
00528
00529 if (strlen (rodsDirent->d_name) == 0) break;
00530
00531 if (strcmp (rodsDirent->d_name, ".") == 0 ||
00532 strcmp (rodsDirent->d_name, "..") == 0) {
00533 free (rodsDirent);
00534 continue;
00535 }
00536
00537 subPhyPathRegInp = *phyPathRegInp;
00538 snprintf (subPhyPathRegInp.objPath, MAX_NAME_LEN, "%s/%s",
00539 phyPathRegInp->objPath, rodsDirent->d_name);
00540
00541 if (matchPathname(ExcludePatterns, rodsDirent->d_name, filePath)) {
00542 continue;
00543 }
00544
00545 memset (&fileStatInp, 0, sizeof (fileStatInp));
00546
00547 snprintf (fileStatInp.fileName, MAX_NAME_LEN, "%s/%s", filePath, rodsDirent->d_name);
00548 rstrcpy(fileStatInp.objPath, subPhyPathRegInp.objPath, MAX_NAME_LEN);
00549 fileStatInp.fileType = fileOpendirInp.fileType;
00550 fileStatInp.addr = fileOpendirInp.addr;
00551 rstrcpy (fileStatInp.rescHier, resc_hier, MAX_NAME_LEN);
00552
00553
00554 status = rsFileStat (rsComm, &fileStatInp, &myStat);
00555
00556 if (status != 0) {
00557 rodsLog (LOG_ERROR,
00558 "dirPathReg: rsFileStat failed for %s, status = %d",
00559 fileStatInp.fileName, status);
00560 free (rodsDirent);
00561 return (status);
00562 }
00563
00564 if ((myStat->st_mode & S_IFREG) != 0) {
00565 if (forceFlag > 0) {
00566
00567 if (isData (rsComm, subPhyPathRegInp.objPath, NULL) >= 0) {
00568 free (myStat);
00569 free (rodsDirent);
00570 continue;
00571 }
00572 }
00573 subPhyPathRegInp.dataSize = myStat->st_size;
00574 if (getValByKey (&phyPathRegInp->condInput, REG_REPL_KW) != NULL) {
00575 status = filePathRegRepl (rsComm, &subPhyPathRegInp,
00576 fileStatInp.fileName, rescInfo);
00577 } else {
00578 addKeyVal (&subPhyPathRegInp.condInput, FILE_PATH_KW,
00579 fileStatInp.fileName);
00580 status = filePathReg (rsComm, &subPhyPathRegInp,
00581 fileStatInp.fileName, rescInfo);
00582 }
00583 } else if ((myStat->st_mode & S_IFDIR) != 0) {
00584 status = dirPathReg (rsComm, &subPhyPathRegInp,
00585 fileStatInp.fileName, rescInfo);
00586 }
00587 free (myStat);
00588 free (rodsDirent);
00589 }
00590
00591 if (status == -1) {
00592 status = 0;
00593 }
00594
00595 fileClosedirInp.fileInx = dirFd;
00596 rsFileClosedir (rsComm, &fileClosedirInp);
00597
00598 return (status);
00599 }
00600
00601 int mountFileDir( rsComm_t* rsComm,
00602 dataObjInp_t* phyPathRegInp,
00603 char* filePath,
00604 rescInfo_t* rescInfo ) {
00605 collInp_t collCreateInp;
00606 int status;
00607 fileStatInp_t fileStatInp;
00608 rodsStat_t *myStat = NULL;
00609 rodsObjStat_t *rodsObjStatOut = NULL;
00610
00611 char* resc_hier = getValByKey( &phyPathRegInp->condInput, RESC_HIER_STR_KW );
00612 if( !resc_hier ) {
00613 rodsLog( LOG_NOTICE, "mountFileDir - RESC_HIER_STR_KW is NULL" );
00614 return -1;
00615 }
00616
00617
00618
00619 std::string location;
00620 eirods::error ret = eirods::get_loc_for_hier_string( resc_hier, location );
00621 if( !ret.ok() ) {
00622 eirods::log( PASSMSG( "failed in get_loc_for_hier_String", ret ) );
00623 return -1;
00624 }
00625
00626 if (rsComm->clientUser.authInfo.authFlag < LOCAL_PRIV_USER_AUTH ) {
00627 rodsLog( LOG_NOTICE, "mountFileDir - insufficient privilege" );
00628 return(CAT_INSUFFICIENT_PRIVILEGE_LEVEL);
00629 }
00630
00631 status = collStat (rsComm, phyPathRegInp, &rodsObjStatOut);
00632 if (status < 0 || NULL == rodsObjStatOut ) {
00633 rodsLog( LOG_NOTICE, "mountFileDir collstat failed." );
00634 return status;
00635 }
00636
00637 if (rodsObjStatOut->specColl != NULL) {
00638 freeRodsObjStat (rodsObjStatOut);
00639 rodsLog (LOG_ERROR,
00640 "mountFileDir: %s already mounted", phyPathRegInp->objPath);
00641 return (SYS_MOUNT_MOUNTED_COLL_ERR);
00642 }
00643 freeRodsObjStat (rodsObjStatOut);
00644
00645 if (isCollEmpty (rsComm, phyPathRegInp->objPath) == False) {
00646 rodsLog (LOG_ERROR,
00647 "mountFileDir: collection %s not empty", phyPathRegInp->objPath);
00648 return (SYS_COLLECTION_NOT_EMPTY);
00649 }
00650
00651 memset (&fileStatInp, 0, sizeof (fileStatInp));
00652
00653 rstrcpy (fileStatInp.fileName, filePath, MAX_NAME_LEN);
00654 rstrcpy (fileStatInp.objPath, phyPathRegInp->objPath, MAX_NAME_LEN);
00655 fileStatInp.fileType = static_cast< fileDriverType_t >( -1 );
00656 rstrcpy (fileStatInp.addr.hostAddr, location.c_str(), NAME_LEN);
00657 rstrcpy (fileStatInp.rescHier, resc_hier, MAX_NAME_LEN);
00658
00659
00660 status = rsFileStat (rsComm, &fileStatInp, &myStat);
00661
00662 if (status < 0) {
00663 fileMkdirInp_t fileMkdirInp;
00664
00665 rodsLog (LOG_NOTICE,
00666 "mountFileDir: rsFileStat failed for %s, status = %d, create it",
00667 fileStatInp.fileName, status);
00668 memset (&fileMkdirInp, 0, sizeof (fileMkdirInp));
00669 rstrcpy (fileMkdirInp.dirName, filePath, MAX_NAME_LEN);
00670 rstrcpy (fileMkdirInp.rescHier, resc_hier, MAX_NAME_LEN);
00671 fileMkdirInp.fileType = static_cast<fileDriverType_t>(-1);
00672 fileMkdirInp.mode = getDefDirMode ();
00673 rstrcpy (fileMkdirInp.addr.hostAddr, location.c_str(), NAME_LEN);
00674 status = rsFileMkdir (rsComm, &fileMkdirInp);
00675 if (status < 0) {
00676 return (status);
00677 }
00678 } else if ((myStat->st_mode & S_IFDIR) == 0) {
00679 rodsLog (LOG_ERROR,
00680 "mountFileDir: phyPath %s is not a directory",
00681 fileStatInp.fileName);
00682 free (myStat);
00683 return (USER_FILE_DOES_NOT_EXIST);
00684 }
00685
00686 free (myStat);
00687
00688
00689 memset (&collCreateInp, 0, sizeof (collCreateInp));
00690 rstrcpy (collCreateInp.collName, phyPathRegInp->objPath, MAX_NAME_LEN);
00691 addKeyVal (&collCreateInp.condInput, COLLECTION_TYPE_KW, MOUNT_POINT_STR);
00692
00693 addKeyVal (&collCreateInp.condInput, COLLECTION_INFO1_KW, filePath);
00694 addKeyVal (&collCreateInp.condInput, COLLECTION_INFO2_KW, resc_hier);
00695
00696
00697
00698 status = rsModColl (rsComm, &collCreateInp);
00699
00700 if (status < 0) {
00701 rodsLog( LOG_NOTICE, "mountFileDir rsModColl < 0." );
00702 status = rsRegColl (rsComm, &collCreateInp);
00703 }
00704
00705 if (status >= 0) {
00706 rodsLog( LOG_NOTICE, "mountFileDir rsModColl > 0." );
00707
00708 char outLogPath[MAX_NAME_LEN];
00709 int status1;
00710
00711 if (getLogPathFromPhyPath (filePath, rescInfo, outLogPath) >= 0 &&
00712 strcmp (outLogPath, phyPathRegInp->objPath) != 0) {
00713
00714 if (isColl (rsComm, outLogPath, NULL) >= 0) {
00715 modAccessControlInp_t modAccessControl;
00716
00717
00718
00719 bzero (&modAccessControl, sizeof (modAccessControl));
00720 modAccessControl.accessLevel = "read";
00721 modAccessControl.userName = rsComm->clientUser.userName;
00722 modAccessControl.zone = rsComm->clientUser.rodsZone;
00723 modAccessControl.path = phyPathRegInp->objPath;
00724 status1 = rsModAccessControl(rsComm, &modAccessControl);
00725 if (status1 < 0) {
00726 rodsLog (LOG_NOTICE,
00727 "mountFileDir: rsModAccessControl err for %s, stat = %d",
00728 phyPathRegInp->objPath, status1);
00729 }
00730 }
00731 }
00732 }
00733
00734 rodsLog( LOG_NOTICE, "mountFileDir return status." );
00735 return (status);
00736 }
00737
00738 int
00739 unmountFileDir (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp)
00740 {
00741 int status;
00742 collInp_t modCollInp;
00743 rodsObjStat_t *rodsObjStatOut = NULL;
00744
00745 status = collStat (rsComm, phyPathRegInp, &rodsObjStatOut);
00746 if (status < 0 || NULL == rodsObjStatOut ) {
00747 return status;
00748 } else if (rodsObjStatOut->specColl == NULL) {
00749 freeRodsObjStat (rodsObjStatOut);
00750 rodsLog (LOG_ERROR,
00751 "unmountFileDir: %s not mounted", phyPathRegInp->objPath);
00752 return (SYS_COLL_NOT_MOUNTED_ERR);
00753 }
00754
00755 if (getStructFileType (rodsObjStatOut->specColl) >= 0) {
00756
00757 status = _rsSyncMountedColl (rsComm, rodsObjStatOut->specColl,
00758 PURGE_STRUCT_FILE_CACHE);
00759 #if 0
00760 if (status < 0) {
00761 freeRodsObjStat (rodsObjStatOut);
00762 return (status);
00763 }
00764 #endif
00765 }
00766
00767 freeRodsObjStat (rodsObjStatOut);
00768
00769 memset (&modCollInp, 0, sizeof (modCollInp));
00770 rstrcpy (modCollInp.collName, phyPathRegInp->objPath, MAX_NAME_LEN);
00771 addKeyVal (&modCollInp.condInput, COLLECTION_TYPE_KW,
00772 "NULL_SPECIAL_VALUE");
00773 addKeyVal (&modCollInp.condInput, COLLECTION_INFO1_KW, "NULL_SPECIAL_VALUE");
00774 addKeyVal (&modCollInp.condInput, COLLECTION_INFO2_KW, "NULL_SPECIAL_VALUE");
00775
00776 status = rsModColl (rsComm, &modCollInp);
00777
00778 return (status);
00779 }
00780
00781 int structFileReg(
00782 rsComm_t* rsComm,
00783 dataObjInp_t* phyPathRegInp ) {
00784
00785
00786 dataObjInp_t dataObjInp;
00787 collInp_t collCreateInp;
00788 int status = 0;
00789 int len = 0;
00790 char* collType = NULL;
00791 char* structFilePath = NULL;
00792 dataObjInfo_t* dataObjInfo = NULL;
00793 rodsObjStat_t* rodsObjStatOut = NULL;
00794 specCollCache_t* specCollCache = NULL;
00795
00796 #if 0
00797
00798 if (rsComm->clientUser.authInfo.authFlag < LOCAL_PRIV_USER_AUTH)
00799 return(CAT_INSUFFICIENT_PRIVILEGE_LEVEL);
00800 #endif
00801 if ((structFilePath = getValByKey (&phyPathRegInp->condInput, FILE_PATH_KW))
00802 == NULL) {
00803 rodsLog (LOG_ERROR,
00804 "structFileReg: No structFilePath input for %s",
00805 phyPathRegInp->objPath);
00806 return (SYS_INVALID_FILE_PATH);
00807 }
00808
00809 collType = getValByKey (&phyPathRegInp->condInput, COLLECTION_TYPE_KW);
00810 if (collType == NULL) {
00811 rodsLog (LOG_ERROR,
00812 "structFileReg: Bad COLLECTION_TYPE_KW for structFilePath %s",
00813 dataObjInp.objPath);
00814 return (SYS_INTERNAL_NULL_INPUT_ERR);
00815 }
00816
00817 len = strlen (phyPathRegInp->objPath);
00818 if (strncmp (structFilePath, phyPathRegInp->objPath, len) == 0 &&
00819 (structFilePath[len] == '\0' || structFilePath[len] == '/')) {
00820 rodsLog (LOG_ERROR,
00821 "structFileReg: structFilePath %s inside collection %s",
00822 structFilePath, phyPathRegInp->objPath);
00823 return (SYS_STRUCT_FILE_INMOUNTED_COLL);
00824 }
00825
00826
00827
00828 if (getSpecCollCache (rsComm, structFilePath, 0, &specCollCache) >= 0) {
00829 rodsLog (LOG_ERROR,
00830 "structFileReg: structFilePath %s is in a mounted path",
00831 structFilePath);
00832 return (SYS_STRUCT_FILE_INMOUNTED_COLL);
00833 }
00834
00835 status = collStat (rsComm, phyPathRegInp, &rodsObjStatOut);
00836 if (status < 0 || NULL == rodsObjStatOut ) return status;
00837
00838 if (rodsObjStatOut->specColl != NULL) {
00839 freeRodsObjStat (rodsObjStatOut);
00840 rodsLog (LOG_ERROR,
00841 "structFileReg: %s already mounted", phyPathRegInp->objPath);
00842 return (SYS_MOUNT_MOUNTED_COLL_ERR);
00843 }
00844
00845 freeRodsObjStat (rodsObjStatOut);
00846
00847 if (isCollEmpty (rsComm, phyPathRegInp->objPath) == False) {
00848 rodsLog (LOG_ERROR,
00849 "structFileReg: collection %s not empty", phyPathRegInp->objPath);
00850 return (SYS_COLLECTION_NOT_EMPTY);
00851 }
00852
00853 memset (&dataObjInp, 0, sizeof (dataObjInp));
00854 rstrcpy (dataObjInp.objPath, structFilePath, sizeof (dataObjInp));
00855
00856 dataObjInp.openFlags = O_WRONLY;
00857 status = getDataObjInfoIncSpecColl (rsComm, &dataObjInp, &dataObjInfo);
00858 if (status < 0 || NULL == dataObjInfo) {
00859 int myStatus;
00860
00861 dataObjInp.condInput = phyPathRegInp->condInput;
00862
00863 rmKeyVal (&dataObjInp.condInput, FILE_PATH_KW);
00864 myStatus = rsDataObjCreate (rsComm, &dataObjInp);
00865 if (myStatus < 0 ) {
00866 rodsLog (LOG_ERROR,
00867 "structFileReg: Problem with open/create structFilePath %s, status = %d",
00868 dataObjInp.objPath, status);
00869 return (status);
00870 } else {
00871 openedDataObjInp_t dataObjCloseInp;
00872 bzero (&dataObjCloseInp, sizeof (dataObjCloseInp));
00873 dataObjCloseInp.l1descInx = myStatus;
00874 rsDataObjClose (rsComm, &dataObjCloseInp);
00875 }
00876 }
00877
00878 char* tmp_hier = getValByKey( &phyPathRegInp->condInput, RESC_HIER_STR_KW );
00879 if( !tmp_hier ) {
00880 rodsLog( LOG_ERROR, "structFileReg - RESC_HIER_STR_KW is NULL" );
00881 return -1;
00882 }
00883
00884 #if 0 // JMC - no longer necessary
00885 if (!structFileSupport (rsComm, phyPathRegInp->objPath,
00886 collType, tmp_hier)) {
00887 rodsLog (LOG_ERROR,
00888 "structFileReg: structFileDriver type %s does not exist for %s",
00889 collType, dataObjInp.objPath);
00890 return (SYS_NOT_SUPPORTED);
00891 }
00892 #endif // JMC - no longer necessary
00893
00894
00895
00896 memset( &collCreateInp, 0, sizeof (collCreateInp) );
00897 rstrcpy( collCreateInp.collName, phyPathRegInp->objPath, MAX_NAME_LEN );
00898 addKeyVal( &collCreateInp.condInput, COLLECTION_TYPE_KW, collType );
00899
00900 addKeyVal( &collCreateInp.condInput, COLLECTION_INFO1_KW, dataObjInp.objPath );
00901
00902
00903
00904 status = rsModColl (rsComm, &collCreateInp);
00905
00906 if (status < 0) {
00907 status = rsRegColl (rsComm, &collCreateInp);
00908 }
00909
00910 return (status);
00911 }
00912
00913 int
00914 structFileSupport (rsComm_t *rsComm, char *collection, char *collType,
00915 char* resc_hier )
00916 {
00917 rodsStat_t *myStat = NULL;
00918 int status;
00919 subFile_t subFile;
00920 specColl_t specColl;
00921
00922 if (rsComm == NULL || collection == NULL || collType == NULL ||
00923 resc_hier == NULL) return 0;
00924
00925 memset (&subFile, 0, sizeof (subFile));
00926 memset (&specColl, 0, sizeof (specColl));
00927
00928 subFile.specColl = &specColl;
00929 rstrcpy (specColl.collection, collection, MAX_NAME_LEN);
00930 specColl.collClass = STRUCT_FILE_COLL;
00931 if (strcmp (collType, HAAW_STRUCT_FILE_STR) == 0) {
00932 specColl.type = HAAW_STRUCT_FILE_T;
00933 } else if (strcmp (collType, TAR_STRUCT_FILE_STR) == 0) {
00934 specColl.type = TAR_STRUCT_FILE_T;
00935 } else {
00936 return (0);
00937 }
00938
00939
00940
00941 std::string location;
00942 eirods::error ret = eirods::get_loc_for_hier_string( resc_hier, location );
00943 if( !ret.ok() ) {
00944 eirods::log( PASSMSG( "failed in get_loc_for_hier_String", ret ) );
00945 return -1;
00946 }
00947
00948 eirods::hierarchy_parser parser;
00949 parser.set_string( resc_hier );
00950 std::string first_resc;
00951 parser.first_resc( first_resc );
00952
00953 snprintf (specColl.objPath, MAX_NAME_LEN, "%s/myFakeFile",collection);
00954 rstrcpy (specColl.resource, first_resc.c_str(), NAME_LEN);
00955 rstrcpy (specColl.rescHier, resc_hier, NAME_LEN);
00956 rstrcpy (specColl.phyPath, "/fakeDir1/fakeDir2/myFakeStructFile", MAX_NAME_LEN );
00957 rstrcpy (subFile.subFilePath, "/fakeDir1/fakeDir2/myFakeFile", MAX_NAME_LEN);
00958 rstrcpy (subFile.addr.hostAddr, location.c_str(), NAME_LEN);
00959
00960 status = rsSubStructFileStat (rsComm, &subFile, &myStat);
00961
00962 if (status == SYS_NOT_SUPPORTED)
00963 return (0);
00964 else
00965 return (1);
00966 }
00967
00968 int
00969 linkCollReg (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp)
00970 {
00971 collInp_t collCreateInp;
00972 int status;
00973 char *linkPath = NULL;
00974 char *collType;
00975 int len;
00976 rodsObjStat_t *rodsObjStatOut = NULL;
00977 specCollCache_t *specCollCache = NULL;
00978
00979 if ((linkPath = getValByKey (&phyPathRegInp->condInput, FILE_PATH_KW))
00980 == NULL) {
00981 rodsLog (LOG_ERROR,
00982 "linkCollReg: No linkPath input for %s",
00983 phyPathRegInp->objPath);
00984 return (SYS_INVALID_FILE_PATH);
00985 }
00986
00987 collType = getValByKey (&phyPathRegInp->condInput, COLLECTION_TYPE_KW);
00988 if (collType == NULL || strcmp (collType, LINK_POINT_STR) != 0) {
00989 rodsLog (LOG_ERROR,
00990 "linkCollReg: Bad COLLECTION_TYPE_KW for linkPath %s",
00991 phyPathRegInp->objPath);
00992 return (SYS_INTERNAL_NULL_INPUT_ERR);
00993 }
00994
00995 if (phyPathRegInp->objPath[0] != '/' || linkPath[0] != '/') {
00996 rodsLog (LOG_ERROR,
00997 "linkCollReg: linkPath %s or collection %s not absolute path",
00998 linkPath, phyPathRegInp->objPath);
00999 return (SYS_COLL_LINK_PATH_ERR);
01000 }
01001
01002 len = strlen (phyPathRegInp->objPath);
01003 if (strncmp (linkPath, phyPathRegInp->objPath, len) == 0 &&
01004 linkPath[len] == '/') {
01005 rodsLog (LOG_ERROR,
01006 "linkCollReg: linkPath %s inside collection %s",
01007 linkPath, phyPathRegInp->objPath);
01008 return (SYS_COLL_LINK_PATH_ERR);
01009 }
01010
01011 len = strlen (linkPath);
01012 if (strncmp (phyPathRegInp->objPath, linkPath, len) == 0 &&
01013 phyPathRegInp->objPath[len] == '/') {
01014 rodsLog (LOG_ERROR,
01015 "linkCollReg: collection %s inside linkPath %s",
01016 linkPath, phyPathRegInp->objPath);
01017 return (SYS_COLL_LINK_PATH_ERR);
01018 }
01019
01020 if (getSpecCollCache (rsComm, linkPath, 0, &specCollCache) >= 0 &&
01021 specCollCache->specColl.collClass != LINKED_COLL) {
01022 rodsLog (LOG_ERROR,
01023 "linkCollReg: linkPath %s is in a spec coll path",
01024 linkPath);
01025 return (SYS_COLL_LINK_PATH_ERR);
01026 }
01027
01028 status = collStat (rsComm, phyPathRegInp, &rodsObjStatOut);
01029 if (status < 0) {
01030
01031 collInp_t collCreateInp;
01032 memset (&collCreateInp, 0, sizeof (collCreateInp));
01033 rstrcpy (collCreateInp.collName, phyPathRegInp->objPath, MAX_NAME_LEN);
01034 status = rsRegColl (rsComm, &collCreateInp);
01035 if (status < 0) {
01036 rodsLog (LOG_ERROR,
01037 "linkCollReg: rsRegColl error for %s, status = %d",
01038 collCreateInp.collName, status);
01039 return status;
01040 }
01041 status = collStat (rsComm, phyPathRegInp, &rodsObjStatOut);
01042 if (status < 0 ) return status;
01043
01044 }
01045
01046 if ( rodsObjStatOut &&
01047 rodsObjStatOut->specColl != NULL &&
01048 rodsObjStatOut->specColl->collClass != LINKED_COLL) {
01049 freeRodsObjStat (rodsObjStatOut);
01050 rodsLog (LOG_ERROR,
01051 "linkCollReg: link collection %s in a spec coll path",
01052 phyPathRegInp->objPath);
01053 return (SYS_COLL_LINK_PATH_ERR);
01054 }
01055
01056 freeRodsObjStat (rodsObjStatOut);
01057
01058 if (isCollEmpty (rsComm, phyPathRegInp->objPath) == False) {
01059 rodsLog (LOG_ERROR,
01060 "linkCollReg: collection %s not empty", phyPathRegInp->objPath);
01061 return (SYS_COLLECTION_NOT_EMPTY);
01062 }
01063
01064
01065
01066 memset (&collCreateInp, 0, sizeof (collCreateInp));
01067 rstrcpy (collCreateInp.collName, phyPathRegInp->objPath, MAX_NAME_LEN);
01068 addKeyVal (&collCreateInp.condInput, COLLECTION_TYPE_KW, collType);
01069
01070
01071 addKeyVal (&collCreateInp.condInput, COLLECTION_INFO1_KW,
01072 linkPath);
01073
01074
01075 status = rsModColl (rsComm, &collCreateInp);
01076
01077 if (status < 0) {
01078 status = rsRegColl (rsComm, &collCreateInp);
01079 }
01080
01081 return (status);
01082 }
01083
01084 pathnamePatterns_t *
01085 readPathnamePatternsFromFile(rsComm_t *rsComm, char *filename, char* resc_hier )
01086 {
01087 int status;
01088 rodsStat_t *stbuf;
01089 fileStatInp_t fileStatInp;
01090 bytesBuf_t fileReadBuf;
01091 fileOpenInp_t fileOpenInp;
01092 fileReadInp_t fileReadInp;
01093 fileCloseInp_t fileCloseInp;
01094 int buf_len, fd;
01095 pathnamePatterns_t *pp;
01096
01097 if (rsComm == NULL || filename == NULL || resc_hier == NULL) {
01098 return NULL;
01099 }
01100
01101
01102
01103
01104 std::string location;
01105 eirods::error ret = eirods::get_loc_for_hier_string( resc_hier, location );
01106 if( !ret.ok() ) {
01107 eirods::log( PASSMSG( "failed in get_loc_for_hier_String", ret ) );
01108 return NULL;
01109 }
01110
01111 memset(&fileStatInp, 0, sizeof(fileStatInp));
01112 rstrcpy(fileStatInp.fileName, filename, MAX_NAME_LEN);
01113
01114 rstrcpy(fileStatInp.addr.hostAddr, location.c_str(), NAME_LEN);
01115 status = rsFileStat(rsComm, &fileStatInp, &stbuf);
01116 if (status != 0) {
01117 if (status != UNIX_FILE_STAT_ERR - ENOENT) {
01118 rodsLog(LOG_DEBUG, "readPathnamePatternsFromFile: can't stat %s. status = %d",
01119 fileStatInp.fileName, status);
01120 }
01121 return NULL;
01122 }
01123 buf_len = stbuf->st_size;
01124 free(stbuf);
01125
01126 memset(&fileOpenInp, 0, sizeof(fileOpenInp));
01127 rstrcpy(fileOpenInp.fileName, filename, MAX_NAME_LEN);
01128
01129 rstrcpy(fileOpenInp.addr.hostAddr, location.c_str(), NAME_LEN);
01130 fileOpenInp.flags = O_RDONLY;
01131 fd = rsFileOpen(rsComm, &fileOpenInp);
01132 if (fd < 0) {
01133 rodsLog(LOG_NOTICE,
01134 "readPathnamePatternsFromFile: can't open %s for reading. status = %d",
01135 fileOpenInp.fileName, fd);
01136 return NULL;
01137 }
01138
01139 memset(&fileReadBuf, 0, sizeof(fileReadBuf));
01140 fileReadBuf.buf = malloc(buf_len);
01141 if (fileReadBuf.buf == NULL) {
01142 rodsLog(LOG_NOTICE, "readPathnamePatternsFromFile: could not malloc buffer");
01143 return NULL;
01144 }
01145
01146 memset(&fileReadInp, 0, sizeof(fileReadInp));
01147 fileReadInp.fileInx = fd;
01148 fileReadInp.len = buf_len;
01149 status = rsFileRead(rsComm, &fileReadInp, &fileReadBuf);
01150
01151 memset(&fileCloseInp, 0, sizeof(fileCloseInp));
01152 fileCloseInp.fileInx = fd;
01153 rsFileClose(rsComm, &fileCloseInp);
01154
01155 if (status < 0) {
01156 rodsLog(LOG_NOTICE, "readPathnamePatternsFromFile: could not read %s. status = %d",
01157 fileOpenInp.fileName, status);
01158 free(fileReadBuf.buf);
01159 return NULL;
01160 }
01161
01162 pp = readPathnamePatterns((char*)fileReadBuf.buf, buf_len);
01163
01164 return pp;
01165 }
01166
01167