00001
00002
00003 #include "subStructFileStat.h"
00004 #include "miscServerFunct.h"
00005 #include "dataObjOpr.h"
00006
00007
00008
00009 #include "eirods_structured_object.h"
00010 #include "eirods_stacktrace.h"
00011
00012
00013
00014 int
00015 rsSubStructFileStat (rsComm_t *rsComm, subFile_t *subFile, rodsStat_t **subStructFileStatOut)
00016 {
00017 rodsServerHost_t *rodsServerHost;
00018 int remoteFlag;
00019 int status;
00020 remoteFlag = resolveHost (&subFile->addr, &rodsServerHost);
00021
00022 if (remoteFlag == LOCAL_HOST) {
00023 status = _rsSubStructFileStat (rsComm, subFile, subStructFileStatOut);
00024 } else if (remoteFlag == REMOTE_HOST) {
00025 status = remoteSubStructFileStat (rsComm, subFile, subStructFileStatOut,
00026 rodsServerHost);
00027 } else {
00028 if (remoteFlag < 0) {
00029 return (remoteFlag);
00030 } else {
00031 rodsLog (LOG_NOTICE,
00032 "rsSubStructFileStat: resolveHost returned unrecognized value %d",
00033 remoteFlag);
00034 return (SYS_UNRECOGNIZED_REMOTE_FLAG);
00035 }
00036 }
00037
00038 return (status);
00039 }
00040
00041 int
00042 remoteSubStructFileStat (rsComm_t *rsComm, subFile_t *subFile,
00043 rodsStat_t **subStructFileStatOut, rodsServerHost_t *rodsServerHost)
00044 {
00045 int status;
00046
00047 if (rodsServerHost == NULL) {
00048 rodsLog (LOG_NOTICE,
00049 "remoteSubStructFileStat: Invalid rodsServerHost");
00050 return SYS_INVALID_SERVER_HOST;
00051 }
00052
00053 if ((status = svrToSvrConnect (rsComm, rodsServerHost)) < 0) {
00054 return status;
00055 }
00056
00057 status = rcSubStructFileStat (rodsServerHost->conn, subFile, subStructFileStatOut);
00058
00059 if (status < 0 && getErrno (status) != ENOENT) {
00060 rodsLog (LOG_NOTICE,
00061 "remoteSubStructFileStat: rcSubStructFileStat failed for %s, status = %d",
00062 subFile->subFilePath, status);
00063 }
00064
00065 return status;
00066 }
00067
00068 int _rsSubStructFileStat( rsComm_t* _comm,
00069 subFile_t* _sub_file,
00070 rodsStat_t** _stat_out ) {
00071
00072
00073 eirods::structured_object struct_obj( *_sub_file );
00074 struct_obj.comm( _comm );
00075
00076 struct_obj.resc_hier( eirods::EIRODS_LOCAL_USE_ONLY_RESOURCE );
00077
00078
00079
00080 struct stat my_stat;
00081 eirods::error stat_err = fileStat( _comm, struct_obj, &my_stat );
00082
00083 if( !stat_err.ok() ) {
00084
00085 #if 0
00086 std::stringstream msg;
00087 msg << "_rsSubStructFileStat - failed on call to fileStat for [";
00088 msg << struct_obj.physical_path();
00089 msg << "]";
00090 eirods::log( PASS( false, -1, msg.str(), stat_err ) );
00091 #endif
00092 return stat_err.code();
00093
00094 } else {
00095
00096
00097
00098 *_stat_out = new rodsStat_t;
00099 int status = statToRodsStat( *_stat_out, &my_stat );
00100
00101
00102
00103 if( status < 0 ) {
00104 delete (*_stat_out);
00105 *_stat_out = NULL;
00106 }
00107
00108 return status;
00109
00110 }
00111
00112 }
00113