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)  

rsFileOpen.cpp
Go to the documentation of this file.
1 
3 /* rsFileOpen.c - server routine that handles the fileOpen
4  * API
5  */
6 
7 /* script generated code */
8 #include "fileOpen.h"
9 #include "fileOpr.hpp"
10 #include "miscServerFunct.hpp"
11 #include "rsGlobalExtern.hpp"
12 #include "rsFileOpen.hpp"
13 
14 // =-=-=-=-=-=-=-
15 #include "irods_log.hpp"
16 #include "irods_file_object.hpp"
17 #include "irods_stacktrace.hpp"
19 
20 int
21 rsFileOpen( rsComm_t *rsComm, fileOpenInp_t *fileOpenInp ) {
23  int remoteFlag;
24  int fileInx;
25 
26  //remoteFlag = resolveHost (&fileOpenInp->addr, &rodsServerHost);
27  irods::error ret = irods::get_host_for_hier_string( fileOpenInp->resc_hier_, remoteFlag, rodsServerHost );
28  if ( !ret.ok() ) {
29  irods::log( PASSMSG( "failed in call to irods::get_host_for_hier_string", ret ) );
30  return -1;
31  }
32 
33 
34  if ( remoteFlag < 0 ) {
35  return remoteFlag;
36  }
37  else {
38  fileInx = rsFileOpenByHost( rsComm, fileOpenInp, rodsServerHost );
39  return fileInx;
40  }
41 }
42 
43 int
44 rsFileOpenByHost( rsComm_t *rsComm, fileOpenInp_t *fileOpenInp,
46  int fileInx;
47  int fd;
48  int remoteFlag;
49 
50  if ( rodsServerHost == NULL ) {
52  "rsFileOpenByHost: Input NULL rodsServerHost" );
54  }
55 
56  remoteFlag = rodsServerHost->localFlag;
57 
58  if ( remoteFlag == LOCAL_HOST ) {
59  fd = _rsFileOpen( rsComm, fileOpenInp );
60  }
61  else if ( remoteFlag == REMOTE_HOST ) {
62  fd = remoteFileOpen( rsComm, fileOpenInp, rodsServerHost );
63  }
64  else {
65  if ( remoteFlag < 0 ) {
66  return remoteFlag;
67  }
68  else {
70  "rsFileOpenByHost: resolveHost returned unrecognized value %d",
71  remoteFlag );
73  }
74  }
75 
76  if ( fd < 0 ) {
77  return fd;
78  }
79  fileInx = allocAndFillFileDesc( rodsServerHost, fileOpenInp->objPath, fileOpenInp->fileName, fileOpenInp->resc_hier_,
80  fd, fileOpenInp->mode );
81 
82  return fileInx;
83 }
84 
85 int
86 remoteFileOpen( rsComm_t *rsComm, fileOpenInp_t *fileOpenInp,
88  int fileInx;
89  int status;
90 
91  if ( rodsServerHost == NULL ) {
93  "remoteFileOpen: Invalid rodsServerHost" );
95  }
96 
97  if ( ( status = svrToSvrConnect( rsComm, rodsServerHost ) ) < 0 ) {
98  return status;
99  }
100 
101  fileInx = rcFileOpen( rodsServerHost->conn, fileOpenInp );
102 
103  if ( fileInx < 0 ) {
105  "remoteFileOpen: rcFileOpen failed for %s",
106  fileOpenInp->fileName );
107  }
108 
109  return fileInx;
110 }
111 
112 // =-=-=-=-=-=-=-
113 // _rsFileOpen - this the local version of rsFileOpen.
115  rsComm_t* _comm,
116  fileOpenInp_t* _open_inp ) {
117  // =-=-=-=-=-=-=-
118  // pointer check
119  if ( !_comm || !_open_inp ) {
120  rodsLog( LOG_ERROR, "_rsFileOpen - null comm or open_inp pointer(s)." );
121  return -1;
122  }
123 
124  // =-=-=-=-=-=-=-
125  // NOTE:: need to check resource permission and vault permission
126  // when RCAT is available
127  if ( ( _open_inp->flags & O_WRONLY ) && ( _open_inp->flags & O_RDWR ) ) {
128  /* both O_WRONLY and O_RDWR are on, can cause I/O to fail */
129  _open_inp->flags &= ~( O_WRONLY );
130  }
131 
132  // =-=-=-=-=-=-=-
133  // call file open on the resource plugin
134  irods::file_object_ptr file_obj(
135  new irods::file_object(
136  _comm,
137  _open_inp->objPath,
138  _open_inp->fileName,
139  _open_inp->resc_hier_,
140  0,
141  _open_inp->mode,
142  _open_inp->flags ) );
143  file_obj->in_pdmo( _open_inp->in_pdmo );
144 
145  // =-=-=-=-=-=-=-
146  // pass condInput
147  file_obj->cond_input( _open_inp->condInput );
148 
149  irods::error ret_err = fileOpen( _comm, file_obj );
150 
151  // =-=-=-=-=-=-=-
152  // log errors, if any.
153  // NOTE:: direct archive access is a special case in that we
154  // need to detect it and then carry on
155  if ( ret_err.code() == DIRECT_ARCHIVE_ACCESS ) {
156  return DIRECT_ARCHIVE_ACCESS;
157 
158  }
159  else if ( !ret_err.ok() ) {
160  std::stringstream msg;
161  msg << "_rsFileOpen: fileOpen for [";
162  msg << _open_inp->fileName;
163  msg << "]";
164  irods::error out_err = PASSMSG( msg.str(), ret_err );
165  irods::log( out_err );
166  return ret_err.code();
167 
168  } // if
169 
170  return file_obj->file_descriptor();
171 
172 } // _rsFileOpen
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
fileOpen.h
SYS_INTERNAL_NULL_INPUT_ERR
@ SYS_INTERNAL_NULL_INPUT_ERR
Definition: rodsErrorTable.h:92
rodsServerHost::localFlag
int localFlag
Definition: rodsConnect.h:68
rsFileOpen.hpp
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
REMOTE_HOST
#define REMOTE_HOST
Definition: rodsConnect.h:45
rsFileOpenByHost
int rsFileOpenByHost(rsComm_t *rsComm, fileOpenInp_t *fileOpenInp, rodsServerHost_t *rodsServerHost)
Definition: rsFileOpen.cpp:44
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
_rsFileOpen
int _rsFileOpen(rsComm_t *_comm, fileOpenInp_t *_open_inp)
Definition: rsFileOpen.cpp:114
irods_resource_backport.hpp
fileOpenInp_t::resc_hier_
char resc_hier_[(1024+64)]
Definition: fileOpen.h:16
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
fileOpenInp_t::fileName
char fileName[(1024+64)]
Definition: fileOpen.h:20
rsGlobalExtern.hpp
irods::error::code
long long code() const
Definition: irods_error.cpp:194
fileOpenInp_t::flags
int flags
Definition: fileOpen.h:21
fileOpenInp_t::objPath
char objPath[(1024+64)]
Definition: fileOpen.h:17
rcFileOpen
int rcFileOpen(rcComm_t *conn, fileOpenInp_t *fileOpenInp)
Definition: rcFileOpen.cpp:23
irods::get_host_for_hier_string
error get_host_for_hier_string(const std::string &, int &, rodsServerHost_t *&)
Definition: irods_resource_backport.cpp:581
SYS_INVALID_SERVER_HOST
@ SYS_INVALID_SERVER_HOST
Definition: rodsErrorTable.h:89
fileOpenInp_t::mode
int mode
Definition: fileOpen.h:22
remoteFileOpen
int remoteFileOpen(rsComm_t *rsComm, fileOpenInp_t *fileOpenInp, rodsServerHost_t *rodsServerHost)
Definition: rsFileOpen.cpp:86
svrToSvrConnect
int svrToSvrConnect(rsComm_t *rsComm, rodsServerHost_t *rodsServerHost)
Definition: miscServerFunct.cpp:106
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
allocAndFillFileDesc
int allocAndFillFileDesc(rodsServerHost_t *rodsServerHost, const std::string &objPath, const std::string &fileName, const std::string &rescHier, int fd, int mode)
Definition: fileOpr.cpp:48
irods::log
void log(const error &)
Definition: irods_log.cpp:13
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
fileOpen
irods::error fileOpen(rsComm_t *, irods::first_class_object_ptr)
Definition: fileDriver.cpp:49
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
fileOpenInp_t::condInput
keyValPair_t condInput
Definition: fileOpen.h:24
rsFileOpen
int rsFileOpen(rsComm_t *rsComm, fileOpenInp_t *fileOpenInp)
Definition: rsFileOpen.cpp:21
fileOpenInp_t
Definition: fileOpen.h:14
irods::file_object
Definition: irods_file_object.hpp:19
fileOpr.hpp
rodsServerHost
Definition: rodsConnect.h:62
irods::file_object_ptr
boost::shared_ptr< file_object > file_object_ptr
Definition: irods_file_object.hpp:145
fileOpenInp_t::in_pdmo
char in_pdmo[(1024+64)]
Definition: fileOpen.h:25
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
DIRECT_ARCHIVE_ACCESS
@ DIRECT_ARCHIVE_ACCESS
Definition: rodsErrorTable.h:763
irods_log.hpp