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