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)  

rsyncUtil.cpp
Go to the documentation of this file.
1 
3 #ifndef windows_platform
4 #include <sys/time.h>
5 #endif
6 #include "rodsPath.h"
7 #include "rodsErrorTable.h"
8 #include "rodsLog.h"
9 #include "rsyncUtil.h"
10 #include "miscUtil.h"
11 #include "checksum.hpp"
12 #include "rcGlobalExtern.h"
13 
14 #include <sstream>
15 #include <boost/filesystem/operations.hpp>
16 #include <boost/filesystem/convenience.hpp>
17 
18 #include <stdlib.h>
19 
20 #include "irods_log.hpp"
21 #include "irods_hasher_factory.hpp"
22 #include "irods_path_recursion.hpp"
23 #include "irods_exception.hpp"
24 
25 static int CurrentTime = 0;
26 int
27 ageExceeded( int ageLimit, int myTime, char *objPath,
28  rodsLong_t fileSize );
29 
30 int
31 rsyncUtil( rcComm_t *conn, rodsEnv *myRodsEnv, rodsArguments_t *myRodsArgs,
32  rodsPathInp_t *rodsPathInp ) {
33 
34  if ( rodsPathInp == NULL ) {
35  return USER__NULL_INPUT_ERR;
36  }
37 
38  int status = 0;
39  int savedStatus = 0;
40 
41  // Issue 4006: disallow mixed files and directory sources with the
42  // recursive (-r) option.
43  status = irods::disallow_file_dir_mix_on_command_line(myRodsArgs, rodsPathInp );
44  if ( status < 0 ) {
45  return status;
46  }
47 
48  savedStatus = resolveRodsTarget( conn, rodsPathInp, RSYNC_OPR );
49  if ( savedStatus < 0 ) {
50  rodsLogError( LOG_ERROR, savedStatus, "rsyncUtil: resolveRodsTarget" );
51  return savedStatus;
52  }
53 
54  dataObjInp_t dataObjOprInp;
55  dataObjCopyInp_t dataObjCopyInp;
56 
57  if ( rodsPathInp->srcPath[0].objType <= COLL_OBJ_T &&
58  rodsPathInp->targPath[0].objType <= COLL_OBJ_T ) {
59  initCondForIrodsToIrodsRsync( myRodsEnv, myRodsArgs, &dataObjCopyInp );
60  }
61  else {
62  initCondForRsync( myRodsEnv, myRodsArgs, &dataObjOprInp );
63  }
64 
65  // Issue 3988: Scan all physical source directories for loops before
66  // doing any actual file transfers.
67  irods::recursion_map_t pathmap;
68 
69  status = irods::file_system_sanity_check( pathmap, myRodsArgs, rodsPathInp );
70  if (status < 0) {
71  return status;
72  }
73 
74  for ( int i = 0; i < rodsPathInp->numSrc; i++ )
75  {
76  rodsPath_t * targPath = &rodsPathInp->targPath[i];
77  rodsPath_t * srcPath = &rodsPathInp->srcPath[i];
78  int srcType = srcPath->objType;
79  int targType = targPath->objType;
80 
81  if ( srcPath->objState != EXIST_ST ) {
83  "rsyncUtil: Source path %s does not exist" );
84  return USER_INPUT_PATH_ERR;
85  }
86 
87  if ( srcPath->objType <= COLL_OBJ_T && srcPath->rodsObjStat != NULL &&
88  rodsPathInp->srcPath[i].rodsObjStat->specColl != NULL ) {
89  dataObjOprInp.specColl = dataObjCopyInp.srcDataObjInp.specColl =
90  srcPath->rodsObjStat->specColl;
91  }
92  else {
93  dataObjOprInp.specColl =
94  dataObjCopyInp.srcDataObjInp.specColl = NULL;
95  }
96 
97  status = 0;
98  if ( srcType == DATA_OBJ_T && targType == LOCAL_FILE_T ) {
99  rmKeyVal( &dataObjOprInp.condInput, TRANSLATED_PATH_KW );
100  status = rsyncDataToFileUtil( conn, srcPath, targPath,
101  myRodsArgs, &dataObjOprInp );
102  }
103  else if ( srcType == LOCAL_FILE_T && targType == DATA_OBJ_T ) {
104  try {
105  if (! irods::is_path_valid_for_recursion(myRodsArgs, srcPath->outPath))
106  {
107  continue;
108  }
109  } catch ( const irods::exception& _e ) {
112  }
113 
114  dataObjOprInp.createMode = rodsPathInp->srcPath[i].objMode;
115  // Issue 4048: Make sure targpath->objState is set correctly
116  getRodsObjType( conn, targPath );
117  status = rsyncFileToDataUtil( conn, srcPath, targPath,
118  myRodsArgs, &dataObjOprInp );
119  }
120  else if ( srcType == DATA_OBJ_T && targType == DATA_OBJ_T ) {
121  rmKeyVal( &dataObjCopyInp.srcDataObjInp.condInput,
123  addKeyVal( &dataObjCopyInp.destDataObjInp.condInput,
124  REG_CHKSUM_KW, "" );
125  status = rsyncDataToDataUtil( conn, srcPath, targPath,
126  myRodsArgs, &dataObjCopyInp );
127  }
128  else if ( srcType == COLL_OBJ_T && targType == LOCAL_DIR_T ) {
129  addKeyVal( &dataObjOprInp.condInput, TRANSLATED_PATH_KW, "" );
130  status = rsyncCollToDirUtil( conn, srcPath, targPath,
131  myRodsEnv, myRodsArgs, &dataObjOprInp );
132  if ( status >= 0 && dataObjOprInp.specColl != NULL &&
133  dataObjOprInp.specColl->collClass == STRUCT_FILE_COLL ) {
134  dataObjOprInp.specColl = NULL;
135  status = rsyncCollToDirUtil( conn, srcPath, targPath,
136  myRodsEnv, myRodsArgs, &dataObjOprInp );
137  }
138  }
139  else if ( srcType == LOCAL_DIR_T && targType == COLL_OBJ_T )
140  {
141  status = rsyncDirToCollUtil( conn, srcPath, targPath,
142  myRodsEnv, myRodsArgs, &dataObjOprInp );
143  }
144  else if ( srcType == COLL_OBJ_T && targType == COLL_OBJ_T ) {
145  addKeyVal( &dataObjCopyInp.srcDataObjInp.condInput,
146  TRANSLATED_PATH_KW, "" );
147  addKeyVal( &dataObjCopyInp.destDataObjInp.condInput,
148  REG_CHKSUM_KW, "" );
149  status = rsyncCollToCollUtil( conn, srcPath, targPath,
150  myRodsEnv, myRodsArgs, &dataObjCopyInp );
151  if ( status >= 0 && dataObjOprInp.specColl != NULL &&
152  dataObjCopyInp.srcDataObjInp.specColl->collClass == STRUCT_FILE_COLL ) {
153  dataObjCopyInp.srcDataObjInp.specColl = NULL;
154  status = rsyncCollToCollUtil( conn, srcPath, targPath,
155  myRodsEnv, myRodsArgs, &dataObjCopyInp );
156  }
157  }
158  else {
159  /* should not be here */
161  "rsyncUtil: invalid srcType %d and targType %d combination for %s",
162  srcType, targType, targPath->outPath );
163  return USER_INPUT_PATH_ERR;
164  }
165  /* XXXX may need to return a global status */
166  if ( status < 0 &&
170  "rsyncUtil: rsync error for %s",
171  targPath->outPath );
172  savedStatus = status;
173  }
174  }
175  return savedStatus;
176 }
177 
178 int
180  rodsPath_t *targPath, rodsArguments_t *myRodsArgs,
181  dataObjInp_t *dataObjOprInp ) {
182  int status;
183  struct timeval startTime, endTime;
184  int getFlag = 0;
185  int syncFlag = 0;
186  char *chksum;
187 
188  if ( srcPath == NULL || targPath == NULL ) {
190  "rsyncDataToFileUtil: NULL srcPath or targPath input" );
191  return USER__NULL_INPUT_ERR;
192  }
193  /* check the age */
194  if ( myRodsArgs->age == True ) {
195  if ( srcPath->rodsObjStat != NULL ) {
196  if ( ageExceeded( myRodsArgs->agevalue,
197  atoi( srcPath->rodsObjStat->modifyTime ),
198  srcPath->outPath, srcPath->size ) ) {
199  return 0;
200  }
201  }
202  }
203 
204  if ( myRodsArgs->verbose == True ) {
205  ( void ) gettimeofday( &startTime, ( struct timezone * )0 );
206  bzero( &conn->transStat, sizeof( transStat_t ) );
207  }
208 
209  rodsEnv env;
210  int ret = getRodsEnv( &env );
211  if ( ret < 0 ) {
212  rodsLogError(
213  LOG_ERROR,
214  ret,
215  "rsyncDataToFileUtil: getRodsEnv failed" );
216  return ret;
217  }
218 
219  if ( targPath->objState == NOT_EXIST_ST ) {
220  getFlag = 1;
221  }
222  else if ( myRodsArgs->sizeFlag == True ) {
223  /* sync by size */
224  if ( targPath->size != srcPath->size ) {
225  getFlag = 1;
226  }
227  }
228  else if ( strlen( srcPath->chksum ) > 0 ) {
229  // =-=-=-=-=-=-=-
230  // extract scheme from checksum string
231  std::string scheme;
233  srcPath->chksum,
234  scheme );
235  if ( !ret.ok() ) {
236  printf( "%s", ret.result().c_str() );
237  }
238 
239  /* src has a checksum value */
240  status = rcChksumLocFile( targPath->outPath,
242  &dataObjOprInp->condInput,
243  scheme.c_str() );
244  if ( status < 0 ) {
246  "rsyncDataToFileUtil: rcChksumLocFile error for %s, status = %d",
247  targPath->outPath, status );
248  return status;
249  }
250  else {
251  chksum = getValByKey( &dataObjOprInp->condInput, RSYNC_CHKSUM_KW );
252  if ( chksum == NULL || strcmp( chksum, srcPath->chksum ) != 0 ) {
253  getFlag = 1;
254  }
255  }
256  }
257  else {
258  /* exist but no chksum */
260  &dataObjOprInp->condInput,
261  env.rodsDefaultHashScheme );
262  if ( status < 0 ) {
264  "rsyncDataToFileUtil: rcChksumLocFile error for %s, status = %d",
265  targPath->outPath, status );
266  return status;
267  }
268  else {
269  syncFlag = 1;
270  }
271  }
272 
273  if ( getFlag + syncFlag > 0 ) {
274  if ( myRodsArgs->verifyChecksum == True ) {
275  addKeyVal( &dataObjOprInp->condInput, VERIFY_CHKSUM_KW, "" );
276  }
277  rstrcpy( dataObjOprInp->objPath, srcPath->outPath, MAX_NAME_LEN );
278  dataObjOprInp->dataSize = srcPath->size;
279  dataObjOprInp->openFlags = O_RDONLY;
280  }
281 
282  if ( getFlag == 1 ) {
283  /* only do the sync if no -l option specified */
284  if ( myRodsArgs->longOption != True ) {
285  status = rcDataObjGet( conn, dataObjOprInp, targPath->outPath );
286  }
287  else {
288  status = 0;
289  printf( "%s %lld N\n", srcPath->outPath, srcPath->size );
290  }
291  rmKeyVal( &dataObjOprInp->condInput, RSYNC_CHKSUM_KW );
292  if ( status >= 0 && myRodsArgs->longOption != True ) {
293  myChmod( targPath->outPath, srcPath->objMode );
294  }
295  }
296  else if ( syncFlag == 1 ) {
297  addKeyVal( &dataObjOprInp->condInput, RSYNC_DEST_PATH_KW,
298  targPath->outPath );
299  addKeyVal( &dataObjOprInp->condInput, RSYNC_MODE_KW, LOCAL_TO_IRODS );
300  status = rcDataObjRsync( conn, dataObjOprInp );
301  rmKeyVal( &dataObjOprInp->condInput, RSYNC_DEST_PATH_KW );
302  rmKeyVal( &dataObjOprInp->condInput, RSYNC_MODE_KW );
303  }
304  else {
305  status = 0;
306  }
307 
308  if ( status >= 0 && myRodsArgs->verbose == True ) {
309  if ( getFlag > 0 ||
310  ( syncFlag > 0 && status == SYS_RSYNC_TARGET_MODIFIED ) ) {
311  ( void ) gettimeofday( &endTime, ( struct timezone * )0 );
312  printTiming( conn, srcPath->outPath, srcPath->size,
313  targPath->outPath, &startTime, &endTime );
314  }
315  else {
316  printNoSync( srcPath->outPath, srcPath->size, "a match" );
317  }
318  }
319 
320  return status;
321 }
322 
323 int
325  rodsPath_t *targPath, rodsArguments_t *myRodsArgs,
326  dataObjInp_t *dataObjOprInp ) {
327  int status;
328  struct timeval startTime, endTime;
329  int putFlag = 0;
330  int syncFlag = 0;
331  char *chksum;
332 
333  if ( srcPath == NULL || targPath == NULL ) {
335  "rsyncFileToDataUtil: NULL srcPath or targPath input" );
336  return USER__NULL_INPUT_ERR;
337  }
338  /* check the age */
339  if ( myRodsArgs->age == True ) {
340 #ifndef windows_platform
341  struct stat statbuf;
342  status = stat( srcPath->outPath, &statbuf );
343 #else
344  struct irodsntstat statbuf;
345  status = iRODSNt_stat( srcPath->outPath, &statbuf );
346 #endif
347  if ( status < 0 ) {
349  "rsyncFileToDataUtil: stat error for %s, errno = %d\n",
350  srcPath->outPath, errno );
351  return USER_INPUT_PATH_ERR;
352  }
353  if ( ageExceeded( myRodsArgs->agevalue, statbuf.st_mtime,
354  srcPath->outPath, srcPath->size ) ) {
355  return 0;
356  }
357  }
358 
359  rodsEnv env;
360  int ret = getRodsEnv( &env );
361  if ( ret < 0 ) {
362  rodsLogError(
363  LOG_ERROR,
364  ret,
365  "rsyncFileToDataUtil: getRodsEnv failed" );
366  return ret;
367  }
368 
369  if ( myRodsArgs->verbose == True ) {
370  ( void ) gettimeofday( &startTime, ( struct timezone * )0 );
371  bzero( &conn->transStat, sizeof( transStat_t ) );
372  }
373 
374  if ( targPath->objState == NOT_EXIST_ST ) {
375  putFlag = 1;
376  if( True == myRodsArgs->verifyChecksum ) {
378  srcPath->outPath,
380  &dataObjOprInp->condInput,
381  env.rodsDefaultHashScheme );
382  if ( status < 0 ) {
383  rodsLogError(
384  LOG_ERROR,
385  status,
386  "rsyncFileToDataUtil: rcChksumLocFile error for %s, status = %d",
387  srcPath->outPath,
388  status );
389  return status;
390  }
391  else {
392  chksum = getValByKey(
393  &dataObjOprInp->condInput,
394  RSYNC_CHKSUM_KW );
395  if ( chksum != NULL ) {
396  addKeyVal(
397  &dataObjOprInp->condInput,
399  chksum );
400  }
401  }
402  }
403  }
404  else if ( myRodsArgs->sizeFlag == True ) {
405  /* sync by size */
406  if ( targPath->size != srcPath->size ) {
407  putFlag = 1;
408  }
409  }
410  else if ( strlen( targPath->chksum ) > 0 ) {
411  // =-=-=-=-=-=-=-
412  // extract scheme from checksum string
413  std::string scheme;
415  targPath->chksum,
416  scheme );
417  if ( !ret.ok() ) {
418  printf( "%s", ret.result().c_str() );
419  }
420 
421  /* src has a checksum value */
423  &dataObjOprInp->condInput,
424  scheme.c_str() );
425  if ( status < 0 ) {
427  "rsyncFileToDataUtil: rcChksumLocFile error for %s, status = %d",
428  srcPath->outPath, status );
429  return status;
430  }
431  else {
432  chksum = getValByKey( &dataObjOprInp->condInput, RSYNC_CHKSUM_KW );
433 
434  if ( chksum == NULL || strcmp( chksum, targPath->chksum ) != 0 ) {
435  if ( chksum != NULL && myRodsArgs->verifyChecksum == True ) {
436  addKeyVal( &dataObjOprInp->condInput, VERIFY_CHKSUM_KW,
437  chksum );
438  }
439 
440  putFlag = 1;
441  }
442  }
443  }
444  else {
445  /* exist but no chksum */
447  &dataObjOprInp->condInput,
448  env.rodsDefaultHashScheme );
449  if ( status < 0 ) {
451  "rsyncFileToDataUtil: rcChksumLocFile error for %s, status = %d",
452  srcPath->outPath, status );
453  return status;
454  }
455  else {
456  chksum = getValByKey( &dataObjOprInp->condInput, RSYNC_CHKSUM_KW );
457  if ( chksum != NULL && myRodsArgs->verifyChecksum == True ) {
458  addKeyVal( &dataObjOprInp->condInput, VERIFY_CHKSUM_KW, chksum );
459  }
460  syncFlag = 1;
461  }
462  }
463 
464  if ( putFlag + syncFlag > 0 ) {
465  rstrcpy( dataObjOprInp->objPath, targPath->outPath, MAX_NAME_LEN );
466  dataObjOprInp->dataSize = srcPath->size;
467  dataObjOprInp->openFlags = O_WRONLY;
468  }
469 
470  if ( putFlag == 1 ) {
471  /* only do the sync if no -l option specified */
472  if ( myRodsArgs->longOption != True ) {
473  status = rcDataObjPut( conn, dataObjOprInp, srcPath->outPath );
474  }
475  else {
476  status = 0;
477  printf( "%s %lld N\n", srcPath->outPath, srcPath->size );
478  }
479  rmKeyVal( &dataObjOprInp->condInput, RSYNC_CHKSUM_KW );
480  }
481  else if ( syncFlag == 1 ) {
482  addKeyVal( &dataObjOprInp->condInput, RSYNC_DEST_PATH_KW,
483  srcPath->outPath );
484  addKeyVal( &dataObjOprInp->condInput, RSYNC_MODE_KW, IRODS_TO_LOCAL );
485  /* only do the sync if no -l option specified */
486  if ( myRodsArgs->longOption != True ) {
487  status = rcDataObjRsync( conn, dataObjOprInp );
488  }
489  else {
490  status = 0;
491  }
492  rmKeyVal( &dataObjOprInp->condInput, RSYNC_DEST_PATH_KW );
493  rmKeyVal( &dataObjOprInp->condInput, RSYNC_MODE_KW );
494  }
495  else {
496  status = 0;
497  }
498 
499  if ( status >= 0 && myRodsArgs->verbose == True ) {
500  if ( putFlag > 0 ||
501  ( syncFlag > 0 && status == SYS_RSYNC_TARGET_MODIFIED ) ) {
502  ( void ) gettimeofday( &endTime, ( struct timezone * )0 );
503  printTiming( conn, srcPath->outPath, srcPath->size,
504  targPath->outPath, &startTime, &endTime );
505  }
506  else {
507  printNoSync( srcPath->outPath, srcPath->size, "a match" );
508  }
509  }
510 
511  return status;
512 }
513 
514 int
516  rodsPath_t *targPath, rodsArguments_t *myRodsArgs,
517  dataObjCopyInp_t *dataObjCopyInp ) {
518  int status;
519  struct timeval startTime, endTime;
520  int syncFlag = 0;
521  int cpFlag = 0;
522 
523  if ( srcPath == NULL || targPath == NULL ) {
525  "rsyncDataToDataUtil: NULL srcPath or targPath input" );
526  return USER__NULL_INPUT_ERR;
527  }
528  /* check the age */
529  if ( myRodsArgs->age == True ) {
530  if ( srcPath->rodsObjStat != NULL ) {
531  if ( ageExceeded( myRodsArgs->agevalue,
532  atoi( srcPath->rodsObjStat->modifyTime ),
533  srcPath->outPath, srcPath->size ) ) {
534  return 0;
535  }
536  }
537  }
538 
539  if ( myRodsArgs->verbose == True ) {
540  ( void ) gettimeofday( &startTime, ( struct timezone * )0 );
541  bzero( &conn->transStat, sizeof( transStat_t ) );
542  }
543 
544  if ( targPath->objState == NOT_EXIST_ST ) {
545  cpFlag = 1;
546  }
547  else if ( myRodsArgs->sizeFlag == True ) {
548  /* sync by size */
549  if ( targPath->size != srcPath->size ) {
550  cpFlag = 1;
551  }
552  }
553  else if ( strlen( srcPath->chksum ) > 0 && strlen( targPath->chksum ) > 0 ) {
554  /* src and trg has a checksum value */
555  if ( strcmp( targPath->chksum, srcPath->chksum ) != 0 ) {
556  cpFlag = 1;
557  }
558  }
559  else {
560  syncFlag = 1;
561  }
562 
563  if ( cpFlag == 1 ) {
564  rstrcpy( dataObjCopyInp->srcDataObjInp.objPath, srcPath->outPath,
565  MAX_NAME_LEN );
566  dataObjCopyInp->srcDataObjInp.dataSize = srcPath->size;
567  rstrcpy( dataObjCopyInp->destDataObjInp.objPath, targPath->outPath,
568  MAX_NAME_LEN );
569  /* only do the sync if no -l option specified */
570  if ( myRodsArgs->longOption != True ) {
571  status = rcDataObjCopy( conn, dataObjCopyInp );
572 
573  if ( status < 0 ) {
574  char* sys_error = NULL;
575  const char* rods_error = rodsErrorName( status, &sys_error );
576  std::stringstream msg;
577  msg << __FUNCTION__;
578  msg << " - Failed to copy the object \"";
579  msg << srcPath->outPath;
580  msg << "\" to \"";
581  msg << targPath->outPath;
582  msg << "\" ";
583  msg << rods_error << " " << sys_error;
584  irods::log( LOG_ERROR, msg.str() );
585  free( sys_error );
586  }
587 
588  }
589  else {
590  status = 0;
591  printf( "%s %lld N\n", srcPath->outPath, srcPath->size );
592  }
593  }
594  else if ( syncFlag == 1 ) {
595  dataObjInp_t *dataObjOprInp = &dataObjCopyInp->destDataObjInp;
596  rstrcpy( dataObjOprInp->objPath, srcPath->outPath,
597  MAX_NAME_LEN );
598  dataObjOprInp->dataSize = srcPath->size;
599  addKeyVal( &dataObjOprInp->condInput, RSYNC_DEST_PATH_KW,
600  targPath->outPath );
601  addKeyVal( &dataObjOprInp->condInput, RSYNC_MODE_KW, IRODS_TO_IRODS );
602  /* only do the sync if no -l option specified */
603  if ( myRodsArgs->longOption != True ) {
604  status = rcDataObjRsync( conn, dataObjOprInp );
605  }
606  else {
607  status = 0;
608  printf( "%s %lld N\n", srcPath->outPath, srcPath->size );
609  }
610  rmKeyVal( &dataObjOprInp->condInput, RSYNC_MODE_KW );
611  rmKeyVal( &dataObjOprInp->condInput, RSYNC_DEST_PATH_KW );
612  }
613  else {
614  status = 0;
615  }
616 
617  if ( status >= 0 && myRodsArgs->verbose == True ) {
618  if ( cpFlag > 0 ||
619  ( syncFlag > 0 && status == SYS_RSYNC_TARGET_MODIFIED ) ) {
620  ( void ) gettimeofday( &endTime, ( struct timezone * )0 );
621  printTiming( conn, srcPath->outPath, srcPath->size,
622  targPath->outPath, &startTime, &endTime );
623  }
624  else {
625  printNoSync( srcPath->outPath, srcPath->size, "a match" );
626  }
627  }
628 
629  return status;
630 }
631 
632 int
634  rodsPath_t *targPath, rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs,
635  dataObjInp_t *dataObjOprInp ) {
636  int status = 0;
637  int savedStatus = 0;
638  char *srcColl, *targDir;
639  char targChildPath[MAX_NAME_LEN];
640  char parPath[MAX_NAME_LEN], childPath[MAX_NAME_LEN];
641  rodsPath_t mySrcPath, myTargPath;
642  collHandle_t collHandle;
643  collEnt_t collEnt;
644  dataObjInp_t childDataObjInp;
645 
646  if ( srcPath == NULL || targPath == NULL ) {
648  "rsyncCollToDirUtil: NULL srcPath or targPath input" );
649  return USER__NULL_INPUT_ERR;
650  }
651 
652  srcColl = srcPath->outPath;
653  targDir = targPath->outPath;
654 
655  if ( rodsArgs->recursive != True ) {
657  "rsyncCollToDirUtil: -r option must be used for collection %s",
658  targDir );
659  return USER_INPUT_OPTION_ERR;
660  }
661 
662  status = rclOpenCollection( conn, srcColl,
663  VERY_LONG_METADATA_FG, &collHandle );
664 
665  if ( status < 0 ) {
667  "rsyncCollToDirUtil: rclOpenCollection of %s error. status = %d",
668  srcColl, status );
669  return status;
670  }
671 
672  memset( &mySrcPath, 0, sizeof( mySrcPath ) );
673  memset( &myTargPath, 0, sizeof( myTargPath ) );
674  myTargPath.objType = LOCAL_FILE_T;
675  mySrcPath.objType = DATA_OBJ_T;
676 
677  while ( ( status = rclReadCollection( conn, &collHandle, &collEnt ) ) >= 0 ) {
678  if ( collEnt.objType == DATA_OBJ_T ) {
679  if ( rodsArgs->age == True ) {
680  if ( ageExceeded( rodsArgs->agevalue,
681  atoi( collEnt.modifyTime ),
682  collEnt.dataName, collEnt.dataSize ) ) {
683  continue;
684  }
685  }
686  snprintf( myTargPath.outPath, MAX_NAME_LEN, "%s/%s",
687  targDir, collEnt.dataName );
688  snprintf( mySrcPath.outPath, MAX_NAME_LEN, "%s/%s",
689  collEnt.collName, collEnt.dataName );
690  /* fill in some info for mySrcPath */
691  if ( strlen( mySrcPath.dataId ) == 0 ) {
692  rstrcpy( mySrcPath.dataId, collEnt.dataId, NAME_LEN );
693  }
694  mySrcPath.size = collEnt.dataSize;
695  mySrcPath.objMode = collEnt.dataMode;
696  rstrcpy( mySrcPath.chksum, collEnt.chksum, NAME_LEN );
697  mySrcPath.objState = EXIST_ST;
698 
699  getFileType( &myTargPath );
700 
701  int status = rsyncDataToFileUtil( conn, &mySrcPath, &myTargPath,
702  rodsArgs, dataObjOprInp );
703  if ( status < 0 ) {
705  "rsyncCollUtil: rsyncDataObjUtil failed for %s. status = %d",
706  mySrcPath.outPath, status );
707  /* need to set global error here */
708  savedStatus = status;
709  }
710  }
711  else if ( collEnt.objType == COLL_OBJ_T ) {
712  if ( ( status = splitPathByKey(
713  collEnt.collName, parPath, MAX_NAME_LEN, childPath, MAX_NAME_LEN, '/' ) ) < 0 ) {
715  "rsyncCollToDirUtil:: splitPathByKey for %s error, stat=%d",
716  collEnt.collName, status );
717  return status;
718  }
719  snprintf( targChildPath, MAX_NAME_LEN, "%s/%s",
720  targDir, childPath );
721 
722  /* only do the sync if no -l option specified */
723  if ( rodsArgs->longOption != True ) {
724  mkdirR( targDir, targChildPath, 0750 );
725  }
726 
727  /* the child is a spec coll. need to drill down */
728  childDataObjInp = *dataObjOprInp;
729  if ( collEnt.specColl.collClass != NO_SPEC_COLL ) {
730  childDataObjInp.specColl = &collEnt.specColl;
731  }
732  else {
733  childDataObjInp.specColl = NULL;
734  }
735  rstrcpy( myTargPath.outPath, targChildPath, MAX_NAME_LEN );
736  rstrcpy( mySrcPath.outPath, collEnt.collName, MAX_NAME_LEN );
737 
738  int status = rsyncCollToDirUtil( conn, &mySrcPath,
739  &myTargPath, myRodsEnv, rodsArgs, &childDataObjInp );
740 
741  if ( status < 0 && status != CAT_NO_ROWS_FOUND ) {
742  return status;
743  }
744  }
745  }
746  rclCloseCollection( &collHandle );
747 
748  if ( savedStatus < 0 ) {
749  return savedStatus;
750  }
751  else if ( status == CAT_NO_ROWS_FOUND ||
753  return 0;
754  }
755  else {
756  return status;
757  }
758 }
759 
760 int
762  rodsPath_t *targPath, rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs,
763  dataObjInp_t *dataObjOprInp ) {
764  namespace fs = boost::filesystem;
765 
766  char *srcDir, *targColl;
767  rodsPath_t mySrcPath, myTargPath;
768  int status = 0;
769 
770  if ( srcPath == NULL || targPath == NULL ) {
772  "rsyncDirToCollUtil: NULL srcPath or targPath input" );
773  return USER__NULL_INPUT_ERR;
774  }
775 
776  srcDir = srcPath->outPath;
777  targColl = targPath->outPath;
778 
779  if ( rodsArgs->recursive != True ) {
781  "rsyncDirToCollUtil: -r option must be used for putting %s directory",
782  srcDir );
783  return USER_INPUT_OPTION_ERR;
784  }
785 
786  fs::path srcDirPath( srcDir );
787  if ( !exists( srcDirPath ) || !is_directory( srcDirPath ) ) {
789  "rsyncDirToCollUtil: opendir local dir error for %s, errno = %d\n",
790  srcDir, errno );
791  return USER_INPUT_PATH_ERR;
792  }
793 
794  try
795  {
796  if (! irods::is_path_valid_for_recursion(rodsArgs, srcDir))
797  {
798  return 0;
799  }
800  }
801  catch ( const irods::exception& _e )
802  {
804  return USER_INPUT_PATH_ERR;
805  }
806 
807  if ( rodsArgs->verbose == True ) {
808  fprintf( stdout, "C- %s:\n", targColl );
809  }
810 
811  memset( &mySrcPath, 0, sizeof( mySrcPath ) );
812  memset( &myTargPath, 0, sizeof( myTargPath ) );
813  myTargPath.objType = DATA_OBJ_T;
814  mySrcPath.objType = LOCAL_FILE_T;
815 
816  fs::directory_iterator end_itr; // default construction yields past-the-end
817  int savedStatus = 0;
818  for ( fs::directory_iterator itr( srcDirPath );
819  itr != end_itr;
820  ++itr ) {
821  fs::path p = itr->path();
822  snprintf( mySrcPath.outPath, MAX_NAME_LEN, "%s", p.c_str() );
823 
824  try {
825  if (! irods::is_path_valid_for_recursion(rodsArgs, mySrcPath.outPath))
826  {
827  continue;
828  }
829  } catch ( const irods::exception& _e ) {
831  return USER_INPUT_PATH_ERR;
832  }
833 
834  if ( !exists( p ) ) {
835  rodsLog( LOG_ERROR, "rsyncDirToCollUtil: stat error for %s, errno = %d\n", mySrcPath.outPath, errno );
836  return USER_INPUT_PATH_ERR;
837  }
838 
839  if ( ( is_regular_file( p ) && rodsArgs->age == True ) &&
840  ageExceeded(
841  rodsArgs->agevalue,
842  last_write_time( p ),
843  mySrcPath.outPath,
844  file_size( p ) ) ) {
845  continue;
846  }
847 
848  bzero( &myTargPath, sizeof( myTargPath ) );
849  fs::path childPath = p.filename();
850  snprintf( myTargPath.outPath, MAX_NAME_LEN, "%s/%s",
851  targColl, childPath.c_str() );
852  if ( is_symlink( p ) ) {
853  fs::path cp = read_symlink( p );
854  // Issue 3663 - If the path is FQDN, do not add srcDir on path
855  if (cp.is_relative()) {
856  snprintf( mySrcPath.outPath, MAX_NAME_LEN, "%s/%s", srcDir, cp.c_str() );
857  } else {
858  snprintf( mySrcPath.outPath, MAX_NAME_LEN, "%s", cp.c_str() );
859  }
860  p = mySrcPath.outPath;
861  }
862  dataObjOprInp->createMode = getPathStMode( p.c_str() );
863  status = 0;
864  if ( is_regular_file( p ) ) {
865  myTargPath.objType = DATA_OBJ_T;
866  mySrcPath.objType = LOCAL_FILE_T;
867  mySrcPath.objState = EXIST_ST;
868 
869  mySrcPath.size = file_size( p );
870  getRodsObjType( conn, &myTargPath );
871  status = rsyncFileToDataUtil( conn, &mySrcPath, &myTargPath,
872  rodsArgs, dataObjOprInp );
873  /* fix a big mem leak */
874  if ( myTargPath.rodsObjStat != NULL ) {
875  freeRodsObjStat( myTargPath.rodsObjStat );
876  myTargPath.rodsObjStat = NULL;
877  }
878  }
879  else if ( is_directory( p ) ) {
880  /* only do the sync if no -l option specified */
881  if ( rodsArgs->longOption != True ) {
882  status = mkCollR (conn, targColl, myTargPath.outPath);
883  }
884  if ( status < 0 ) {
886  "rsyncDirToCollUtil: mkColl error for %s",
887  myTargPath.outPath );
888  }
889  else {
890  myTargPath.objType = COLL_OBJ_T;
891  mySrcPath.objType = LOCAL_DIR_T;
892  mySrcPath.objState = myTargPath.objState = EXIST_ST;
893  getRodsObjType( conn, &myTargPath );
894  status = rsyncDirToCollUtil( conn, &mySrcPath, &myTargPath,
895  myRodsEnv, rodsArgs, dataObjOprInp );
896  /* fix a big mem leak */
897  if ( myTargPath.rodsObjStat != NULL ) {
898  freeRodsObjStat( myTargPath.rodsObjStat );
899  myTargPath.rodsObjStat = NULL;
900  }
901  }
902  }
903  else {
905  "rsyncDirToCollUtil: unknown local path %s",
906  mySrcPath.outPath );
908  }
909 
910  if ( status < 0 &&
913  savedStatus = status;
915  "rsyncDirToCollUtil: put %s failed. status = %d",
916  mySrcPath.outPath, status );
917  }
918  }
919 
920  return savedStatus;
921 
922 }
923 
924 int
926  rodsPath_t *targPath, rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs,
927  dataObjCopyInp_t *dataObjCopyInp ) {
928  int status = 0;
929  int savedStatus = 0;
930  char *srcColl, *targColl;
931  char targChildPath[MAX_NAME_LEN];
932  char parPath[MAX_NAME_LEN], childPath[MAX_NAME_LEN];
933 
934  rodsPath_t mySrcPath, myTargPath;
935  collHandle_t collHandle;
936  collEnt_t collEnt;
937  dataObjCopyInp_t childDataObjCopyInp;
938 
939  dataObjInp_t *dataObjOprInp = &collHandle.dataObjInp;
940 
941  if ( srcPath == NULL || targPath == NULL ) {
943  "rsyncCollToCollUtil: NULL srcPath or targPath input" );
944  return USER__NULL_INPUT_ERR;
945  }
946 
947  srcColl = srcPath->outPath;
948  targColl = targPath->outPath;
949 
950  if ( rodsArgs->recursive != True ) {
952  "rsyncCollToCollUtil: -r option must be used for collection %s",
953  targColl );
954  return USER_INPUT_OPTION_ERR;
955  }
956 
957  status = rclOpenCollection( conn, srcColl,
958  VERY_LONG_METADATA_FG, &collHandle );
959 
960  if ( status < 0 ) {
962  "getCollUtil: rclOpenCollection of %s error. status = %d",
963  srcColl, status );
964  return status;
965  }
966 
967  if ( dataObjOprInp->specColl != NULL ) {
968  if ( rodsArgs->verbose == True ) {
969  if ( rodsArgs->verbose == True ) {
970  char objType[NAME_LEN];
971  status = getSpecCollTypeStr( dataObjOprInp->specColl, objType );
972  if ( status < 0 ) {
973  fprintf( stdout, "C- %s :\n", targColl );
974  }
975  else {
976  fprintf( stdout, "C- %s %-5.5s :\n", targColl, objType );
977  }
978  }
979  }
980  }
981 
982  memset( &mySrcPath, 0, sizeof( mySrcPath ) );
983  memset( &myTargPath, 0, sizeof( myTargPath ) );
984  myTargPath.objType = DATA_OBJ_T;
985  mySrcPath.objType = DATA_OBJ_T;
986 
987  while ( ( status = rclReadCollection( conn, &collHandle, &collEnt ) ) >= 0 ) {
988  if ( collEnt.objType == DATA_OBJ_T ) {
989  if ( rodsArgs->age == True ) {
990  if ( ageExceeded( rodsArgs->agevalue,
991  atoi( collEnt.modifyTime ),
992  collEnt.dataName, collEnt.dataSize ) ) {
993  continue;
994  }
995  }
996 
997  snprintf( myTargPath.outPath, MAX_NAME_LEN, "%s/%s",
998  targColl, collEnt.dataName );
999 
1000  snprintf( mySrcPath.outPath, MAX_NAME_LEN, "%s/%s",
1001  collEnt.collName, collEnt.dataName );
1002  /* fill in some info for mySrcPath */
1003  if ( strlen( mySrcPath.dataId ) == 0 ) {
1004  rstrcpy( mySrcPath.dataId, collEnt.dataId, NAME_LEN );
1005  }
1006  mySrcPath.size = collEnt.dataSize;
1007  rstrcpy( mySrcPath.chksum, collEnt.chksum, NAME_LEN );
1008  mySrcPath.objState = EXIST_ST;
1009 
1010  getRodsObjType( conn, &myTargPath );
1011 
1012  int status = rsyncDataToDataUtil( conn, &mySrcPath, &myTargPath,
1013  rodsArgs, dataObjCopyInp );
1014  if ( myTargPath.rodsObjStat != NULL ) {
1015  freeRodsObjStat( myTargPath.rodsObjStat );
1016  myTargPath.rodsObjStat = NULL;
1017  }
1018  if ( status < 0 ) {
1020  "rsyncCollToCollUtil: rsyncDataToDataUtil failed for %s.stat=%d",
1021  myTargPath.outPath, status );
1022  /* need to set global error here */
1023  savedStatus = status;
1024  }
1025  }
1026  else if ( collEnt.objType == COLL_OBJ_T ) {
1027  if ( ( status = splitPathByKey(
1028  collEnt.collName, parPath, MAX_NAME_LEN, childPath, MAX_NAME_LEN, '/' ) ) < 0 ) {
1030  "rsyncCollToCollUtil:: splitPathByKey for %s error, status = %d",
1031  collEnt.collName, status );
1032  return status;
1033  }
1034  snprintf( targChildPath, MAX_NAME_LEN, "%s/%s",
1035  targColl, childPath );
1036 
1037  if ( rodsArgs->longOption != True ) { /* only do the sync if no -l option specified */
1038  mkColl( conn, targChildPath );
1039  }
1040 
1041  /* the child is a spec coll. need to drill down */
1042  childDataObjCopyInp = *dataObjCopyInp;
1043  if ( collEnt.specColl.collClass != NO_SPEC_COLL )
1044  childDataObjCopyInp.srcDataObjInp.specColl =
1045  &collEnt.specColl;
1046  rstrcpy( myTargPath.outPath, targChildPath, MAX_NAME_LEN );
1047  rstrcpy( mySrcPath.outPath, collEnt.collName, MAX_NAME_LEN );
1048  int status = rsyncCollToCollUtil( conn, &mySrcPath,
1049  &myTargPath, myRodsEnv, rodsArgs, &childDataObjCopyInp );
1050 
1051 
1052  if ( status < 0 && status != CAT_NO_ROWS_FOUND ) {
1053  return status;
1054  }
1055 
1056 
1057 
1058  }
1059  }
1060  rclCloseCollection( &collHandle );
1061 
1062  if ( savedStatus < 0 ) {
1063  return savedStatus;
1064  }
1065  else if ( status == CAT_NO_ROWS_FOUND ||
1067  return 0;
1068  }
1069  else {
1070  return status;
1071  }
1072 }
1073 
1074 int
1076  dataObjInp_t *dataObjInp ) {
1077  char tmpStr[NAME_LEN];
1078 
1079 
1080  if ( dataObjInp == NULL ) {
1081  rodsLog( LOG_ERROR,
1082  "initCondForRsync: NULL dataObjOprInp input" );
1083  return USER__NULL_INPUT_ERR;
1084  }
1085 
1086  memset( dataObjInp, 0, sizeof( dataObjInp_t ) );
1087 
1088  if ( rodsArgs == NULL ) {
1089  return 0;
1090  }
1091 
1092  /* always turn on the force flag */
1093  addKeyVal( &dataObjInp->condInput, FORCE_FLAG_KW, "" );
1094 
1095  if ( rodsArgs->sizeFlag == True ) {
1096  addKeyVal( &dataObjInp->condInput, VERIFY_BY_SIZE_KW, "" );
1097  }
1098 
1099  if ( rodsArgs->all == True ) {
1100  addKeyVal( &dataObjInp->condInput, ALL_KW, "" );
1101  }
1102 
1103 #ifdef windows_platform
1104  dataObjInp->numThreads = NO_THREADING;
1105 #else
1106  if ( rodsArgs->number == True ) {
1107  if ( rodsArgs->numberValue == 0 ) {
1108  dataObjInp->numThreads = NO_THREADING;
1109  }
1110  else {
1111  dataObjInp->numThreads = rodsArgs->numberValue;
1112  }
1113  }
1114 #endif
1115 
1116  if ( rodsArgs->resource == True ) {
1117  if ( rodsArgs->resourceString == NULL ) {
1118  rodsLog( LOG_ERROR,
1119  "initCondForRepl: NULL resourceString error" );
1120  return USER__NULL_INPUT_ERR;
1121  }
1122  else {
1123  addKeyVal( &dataObjInp->condInput, DEST_RESC_NAME_KW,
1124  rodsArgs->resourceString );
1125  }
1126  }
1127  else if ( myRodsEnv != NULL && strlen( myRodsEnv->rodsDefResource ) > 0 ) {
1128  addKeyVal( &dataObjInp->condInput, DEST_RESC_NAME_KW,
1129  myRodsEnv->rodsDefResource );
1130  }
1131  if ( rodsArgs->age == True ) {
1132  snprintf( tmpStr, NAME_LEN, "%d", rodsArgs->agevalue );
1133  addKeyVal( &dataObjInp->condInput, AGE_KW, tmpStr );
1134  }
1135 
1136  return 0;
1137 }
1138 
1139 int
1141  dataObjCopyInp_t *dataObjCopyInp ) {
1142  char tmpStr[NAME_LEN];
1143 
1144  if ( dataObjCopyInp == NULL ) {
1145  rodsLog( LOG_ERROR,
1146  "initCondForCp: NULL dataObjCopyInp incp" );
1147  return USER__NULL_INPUT_ERR;
1148  }
1149 
1150  memset( dataObjCopyInp, 0, sizeof( dataObjCopyInp_t ) );
1151 
1152  if ( rodsArgs == NULL ) {
1153  return 0;
1154  }
1155 
1156  /* always turn on the force flag */
1157  addKeyVal( &dataObjCopyInp->destDataObjInp.condInput, FORCE_FLAG_KW, "" );
1158 
1159  if ( rodsArgs->sizeFlag == True ) {
1160  addKeyVal( &dataObjCopyInp->destDataObjInp.condInput,
1161  VERIFY_BY_SIZE_KW, "" );
1162  }
1163 
1164  if ( rodsArgs->all == True ) {
1165  addKeyVal( &dataObjCopyInp->destDataObjInp.condInput, ALL_KW, "" );
1166  }
1167 
1168  if ( rodsArgs->resource == True ) {
1169  if ( rodsArgs->resourceString == NULL ) {
1170  rodsLog( LOG_ERROR,
1171  "initCondForRepl: NULL resourceString error" );
1172  return USER__NULL_INPUT_ERR;
1173  }
1174  else {
1175  addKeyVal( &dataObjCopyInp->destDataObjInp.condInput,
1176  DEST_RESC_NAME_KW, rodsArgs->resourceString );
1177  }
1178  }
1179  else if ( myRodsEnv != NULL && strlen( myRodsEnv->rodsDefResource ) > 0 ) {
1180  addKeyVal( &dataObjCopyInp->destDataObjInp.condInput,
1181  DEST_RESC_NAME_KW, myRodsEnv->rodsDefResource );
1182  }
1183 // =-=-=-=-=-=-=-
1184 // JMC - backport 4865
1185 #ifdef windows_platform
1186  dataObjCopyInp->destDataObjInp.numThreads = NO_THREADING;
1187 #else
1188  if ( rodsArgs->number == True ) {
1189  if ( rodsArgs->numberValue == 0 ) {
1190  dataObjCopyInp->destDataObjInp.numThreads = NO_THREADING;
1191  }
1192  else {
1193  dataObjCopyInp->destDataObjInp.numThreads = rodsArgs->numberValue;
1194  }
1195  }
1196 #endif
1197 // =-=-=-=-=-=-=-
1198  if ( rodsArgs->age == True ) {
1199  snprintf( tmpStr, NAME_LEN, "%d", rodsArgs->agevalue );
1200  addKeyVal( &dataObjCopyInp->destDataObjInp.condInput, AGE_KW, tmpStr );
1201  }
1202 
1203  if ( rodsArgs->verifyChecksum == True ) {
1204  addKeyVal( &dataObjCopyInp->destDataObjInp.condInput,
1205  VERIFY_CHKSUM_KW, "" );
1206  }
1207 
1208  return 0;
1209 }
1210 
1211 int
1212 ageExceeded( int ageLimit, int myTime, char *objPath,
1213  rodsLong_t fileSize ) {
1214  int age;
1215 
1216  if ( CurrentTime == 0 ) {
1217  CurrentTime = time( 0 );
1218  }
1219  age = CurrentTime - myTime;
1220  if ( age > ageLimit * 60 ) {
1221  printNoSync( objPath, fileSize, "age" );
1222  return 1;
1223  }
1224  else {
1225  return 0;
1226  }
1227 }
1228 
rsyncDataToDataUtil
int rsyncDataToDataUtil(rcComm_t *conn, rodsPath_t *srcPath, rodsPath_t *targPath, rodsArguments_t *myRodsArgs, dataObjCopyInp_t *dataObjCopyInp)
Definition: rsyncUtil.cpp:515
ageExceeded
int ageExceeded(int ageLimit, int myTime, char *objPath, rodsLong_t fileSize)
Definition: rsyncUtil.cpp:1212
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
rcComm_t
Definition: rcConnect.h:95
NULL
#define NULL
Definition: rodsDef.h:70
rsyncCollToCollUtil
int rsyncCollToCollUtil(rcComm_t *conn, rodsPath_t *srcPath, rodsPath_t *targPath, rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs, dataObjCopyInp_t *dataObjCopyInp)
Definition: rsyncUtil.cpp:925
RodsPath::rodsObjStat
rodsObjStat_t * rodsObjStat
Definition: rodsPath.h:27
True
#define True
Definition: parseCommandLine.h:11
IRODS_TO_IRODS
#define IRODS_TO_IRODS
Definition: rodsDef.h:126
DataObjCopyInp::srcDataObjInp
dataObjInp_t srcDataObjInp
Definition: dataObjCopy.h:26
addKeyVal
int addKeyVal(keyValPair_t *condInput, const char *keyWord, const char *value)
Definition: rcMisc.cpp:789
rodsPath.h
getSpecCollTypeStr
int getSpecCollTypeStr(specColl_t *specColl, char *outStr)
Definition: rcMisc.cpp:3099
rclOpenCollection
int rclOpenCollection(rcComm_t *conn, char *collection, int flag, collHandle_t *collHandle)
Definition: miscUtil.cpp:1057
rodsArguments_t::sizeFlag
int sizeFlag
Definition: parseCommandLine.h:90
rodsArguments_t::all
int all
Definition: parseCommandLine.h:18
DataObjCopyInp
Definition: dataObjCopy.h:25
RodsPath::chksum
char chksum[64]
Definition: rodsPath.h:26
DataObjInp::openFlags
int openFlags
Definition: dataObjInpOut.h:68
getRodsEnv
int getRodsEnv(rodsEnv *myRodsEnv)
Definition: getRodsEnv.cpp:112
rodsArguments_t
Definition: parseCommandLine.h:14
irods::disallow_file_dir_mix_on_command_line
int disallow_file_dir_mix_on_command_line(rodsArguments_t const *const rodsArgs, rodsPathInp_t const *const rodsPathInp)
Definition: irods_path_recursion.cpp:354
DataObjInp::specColl
specColl_t * specColl
Definition: dataObjInpOut.h:73
initCondForIrodsToIrodsRsync
int initCondForIrodsToIrodsRsync(rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs, dataObjCopyInp_t *dataObjCopyInp)
Definition: rsyncUtil.cpp:1140
RodsPathInp
Definition: rodsPath.h:33
collHandle_t
Definition: miscUtil.h:97
DataObjInp::dataSize
rodsLong_t dataSize
Definition: dataObjInpOut.h:70
rodsArguments_t::verbose
int verbose
Definition: parseCommandLine.h:107
CollEnt::collName
char * collName
Definition: miscUtil.h:119
irods_exception.hpp
SYS_SPEC_COLL_OBJ_NOT_EXIST
@ SYS_SPEC_COLL_OBJ_NOT_EXIST
Definition: rodsErrorTable.h:123
env
Definition: restructs.hpp:226
RSYNC_DEST_PATH_KW
#define RSYNC_DEST_PATH_KW
Definition: rodsKeyWdDef.h:57
irods::experimental::administration::client::v1::exists
auto exists(rcComm_t &conn, const user &user) -> bool
Definition: user_administration.cpp:359
mkCollR
int mkCollR(rcComm_t *conn, char *startColl, char *destColl)
Definition: miscUtil.cpp:51
pid_age.p
p
Definition: pid_age.py:13
resolveRodsTarget
int resolveRodsTarget(rcComm_t *conn, rodsPathInp_t *rodsPathInp, int oprType)
Definition: miscUtil.cpp:2342
CollEnt::dataSize
rodsLong_t dataSize
Definition: miscUtil.h:118
checksum.hpp
irods::experimental::filesystem::client::last_write_time
auto last_write_time(rcComm_t &_comm, const path &_p) -> object_time_type
Definition: filesystem.cpp:645
mkdirR
int mkdirR(char *startDir, char *destDir, int mode)
Definition: miscUtil.cpp:106
RodsPath::objState
objStat_t objState
Definition: rodsPath.h:20
irods::get_hash_scheme_from_checksum
error get_hash_scheme_from_checksum(const std::string &checksum, std::string &scheme)
Definition: irods_hasher_factory.cpp:39
ALL_KW
#define ALL_KW
Definition: rodsKeyWdDef.h:10
rodsArguments_t::resource
int resource
Definition: parseCommandLine.h:86
STRUCT_FILE_COLL
@ STRUCT_FILE_COLL
Definition: objInfo.h:47
rcGlobalExtern.h
getPathStMode
int getPathStMode(const char *p)
Definition: rcMisc.cpp:4354
RodsPathInp::srcPath
rodsPath_t * srcPath
Definition: rodsPath.h:35
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
RodsPath::objType
objType_t objType
Definition: rodsPath.h:19
rodsErrorName
const char * rodsErrorName(int errorValue, char **subName)
Definition: rodsLog.cpp:373
NO_THREADING
#define NO_THREADING
Definition: rodsDef.h:100
CollEnt::dataId
char * dataId
Definition: miscUtil.h:121
RSYNC_OPR
#define RSYNC_OPR
Definition: dataObjInpOut.h:180
RodsPath::dataId
char dataId[64]
Definition: rodsPath.h:25
freeRodsObjStat
int freeRodsObjStat(rodsObjStat_t *rodsObjStat)
Definition: rcMisc.cpp:3537
mkColl
int mkColl(rcComm_t *conn, char *collection)
Definition: miscUtil.cpp:31
REG_CHKSUM_KW
#define REG_CHKSUM_KW
Definition: rodsKeyWdDef.h:15
COLL_OBJ_T
@ COLL_OBJ_T
Definition: rodsType.h:39
RodsPathInp::targPath
rodsPath_t * targPath
Definition: rodsPath.h:37
DEST_RESC_NAME_KW
#define DEST_RESC_NAME_KW
Definition: rodsKeyWdDef.h:20
rsyncDataToFileUtil
int rsyncDataToFileUtil(rcComm_t *conn, rodsPath_t *srcPath, rodsPath_t *targPath, rodsArguments_t *myRodsArgs, dataObjInp_t *dataObjOprInp)
Definition: rsyncUtil.cpp:179
rodsArguments_t::verifyChecksum
int verifyChecksum
Definition: parseCommandLine.h:53
rodsObjStat::modifyTime
char modifyTime[32]
Definition: objStat.h:17
rsyncFileToDataUtil
int rsyncFileToDataUtil(rcComm_t *conn, rodsPath_t *srcPath, rodsPath_t *targPath, rodsArguments_t *myRodsArgs, dataObjInp_t *dataObjOprInp)
Definition: rsyncUtil.cpp:324
myChmod
int myChmod(char *inPath, uint dataMode)
Definition: miscUtil.cpp:1815
printNoSync
int printNoSync(char *objPath, rodsLong_t fileSize, char *reason)
Definition: miscUtil.cpp:491
rclCloseCollection
int rclCloseCollection(collHandle_t *collHandle)
Definition: miscUtil.cpp:1354
rsyncUtil.h
LOCAL_TO_IRODS
#define LOCAL_TO_IRODS
Definition: rodsDef.h:124
rodsArguments_t::age
int age
Definition: parseCommandLine.h:16
rcDataObjGet
int rcDataObjGet(rcComm_t *conn, dataObjInp_t *dataObjInp, char *locFilePath)
Definition: rcDataObjGet.cpp:91
CollEnt
Definition: miscUtil.h:113
CollEnt::specColl
specColl_t specColl
Definition: miscUtil.h:130
DataObjInp
Definition: dataObjInpOut.h:65
collHandle_t::dataObjInp
dataObjInp_t dataObjInp
Definition: miscUtil.h:105
irods::file_system_sanity_check
int file_system_sanity_check(irods::recursion_map_t &, rodsArguments_t const *const, rodsPathInp_t const *const)
Definition: irods_path_recursion.cpp:282
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
rmKeyVal
int rmKeyVal(keyValPair_t *condInput, const char *keyWord)
Definition: rcMisc.cpp:710
VERIFY_BY_SIZE_KW
#define VERIFY_BY_SIZE_KW
Definition: rodsKeyWdDef.h:17
RodsPath::size
rodsLong_t size
Definition: rodsPath.h:21
transStat_t
Definition: objInfo.h:286
CollEnt::modifyTime
char * modifyTime
Definition: miscUtil.h:123
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
NO_SPEC_COLL
@ NO_SPEC_COLL
Definition: objInfo.h:46
RSYNC_MODE_KW
#define RSYNC_MODE_KW
Definition: rodsKeyWdDef.h:56
TRANSLATED_PATH_KW
#define TRANSLATED_PATH_KW
Definition: rodsKeyWdDef.h:97
splitPathByKey
int splitPathByKey(const char *srcPath, char *dir, size_t maxDirLen, char *file, size_t maxFileLen, char key)
Definition: stringOpr.cpp:222
rodsLog.h
irods::log
void log(const error &)
Definition: irods_log.cpp:13
rodsArguments_t::resourceString
char * resourceString
Definition: parseCommandLine.h:87
rsyncUtil
int rsyncUtil(rcComm_t *conn, rodsEnv *myRodsEnv, rodsArguments_t *myRodsArgs, rodsPathInp_t *rodsPathInp)
Definition: rsyncUtil.cpp:31
CollEnt::dataMode
uint dataMode
Definition: miscUtil.h:117
irods::is_path_valid_for_recursion
bool is_path_valid_for_recursion(boost::filesystem::path const &, recursion_map_t &, bool)
Definition: irods_path_recursion.cpp:80
irods::exception::client_display_what
virtual const char * client_display_what() const
Definition: irods_exception.cpp:52
rsyncCollToDirUtil
int rsyncCollToDirUtil(rcComm_t *conn, rodsPath_t *srcPath, rodsPath_t *targPath, rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs, dataObjInp_t *dataObjOprInp)
Definition: rsyncUtil.cpp:633
irods::error
Definition: irods_error.hpp:23
AGE_KW
#define AGE_KW
Definition: rodsKeyWdDef.h:221
DATA_OBJ_T
@ DATA_OBJ_T
Definition: rodsType.h:38
DataObjInp::createMode
int createMode
Definition: dataObjInpOut.h:67
CollEnt::dataName
char * dataName
Definition: miscUtil.h:120
rcDataObjCopy
int rcDataObjCopy(rcComm_t *conn, dataObjCopyInp_t *dataObjCopyInp)
Definition: rcDataObjCopy.cpp:85
rodsEnv::rodsDefResource
char rodsDefResource[64]
Definition: getRodsEnv.h:17
RodsPath::outPath
char outPath[(1024+64)]
Definition: rodsPath.h:24
DataObjCopyInp::destDataObjInp
dataObjInp_t destDataObjInp
Definition: dataObjCopy.h:27
printTiming
int printTiming(rcComm_t *conn, char *objPath, rodsLong_t fileSize, char *localFile, struct timeval *startTime, struct timeval *endTime)
Definition: miscUtil.cpp:396
rodsArguments_t::recursive
int recursive
Definition: parseCommandLine.h:85
FORCE_FLAG_KW
#define FORCE_FLAG_KW
Definition: rodsKeyWdDef.h:13
rsyncDirToCollUtil
int rsyncDirToCollUtil(rcComm_t *conn, rodsPath_t *srcPath, rodsPath_t *targPath, rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs, dataObjInp_t *dataObjOprInp)
Definition: rsyncUtil.cpp:761
RodsPath::objMode
uint objMode
Definition: rodsPath.h:22
rcChksumLocFile
int rcChksumLocFile(char *fileName, char *chksumFlag, keyValPair_t *condInput, const char *)
Definition: checksum.cpp:228
CAT_NO_ROWS_FOUND
@ CAT_NO_ROWS_FOUND
Definition: rodsErrorTable.h:423
RSYNC_CHKSUM_KW
#define RSYNC_CHKSUM_KW
Definition: rodsKeyWdDef.h:58
IRODS_TO_LOCAL
#define IRODS_TO_LOCAL
Definition: rodsDef.h:125
SYS_RSYNC_TARGET_MODIFIED
#define SYS_RSYNC_TARGET_MODIFIED
Definition: rodsDef.h:114
initCondForRsync
int initCondForRsync(rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs, dataObjInp_t *dataObjInp)
Definition: rsyncUtil.cpp:1075
VERY_LONG_METADATA_FG
#define VERY_LONG_METADATA_FG
Definition: miscUtil.h:91
rodsArguments_t::agevalue
int agevalue
Definition: parseCommandLine.h:17
VERIFY_CHKSUM_KW
#define VERIFY_CHKSUM_KW
Definition: rodsKeyWdDef.h:16
USER_INPUT_OPTION_ERR
@ USER_INPUT_OPTION_ERR
Definition: rodsErrorTable.h:249
LOCAL_DIR_T
@ LOCAL_DIR_T
Definition: rodsType.h:42
irods_hasher_factory.hpp
rodsLogError
void rodsLogError(int level, int errCode, char *formatStr,...)
Definition: rodsLog.cpp:422
RodsPathInp::numSrc
int numSrc
Definition: rodsPath.h:34
irods::exception
Definition: irods_exception.hpp:15
rodsArguments_t::longOption
int longOption
Definition: parseCommandLine.h:56
rcComm_t::transStat
transferStat_t transStat
Definition: rcConnect.h:108
rcDataObjRsync
int rcDataObjRsync(rcComm_t *conn, dataObjInp_t *dataObjInp)
Definition: rcDataObjRsync.cpp:92
CollEnt::objType
objType_t objType
Definition: miscUtil.h:114
rclReadCollection
int rclReadCollection(rcComm_t *conn, collHandle_t *collHandle, collEnt_t *collEnt)
Definition: miscUtil.cpp:1108
EXIST_ST
@ EXIST_ST
Definition: rodsType.h:49
rodsErrorTable.h
rodsObjStat::specColl
specColl_t * specColl
Definition: objStat.h:18
rcDataObjPut
int rcDataObjPut(rcComm_t *conn, dataObjInp_t *dataObjInp, char *locFilePath)
Definition: rcDataObjPut.cpp:100
irods_path_recursion.hpp
RodsPath
Definition: rodsPath.h:18
miscUtil.h
rodsArguments_t::numberValue
int numberValue
Definition: parseCommandLine.h:69
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
LOCAL_FILE_T
@ LOCAL_FILE_T
Definition: rodsType.h:41
DataObjInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:74
rodsEnv
Definition: getRodsEnv.h:8
NOT_EXIST_ST
@ NOT_EXIST_ST
Definition: rodsType.h:48
NAME_LEN
#define NAME_LEN
Definition: rodsDef.h:55
irods::recursion_map_t
std::map< std::string, std::string > recursion_map_t
Definition: irods_path_recursion.hpp:20
getFileType
int getFileType(rodsPath_t *rodsPath)
Definition: rodsPath.cpp:232
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
getRodsObjType
int getRodsObjType(rcComm_t *conn, rodsPath_t *rodsPath)
Definition: miscUtil.cpp:200
USER_INPUT_PATH_ERR
@ USER_INPUT_PATH_ERR
Definition: rodsErrorTable.h:248
CurrentTime
static int CurrentTime
Definition: rsyncUtil.cpp:25
DataObjInp::numThreads
int numThreads
Definition: dataObjInpOut.h:71
irods::error::result
std::string result() const
Definition: irods_error.cpp:201
CollEnt::chksum
char * chksum
Definition: miscUtil.h:124
irods_log.hpp
rodsLong_t
long long rodsLong_t
Definition: rodsType.h:32
rodsArguments_t::number
int number
Definition: parseCommandLine.h:68
SpecColl::collClass
specCollClass_t collClass
Definition: objInfo.h:77
USER__NULL_INPUT_ERR
@ USER__NULL_INPUT_ERR
Definition: rodsErrorTable.h:247