irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

rsFileRead.cpp
Go to the documentation of this file.
1 
3 /* rsFileRead.c - server routine that handles the fileRead
4  * API
5  */
6 
7 /* script generated code */
8 #include "fileRead.h"
9 #include "miscServerFunct.hpp"
10 #include "rsGlobalExtern.hpp"
11 #include "rsFileRead.hpp"
12 
13 // =-=-=-=-=-=-=-
14 #include "irods_log.hpp"
15 #include "irods_file_object.hpp"
16 #include "irods_stacktrace.hpp"
17 
18 int
19 rsFileRead( rsComm_t *rsComm, fileReadInp_t *fileReadInp,
20  bytesBuf_t *fileReadOutBBuf ) {
22  int remoteFlag;
23  int retVal;
24 
25 
26  remoteFlag = getServerHostByFileInx( fileReadInp->fileInx,
27  &rodsServerHost );
28 
29  if ( fileReadInp->len > 0 ) {
30  if ( fileReadOutBBuf->buf == NULL ) {
31  fileReadOutBBuf->buf = malloc( fileReadInp->len );
32  }
33  }
34  else {
35  return 0;
36  }
37 
38  if ( remoteFlag == LOCAL_HOST ) {
39  retVal = _rsFileRead( rsComm, fileReadInp, fileReadOutBBuf );
40  }
41  else if ( remoteFlag == REMOTE_HOST ) {
42  retVal = remoteFileRead( rsComm, fileReadInp, fileReadOutBBuf,
44  }
45  else {
46  if ( remoteFlag < 0 ) {
47  return remoteFlag;
48  }
49  else {
51  "rsFileRead: resolveHost returned unrecognized value %d",
52  remoteFlag );
54  }
55  }
56 
57  return retVal;
58 }
59 
60 int
61 remoteFileRead( rsComm_t *rsComm, fileReadInp_t *fileReadInp,
62  bytesBuf_t *fileReadOutBBuf, rodsServerHost_t *rodsServerHost ) {
63  int retVal;
64 
65  if ( rodsServerHost == NULL ) {
67  "remoteFileRead: Invalid rodsServerHost" );
69  }
70 
71  if ( ( retVal = svrToSvrConnect( rsComm, rodsServerHost ) ) < 0 ) {
72  return retVal;
73  }
74 
75  fileReadInp->fileInx = convL3descInx( fileReadInp->fileInx );
76  retVal = rcFileRead( rodsServerHost->conn, fileReadInp,
77  fileReadOutBBuf );
78 
79  if ( retVal < 0 ) {
81  "remoteFileRead: rcFileRead failed for %s",
82  FileDesc[fileReadInp->fileInx].fileName );
83  }
84 
85  return retVal;
86 }
87 
88 /* _rsFileRead - this the local version of rsFileRead.
89  */
90 
92  rsComm_t* _comm,
93  fileReadInp_t* _read_inp,
94  bytesBuf_t* _read_bbuf ) {
95  // =-=-=-=-=-=-=-
96  // XXXX need to check resource permission and vault permission
97  // when RCAT is available
98 
99  // =-=-=-=-=-=-=-
100  // call resource plugin for POSIX read
101  irods::file_object_ptr file_obj(
102  new irods::file_object(
103  _comm,
104  FileDesc[_read_inp->fileInx].objPath,
105  FileDesc[_read_inp->fileInx].fileName,
106  FileDesc[_read_inp->fileInx].rescHier,
107  FileDesc[_read_inp->fileInx].fd,
108  0, 0 ) );
109 
110  irods::error ret = fileRead( _comm,
111  file_obj,
112  _read_bbuf->buf,
113  _read_inp->len );
114  // =-=-=-=-=-=-=
115  // log an error if the read failed,
116  // pass long read error
117  if ( !ret.ok() ) {
118  std::stringstream msg;
119  msg << "fileRead failed for ";
120  msg << file_obj->physical_path();
121  msg << "]";
122  irods::error err = PASSMSG( msg.str(), ret );
123  irods::log( err );
124  }
125  else {
126  _read_bbuf->len = ret.code();
127  }
128 
129  return ret.code();
130 
131 } // _rsFileRead
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
NULL
#define NULL
Definition: rodsDef.h:70
rsComm_t
Definition: rcConnect.h:145
FileReadInp::len
int len
Definition: fileRead.h:9
BytesBuf::buf
void * buf
Definition: rodsDef.h:199
rcFileRead
int rcFileRead(rcComm_t *conn, fileReadInp_t *fileReadInp, bytesBuf_t *fileReadOutBBuf)
Definition: rcFileRead.cpp:24
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
SYS_UNRECOGNIZED_REMOTE_FLAG
@ SYS_UNRECOGNIZED_REMOTE_FLAG
Definition: rodsErrorTable.h:88
irods_file_object.hpp
irods_stacktrace.hpp
getServerHostByFileInx
int getServerHostByFileInx(int fileInx, rodsServerHost_t **rodsServerHost)
Definition: fileOpr.cpp:99
REMOTE_HOST
#define REMOTE_HOST
Definition: rodsConnect.h:45
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
fileDesc_t::rescHier
char * rescHier
Definition: fileOpr.hpp:28
fileRead.h
BytesBuf::len
int len
Definition: rodsDef.h:198
rsGlobalExtern.hpp
FileReadInp
Definition: fileRead.h:7
irods::error::code
long long code() const
Definition: irods_error.cpp:194
fileDesc_t::objPath
char * objPath
Definition: fileOpr.hpp:29
SYS_INVALID_SERVER_HOST
@ SYS_INVALID_SERVER_HOST
Definition: rodsErrorTable.h:89
convL3descInx
int convL3descInx(int l3descInx)
Definition: objDesc.cpp:571
svrToSvrConnect
int svrToSvrConnect(rsComm_t *rsComm, rodsServerHost_t *rodsServerHost)
Definition: miscServerFunct.cpp:106
remoteFileRead
int remoteFileRead(rsComm_t *rsComm, fileReadInp_t *fileReadInp, bytesBuf_t *fileReadOutBBuf, rodsServerHost_t *rodsServerHost)
Definition: rsFileRead.cpp:61
irods::log
void log(const error &)
Definition: irods_log.cpp:13
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
BytesBuf
Definition: rodsDef.h:197
irods::error
Definition: irods_error.hpp:23
FileReadInp::fileInx
int fileInx
Definition: fileRead.h:8
miscServerFunct.hpp
rsFileRead
int rsFileRead(rsComm_t *rsComm, fileReadInp_t *fileReadInp, bytesBuf_t *fileReadOutBBuf)
Definition: rsFileRead.cpp:19
FileDesc
fileDesc_t FileDesc[1026]
Definition: irods_server_globals.cpp:28
rsFileRead.hpp
irods::file_object
Definition: irods_file_object.hpp:19
rodsServerHost
Definition: rodsConnect.h:62
_rsFileRead
int _rsFileRead(rsComm_t *_comm, fileReadInp_t *_read_inp, bytesBuf_t *_read_bbuf)
Definition: rsFileRead.cpp:91
fileDesc_t::fd
int fd
Definition: fileOpr.hpp:32
irods::file_object_ptr
boost::shared_ptr< file_object > file_object_ptr
Definition: irods_file_object.hpp:145
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
fileDesc_t::fileName
char * fileName
Definition: fileOpr.hpp:27
irods_log.hpp
fileRead
irods::error fileRead(rsComm_t *, irods::first_class_object_ptr, void *, int)
Definition: fileDriver.cpp:81