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)  

rsDataObjRename.cpp
Go to the documentation of this file.
1 
3 /* rsDataObjRename.c - rename a data object.
4  */
5 #include "dataObjRename.h"
6 #include "objMetaOpr.hpp"
7 #include "dataObjOpr.hpp"
8 #include "collection.hpp"
9 #include "rcMisc.h"
10 #include "resource.hpp"
11 #include "rodsErrorTable.h"
12 #include "specColl.hpp"
13 #include "physPath.hpp"
14 #include "subStructFileRename.h"
16 #include "dataObjUnlink.h"
17 #include "dataObjClose.h"
18 #include "phyBundleColl.h"
19 #include "regDataObj.h"
20 #include "fileOpendir.h"
21 #include "fileReaddir.h"
22 #include "fileClosedir.h"
23 #include "rmColl.h"
24 #include "miscServerFunct.hpp"
25 #include "rsDataObjRename.hpp"
26 #include "rsDataObjUnlink.hpp"
28 #include "rsFileRename.hpp"
29 #include "rsRegDataObj.hpp"
30 #include "rsQuerySpecColl.hpp"
31 #include "rsFileReaddir.hpp"
32 #include "rsDataObjClose.hpp"
33 #include "rsRmColl.hpp"
35 #include "irods_stacktrace.hpp"
39 #include "irods_re_structs.hpp"
40 
41 int
42 rsDataObjRename( rsComm_t *rsComm, dataObjCopyInp_t *dataObjRenameInp ) {
43  int status;
44  dataObjInp_t *srcDataObjInp, *destDataObjInp;
46  dataObjInfo_t *srcDataObjInfo = NULL;
47  dataObjInfo_t *destDataObjInfo = NULL;
48  specCollCache_t *specCollCache = NULL;
49  int srcType, destType;
50 
51  srcDataObjInp = &dataObjRenameInp->srcDataObjInp;
52  destDataObjInp = &dataObjRenameInp->destDataObjInp;
53 
54  /* don't translate the link pt. treat it as a normal collection */
55  addKeyVal( &srcDataObjInp->condInput, NO_TRANSLATE_LINKPT_KW, "" );
56  resolveLinkedPath( rsComm, srcDataObjInp->objPath, &specCollCache,
57  &srcDataObjInp->condInput );
58  rmKeyVal( &srcDataObjInp->condInput, NO_TRANSLATE_LINKPT_KW );
59 
60  resolveLinkedPath( rsComm, destDataObjInp->objPath, &specCollCache,
61  &destDataObjInp->condInput );
62 
63  if ( strcmp( srcDataObjInp->objPath, destDataObjInp->objPath ) == 0 ) {
65  }
66 
67  /* connect to rcat for cross zone */
69  rsComm,
71  ( const char* )srcDataObjInp->objPath,
72  &rodsServerHost );
73  if ( status < 0 || NULL == rodsServerHost ) {
74  return status;
75  }
76  else if ( rodsServerHost->rcatEnabled == REMOTE_ICAT ) {
77  status = rcDataObjRename( rodsServerHost->conn, dataObjRenameInp );
78  return status;
79  }
80 
81  srcType = resolvePathInSpecColl( rsComm, srcDataObjInp->objPath,
82  WRITE_COLL_PERM, 0, &srcDataObjInfo );
83 
84  destType = resolvePathInSpecColl( rsComm, destDataObjInp->objPath,
85  WRITE_COLL_PERM, 0, &destDataObjInfo );
86 
87  if ( srcDataObjInfo != NULL &&
88  srcDataObjInfo->specColl != NULL &&
89  strcmp( srcDataObjInfo->specColl->collection,
90  srcDataObjInp->objPath ) == 0 ) {
91  /* this must be the link pt or mount pt. treat it as normal coll */
92  freeDataObjInfo( srcDataObjInfo );
93  srcDataObjInfo = NULL;
95  }
96 
97  if ( !isSameZone( srcDataObjInp->objPath, destDataObjInp->objPath ) ) {
99  }
100 
101  if ( destType >= 0 ) {
103  "rsDataObjRename: dest specColl objPath %s exists",
104  destDataObjInp->objPath );
105  freeDataObjInfo( srcDataObjInfo );
106  freeDataObjInfo( destDataObjInfo );
108  }
109 
110  if ( srcType >= 0 ) {
111  /* src is a specColl of some sort. dest must also be a specColl in
112  * order to rename, except in the special case where src is in a
113  * mounted collection. Otherwise, bail out with specColl conflict error. */
114  if ( NULL != srcDataObjInfo && SYS_SPEC_COLL_OBJ_NOT_EXIST == destType ) {
115  status = specCollObjRename( rsComm, srcDataObjInfo, destDataObjInfo );
116  }
117  else if ( NULL != srcDataObjInfo && NULL != srcDataObjInfo->specColl &&
118  MOUNTED_COLL == srcDataObjInfo->specColl->collClass ) {
119  status = moveMountedCollObj( rsComm, srcDataObjInfo, srcType, destDataObjInp );
120  }
121  else {
123  "rsDataObjRename: src %s is in spec coll but dest %s is not",
124  srcDataObjInp->objPath, destDataObjInp->objPath );
126  }
127  freeDataObjInfo( srcDataObjInfo );
128  freeDataObjInfo( destDataObjInfo );
129  return status;
130  }
131  else if ( srcType == SYS_SPEC_COLL_OBJ_NOT_EXIST ) {
133  }
134  else if ( destType == SYS_SPEC_COLL_OBJ_NOT_EXIST ) {
135  /* source is normal object but dest is not */
137  "rsDataObjRename: src %s is not in spec coll but dest %s is",
138  srcDataObjInp->objPath, destDataObjInp->objPath );
140  }
141 
143  rsComm,
144  MASTER_RCAT,
145  ( const char* )dataObjRenameInp->srcDataObjInp.objPath,
146  &rodsServerHost );
147  if ( status < 0 ) {
148  return status;
149  }
150  if ( rodsServerHost->localFlag == LOCAL_HOST ) {
151  std::string svc_role;
152  irods::error ret = get_catalog_service_role(svc_role);
153  if(!ret.ok()) {
154  irods::log(PASS(ret));
155  return ret.code();
156  }
157 
158  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
159  status = _rsDataObjRename( rsComm, dataObjRenameInp );
160  } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
162  } else {
163  rodsLog(
164  LOG_ERROR,
165  "role not supported [%s]",
166  svc_role.c_str() );
168  }
169  }
170  else {
171  status = rcDataObjRename( rodsServerHost->conn, dataObjRenameInp );
172  }
173 
174  return status;
175 }
176 
177 int
178 getMultiCopyPerResc( rsComm_t *rsComm ) { // JMC - backport 4556
179  ruleExecInfo_t rei;
180 
181  memset( &rei, 0, sizeof( rei ) );
182  rei.rsComm = rsComm; // JMC - backport 4556
183  applyRule( "acSetMultiReplPerResc", NULL, &rei, NO_SAVE_REI );
184  if ( strcmp( rei.statusStr, MULTI_COPIES_PER_RESC ) == 0 ) {
185  return 1;
186  }
187  else {
188  return 0;
189  }
190 }
191 
192 
193 int
194 _rsDataObjRename( rsComm_t *rsComm, dataObjCopyInp_t *dataObjRenameInp ) {
195  std::string svc_role;
196  irods::error ret = get_catalog_service_role(svc_role);
197  if(!ret.ok()) {
198  irods::log(PASS(ret));
199  return ret.code();
200  }
201 
202  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
203  if ( rsComm == NULL ) {
204  rodsLog( LOG_ERROR, "_rsDataObjRename was passed a null rsComm" );
206  }
207  int status;
208  char srcColl[MAX_NAME_LEN], srcObj[MAX_NAME_LEN];
209  char destColl[MAX_NAME_LEN], destObj[MAX_NAME_LEN];
210  dataObjInp_t *srcDataObjInp, *destDataObjInp;
211  dataObjInfo_t *dataObjInfoHead = NULL;
212  rodsLong_t srcId, destId;
213  int multiCopyFlag;
214  int acPreProcFromRenameFlag = 0;
215 
216  const char *args[MAX_NUM_OF_ARGS_IN_ACTION];
217  int i, argc;
218  ruleExecInfo_t rei2;
219 
220  memset( ( char* )&rei2, 0, sizeof( ruleExecInfo_t ) );
221  rei2.rsComm = rsComm;
222  rei2.uoic = &rsComm->clientUser;
223  rei2.uoip = &rsComm->proxyUser;
224  rei2.doinp = &dataObjRenameInp->srcDataObjInp;
225 
226  srcDataObjInp = &dataObjRenameInp->srcDataObjInp;
227  destDataObjInp = &dataObjRenameInp->destDataObjInp;
228 
229  if ( ( status = splitPathByKey(
230  srcDataObjInp->objPath, srcColl, MAX_NAME_LEN, srcObj, MAX_NAME_LEN, '/' ) ) < 0 ) {
232  "_rsDataObjRename: splitPathByKey for %s error, status = %d",
233  srcDataObjInp->objPath, status );
234  return status;
235  }
236 
237  if ( ( status = splitPathByKey(
238  destDataObjInp->objPath, destColl, MAX_NAME_LEN, destObj, MAX_NAME_LEN, '/' ) ) < 0 ) {
240  "_rsDataObjRename: splitPathByKey for %s error, status = %d",
241  destDataObjInp->objPath, status );
242  return status;
243  }
244 
245  multiCopyFlag = getMultiCopyPerResc( rsComm ); // JMC - backport 4556
246 
247  if ( srcDataObjInp->oprType == RENAME_DATA_OBJ ) {
248 
249  status = getDataObjInfo( rsComm, srcDataObjInp, &dataObjInfoHead, ACCESS_DELETE_OBJECT, 0 );
250 
251  if ( status >= 0 || NULL != dataObjInfoHead ) {
252  srcId = dataObjInfoHead->dataId;
253  }
254  else {
256  "_rsDataObjRename: src data %s does not exist, status = %d",
257  srcDataObjInp->objPath, status );
258  return status;
259  }
260  }
261  else if ( srcDataObjInp->oprType == RENAME_COLL ) {
262  status = isColl( rsComm, srcDataObjInp->objPath, &srcId );
263  if ( status < 0 ) {
265  "_rsDataObjRename: src coll %s does not exist, status = %d",
266  srcDataObjInp->objPath, status );
267  return status;
268  }
269  }
270  else {
271  if ( ( status = isData( rsComm, srcDataObjInp->objPath, &srcId ) ) >= 0 ) {
272  if ( isData( rsComm, destDataObjInp->objPath, &destId ) >= 0 &&
273  getValByKey( &srcDataObjInp->condInput, FORCE_FLAG_KW ) != NULL ) {
274  /* dest exist */
275  rsDataObjUnlink( rsComm, destDataObjInp );
276  }
277  srcDataObjInp->oprType = destDataObjInp->oprType = RENAME_DATA_OBJ;
278  status = getDataObjInfo( rsComm, srcDataObjInp, &dataObjInfoHead,
280 
281  if ( status < 0 ) {
283  "_rsDataObjRename: src data %s does not exist, status = %d",
284  srcDataObjInp->objPath, status );
285  return status;
286  }
287  }
288  else if ( ( status = isColl( rsComm, srcDataObjInp->objPath, &srcId ) )
289  >= 0 ) {
290  srcDataObjInp->oprType = destDataObjInp->oprType = RENAME_COLL;
291  }
292  else {
294  "_rsDataObjRename: src obj %s does not exist, status = %d",
295  srcDataObjInp->objPath, status );
296  return status;
297  }
298  }
299 
300  if ( srcDataObjInp->oprType == RENAME_DATA_OBJ ) {
301  if ( strstr( dataObjInfoHead->dataType, BUNDLE_STR ) != NULL ) { // JMC - backport 4658
303  "_rsDataObjRename: cannot rename tar bundle type obj %s",
304  srcDataObjInp->objPath );
305  return CANT_RM_MV_BUNDLE_TYPE;
306  }
307  }
308 
309  if ( strcmp( srcObj, destObj ) != 0 ) {
310  /* rename */
311  if ( srcId < 0 ) {
312  status = srcId;
313  return status;
314  }
315 
317  argc = 2;
318  args[0] = srcDataObjInp->objPath;
319  args[1] = destDataObjInp->objPath;
320  acPreProcFromRenameFlag = 1;
321  i = applyRuleArg( "acPreProcForObjRename", args, argc, &rei2, NO_SAVE_REI );
322  if ( i < 0 ) {
323  if ( rei2.status < 0 ) {
324  i = rei2.status;
325  }
327  "rsDataObjRename: acPreProcForObjRename error for source %s and destination %s,stat=%d",
328  args[0], args[1], i );
329  return i;
330  }
333  status = chlRenameObject( rsComm, srcId, destObj );
334  }
335 
336  if ( status < 0 ) {
337  return status;
338  }
339 
340  if ( strcmp( srcColl, destColl ) != 0 ) {
341  /* move. The destColl is the target */
342  status = isColl( rsComm, destColl, &destId );
343  if (status < 0) {
344  rodsLog(LOG_ERROR, "_rsDataObjRename: Destination collection does not exist [collection = %s, error_code = %d]",
345  destColl, status);
346  return CAT_UNKNOWN_COLLECTION;
347  }
348 
350  if ( acPreProcFromRenameFlag == 0 ) {
351  args[0] = srcDataObjInp->objPath;
352  args[1] = destDataObjInp->objPath;
353  argc = 2;
354  i = applyRuleArg( "acPreProcForObjRename", args, argc, &rei2, NO_SAVE_REI );
355  if ( i < 0 ) {
356  if ( rei2.status < 0 ) {
357  i = rei2.status;
358  }
360  "rsDataObjRename: acPreProcForObjRename error for source %s and destination %s,stat=%d",
361  args[0], args[1], i );
362  return i;
363  }
364  }
367  status = chlMoveObject( rsComm, srcId, destId );
368  }
369  if ( status >= 0 ) {
370  if ( multiCopyFlag > 0 ) {
371  status = chlCommit( rsComm );
372  return status;
373  }
374  else {
375  /* enforce physPath consistency */
376  if ( srcDataObjInp->oprType == RENAME_DATA_OBJ ) {
377  dataObjInfo_t *tmpDataObjInfo;
378 
379  /* update src dataObjInfoHead with dest objPath */
380  tmpDataObjInfo = dataObjInfoHead;
381  while ( tmpDataObjInfo != NULL ) {
382  rstrcpy( tmpDataObjInfo->objPath, destDataObjInp->objPath, MAX_NAME_LEN );
383 
384  tmpDataObjInfo = tmpDataObjInfo->next;
385  }
386  status = syncDataObjPhyPath( rsComm, destDataObjInp, dataObjInfoHead, NULL );
387  freeAllDataObjInfo( dataObjInfoHead );
388  }
389  else {
390  status = syncCollPhyPath( rsComm, destDataObjInp->objPath );
391  }
392 
393  if ( status >= 0 ) {
394  status = chlCommit( rsComm );
395  }
396  else {
397  chlRollback( rsComm );
398  }
399  }
400  if ( status >= 0 ) {
401  args[0] = srcDataObjInp->objPath;
402  args[1] = destDataObjInp->objPath;
403  argc = 2;
404  status = applyRuleArg( "acPostProcForObjRename", args, argc,
405  &rei2, NO_SAVE_REI );
406  if ( status < 0 ) {
407  if ( rei2.status < 0 ) {
408  status = rei2.status;
409  }
411  "rsDataObjRename: acPostProc err for src %s dest %s,stat=%d",
412  args[0], args[1], status );
413  }
414  }
415  }
416  else {
417  chlRollback( rsComm );
418  }
419  return status;
420  } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
421  return SYS_NO_ICAT_SERVER_ERR;
422  } else {
423  rodsLog(
424  LOG_ERROR,
425  "role not supported [%s]",
426  svc_role.c_str() );
428  }
429 
430 }
431 
432 int
433 specCollObjRename( rsComm_t *rsComm, dataObjInfo_t *srcDataObjInfo,
434  dataObjInfo_t *destDataObjInfo ) {
435  int status;
436  char *newPath;
437 
438  if ( getStructFileType( srcDataObjInfo->specColl ) >= 0 ) {
439  /* structFile type, use the logical subPath */
440  newPath = destDataObjInfo->subPath;
441  }
442  else {
443  /* mounted fs, use phy path */
444  newPath = destDataObjInfo->filePath;
445  }
446 
447  status = l3Rename( rsComm, srcDataObjInfo, newPath );
448 
449  if ( status < 0 ) {
451  "specCollObjRename: l3Rename error from %s to %s, status = %d",
452  srcDataObjInfo->subPath, newPath, status );
453  return status;
454  }
455  return status;
456 }
457 
458 int
459 l3Rename( rsComm_t *rsComm, dataObjInfo_t *dataObjInfo, char *newFileName ) {
460  fileRenameInp_t fileRenameInp;
461  int status;
462 
463  irods::error resc_err = irods::is_hier_live( dataObjInfo->rescHier );
464  if ( !resc_err.ok() ) {
465  return resc_err.code();
466  }
467 
468  std::string location;
469  irods::error ret = irods::get_loc_for_hier_string( dataObjInfo->rescHier, location );
470  if ( !ret.ok() ) {
471  irods::log( PASSMSG( "l3Rename - failed in get_loc_for_hier_string", ret ) );
472  return -1;
473  }
474 
475  if ( getStructFileType( dataObjInfo->specColl ) >= 0 ) {
476  subStructFileRenameInp_t subStructFileRenameInp;
477  memset( &subStructFileRenameInp, 0, sizeof( subStructFileRenameInp ) );
478  rstrcpy( subStructFileRenameInp.subFile.subFilePath, dataObjInfo->subPath,
479  MAX_NAME_LEN );
480  rstrcpy( subStructFileRenameInp.newSubFilePath, newFileName, MAX_NAME_LEN );
481  rstrcpy( subStructFileRenameInp.subFile.addr.hostAddr, location.c_str(), NAME_LEN );
482  rstrcpy( subStructFileRenameInp.resc_hier, dataObjInfo->rescHier, MAX_NAME_LEN );
483  subStructFileRenameInp.subFile.specColl = dataObjInfo->specColl;
484  status = rsSubStructFileRename( rsComm, &subStructFileRenameInp );
485  }
486  else {
487  memset( &fileRenameInp, 0, sizeof( fileRenameInp ) );
488  rstrcpy( fileRenameInp.oldFileName, dataObjInfo->filePath, MAX_NAME_LEN );
489  rstrcpy( fileRenameInp.newFileName, newFileName, MAX_NAME_LEN );
490  rstrcpy( fileRenameInp.rescHier, dataObjInfo->rescHier, MAX_NAME_LEN );
491  rstrcpy( fileRenameInp.objPath, dataObjInfo->objPath, MAX_NAME_LEN );
492  rstrcpy( fileRenameInp.addr.hostAddr, location.c_str(), NAME_LEN );
493  fileRenameOut_t* ren_out = 0;
494  status = rsFileRename( rsComm, &fileRenameInp, &ren_out );
495  free( ren_out );
496  }
497  return status;
498 }
499 
500 /* moveMountedCollObj - move a mounted collection obj to a normal obj */
501 int
502 moveMountedCollObj( rsComm_t *rsComm, dataObjInfo_t *srcDataObjInfo,
503  int srcType, dataObjInp_t *destDataObjInp ) {
504  int status;
505 
506  if ( srcType == DATA_OBJ_T ) {
507  status = moveMountedCollDataObj( rsComm, srcDataObjInfo,
508  destDataObjInp );
509  }
510  else if ( srcType == COLL_OBJ_T ) {
511  status = moveMountedCollCollObj( rsComm, srcDataObjInfo,
512  destDataObjInp );
513  }
514  else {
516  }
517  return status;
518 }
519 
520 int
522  dataObjInp_t *destDataObjInp ) {
523  dataObjInfo_t destDataObjInfo;
524  fileRenameInp_t fileRenameInp;
525  int status;
526 
527  if ( rsComm == NULL || srcDataObjInfo == NULL || destDataObjInp == NULL ) {
528  return USER__NULL_INPUT_ERR;
529  }
530  bzero( &destDataObjInfo, sizeof( destDataObjInfo ) );
531  bzero( &fileRenameInp, sizeof( fileRenameInp ) );
532  rstrcpy( destDataObjInfo.objPath, destDataObjInp->objPath, MAX_NAME_LEN );
533  rstrcpy( destDataObjInfo.dataType, srcDataObjInfo->dataType, NAME_LEN );
534  destDataObjInfo.dataSize = srcDataObjInfo->dataSize;
535 
536  rstrcpy( destDataObjInfo.rescName, srcDataObjInfo->rescName, NAME_LEN );
537  rstrcpy( destDataObjInfo.rescHier, srcDataObjInfo->rescHier, MAX_NAME_LEN );
538  irods::error ret = resc_mgr.hier_to_leaf_id(srcDataObjInfo->rescHier,destDataObjInfo.rescId);
539  if( !ret.ok() ) {
540  irods::log(PASS(ret));
541  }
542  status = getFilePathName( rsComm, &destDataObjInfo, destDataObjInp );
543  if ( status < 0 ) {
545  "moveMountedCollDataObj: getFilePathName err for %s. status = %d",
546  destDataObjInfo.objPath, status );
547  return status;
548  }
549 
550  status = filePathTypeInResc( rsComm, destDataObjInfo.objPath, destDataObjInfo.filePath, destDataObjInfo.rescHier );
551  if ( status == LOCAL_DIR_T ) {
554  "moveMountedCollDataObj: targ path %s is a dir. status = %d",
555  destDataObjInfo.filePath, status );
556  return status;
557  }
558  else if ( status == LOCAL_FILE_T ) {
559  dataObjInfo_t myDataObjInfo;
560  status = chkOrphanFile( rsComm, destDataObjInfo.filePath,
561  destDataObjInfo.rescName, &myDataObjInfo );
562  if ( status == 1 ) {
563  /* orphan */
564  char new_fn[ MAX_NAME_LEN ];
565  rstrcpy( fileRenameInp.oldFileName, destDataObjInfo.filePath, MAX_NAME_LEN );
566  int error_code = renameFilePathToNewDir( rsComm, ORPHAN_DIR, &fileRenameInp, 1, new_fn );
567  if ( error_code < 0 ) {
568  rodsLog( LOG_ERROR, "renameFilePathToNewDir failed in moveMountedCollDataObj with error code %d", error_code );
569  }
570  snprintf( destDataObjInfo.filePath, sizeof( destDataObjInfo.filePath ), "%s", new_fn );
571  }
572  else if ( status == 0 ) {
573  /* obj exist */
575  }
576  else {
577  return status;
578  }
579  }
580  status = l3Rename( rsComm, srcDataObjInfo, destDataObjInfo.filePath );
581 
582  if ( status < 0 ) {
584  "moveMountedCollDataObj: l3Rename error from %s to %s, status = %d",
585  srcDataObjInfo->filePath, destDataObjInfo.filePath, status );
586  return status;
587  }
588  status = svrRegDataObj( rsComm, &destDataObjInfo );
589  if ( status < 0 ) {
590  l3Rename( rsComm, &destDataObjInfo, srcDataObjInfo->filePath );
592  "moveMountedCollDataObj: rsRegDataObj for %s failed, status = %d",
593  destDataObjInfo.objPath, status );
594  }
595  return status;
596 }
597 
598 int
600  dataObjInp_t *destDataObjInp ) {
601  int l3descInx;
602  fileReaddirInp_t fileReaddirInp;
604  rodsStat_t *fileStatOut = NULL;
605  dataObjInfo_t subSrcDataObjInfo;
606  dataObjInp_t subDestDataObjInp;
607  int status;
608  int savedStatus = 0;
609 
610  subSrcDataObjInfo = *srcDataObjInfo;
611  bzero( &subDestDataObjInp, sizeof( subDestDataObjInp ) );
612  l3descInx = l3Opendir( rsComm, srcDataObjInfo );
613  fileReaddirInp.fileInx = l3descInx;
614  rsMkCollR( rsComm, "/", destDataObjInp->objPath );
615  while ( rsFileReaddir( rsComm, &fileReaddirInp, &rodsDirent ) >= 0 ) {
616  if ( rodsDirent == NULL ) {
617  savedStatus = SYS_INTERNAL_NULL_INPUT_ERR;
618  break;
619  }
620 
621  rodsDirent_t myRodsDirent = *rodsDirent;
622  free( rodsDirent );
623 
624  if ( strcmp( myRodsDirent.d_name, "." ) == 0 ||
625  strcmp( myRodsDirent.d_name, ".." ) == 0 ) {
626  continue;
627  }
628 
629  snprintf( subSrcDataObjInfo.objPath, MAX_NAME_LEN, "%s/%s",
630  srcDataObjInfo->objPath, myRodsDirent.d_name );
631  snprintf( subSrcDataObjInfo.subPath, MAX_NAME_LEN, "%s/%s",
632  srcDataObjInfo->subPath, myRodsDirent.d_name );
633  snprintf( subSrcDataObjInfo.filePath, MAX_NAME_LEN, "%s/%s",
634  srcDataObjInfo->filePath, myRodsDirent.d_name );
635 
636  status = l3Stat( rsComm, &subSrcDataObjInfo, &fileStatOut );
637  if ( status < 0 || fileStatOut == NULL ) { // JMC cppcheck
639  "moveMountedCollCollObj: l3Stat for %s error, status = %d",
640  subSrcDataObjInfo.filePath, status );
641  return status;
642  }
643  snprintf( subSrcDataObjInfo.dataCreate, TIME_LEN, "%d",
644  fileStatOut->st_ctim );
645  snprintf( subSrcDataObjInfo.dataModify, TIME_LEN, "%d",
646  fileStatOut->st_mtim );
647  snprintf( subDestDataObjInp.objPath, MAX_NAME_LEN, "%s/%s",
648  destDataObjInp->objPath, myRodsDirent.d_name );
649  if ( ( fileStatOut->st_mode & S_IFREG ) != 0 ) { /* a file */
650  subSrcDataObjInfo.dataSize = fileStatOut->st_size;
651  status = moveMountedCollDataObj( rsComm, &subSrcDataObjInfo,
652  &subDestDataObjInp );
653  }
654  else {
655  status = moveMountedCollCollObj( rsComm, &subSrcDataObjInfo,
656  &subDestDataObjInp );
657  }
658  if ( status < 0 ) {
659  savedStatus = status;
661  "moveMountedCollCollObj: moveMountedColl for %s error, stat = %d",
662  subSrcDataObjInfo.objPath, status );
663  }
664  free( fileStatOut );
665  fileStatOut = NULL;
666  }
667  l3Rmdir( rsComm, srcDataObjInfo );
668  return savedStatus;
669 }
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
NULL
#define NULL
Definition: rodsDef.h:70
rodsStat::st_mode
unsigned int st_mode
Definition: rodsType.h:56
regDataObj.h
fileReaddirInp_t::fileInx
int fileInx
Definition: fileReaddir.h:8
rsComm_t
Definition: rcConnect.h:145
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
irods::CFG_SERVICE_ROLE_CONSUMER
const std::string CFG_SERVICE_ROLE_CONSUMER("consumer")
irods_configuration_keywords.hpp
SYS_INTERNAL_NULL_INPUT_ERR
@ SYS_INTERNAL_NULL_INPUT_ERR
Definition: rodsErrorTable.h:92
rodsServerHost::localFlag
int localFlag
Definition: rodsConnect.h:68
rodsStat::st_ctim
unsigned int st_ctim
Definition: rodsType.h:63
DataObjInfo::dataCreate
char dataCreate[32]
Definition: objInfo.h:150
SYS_SERVICE_ROLE_NOT_SUPPORTED
@ SYS_SERVICE_ROLE_NOT_SUPPORTED
Definition: rodsErrorTable.h:217
getMultiCopyPerResc
int getMultiCopyPerResc(rsComm_t *rsComm)
Definition: rsDataObjRename.cpp:178
DataObjCopyInp
Definition: dataObjCopy.h:25
getFilePathName
int getFilePathName(rsComm_t *rsComm, dataObjInfo_t *dataObjInfo, dataObjInp_t *dataObjInp)
Definition: physPath.cpp:87
DataObjInfo::dataModify
char dataModify[32]
Definition: objInfo.h:151
specColl.hpp
CANT_RM_MV_BUNDLE_TYPE
@ CANT_RM_MV_BUNDLE_TYPE
Definition: rodsErrorTable.h:272
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
isColl
int isColl(rsComm_t *rsComm, char *objName, rodsLong_t *collId)
Definition: objMetaOpr.cpp:204
rodsServerHost::rcatEnabled
int rcatEnabled
Definition: rodsConnect.h:65
irods_stacktrace.hpp
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
resc_mgr
irods::resource_manager resc_mgr
Definition: irods_resource_manager.cpp:31
Subfile::subFilePath
char subFilePath[(1024+64)]
Definition: objInfo.h:318
rodsDirent::d_name
char d_name[256]
Definition: rodsType.h:75
fileReaddir.h
SYS_NO_ICAT_SERVER_ERR
@ SYS_NO_ICAT_SERVER_ERR
Definition: rodsErrorTable.h:104
NO_SAVE_REI
#define NO_SAVE_REI
Definition: rodsDef.h:103
SYS_SPEC_COLL_OBJ_NOT_EXIST
@ SYS_SPEC_COLL_OBJ_NOT_EXIST
Definition: rodsErrorTable.h:123
fileRenameOut_t
Definition: fileRename.h:16
moveMountedCollDataObj
int moveMountedCollDataObj(rsComm_t *rsComm, dataObjInfo_t *srcDataObjInfo, dataObjInp_t *destDataObjInp)
Definition: rsDataObjRename.cpp:521
DataObjInfo::dataType
char dataType[64]
Definition: objInfo.h:133
isData
int isData(rsComm_t *rsComm, char *objName, rodsLong_t *dataId)
Definition: objMetaOpr.cpp:47
rcMisc.h
irods::is_hier_live
error is_hier_live(const std::string &)
Definition: irods_resource_backport.cpp:234
freeDataObjInfo
int freeDataObjInfo(dataObjInfo_t *dataObjInfo)
Definition: rcMisc.cpp:544
rsFileRename
int rsFileRename(rsComm_t *rsComm, fileRenameInp_t *fileRenameInp, fileRenameOut_t **)
Definition: rsFileRename.cpp:22
DataObjInfo::rescId
rodsLong_t rescId
Definition: objInfo.h:164
RENAME_COLL
#define RENAME_COLL
Definition: dataObjInpOut.h:178
filePathTypeInResc
int filePathTypeInResc(rsComm_t *rsComm, const std::string &objPath, const std::string &fileName, const std::string &rescHier)
Definition: fileOpr.cpp:529
svrRegDataObj
int svrRegDataObj(rsComm_t *rsComm, dataObjInfo_t *dataObjInfo)
Definition: rsRegDataObj.cpp:120
DataObjInfo::rescHier
char rescHier[(1024+64)]
Definition: objInfo.h:132
getStructFileType
int getStructFileType(specColl_t *specColl)
Definition: objMetaOpr.cpp:386
dataObjRename.h
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
renameFilePathToNewDir
int renameFilePathToNewDir(rsComm_t *rsComm, char *newDir, fileRenameInp_t *fileRenameInp, int renameFlag, char *)
Definition: physPath.cpp:652
fileRenameInp_t::newFileName
char newFileName[(1024+64)]
Definition: fileRename.h:10
rodsStat::st_mtim
unsigned int st_mtim
Definition: rodsType.h:62
isSameZone
int isSameZone(char *zoneHint1, char *zoneHint2)
Definition: rodsConnect.cpp:891
irods_resource_backport.hpp
Subfile::specColl
specColl_t * specColl
Definition: objInfo.h:322
WRITE_COLL_PERM
@ WRITE_COLL_PERM
Definition: objInfo.h:99
rsFileReaddir
int rsFileReaddir(rsComm_t *rsComm, fileReaddirInp_t *fileReaddirInp, rodsDirent_t **fileReaddirOut)
Definition: rsFileReaddir.cpp:16
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
SubStructFileRenameInp
Definition: subStructFileRename.h:7
rmColl.h
fileRenameInp_t
Definition: fileRename.h:7
DataObjInfo::filePath
char filePath[(1024+64)]
Definition: objInfo.h:137
l3Opendir
int l3Opendir(rsComm_t *rsComm, dataObjInfo_t *dataObjInfo)
Definition: rsQuerySpecColl.cpp:489
chlCommit
int chlCommit(rsComm_t *rsComm)
Definition: icatHighLevelRoutines.cpp:1090
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
chlRenameObject
int chlRenameObject(rsComm_t *rsComm, rodsLong_t objId, const char *newName)
Definition: icatHighLevelRoutines.cpp:2962
irods_resource_redirect.hpp
NO_TRANSLATE_LINKPT_KW
#define NO_TRANSLATE_LINKPT_KW
Definition: rodsKeyWdDef.h:98
DataObjInfo::dataId
rodsLong_t dataId
Definition: objInfo.h:143
REMOTE_ICAT
#define REMOTE_ICAT
Definition: rodsConnect.h:54
DataObjInfo::next
struct DataObjInfo * next
Definition: objInfo.h:163
rsDataObjRename
int rsDataObjRename(rsComm_t *rsComm, dataObjCopyInp_t *dataObjRenameInp)
Definition: rsDataObjRename.cpp:42
DataObjInfo::specColl
specColl_t * specColl
Definition: objInfo.h:158
rsFileRename.hpp
fileClosedir.h
resolveLinkedPath
int resolveLinkedPath(rsComm_t *rsComm, char *objPath, specCollCache_t **specCollCache, keyValPair_t *condInput)
Definition: specColl.cpp:711
RuleExecInfo::rsComm
rsComm_t * rsComm
Definition: irods_re_structs.hpp:22
RENAME_DATA_OBJ
#define RENAME_DATA_OBJ
Definition: dataObjInpOut.h:177
SYS_DEST_SPEC_COLL_SUB_EXIST
@ SYS_DEST_SPEC_COLL_SUB_EXIST
Definition: rodsErrorTable.h:125
rodsStat::st_size
rodsLong_t st_size
Definition: rodsType.h:53
COLL_OBJ_T
@ COLL_OBJ_T
Definition: rodsType.h:39
rsSubStructFileRename
int rsSubStructFileRename(rsComm_t *rsComm, subStructFileRenameInp_t *subStructFileRenameInp)
Definition: rsSubStructFileRename.cpp:12
irods::error::code
long long code() const
Definition: irods_error.cpp:194
rodsStat
Definition: rodsType.h:52
CAT_UNKNOWN_COLLECTION
@ CAT_UNKNOWN_COLLECTION
Definition: rodsErrorTable.h:429
l3Stat
int l3Stat(rsComm_t *rsComm, dataObjInfo_t *dataObjInfo, rodsStat_t **myStat)
Definition: rsDataObjClose.cpp:768
rsComm_t::proxyUser
userInfo_t proxyUser
Definition: rcConnect.h:152
freeAllDataObjInfo
int freeAllDataObjInfo(dataObjInfo_t *dataObjInfoHead)
Definition: rcMisc.cpp:561
TIME_LEN
#define TIME_LEN
Definition: rodsDef.h:54
SubStructFileRenameInp::newSubFilePath
char newSubFilePath[(1024+64)]
Definition: subStructFileRename.h:9
l3Rename
int l3Rename(rsComm_t *rsComm, dataObjInfo_t *dataObjInfo, char *newFileName)
Definition: rsDataObjRename.cpp:459
fileOpendir.h
RuleExecInfo::statusStr
char statusStr[(1024+64)]
Definition: irods_re_structs.hpp:20
rsDataObjRename.hpp
irods::CFG_SERVICE_ROLE_PROVIDER
const std::string CFG_SERVICE_ROLE_PROVIDER("provider")
applyRuleArg
int applyRuleArg(const char *action, const char *args[20], int argc, ruleExecInfo_t *rei, int reiSaveFlag)
Definition: irods_re_structs.cpp:95
moveMountedCollObj
int moveMountedCollObj(rsComm_t *rsComm, dataObjInfo_t *srcDataObjInfo, int srcType, dataObjInp_t *destDataObjInp)
Definition: rsDataObjRename.cpp:502
DataObjInp
Definition: dataObjInpOut.h:65
rsDataObjClose.hpp
rsSubStructFileRename.hpp
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
chlRollback
int chlRollback(rsComm_t *rsComm)
Definition: icatHighLevelRoutines.cpp:1039
MAX_NUM_OF_ARGS_IN_ACTION
#define MAX_NUM_OF_ARGS_IN_ACTION
Definition: irods_re_structs.hpp:13
syncDataObjPhyPath
int syncDataObjPhyPath(rsComm_t *rsComm, dataObjInp_t *dataObjInp, dataObjInfo_t *dataObjInfoHead, char *acLCollection)
Definition: physPath.cpp:742
Subfile::addr
rodsHostAddr_t addr
Definition: objInfo.h:317
SYS_NO_RCAT_SERVER_ERR
@ SYS_NO_RCAT_SERVER_ERR
Definition: rodsErrorTable.h:110
moveMountedCollCollObj
int moveMountedCollCollObj(rsComm_t *rsComm, dataObjInfo_t *srcDataObjInfo, dataObjInp_t *destDataObjInp)
Definition: rsDataObjRename.cpp:599
rmKeyVal
int rmKeyVal(keyValPair_t *condInput, const char *keyWord)
Definition: rcMisc.cpp:710
rsFileReaddir.hpp
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
collection.hpp
splitPathByKey
int splitPathByKey(const char *srcPath, char *dir, size_t maxDirLen, char *file, size_t maxFileLen, char key)
Definition: stringOpr.cpp:222
specCollObjRename
int specCollObjRename(rsComm_t *rsComm, dataObjInfo_t *srcDataObjInfo, dataObjInfo_t *destDataObjInfo)
Definition: rsDataObjRename.cpp:433
physPath.hpp
irods::log
void log(const error &)
Definition: irods_log.cpp:13
fileRenameInp_t::rescHier
char rescHier[(1024+64)]
Definition: fileRename.h:11
rodsDirent
Definition: rodsType.h:70
fileRenameInp_t::objPath
char objPath[(1024+64)]
Definition: fileRename.h:12
rsComm_t::clientUser
userInfo_t clientUser
Definition: rcConnect.h:153
dataObjClose.h
getDataObjInfo
int getDataObjInfo(rsComm_t *rsComm, dataObjInp_t *dataObjInp, dataObjInfo_t **dataObjInfoHead, char *accessPerm, int ignoreCondInput)
Definition: dataObjOpr.cpp:87
resolvePathInSpecColl
int resolvePathInSpecColl(rsComm_t *rsComm, char *objPath, specCollPerm_t specCollPerm, int inCachOnly, dataObjInfo_t **dataObjInfo)
Definition: specColl.cpp:644
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
DATA_OBJ_T
@ DATA_OBJ_T
Definition: rodsType.h:38
SubStructFileRenameInp::subFile
subFile_t subFile
Definition: subStructFileRename.h:8
getAndConnRcatHost
int getAndConnRcatHost(rsComm_t *rsComm, int rcatType, const char *rcatZoneHint, rodsServerHost_t **rodsServerHost)
Definition: rodsConnect.cpp:26
SYS_PATH_IS_NOT_A_FILE
@ SYS_PATH_IS_NOT_A_FILE
Definition: rodsErrorTable.h:119
SpecColl::collection
char collection[(1024+64)]
Definition: objInfo.h:79
DataObjCopyInp::destDataObjInp
dataObjInp_t destDataObjInp
Definition: dataObjCopy.h:27
irods_hierarchy_parser.hpp
FORCE_FLAG_KW
#define FORCE_FLAG_KW
Definition: rodsKeyWdDef.h:13
MASTER_RCAT
#define MASTER_RCAT
Definition: rodsDef.h:85
irods::resource_manager::hier_to_leaf_id
error hier_to_leaf_id(const std::string &, rodsLong_t &)
Definition: irods_resource_manager.cpp:1082
MULTI_COPIES_PER_RESC
#define MULTI_COPIES_PER_RESC
Definition: dataObjOpr.hpp:32
get_catalog_service_role
irods::error get_catalog_service_role(std::string &_role)
Definition: miscServerFunct.cpp:3153
rodsServerHost
Definition: rodsConnect.h:62
DataObjInfo::rescName
char rescName[64]
Definition: objInfo.h:131
rcDataObjRename
int rcDataObjRename(rcComm_t *conn, dataObjCopyInp_t *dataObjRenameInp)
Definition: rcDataObjRename.cpp:68
DataObjInp::oprType
int oprType
Definition: dataObjInpOut.h:72
rodsHostAddr_t::hostAddr
char hostAddr[256]
Definition: rodsDef.h:297
fileRenameInp_t::oldFileName
char oldFileName[(1024+64)]
Definition: fileRename.h:9
rsMkCollR
int rsMkCollR(rsComm_t *rsComm, const char *startColl, const char *destColl)
Definition: collection.cpp:428
SYS_SPEC_COLL_NOT_IN_CACHE
@ SYS_SPEC_COLL_NOT_IN_CACHE
Definition: rodsErrorTable.h:122
RuleExecInfo
Definition: irods_re_structs.hpp:18
irods_re_structs.hpp
LOCAL_DIR_T
@ LOCAL_DIR_T
Definition: rodsType.h:42
MOUNTED_COLL
@ MOUNTED_COLL
Definition: objInfo.h:48
rsQuerySpecColl.hpp
applyRule
int applyRule(char *inAction, msParamArray_t *inMsParamArray, ruleExecInfo_t *rei, int reiSaveFlag)
Definition: irods_re_structs.cpp:65
resource.hpp
ORPHAN_DIR
#define ORPHAN_DIR
Definition: physPath.hpp:21
icatHighLevelRoutines.hpp
phyBundleColl.h
SYS_UNMATCHED_SPEC_COLL_TYPE
@ SYS_UNMATCHED_SPEC_COLL_TYPE
Definition: rodsErrorTable.h:120
rsRmColl.hpp
DataObjInfo::objPath
char objPath[(1024+64)]
Definition: objInfo.h:130
rsRegDataObj.hpp
rodsErrorTable.h
SYS_SRC_DEST_SPEC_COLL_CONFLICT
@ SYS_SRC_DEST_SPEC_COLL_CONFLICT
Definition: rodsErrorTable.h:126
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
LOCAL_FILE_T
@ LOCAL_FILE_T
Definition: rodsType.h:41
dataObjOpr.hpp
DataObjInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:74
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
ACCESS_DELETE_OBJECT
#define ACCESS_DELETE_OBJECT
Definition: icatDefines.h:60
SYS_COPY_ALREADY_IN_RESC
@ SYS_COPY_ALREADY_IN_RESC
Definition: rodsErrorTable.h:113
fileReaddirInp_t
Definition: fileReaddir.h:7
NAME_LEN
#define NAME_LEN
Definition: rodsDef.h:55
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
DataObjInfo
Definition: objInfo.h:129
SAME_SRC_DEST_PATHS_ERR
@ SAME_SRC_DEST_PATHS_ERR
Definition: rodsErrorTable.h:260
DataObjInfo::dataSize
rodsLong_t dataSize
Definition: objInfo.h:134
SYS_CROSS_ZONE_MV_NOT_SUPPORTED
@ SYS_CROSS_ZONE_MV_NOT_SUPPORTED
Definition: rodsErrorTable.h:174
_rsDataObjRename
int _rsDataObjRename(rsComm_t *rsComm, dataObjCopyInp_t *dataObjRenameInp)
Definition: rsDataObjRename.cpp:194
subStructFileRename.h
SpecCollCache
Definition: objInfo.h:102
rodsLong_t
long long rodsLong_t
Definition: rodsType.h:32
fileRenameInp_t::addr
rodsHostAddr_t addr
Definition: fileRename.h:8
objMetaOpr.hpp
SpecColl::collClass
specCollClass_t collClass
Definition: objInfo.h:77
l3Rmdir
int l3Rmdir(rsComm_t *rsComm, dataObjInfo_t *dataObjInfo)
Definition: rsRmColl.cpp:567
syncCollPhyPath
int syncCollPhyPath(rsComm_t *rsComm, char *collection)
Definition: physPath.cpp:912
DataObjInfo::subPath
char subPath[(1024+64)]
Definition: objInfo.h:157
chkOrphanFile
int chkOrphanFile(rsComm_t *rsComm, char *filePath, const char *rescName, dataObjInfo_t *dataObjInfo)
Definition: dataObjOpr.cpp:1099
USER__NULL_INPUT_ERR
@ USER__NULL_INPUT_ERR
Definition: rodsErrorTable.h:247
SubStructFileRenameInp::resc_hier
char resc_hier[(1024+64)]
Definition: subStructFileRename.h:10
chlMoveObject
int chlMoveObject(rsComm_t *rsComm, rodsLong_t objId, rodsLong_t targetCollId)
Definition: icatHighLevelRoutines.cpp:3016
BUNDLE_STR
#define BUNDLE_STR
Definition: phyBundleColl.h:13