00001
00002
00003 #include "subStructFileOpendir.h"
00004 #include "miscServerFunct.h"
00005 #include "dataObjOpr.h"
00006
00007
00008
00009 #include "eirods_structured_object.h"
00010
00011 int
00012 rsSubStructFileOpendir (rsComm_t *rsComm, subFile_t *subFile)
00013 {
00014 rodsServerHost_t *rodsServerHost;
00015 int remoteFlag;
00016 int fd;
00017
00018 remoteFlag = resolveHost (&subFile->addr, &rodsServerHost);
00019
00020 if (remoteFlag == LOCAL_HOST) {
00021 fd = _rsSubStructFileOpendir (rsComm, subFile);
00022 } else if (remoteFlag == REMOTE_HOST) {
00023 fd = remoteSubStructFileOpendir (rsComm, subFile, rodsServerHost);
00024 } else {
00025 if (remoteFlag < 0) {
00026 return (remoteFlag);
00027 } else {
00028 rodsLog (LOG_NOTICE,
00029 "rsSubStructFileOpendir: resolveHost returned unrecognized value %d",
00030 remoteFlag);
00031 return (SYS_UNRECOGNIZED_REMOTE_FLAG);
00032 }
00033 }
00034
00035 return (fd);
00036 }
00037
00038 int
00039 remoteSubStructFileOpendir (rsComm_t *rsComm, subFile_t *subFile,
00040 rodsServerHost_t *rodsServerHost)
00041 {
00042 int fd;
00043 int status;
00044
00045 if (rodsServerHost == NULL) {
00046 rodsLog (LOG_NOTICE,
00047 "remoteSubStructFileOpendir: Invalid rodsServerHost");
00048 return SYS_INVALID_SERVER_HOST;
00049 }
00050
00051 if ((status = svrToSvrConnect (rsComm, rodsServerHost)) < 0) {
00052 return status;
00053 }
00054
00055 fd = rcSubStructFileOpendir (rodsServerHost->conn, subFile);
00056
00057 if (fd < 0) {
00058 rodsLog (LOG_NOTICE,
00059 "remoteSubStructFileOpendir: rcSubStructFileOpendir failed for %s, status = %d",
00060 subFile->subFilePath, fd);
00061 }
00062
00063 return fd;
00064 }
00065
00066 int _rsSubStructFileOpendir( rsComm_t* _comm,
00067 subFile_t* _sub_file ) {
00068
00069
00070 eirods::structured_object struct_obj( *_sub_file );
00071 struct_obj.comm( _comm );
00072
00073 struct_obj.resc_hier( eirods::EIRODS_LOCAL_USE_ONLY_RESOURCE );
00074
00075
00076
00077 eirods::error opendir_err = fileOpendir( _comm, struct_obj );
00078 if( !opendir_err.ok() ) {
00079 std::stringstream msg;
00080 msg << "failed on call to fileOpendir for [";
00081 msg << struct_obj.physical_path();
00082 msg << "]";
00083 eirods::log( PASSMSG( msg.str(), opendir_err ) );
00084 return opendir_err.code();
00085
00086 } else {
00087 return opendir_err.code();
00088
00089 }
00090 }
00091