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