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)  

rsDataObjOpen.cpp
Go to the documentation of this file.
1 
3 /* This is script-generated code (for the most part). */
4 /* See dataObjOpen.h for a description of this API call.*/
5 
6 #include "dataObjOpen.h"
7 #include "dataObjOpenAndStat.h"
8 #include "rodsErrorTable.h"
9 #include "rodsLog.h"
10 #include "objMetaOpr.hpp"
11 #include "resource.hpp"
12 #include "resource.hpp"
13 #include "dataObjOpr.hpp"
14 #include "physPath.hpp"
15 #include "dataObjCreate.h"
16 #include "dataObjLock.h"
17 #include "rsDataObjOpen.hpp"
18 #include "apiNumber.h"
19 #include "rsDataObjCreate.hpp"
20 #include "rsModDataObjMeta.hpp"
21 #include "rsSubStructFileOpen.hpp"
22 #include "rsFileOpen.hpp"
23 #include "rsDataObjRepl.hpp"
24 #include "rsRegReplica.hpp"
25 #include "rsDataObjClose.hpp"
26 
27 #include "fileOpen.h"
28 #include "subStructFileOpen.h"
29 #include "rsGlobalExtern.hpp"
30 #include "rcGlobalExtern.h"
31 #include "getRemoteZoneResc.h"
32 #include "regReplica.h"
33 #include "regDataObj.h"
34 #include "dataObjClose.h"
35 #include "dataObjRepl.h"
36 
37 // =-=-=-=-=-=-=-
41 #include "irods_stacktrace.hpp"
44 
45 int rsDataObjOpen(rsComm_t *rsComm, dataObjInp_t *dataObjInp)
46 {
47  if (has_trailing_path_separator(dataObjInp->objPath)) {
48  return USER_INPUT_PATH_ERR;
49  }
50 
51  if ((dataObjInp->openFlags & O_ACCMODE) == O_RDONLY && (dataObjInp->openFlags & O_TRUNC)) {
53  }
54 
55  int status, l1descInx;
56  int remoteFlag;
58 
59  remoteFlag = getAndConnRemoteZone( rsComm, dataObjInp, &rodsServerHost,
60  REMOTE_OPEN );
61  if ( remoteFlag < 0 ) {
62  return remoteFlag;
63  }
64  else if ( remoteFlag == REMOTE_HOST ) {
65  openStat_t *openStat = NULL;
67  &openStat );
68  if ( status < 0 ) {
69  return status;
70  }
71  l1descInx = allocAndSetL1descForZoneOpr( status, dataObjInp,
72  rodsServerHost, openStat );
73  if ( openStat != NULL ) {
74  free( openStat );
75  }
76  return l1descInx;
77  }
78  else {
79  // dataObjInfo_t linked list
80  dataObjInfo_t *dataObjInfoHead = NULL;
81 
82  // resource hierarchy
83  std::string hier;
84 
85  // =-=-=-=-=-=-=-
86  // determine the resource hierarchy if one is not provided
87  if ( getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW ) == NULL ) {
88 
91  rsComm,
92  dataObjInp,
93  hier,
94  &dataObjInfoHead );
95  if (ret.ok()) {
96  // =-=-=-=-=-=-=-
97  // we resolved the redirect and have a host, set the hier str for subsequent
98  // api calls, etc.
99  addKeyVal( &dataObjInp->condInput, RESC_HIER_STR_KW, hier.c_str() );
100  }
101 
102  }
103  else {
104  // file object for file_object_factory
105  irods::file_object_ptr file_obj( new irods::file_object() );
106 
107  // get resource hierarchy from condInput
108  hier = getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW );
109 
110  // get replicas vector populated
111  irods::error fac_err = irods::file_object_factory(rsComm, dataObjInp, file_obj, &dataObjInfoHead);
112 
113  }// if ( getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW ) == NULL )
114 
115  l1descInx = _rsDataObjOpen( rsComm, dataObjInp, dataObjInfoHead );
116 
117  }
118 
119  return l1descInx;
120 }
121 
122 /* _rsDataObjOpen - handle internal server dataObj open request.
123  * valid phyOpenFlag are DO_PHYOPEN, DO_NOT_PHYOPEN and PHYOPEN_BY_SIZE
124  */
125 
126 int
127 _rsDataObjOpen( rsComm_t *rsComm, dataObjInp_t *dataObjInp, dataObjInfo_t *dataObjInfoHead ) {
128  int status = 0;
129  int phyOpenFlag = DO_PHYOPEN;
130  if ( getValByKey( &dataObjInp->condInput, NO_OPEN_FLAG_KW ) != NULL ) {
131  phyOpenFlag = DO_NOT_PHYOPEN;
132  }
133  else if ( getValByKey( &dataObjInp->condInput, PHYOPEN_BY_SIZE_KW )
134  != NULL ) {
135  phyOpenFlag = PHYOPEN_BY_SIZE;
136  }
137  // =-=-=-=-=-=-=-
138  // JMC - backport 4604
139  char * lockType = getValByKey( &dataObjInp->condInput, LOCK_TYPE_KW );
140  int lockFd = -1; // JMC - backport 4604
141  if ( lockType != NULL ) {
142  lockFd = irods::server_api_call(
144  rsComm,
145  dataObjInp,
146  NULL,
147  ( void** ) NULL,
148  NULL );
149  if ( lockFd > 0 ) {
150  /* rm it so it won't be done again causing deadlock */
151  rmKeyVal( &dataObjInp->condInput, LOCK_TYPE_KW );
152  }
153  else {
154  rodsLogError( LOG_ERROR, lockFd,
155  "_rsDataObjOpen: lock error for %s. lockType = %s",
156  dataObjInp->objPath, lockType );
157  return lockFd;
158  }
159  }
160 
161  int writeFlag = getWriteFlag( dataObjInp->openFlags );
162 
163  // check earlier attempt at resolving resource hierarchy
164  if (!getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW)) {
165  int l1descInx = 0;
166  if ( dataObjInp->openFlags & O_CREAT && writeFlag > 0 ) {
167  l1descInx = rsDataObjCreate( rsComm, dataObjInp );
168  status = l1descInx; // JMC - backport 4604
169  }
170  // =-=-=-=-=-=-=-
171  // JMC - backport 4604
172  if ( lockFd >= 0 ) {
173  if ( status > 0 ) {
174  L1desc[l1descInx].lockFd = lockFd;
175  }
176  else {
177  char fd_string[NAME_LEN];
178  snprintf( fd_string, sizeof( fd_string ), "%-d", lockFd );
179  addKeyVal( &dataObjInp->condInput, LOCK_FD_KW, fd_string );
182  rsComm,
183  dataObjInp,
184  NULL,
185  ( void** ) NULL,
186  NULL );
187 
188  }
189  }
190  return status;
191  }
192  else {
194  /* screen out any stale copies */
195  status = sortObjInfoForOpen( &dataObjInfoHead, &dataObjInp->condInput, writeFlag );
196  if ( status < 0 ) { // JMC - backport 4604
197  if ( lockFd > 0 ) {
198  char fd_string[NAME_LEN];
199  snprintf( fd_string, sizeof( fd_string ), "%-d", lockFd );
200  addKeyVal( &dataObjInp->condInput, LOCK_FD_KW, fd_string );
203  rsComm,
204  dataObjInp,
205  NULL,
206  ( void** ) NULL,
207  NULL );
208 
209 
210  }
211  std::stringstream msg;
212  msg << __FUNCTION__;
213  msg << " - Unable to select a data obj info matching the resource hierarchy from the keywords.";
214  irods::log( ERROR( status, msg.str() ) );
215  return status;
216  }
218  status = applyPreprocRuleForOpen( rsComm, dataObjInp, &dataObjInfoHead );
219  if ( status < 0 ) { // JMC - backport 4604
220  if ( lockFd > 0 ) {
221  char fd_string[NAME_LEN];
222  snprintf( fd_string, sizeof( fd_string ), "%-d", lockFd );
223  addKeyVal( &dataObjInp->condInput, LOCK_FD_KW, fd_string );
226  rsComm,
227  dataObjInp,
228  NULL,
229  ( void** ) NULL,
230  NULL );
231 
232  }
233  return status;
234  }
235  }
236 
237  dataObjInfo_t * compDataObjInfo = NULL;
238  if ( getStructFileType( dataObjInfoHead->specColl ) >= 0 ) {
239  /* special coll. Nothing to do */
240  }
241  else if ( writeFlag > 0 ) {
242  // JMC :: had to reformat this code to find a missing {
243  // :: i seriously hope its in the right place...
244  status = procDataObjOpenForWrite( rsComm, dataObjInp, &dataObjInfoHead, &compDataObjInfo );
245  }
246 
247  if ( status < 0 ) {
248  if ( lockFd > 0 ) {
249  char fd_string[NAME_LEN];
250  snprintf( fd_string, sizeof( fd_string ), "%-d", lockFd );
251  addKeyVal( &dataObjInp->condInput, LOCK_FD_KW, fd_string );
254  rsComm,
255  dataObjInp,
256  NULL,
257  ( void** ) NULL,
258  NULL );
259  }
260  freeAllDataObjInfo( dataObjInfoHead );
261  return status;
262  }
263 
264  std::string resc_class;
265  irods::error prop_err = irods::get_resource_property<std::string>(
266  dataObjInfoHead->rescId, "class", resc_class );
267  if ( prop_err.ok() ) {
268  if ( resc_class == "bundle" ) {
269  status = stageBundledData( rsComm, &dataObjInfoHead );
270  if ( status < 0 ) {
272  "_rsDataObjOpen: stageBundledData of %s failed stat=%d",
273  dataObjInfoHead->objPath, status );
274  freeAllDataObjInfo( dataObjInfoHead );
275  if ( lockFd >= 0 ) {
276  char fd_string[NAME_LEN];
277  snprintf( fd_string, sizeof( fd_string ), "%-d", lockFd );
278  addKeyVal( &dataObjInp->condInput, LOCK_FD_KW, fd_string );
281  rsComm,
282  dataObjInp,
283  NULL,
284  ( void** ) NULL,
285  NULL );
286  }
287  return status;
288  }
289  }
290  }
291 
292  /* If compDataObjInfo != NULL, an existing COMPOUND_CL DataObjInfo exist.
293  * Need to replicate to * this DataObjInfo in rsdataObjClose.
294  * For read, compDataObjInfo should be NULL. */
295  dataObjInfo_t * tmpDataObjInfo = dataObjInfoHead;
296 
297  while ( tmpDataObjInfo != NULL ) {
298  dataObjInfo_t * nextDataObjInfo = tmpDataObjInfo->next;
299  tmpDataObjInfo->next = NULL;
300 
301  int l1descInx = status = _rsDataObjOpenWithObjInfo( rsComm, dataObjInp, phyOpenFlag, tmpDataObjInfo );
302 
303  if ( l1descInx >= 0 ) {
304  if ( compDataObjInfo != NULL ) {
305  L1desc[l1descInx].replDataObjInfo = compDataObjInfo;
306  }
307 
308  dataObjInfo_t *otherDataObjInfo = NULL;
309  queDataObjInfo( &otherDataObjInfo, nextDataObjInfo, 0, 1 ); // JMC - backport 4542
310  L1desc[l1descInx].otherDataObjInfo = otherDataObjInfo; // JMC - backport 4542
311 
312  if ( writeFlag > 0 ) {
313  L1desc[l1descInx].openType = OPEN_FOR_WRITE_TYPE;
314  }
315  else {
316  L1desc[l1descInx].openType = OPEN_FOR_READ_TYPE;
317  }
318  if ( lockFd >= 0 ) {
319  L1desc[l1descInx].lockFd = lockFd;
320  }
321  return l1descInx;
322 
323  } // if l1descInx >= 0
324 
325  tmpDataObjInfo = nextDataObjInfo;
326  } // while
327 
328  return status;
329 } // BAD
330 
331 /* _rsDataObjOpenWithObjInfo - given a dataObjInfo, open a single copy
332  * of the data object.
333  *
334  * return l1descInx
335  */
336 
337 int
339  int phyOpenFlag, dataObjInfo_t *dataObjInfo ) { // JMC - backport 4537
340  int replStatus;
341  int status;
342  int l1descInx;
343  l1descInx = allocL1desc();
344 
345  if ( l1descInx < 0 ) {
346  return l1descInx;
347  }
348 
349  // kv pasthru
350  copyKeyVal(
351  &dataObjInp->condInput,
352  &dataObjInfo->condInput );
353 
354  replStatus = dataObjInfo->replStatus | OPEN_EXISTING_COPY;
355 
356  /* the size was set to -1 because we don't know the target size.
357  * For copy and replicate, the calling routine should modify this
358  * dataSize */
359  fillL1desc( l1descInx, dataObjInp, dataObjInfo, replStatus, -1 );
360  if ( getValByKey( &dataObjInp->condInput, PURGE_CACHE_KW ) != NULL ) {
361  L1desc[l1descInx].purgeCacheFlag = 1;
362  }
363 
364  if ( phyOpenFlag == DO_NOT_PHYOPEN ) {
365  /* don't actually physically open the file */
366  status = 0;
367  }
368  else if ( phyOpenFlag == PHYOPEN_BY_SIZE ) {
369  int single_buff_sz;
370  try {
371  single_buff_sz = irods::get_advanced_setting<const int>(irods::CFG_MAX_SIZE_FOR_SINGLE_BUFFER) * 1024 * 1024;
372  } catch ( const irods::exception& e ) {
373  irods::log(e);
374  return e.code();
375  }
376 
377  /* open for put or get. May do "dataInclude" */
378  if ( getValByKey( &dataObjInp->condInput, DATA_INCLUDED_KW ) != NULL
379  && dataObjInfo->dataSize <= single_buff_sz ) {
380  status = 0;
381  }
382  else if ( dataObjInfo->dataSize != UNKNOWN_FILE_SZ &&
383  dataObjInfo->dataSize <= single_buff_sz ) {
384  status = 0;
385  }
386  else {
387  status = dataOpen( rsComm, l1descInx );
388  }
389  }
390  else {
391  status = dataOpen( rsComm, l1descInx );
392  }
393 
394  if ( status < 0 ) {
395  freeL1desc( l1descInx );
396  return status;
397  }
398  else {
399  return l1descInx;
400  }
401 }
402 
403 int dataOpen(rsComm_t *rsComm, int l1descInx)
404 {
405  auto& fd = L1desc[l1descInx];
406  dataObjInfo_t *info = fd.dataObjInfo;
407 
408  int status = l3Open(rsComm, l1descInx);
409 
410  if (status <= 0) {
411  rodsLog(LOG_NOTICE, "dataOpen: l3Open of %s failed, status = %d", info->filePath, status);
412  return status;
413  }
414 
415  fd.l3descInx = status;
416 
417  // Set the size of the data object to zero in the catalog if the file was truncated.
418  // It is important that the catalog reflect truncation immediately because operations
419  // following the open may depend on the size of the data object.
420  if (fd.dataObjInp->openFlags & O_TRUNC) {
421  if (const auto access_mode = (fd.dataObjInp->openFlags & O_ACCMODE);
422  access_mode == O_WRONLY || access_mode == O_RDWR)
423  {
424  dataObjInfo_t path_input{};
425  rstrcpy(path_input.objPath, fd.dataObjInp->objPath, MAX_NAME_LEN);
426 
427  keyValPair_t reg_params{};
428  addKeyVal(&reg_params, DATA_SIZE_KW, "0");
429 
430  modDataObjMeta_t input{};
431  input.dataObjInfo = &path_input;
432  input.regParam = &reg_params;
433 
434  if (const auto ec = rsModDataObjMeta(rsComm, &input); ec != 0) {
435  rodsLog(LOG_ERROR, "dataOpen: Could not update size of data object [status = %d, path = %s]",
436  ec, path_input.objPath);
437  return ec;
438  }
439 
440  fd.dataSize = 0;
441 
442  if (fd.dataObjInfo) {
443  fd.dataObjInfo->dataSize = 0;
444  }
445  }
446  }
447 
448  return 0;
449 }
450 
451 int
452 l3Open( rsComm_t *rsComm, int l1descInx ) {
453  dataObjInfo_t *dataObjInfo;
454  int l3descInx;
455  int mode, flags;
456 
457  dataObjInfo = L1desc[l1descInx].dataObjInfo;
458 
459  std::string location;
460  irods::error ret = irods::get_loc_for_hier_string( dataObjInfo->rescHier, location );
461  if ( !ret.ok() ) {
462  irods::log( PASSMSG( "l3Open - failed in get_loc_for_hier_string", ret ) );
463  return -1;
464  }
465 
466  if ( getStructFileType( dataObjInfo->specColl ) >= 0 ) {
467  subFile_t subFile;
468  memset( &subFile, 0, sizeof( subFile ) );
469  rstrcpy( subFile.subFilePath, dataObjInfo->subPath, MAX_NAME_LEN );
470  rstrcpy( subFile.addr.hostAddr, location.c_str(), NAME_LEN );
471  subFile.specColl = dataObjInfo->specColl;
472  subFile.mode = getFileMode( L1desc[l1descInx].dataObjInp );
473  subFile.flags = getFileFlags( l1descInx );
474  l3descInx = rsSubStructFileOpen( rsComm, &subFile );
475  }
476  else {
477  mode = getFileMode( L1desc[l1descInx].dataObjInp );
478  flags = getFileFlags( l1descInx );
479  l3descInx = _l3Open( rsComm, dataObjInfo, mode, flags );
480  }
481  return l3descInx;
482 }
483 
484 int
485 _l3Open( rsComm_t *rsComm, dataObjInfo_t *dataObjInfo, int mode, int flags ) {
486  int l3descInx;
487  fileOpenInp_t fileOpenInp;
488 
489  // =-=-=-=-=-=-=-
490  // extract the host location from the resource hierarchy
491  std::string location;
492  irods::error ret = irods::get_loc_for_hier_string( dataObjInfo->rescHier, location );
493  if ( !ret.ok() ) {
494  irods::log( PASSMSG( "l3Open - failed in get_loc_for_hier_string", ret ) );
495  return -1;
496  }
497 
498  memset( &fileOpenInp, 0, sizeof( fileOpenInp ) );
499  rstrcpy( fileOpenInp.resc_name_, dataObjInfo->rescName, MAX_NAME_LEN );
500  rstrcpy( fileOpenInp.resc_hier_, dataObjInfo->rescHier, MAX_NAME_LEN );
501  rstrcpy( fileOpenInp.objPath, dataObjInfo->objPath, MAX_NAME_LEN );
502  rstrcpy( fileOpenInp.addr.hostAddr, location.c_str(), NAME_LEN );
503  rstrcpy( fileOpenInp.fileName, dataObjInfo->filePath, MAX_NAME_LEN );
504  fileOpenInp.mode = mode;
505  fileOpenInp.flags = flags;
506  rstrcpy( fileOpenInp.in_pdmo, dataObjInfo->in_pdmo, MAX_NAME_LEN );
507 
508  // kv passthru
509  copyKeyVal(
510  &dataObjInfo->condInput,
511  &fileOpenInp.condInput );
512 
513  l3descInx = rsFileOpen( rsComm, &fileOpenInp );
514  clearKeyVal( &fileOpenInp.condInput );
515  return l3descInx;
516 }
517 
518 /* l3OpenByHost - call level3 open - this differs from l3Open in that
519  * rsFileOpenByHost is called instead of rsFileOpen
520  */
521 
522 int
523 l3OpenByHost( rsComm_t *rsComm, int l3descInx, int flags ) {
524  fileOpenInp_t fileOpenInp;
525  int newL3descInx;
526 
527  memset( &fileOpenInp, 0, sizeof( fileOpenInp ) );
528  rstrcpy( fileOpenInp.resc_hier_, FileDesc[l3descInx].rescHier, MAX_NAME_LEN );
529  rstrcpy( fileOpenInp.fileName, FileDesc[l3descInx].fileName, MAX_NAME_LEN );
530  rstrcpy( fileOpenInp.objPath, FileDesc[l3descInx].objPath, MAX_NAME_LEN );
531  fileOpenInp.mode = FileDesc[l3descInx].mode;
532  fileOpenInp.flags = flags;
533 
534  // kv passthru
535  //copyKeyVal(
536  // &dataObjInfo->condInput,
537  // &fileOpenInp.condInput );
538 
539  newL3descInx = rsFileOpenByHost( rsComm, &fileOpenInp,
540  FileDesc[l3descInx].rodsServerHost );
541 
542  return newL3descInx;
543 }
544 
545 int
547  dataObjInfo_t **dataObjInfoHead ) {
548  int status;
549  ruleExecInfo_t rei;
550 
551  initReiWithDataObjInp( &rei, rsComm, dataObjInp );
552  rei.doi = *dataObjInfoHead;
553 
554  // make resource properties available as rule session variables
556 
557  status = applyRule( "acPreprocForDataObjOpen", NULL, &rei, NO_SAVE_REI );
559  free(rei.condInputData);
560 
561  if ( status < 0 ) {
562  if ( rei.status < 0 ) {
563  status = rei.status;
564  }
566  "applyPreprocRuleForOpen:acPreprocForDataObjOpen error for %s,stat=%d",
567  dataObjInp->objPath, status );
568  }
569  else {
570  *dataObjInfoHead = rei.doi;
571  }
572  return status;
573 }
574 
575 /* createEmptyRepl - Physically create a zero length file and register
576  * as a replica and queue the dataObjInfo on the top of dataObjInfoHead.
577  */
578 int
579 createEmptyRepl( rsComm_t *rsComm, dataObjInp_t *dataObjInp,
580  dataObjInfo_t **dataObjInfoHead ) {
581  int status;
582  regReplica_t regReplicaInp;
583  keyValPair_t *condInput = &dataObjInp->condInput;
584  dataObjInfo_t *myDataObjInfo;
585 
586  std::string resc_name;
587 
588  if ( getValByKey( condInput, DEST_RESC_NAME_KW ) == NULL &&
589  getValByKey( condInput, BACKUP_RESC_NAME_KW ) == NULL &&
590  getValByKey( condInput, DEF_RESC_NAME_KW ) == NULL ) {
591  return USER_NO_RESC_INPUT_ERR;
592  }
593 
594  status = getRescForCreate( rsComm, dataObjInp, resc_name );
595  if ( status < 0 || resc_name.empty() ) {
596  return status; // JMC cppcheck
597  }
598 
599  myDataObjInfo = ( dataObjInfo_t* )malloc( sizeof( dataObjInfo_t ) );
600  *myDataObjInfo = *( *dataObjInfoHead );
601 
602  rstrcpy( myDataObjInfo->rescName, ( *dataObjInfoHead )->rescName, NAME_LEN );
603 
604  char* resc_hier = getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW );
605  if ( resc_hier ) {
606  rstrcpy( myDataObjInfo->rescHier, resc_hier, MAX_NAME_LEN ); // hier sent from upper level code
607  }
608  else {
609  rodsLog( LOG_NOTICE, "createEmptyRepl :: using rescName for hier" );
610  rstrcpy( myDataObjInfo->rescHier, ( *dataObjInfoHead )->rescName, MAX_NAME_LEN ); // in kw else
611  }
612 
613  rodsLong_t resc_id;
614  irods::error ret = resc_mgr.hier_to_leaf_id( myDataObjInfo->rescHier, resc_id );
615  myDataObjInfo->rescId = resc_id;
616 
617  status = getFilePathName( rsComm, myDataObjInfo, dataObjInp );
618  if ( status < 0 ) {
619  rodsLog( LOG_ERROR, "getFilePathName failed in %s with status %d", __FUNCTION__, status );
620  return status;
621  }
622 
623  status = l3CreateByObjInfo( rsComm, dataObjInp, myDataObjInfo );
624  if ( status < 0 ) {
625  rodsLog( LOG_ERROR, "l3CreateByObjInfo failed in %s with status %d", __FUNCTION__, status );
626  return status;
627  }
628 
629  /* close it */
630  _l3Close( rsComm, status );
631 
632  /* register the replica */
633  memset( &regReplicaInp, 0, sizeof( regReplicaInp ) );
634  regReplicaInp.srcDataObjInfo = *dataObjInfoHead;
635  regReplicaInp.destDataObjInfo = myDataObjInfo;
636  if ( getValByKey( &dataObjInp->condInput, ADMIN_KW ) != NULL ) {
637  addKeyVal( &regReplicaInp.condInput, ADMIN_KW, "" );
638  }
639  status = rsRegReplica( rsComm, &regReplicaInp );
640  clearKeyVal( &regReplicaInp.condInput );
641 
642 
643  if ( status < 0 ) {
644  free( myDataObjInfo );
645  }
646  else {
647  /* queue it on top */
648  myDataObjInfo->next = *dataObjInfoHead;
649  *dataObjInfoHead = myDataObjInfo;
650  }
651  return status;
652 }
653 
654 // =-=-=-=-=-=-=-
655 // JMC - backport 4590
656 int
658  dataObjInfo_t **dataObjInfoHead,
659  dataObjInfo_t **compDataObjInfo ) {
660  int status = 0;
661 
662  /* put the copy with destResc on top */
663  status = requeDataObjInfoByDestResc( dataObjInfoHead, &dataObjInp->condInput, 1, 1 );
664 
665  /* status < 0 means there is no copy in the DEST_RESC */
666  if ( status < 0 && ( *dataObjInfoHead )->specColl == NULL &&
667  getValByKey( &dataObjInp->condInput, DEST_RESC_NAME_KW ) != NULL ) {
668 
669  /* we don't have a copy, so create an empty dataObjInfo */
670  status = createEmptyRepl( rsComm, dataObjInp, dataObjInfoHead );
671  if ( status < 0 ) {
673  "procDataObjForOpenWrite: createEmptyRepl of %s failed",
674  ( *dataObjInfoHead )->objPath );
675  return status;
676  }
677 
678  }
679  else { /* The target data object exists */
680  status = 0;
681  }
682 
683  if ( *compDataObjInfo != NULL ) {
684  dequeDataObjInfo( dataObjInfoHead, *compDataObjInfo );
685  }
686  return status;
687 }
688 
689 #if 0
690 irods::error selectObjInfo(
692  dataObjInfo_t * _dataObjInfoHead,
693  keyValPair_t* _condInput,
694  dataObjInfo_t** _rtn_dataObjInfo ) {
695  irods::error result = SUCCESS();
696  *_rtn_dataObjInfo = NULL;
697  char* resc_hier = getValByKey( _condInput, RESC_HIER_STR_KW );
698  if ( !resc_hier ) {
699  std::stringstream msg;
700  msg << __FUNCTION__;
701  msg << " - No resource hierarchy specified in keywords.";
702  result = ERROR( SYS_INVALID_INPUT_PARAM, msg.str() );
703  }
704  else {
705  for ( dataObjInfo_t* dataObjInfo = _dataObjInfoHead;
706  result.ok() && *_rtn_dataObjInfo == NULL && dataObjInfo != NULL;
707  dataObjInfo = dataObjInfo->next ) {
708  if ( strcmp( resc_hier, dataObjInfo->rescHier ) == 0 ) {
709  *_rtn_dataObjInfo = dataObjInfo;
710  }
711  }
712  if ( *_rtn_dataObjInfo == NULL ) {
713  std::stringstream msg;
714  msg << __FUNCTION__;
715  msg << " - Failed to find a data obj matching resource hierarchy: \"";
716  msg << resc_hier;
717  msg << "\"";
718  result = ERROR( HIERARCHY_ERROR, msg.str() );
719  }
720  }
721  return result;
722 }
723 #endif
allocL1desc
int allocL1desc()
Definition: objDesc.cpp:39
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
getValByKey
char * getValByKey(const keyValPair_t *condInput, const char *keyWord)
Definition: rcMisc.cpp:675
DataObjInp::objPath
char objPath[(1024+64)]
Definition: dataObjInpOut.h:66
L1desc
l1desc_t L1desc[1026]
Definition: irods_server_globals.cpp:29
LOCK_TYPE_KW
#define LOCK_TYPE_KW
Definition: rodsKeyWdDef.h:115
NULL
#define NULL
Definition: rodsDef.h:70
regDataObj.h
rsComm_t
Definition: rcConnect.h:145
fileOpen.h
applyPreprocRuleForOpen
int applyPreprocRuleForOpen(rsComm_t *rsComm, dataObjInp_t *dataObjInp, dataObjInfo_t **dataObjInfoHead)
Definition: rsDataObjOpen.cpp:546
addKeyVal
int addKeyVal(keyValPair_t *condInput, const char *keyWord, const char *value)
Definition: rcMisc.cpp:789
l1desc::replDataObjInfo
dataObjInfo_t * replDataObjInfo
Definition: objDesc.hpp:57
getRemoteZoneResc.h
UNKNOWN_FILE_SZ
#define UNKNOWN_FILE_SZ
Definition: rodsDef.h:92
rsFileOpen.hpp
DataObjInp::openFlags
int openFlags
Definition: dataObjInpOut.h:68
getFilePathName
int getFilePathName(rsComm_t *rsComm, dataObjInfo_t *dataObjInfo, dataObjInp_t *dataObjInp)
Definition: physPath.cpp:87
irods_server_properties.hpp
rsDataObjOpen
int rsDataObjOpen(rsComm_t *rsComm, dataObjInp_t *dataObjInp)
Definition: rsDataObjOpen.cpp:45
DO_PHYOPEN
#define DO_PHYOPEN
Definition: dataObjOpen.h:14
rsDataObjOpen.hpp
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
rsDataObjCreate.hpp
dequeDataObjInfo
int dequeDataObjInfo(dataObjInfo_t **dataObjInfoHead, dataObjInfo_t *dataObjInfo)
Definition: rcMisc.cpp:635
fileOpenInp_t::resc_name_
char resc_name_[(1024+64)]
Definition: fileOpen.h:15
Subfile
Definition: objInfo.h:316
fileDesc_t::mode
int mode
Definition: fileOpr.hpp:30
PHYOPEN_BY_SIZE_KW
#define PHYOPEN_BY_SIZE_KW
Definition: rodsKeyWdDef.h:46
irods_stacktrace.hpp
RuleExecInfo::status
int status
Definition: irods_re_structs.hpp:19
irods::server_api_call
int server_api_call(int _api_index, rsComm_t *_comm, INP_T *_input, bytesBuf_t *_input_buffer, OUT_T **_output, bytesBuf_t *_output_buffer)
Definition: irods_server_api_call.hpp:11
l1desc::lockFd
int lockFd
Definition: objDesc.hpp:55
resc_mgr
irods::resource_manager resc_mgr
Definition: irods_resource_manager.cpp:31
Subfile::subFilePath
char subFilePath[(1024+64)]
Definition: objInfo.h:318
irods::resolve_resource_hierarchy
error resolve_resource_hierarchy(const std::string &, rsComm_t *, dataObjInp_t *, std::string &, dataObjInfo_t **_data_obj_info=0)
Definition: irods_resource_redirect.cpp:505
rsDataObjCreate
int rsDataObjCreate(rsComm_t *rsComm, dataObjInp_t *dataObjInp)
Definition: rsDataObjCreate.cpp:77
NO_SAVE_REI
#define NO_SAVE_REI
Definition: rodsDef.h:103
_rsDataObjOpenWithObjInfo
int _rsDataObjOpenWithObjInfo(rsComm_t *rsComm, dataObjInp_t *dataObjInp, int phyOpenFlag, dataObjInfo_t *dataObjInfo)
Definition: rsDataObjOpen.cpp:338
has_trailing_path_separator
int has_trailing_path_separator(const char *path)
Definition: rodsPath.cpp:526
allocAndSetL1descForZoneOpr
int allocAndSetL1descForZoneOpr(int l3descInx, dataObjInp_t *dataObjInp, rodsServerHost_t *remoteZoneHost, openStat_t *openStat)
Definition: objDesc.cpp:638
rcDataObjOpenAndStat
int rcDataObjOpenAndStat(rcComm_t *conn, dataObjInp_t *dataObjInp, openStat_t **openStat)
Definition: rcDataObjOpenAndStat.cpp:69
REMOTE_HOST
#define REMOTE_HOST
Definition: rodsConnect.h:45
REMOTE_OPEN
#define REMOTE_OPEN
Definition: getRemoteZoneResc.h:5
l3OpenByHost
int l3OpenByHost(rsComm_t *rsComm, int l3descInx, int flags)
Definition: rsDataObjOpen.cpp:523
DataObjInfo::rescId
rodsLong_t rescId
Definition: objInfo.h:164
l1desc::dataObjInfo
dataObjInfo_t * dataObjInfo
Definition: objDesc.hpp:42
DataObjInfo::rescHier
char rescHier[(1024+64)]
Definition: objInfo.h:132
getStructFileType
int getStructFileType(specColl_t *specColl)
Definition: objMetaOpr.cpp:386
DataObjInfo::replStatus
int replStatus
Definition: objInfo.h:141
_rsDataObjOpen
int _rsDataObjOpen(rsComm_t *rsComm, dataObjInp_t *dataObjInp, dataObjInfo_t *dataObjInfoHead)
Definition: rsDataObjOpen.cpp:127
stageBundledData
int stageBundledData(rsComm_t *rsComm, dataObjInfo_t **subfileObjInfoHead)
Definition: rsDataObjRepl.cpp:1468
RuleExecInfo::doi
dataObjInfo_t * doi
Definition: irods_re_structs.hpp:28
DataObjInfo::condInput
keyValPair_t condInput
Definition: objInfo.h:161
irods_resource_backport.hpp
Subfile::specColl
specColl_t * specColl
Definition: objInfo.h:322
fileOpenInp_t::resc_hier_
char resc_hier_[(1024+64)]
Definition: fileOpen.h:16
fillL1desc
int fillL1desc(int l1descInx, dataObjInp_t *dataObjInp, dataObjInfo_t *dataObjInfo, int replStatus, rodsLong_t dataSize)
Definition: objDesc.cpp:154
LOCK_FD_KW
#define LOCK_FD_KW
Definition: rodsKeyWdDef.h:117
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
irods::CFG_MAX_SIZE_FOR_SINGLE_BUFFER
const std::string CFG_MAX_SIZE_FOR_SINGLE_BUFFER("maximum_size_for_single_buffer_in_megabytes")
rcGlobalExtern.h
DataObjInfo::filePath
char filePath[(1024+64)]
Definition: objInfo.h:137
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
dataObjCreate.h
irods_resource_redirect.hpp
DATA_SIZE_KW
#define DATA_SIZE_KW
Definition: rodsKeyWdDef.h:24
SYS_INVALID_INPUT_PARAM
@ SYS_INVALID_INPUT_PARAM
Definition: rodsErrorTable.h:195
fileOpenInp_t::fileName
char fileName[(1024+64)]
Definition: fileOpen.h:20
DataObjInfo::next
struct DataObjInfo * next
Definition: objInfo.h:163
DataObjInfo::specColl
specColl_t * specColl
Definition: objInfo.h:158
l1desc::openType
int openType
Definition: objDesc.hpp:38
fileDesc_t::rescHier
char * rescHier
Definition: fileOpr.hpp:28
PURGE_CACHE_KW
#define PURGE_CACHE_KW
Definition: rodsKeyWdDef.h:110
rsFileOpen
int rsFileOpen(rsComm_t *rsComm, fileOpenInp_t *fileOpenInp)
Definition: rsFileOpen.cpp:21
regReplica_t::condInput
keyValPair_t condInput
Definition: regReplica.h:10
irods::get_resc_properties_as_kvp
error get_resc_properties_as_kvp(const std::string &, keyValPair_t *)
Definition: irods_resource_backport.cpp:500
initReiWithDataObjInp
int initReiWithDataObjInp(ruleExecInfo_t *rei, rsComm_t *rsComm, dataObjInp_t *dataObjIn)
Definition: irods_re_structs.cpp:164
getFileFlags
int getFileFlags(int l1descInx)
Definition: physPath.cpp:70
rsSubStructFileOpen
int rsSubStructFileOpen(rsComm_t *rsComm, subFile_t *subFile)
Definition: rsSubStructFileOpen.cpp:13
PHYOPEN_BY_SIZE
#define PHYOPEN_BY_SIZE
Definition: dataObjOpen.h:16
regReplica_t::destDataObjInfo
dataObjInfo_t * destDataObjInfo
Definition: regReplica.h:9
BACKUP_RESC_NAME_KW
#define BACKUP_RESC_NAME_KW
Definition: rodsKeyWdDef.h:22
DEST_RESC_NAME_KW
#define DEST_RESC_NAME_KW
Definition: rodsKeyWdDef.h:20
SUCCESS
#define SUCCESS()
Definition: irods_error.hpp:121
RuleExecInfo::condInputData
keyValPair_t * condInputData
Definition: irods_re_structs.hpp:34
rsGlobalExtern.hpp
irods::OPEN_OPERATION
const std::string OPEN_OPERATION("OPEN")
fileOpenInp_t::flags
int flags
Definition: fileOpen.h:21
_l3Close
int _l3Close(rsComm_t *rsComm, int l3descInx)
Definition: rsDataObjClose.cpp:756
RESC_HIER_STR_KW
#define RESC_HIER_STR_KW
Definition: rodsKeyWdDef.h:225
fileOpenInp_t::addr
rodsHostAddr_t addr
Definition: fileOpen.h:19
DATA_INCLUDED_KW
#define DATA_INCLUDED_KW
Definition: rodsKeyWdDef.h:36
rsFileOpenByHost
int rsFileOpenByHost(rsComm_t *rsComm, fileOpenInp_t *fileOpenInp, rodsServerHost_t *rodsServerHost)
Definition: rsFileOpen.cpp:44
irods::file_object_factory
error file_object_factory(rsComm_t *, dataObjInp_t *, file_object_ptr, dataObjInfo_t **)
Definition: irods_file_object.cpp:271
fileOpenInp_t::objPath
char objPath[(1024+64)]
Definition: fileOpen.h:17
DataObjInfo::in_pdmo
char in_pdmo[(1024+64)]
Definition: objInfo.h:162
freeAllDataObjInfo
int freeAllDataObjInfo(dataObjInfo_t *dataObjInfoHead)
Definition: rcMisc.cpp:561
fileDesc_t::objPath
char * objPath
Definition: fileOpr.hpp:29
rsRegReplica
int rsRegReplica(rsComm_t *rsComm, regReplica_t *regReplicaInp)
Definition: rsRegReplica.cpp:187
l3Open
int l3Open(rsComm_t *rsComm, int l1descInx)
Definition: rsDataObjOpen.cpp:452
DataObjInp
Definition: dataObjInpOut.h:65
rsDataObjClose.hpp
NO_OPEN_FLAG_KW
#define NO_OPEN_FLAG_KW
Definition: rodsKeyWdDef.h:45
USER_INCOMPATIBLE_OPEN_FLAGS
@ USER_INCOMPATIBLE_OPEN_FLAGS
Definition: rodsErrorTable.h:290
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
terminate_irods_processes.e
e
Definition: terminate_irods_processes.py:19
getWriteFlag
int getWriteFlag(int openFlag)
Definition: physPath.cpp:386
OPEN_EXISTING_COPY
#define OPEN_EXISTING_COPY
Definition: objInfo.h:116
Subfile::addr
rodsHostAddr_t addr
Definition: objInfo.h:317
rmKeyVal
int rmKeyVal(keyValPair_t *condInput, const char *keyWord)
Definition: rcMisc.cpp:710
ADMIN_KW
#define ADMIN_KW
Definition: rodsKeyWdDef.h:62
fileOpenInp_t::mode
int mode
Definition: fileOpen.h:22
sortObjInfoForOpen
int sortObjInfoForOpen(dataObjInfo_t **dataObjInfoHead, keyValPair_t *condInput, int writeFlag)
Definition: dataObjOpr.cpp:548
USER_NO_RESC_INPUT_ERR
@ USER_NO_RESC_INPUT_ERR
Definition: rodsErrorTable.h:252
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
rodsLog.h
OPEN_FOR_WRITE_TYPE
#define OPEN_FOR_WRITE_TYPE
Definition: dataObjInpOut.h:195
physPath.hpp
irods::log
void log(const error &)
Definition: irods_log.cpp:13
DEF_RESC_NAME_KW
#define DEF_RESC_NAME_KW
Definition: rodsKeyWdDef.h:21
createEmptyRepl
int createEmptyRepl(rsComm_t *rsComm, dataObjInp_t *dataObjInp, dataObjInfo_t **dataObjInfoHead)
Definition: rsDataObjOpen.cpp:579
OpenStat
Definition: dataObjOpenAndStat.h:8
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
dataObjClose.h
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
regReplica.h
irods::error
Definition: irods_error.hpp:23
regReplica_t::srcDataObjInfo
dataObjInfo_t * srcDataObjInfo
Definition: regReplica.h:8
dataObjOpenAndStat.h
modDataObjMeta_t::dataObjInfo
dataObjInfo_t * dataObjInfo
Definition: modDataObjMeta.h:8
OPEN_FOR_READ_TYPE
#define OPEN_FOR_READ_TYPE
Definition: dataObjInpOut.h:194
dataObjRepl.h
HIERARCHY_ERROR
@ HIERARCHY_ERROR
Definition: rodsErrorTable.h:752
apiNumber.h
rsSubStructFileOpen.hpp
fileOpenInp_t::condInput
keyValPair_t condInput
Definition: fileOpen.h:24
FileDesc
fileDesc_t FileDesc[1026]
Definition: irods_server_globals.cpp:28
irods_hierarchy_parser.hpp
getRescForCreate
int getRescForCreate(rsComm_t *rsComm, dataObjInp_t *dataObjInp, std::string &_resc_name)
Definition: rsDataObjCreate.cpp:604
fileOpenInp_t
Definition: fileOpen.h:14
DO_NOT_PHYOPEN
#define DO_NOT_PHYOPEN
Definition: dataObjOpen.h:15
irods::resource_manager::hier_to_leaf_id
error hier_to_leaf_id(const std::string &, rodsLong_t &)
Definition: irods_resource_manager.cpp:1082
dataOpen
int dataOpen(rsComm_t *rsComm, int l1descInx)
Definition: rsDataObjOpen.cpp:403
irods::file_object
Definition: irods_file_object.hpp:19
rodsServerHost
Definition: rodsConnect.h:62
DataObjInfo::rescName
char rescName[64]
Definition: objInfo.h:131
rodsHostAddr_t::hostAddr
char hostAddr[256]
Definition: rodsDef.h:297
DATA_OBJ_UNLOCK_AN
#define DATA_OBJ_UNLOCK_AN
Definition: apiNumber.h:109
l1desc::otherDataObjInfo
dataObjInfo_t * otherDataObjInfo
Definition: objDesc.hpp:43
subStructFileOpen.h
irods::file_object_ptr
boost::shared_ptr< file_object > file_object_ptr
Definition: irods_file_object.hpp:145
RuleExecInfo
Definition: irods_re_structs.hpp:18
rsModDataObjMeta
int rsModDataObjMeta(rsComm_t *rsComm, modDataObjMeta_t *modDataObjMetaInp)
Definition: rsModDataObjMeta.cpp:23
rodsLogError
void rodsLogError(int level, int errCode, char *formatStr,...)
Definition: rodsLog.cpp:422
getAndConnRemoteZone
int getAndConnRemoteZone(rsComm_t *rsComm, dataObjInp_t *dataObjInp, rodsServerHost_t **rodsServerHost, char *remotZoneOpr)
Definition: rodsConnect.cpp:784
rsModDataObjMeta.hpp
irods_server_api_call.hpp
applyRule
int applyRule(char *inAction, msParamArray_t *inMsParamArray, ruleExecInfo_t *rei, int reiSaveFlag)
Definition: irods_re_structs.cpp:65
resource.hpp
irods::exception
Definition: irods_exception.hpp:15
getFileMode
int getFileMode(dataObjInp_t *dataObjInp)
Definition: physPath.cpp:48
rsRegReplica.hpp
dataObjOpen.h
DataObjInfo::objPath
char objPath[(1024+64)]
Definition: objInfo.h:130
Subfile::mode
int mode
Definition: objInfo.h:319
rodsErrorTable.h
DATA_OBJ_LOCK_AN
#define DATA_OBJ_LOCK_AN
Definition: apiNumber.h:126
requeDataObjInfoByDestResc
int requeDataObjInfoByDestResc(dataObjInfo_t **dataObjInfoHead, keyValPair_t *condInput, int writeFlag, int topFlag)
Definition: dataObjOpr.cpp:1752
fileOpenInp_t::in_pdmo
char in_pdmo[(1024+64)]
Definition: fileOpen.h:25
mode
int mode
Definition: filesystem.cpp:104
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
dataObjOpr.hpp
dataObjLock.h
DataObjInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:74
modDataObjMeta_t
Definition: modDataObjMeta.h:7
irods::get_loc_for_hier_string
error get_loc_for_hier_string(const std::string &_hier, std::string &_loc)
Definition: irods_resource_backport.cpp:633
regReplica_t
Definition: regReplica.h:7
NAME_LEN
#define NAME_LEN
Definition: rodsDef.h:55
freeL1desc
int freeL1desc(int l1descInx)
Definition: objDesc.cpp:124
KeyValPair
Definition: objInfo.h:120
Subfile::flags
int flags
Definition: objInfo.h:320
clearKeyVal
int clearKeyVal(keyValPair_t *condInput)
Definition: rcMisc.cpp:1047
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
procDataObjOpenForWrite
int procDataObjOpenForWrite(rsComm_t *rsComm, dataObjInp_t *dataObjInp, dataObjInfo_t **dataObjInfoHead, dataObjInfo_t **compDataObjInfo)
Definition: rsDataObjOpen.cpp:657
DataObjInfo
Definition: objInfo.h:129
USER_INPUT_PATH_ERR
@ USER_INPUT_PATH_ERR
Definition: rodsErrorTable.h:248
DataObjInfo::dataSize
rodsLong_t dataSize
Definition: objInfo.h:134
queDataObjInfo
int queDataObjInfo(dataObjInfo_t **dataObjInfoHead, dataObjInfo_t *dataObjInfo, int singleInfoFlag, int topFlag)
Definition: rcMisc.cpp:581
fileDesc_t::fileName
char * fileName
Definition: fileOpr.hpp:27
rsDataObjRepl.hpp
l3CreateByObjInfo
int l3CreateByObjInfo(rsComm_t *rsComm, dataObjInp_t *dataObjInp, dataObjInfo_t *dataObjInfo)
Definition: rsDataObjCreate.cpp:533
rodsLong_t
long long rodsLong_t
Definition: rodsType.h:32
objMetaOpr.hpp
DataObjInfo::subPath
char subPath[(1024+64)]
Definition: objInfo.h:157
_l3Open
int _l3Open(rsComm_t *rsComm, dataObjInfo_t *dataObjInfo, int mode, int flags)
Definition: rsDataObjOpen.cpp:485
copyKeyVal
int copyKeyVal(const keyValPair_t *srcCondInput, keyValPair_t *destCondInput)
Definition: rcMisc.cpp:751
l1desc::purgeCacheFlag
int purgeCacheFlag
Definition: objDesc.hpp:54