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)  

miscUtil.cpp
Go to the documentation of this file.
1 
4 #ifndef windows_platform
5 #include <sys/time.h>
6 #endif
7 #include <fnmatch.h>
8 #include "rodsClient.h"
9 #include "rodsLog.h"
10 #include "miscUtil.h"
11 #include "rcGlobalExtern.h"
12 
13 #include "irods_stacktrace.hpp"
14 #include "irods_path_recursion.hpp"
15 #include "irods_exception.hpp"
16 
17 #include "get_hier_from_leaf_id.h"
18 
19 #include <fstream>
20 #include <boost/filesystem/operations.hpp>
21 #include <boost/filesystem/convenience.hpp>
22 
23 /* VERIFY_DIV - contributed by g.soudlenkov@auckland.ac.nz */
24 #define VERIFY_DIV(_v1_,_v2_) ((_v2_)? (float)(_v1_)/(_v2_):0.0)
25 
26 static uint Myumask = INIT_UMASK_VAL;
27 
28 const char NON_ROOT_COLL_CHECK_STR[] = "<>'/'";
29 
30 int
31 mkColl( rcComm_t *conn, char *collection ) {
32  int status;
33  collInp_t collCreateInp;
34 
35  memset( &collCreateInp, 0, sizeof( collCreateInp ) );
36 
37  rstrcpy( collCreateInp.collName, collection, MAX_NAME_LEN );
38 
39  status = rcCollCreate( conn, &collCreateInp );
40 
42  status = 0;
43  }
44 
45  return status;
46 }
47 
48 /* mk the directory recursively */
49 
50 int
51 mkCollR( rcComm_t *conn, char *startColl, char *destColl ) {
52  int status;
53  int startLen;
54  int pathLen, tmpLen;
55  char tmpPath[MAX_NAME_LEN];
56  rodsPath_t rodsPath;
57 
58  startLen = strlen( startColl );
59  pathLen = strlen( destColl );
60 
61  rstrcpy( tmpPath, destColl, MAX_NAME_LEN );
62 
63  tmpLen = pathLen;
64 
65  memset( &rodsPath, 0, sizeof( rodsPath ) );
66  while ( tmpLen > startLen ) {
67  rodsPath.objType = COLL_OBJ_T;
68  rodsPath.objState = UNKNOWN_ST;
69  rstrcpy( rodsPath.outPath, tmpPath, MAX_NAME_LEN );
70  status = getRodsObjType( conn, &rodsPath );
71  if ( status >= 0 && rodsPath.objState == EXIST_ST ) {
72  clearRodsPath( &rodsPath );
73  break;
74  }
75  else {
76  clearRodsPath( &rodsPath );
77  }
78 
79  /* Go backward */
80 
81  while ( tmpLen && tmpPath[tmpLen] != '/' ) {
82  tmpLen --;
83  }
84  tmpPath[tmpLen] = '\0';
85  }
86 
87  /* Now we go forward and make the required coll */
88  while ( tmpLen < pathLen ) {
89  /* Put back the '/' */
90  tmpPath[tmpLen] = '/';
91  status = mkColl( conn, tmpPath );
92  if ( status < 0 ) {
94  "mkCollR: mkdir failed for %s, status =%d",
95  tmpPath, status );
96  return status;
97  }
98  while ( tmpLen && tmpPath[tmpLen] != '\0' ) {
99  tmpLen ++;
100  }
101  }
102  return 0;
103 }
104 
105 int
106 mkdirR( char *startDir, char *destDir, int mode ) {
107  using namespace boost::filesystem;
108  int status = 0;
109  int startLen;
110  int pathLen, tmpLen;
111  char tmpPath[MAX_NAME_LEN];
112  startLen = strlen( startDir );
113  pathLen = strlen( destDir );
114 
115  rstrcpy( tmpPath, destDir, MAX_NAME_LEN );
116 
117  tmpLen = pathLen;
118 
119  while ( tmpLen > startLen ) {
120  path p( tmpPath );
121  if ( exists( p ) ) {
122  break;
123  }
124 
125  /* Go backward */
126 
127  while ( tmpLen && tmpPath[tmpLen] != '/' ) {
128  tmpLen --;
129  }
130  tmpPath[tmpLen] = '\0';
131  }
132 
133  /* Now we go forward and make the required coll */
134  while ( tmpLen < pathLen ) {
135  /* Put back the '/' */
136  tmpPath[tmpLen] = '/';
137 #ifdef _WIN32
138  status = iRODSNt_mkdir( tmpPath, mode );
139 #else
140 
141  status = mkdir( tmpPath, mode );
142 #endif
143  if ( status < 0 ) {
145  "mkdirR: mkdir failed for %s, errno =%d",
146  tmpPath, errno );
147  return UNIX_FILE_MKDIR_ERR - errno;
148  }
149  while ( tmpLen && tmpPath[tmpLen] != '\0' ) {
150  tmpLen ++;
151  }
152  }
153  return 0;
154 }
155 
156 int
157 mkdirForFilePath( char* filePath ) {
158  char child[MAX_NAME_LEN], parent[MAX_NAME_LEN];
159  int status;
160 
161  if ( ( status = splitPathByKey( filePath, parent, MAX_NAME_LEN, child, MAX_NAME_LEN, '/' ) ) < 0 ) {
163  "mkdirForFilePath:: splitPathByKey for %s error, status = %d",
164  filePath, status );
165  return status;
166  }
167 
168  status = mkdirR( "/", parent, DEFAULT_DIR_MODE );
169 
170  return status;
171 }
172 
173 int
174 rmdirR( char *startDir, char *destDir ) {
175  int startLen;
176  int pathLen, tmpLen;
177  char tmpPath[MAX_NAME_LEN];
178 
179  startLen = strlen( startDir );
180  pathLen = strlen( destDir );
181 
182  rstrcpy( tmpPath, destDir, MAX_NAME_LEN );
183 
184  tmpLen = pathLen;
185 
186  while ( tmpLen > startLen ) {
187  rmdir( tmpPath );
188 
189  /* Go backward */
190 
191  while ( tmpLen && tmpPath[tmpLen] != '/' ) {
192  tmpLen --;
193  }
194  tmpPath[tmpLen] = '\0';
195  }
196  return 0;
197 }
198 
199 int
200 getRodsObjType( rcComm_t *conn, rodsPath_t *rodsPath ) {
201  int status;
202  dataObjInp_t dataObjInp;
203  rodsObjStat_t *rodsObjStatOut = NULL;
204 
205  if ( rodsPath == NULL ) {
206  return USER__NULL_INPUT_ERR;
207  }
208 
209  memset( &dataObjInp, 0, sizeof( dataObjInp ) );
210 
211  rstrcpy( dataObjInp.objPath, rodsPath->outPath, MAX_NAME_LEN );
212  status = rcObjStat( conn, &dataObjInp, &rodsObjStatOut );
213 
214  if ( status < 0 ) {
215 
216  rodsPath->objState = NOT_EXIST_ST;
217 
220  return NOT_EXIST_ST;
221  }
222  else {
224  "rcObjStat of %s failed", rodsPath->outPath );
225  return status;
226  }
227  }
228  else if ( rodsPath->objType == COLL_OBJ_T &&
229  rodsObjStatOut->objType != COLL_OBJ_T ) {
230  rodsPath->objState = NOT_EXIST_ST;
231  }
232  else if ( rodsPath->objType == DATA_OBJ_T &&
233  rodsObjStatOut->objType != DATA_OBJ_T ) {
234  rodsPath->objState = NOT_EXIST_ST;
235  }
236  else {
237  if ( rodsObjStatOut->objType == UNKNOWN_OBJ_T ) {
238  rodsPath->objState = NOT_EXIST_ST;
239  }
240  else {
241  rodsPath->objState = EXIST_ST;
242  }
243  rodsPath->objType = rodsObjStatOut->objType;
244  if ( rodsPath->objType == DATA_OBJ_T ) {
245  rodsPath->objMode = rodsObjStatOut->dataMode;
246  rstrcpy( rodsPath->dataId, rodsObjStatOut->dataId, NAME_LEN );
247  rodsPath->size = rodsObjStatOut->objSize;
248  rstrcpy( rodsPath->chksum, rodsObjStatOut->chksum, NAME_LEN );
249  }
250  }
251  rodsPath->rodsObjStat = rodsObjStatOut;
252 
253  return rodsPath->objState;
254 }
255 
256 /* genAllInCollQCond - Generate a sqlCondInp for querying every thing under
257  * a collection.
258  * The server will handle special char such as "-" and "%".
259  */
260 
261 int
262 genAllInCollQCond( char *collection, char *collQCond ) {
263  if ( collection == NULL ) {
264  return USER__NULL_INPUT_ERR;
265  }
266 
267  if ( strcmp( collection, "/" ) == 0 ) {
268  snprintf( collQCond, MAX_NAME_LEN, " like '/%%' " );
269  }
270  else {
271 
272  snprintf( collQCond, MAX_NAME_LEN, " = '%s' || like '%s/%%' ",
273  collection, collection );
274  }
275  return 0;
276 }
277 
278 /* queryCollInColl - query the subCollections in a collection.
279  */
280 
281 int
282 queryCollInColl( queryHandle_t *queryHandle, char *collection,
283  int flags, genQueryInp_t *genQueryInp,
284  genQueryOut_t **genQueryOut ) {
285  char collQCond[MAX_NAME_LEN];
286  int status;
287 
288  if ( collection == NULL || genQueryOut == NULL ) {
289  return USER__NULL_INPUT_ERR;
290  }
291 
292  memset( genQueryInp, 0, sizeof( genQueryInp_t ) );
293 
294  snprintf( collQCond, MAX_NAME_LEN, "%s", NON_ROOT_COLL_CHECK_STR);
295  addInxVal( &genQueryInp->sqlCondInp, COL_COLL_NAME, collQCond );
296 
297  if ( ( flags & RECUR_QUERY_FG ) != 0 ) {
298  genAllInCollQCond( collection, collQCond );
299  addInxVal( &genQueryInp->sqlCondInp, COL_COLL_NAME, collQCond );
300  }
301  else {
302  snprintf( collQCond, MAX_NAME_LEN, "='%s'", collection );
303  addInxVal( &genQueryInp->sqlCondInp, COL_COLL_PARENT_NAME, collQCond );
304  }
305  addInxIval( &genQueryInp->selectInp, COL_COLL_NAME, 1 );
306  addInxIval( &genQueryInp->selectInp, COL_COLL_OWNER_NAME, 1 );
307  addInxIval( &genQueryInp->selectInp, COL_COLL_CREATE_TIME, 1 );
308  addInxIval( &genQueryInp->selectInp, COL_COLL_MODIFY_TIME, 1 );
309  addInxIval( &genQueryInp->selectInp, COL_COLL_TYPE, 1 );
310  addInxIval( &genQueryInp->selectInp, COL_COLL_INFO1, 1 );
311  addInxIval( &genQueryInp->selectInp, COL_COLL_INFO2, 1 );
312 
313  genQueryInp->maxRows = MAX_SQL_ROWS;
314 
315  status = ( *queryHandle->genQuery )(
316  ( rcComm_t * ) queryHandle->conn, genQueryInp, genQueryOut );
317 
318  return status;
319 }
320 
321 /* queryDataObjInColl - query the DataObj in a collection.
322  */
323 int
324 queryDataObjInColl( queryHandle_t *queryHandle, char *collection,
325  int flags, genQueryInp_t *genQueryInp,
326  genQueryOut_t **genQueryOut, keyValPair_t *condInput ) {
327  char collQCond[MAX_NAME_LEN];
328  int status;
329  char *rescName = NULL;
330  if ( collection == NULL || genQueryOut == NULL ) {
331  return USER__NULL_INPUT_ERR;
332  }
333 
334  memset( genQueryInp, 0, sizeof( genQueryInp_t ) );
335 
336  if ( ( flags & RECUR_QUERY_FG ) != 0 ) {
337  genAllInCollQCond( collection, collQCond );
338  addInxVal( &genQueryInp->sqlCondInp, COL_COLL_NAME, collQCond );
339  }
340  else {
341  snprintf( collQCond, MAX_NAME_LEN, " = '%s'", collection );
342  addInxVal( &genQueryInp->sqlCondInp, COL_COLL_NAME, collQCond );
343  }
344  if ( ( flags & INCLUDE_CONDINPUT_IN_QUERY ) != 0 &&
345  condInput != NULL &&
346  ( rescName = getValByKey( condInput, RESC_NAME_KW ) ) != NULL ) {
347  snprintf( collQCond, MAX_NAME_LEN, " = '%s'", rescName );
348  addInxVal( &genQueryInp->sqlCondInp, COL_D_RESC_NAME, collQCond );
349  }
350 
351  setQueryInpForData( flags, genQueryInp );
352 
353  genQueryInp->maxRows = MAX_SQL_ROWS;
354  genQueryInp->options = RETURN_TOTAL_ROW_COUNT;
355 
356  status = ( *queryHandle->genQuery )(
357  ( rcComm_t * ) queryHandle->conn, genQueryInp, genQueryOut );
358 
359  return status;
360 
361 }
362 
363 int
364 setQueryInpForData( int flags, genQueryInp_t *genQueryInp ) {
365 
366  if ( genQueryInp == NULL ) {
367  return USER__NULL_INPUT_ERR;
368  }
369 
370  addInxIval( &genQueryInp->selectInp, COL_COLL_NAME, 1 );
371  addInxIval( &genQueryInp->selectInp, COL_DATA_NAME, 1 );
372  addInxIval( &genQueryInp->selectInp, COL_D_DATA_ID, 1 );
373  addInxIval( &genQueryInp->selectInp, COL_DATA_MODE, 1 );
374  addInxIval( &genQueryInp->selectInp, COL_DATA_SIZE, 1 );
375  addInxIval( &genQueryInp->selectInp, COL_D_MODIFY_TIME, 1 );
376  addInxIval( &genQueryInp->selectInp, COL_D_CREATE_TIME, 1 );
377  if ( ( flags & LONG_METADATA_FG ) != 0 ||
378  ( flags & VERY_LONG_METADATA_FG ) != 0 ) {
379  addInxIval( &genQueryInp->selectInp, COL_D_RESC_NAME, 1 );
380  addInxIval( &genQueryInp->selectInp, COL_D_RESC_HIER, 1 );
381  addInxIval( &genQueryInp->selectInp, COL_D_OWNER_NAME, 1 );
382  addInxIval( &genQueryInp->selectInp, COL_DATA_REPL_NUM, 1 );
383  addInxIval( &genQueryInp->selectInp, COL_D_REPL_STATUS, 1 );
384 
385  if ( ( flags & VERY_LONG_METADATA_FG ) != 0 ) {
386  addInxIval( &genQueryInp->selectInp, COL_D_DATA_PATH, 1 );
387  addInxIval( &genQueryInp->selectInp, COL_D_DATA_CHECKSUM, 1 );
388  addInxIval( &genQueryInp->selectInp, COL_DATA_TYPE_NAME, 1 );
389  }
390  }
391 
392  return 0;
393 }
394 
395 int
396 printTiming( rcComm_t *conn, char *objPath, rodsLong_t fileSize,
397  char *localFile, struct timeval *startTime, struct timeval *endTime ) {
398  struct timeval diffTime;
399  char myDir[MAX_NAME_LEN], myFile[MAX_NAME_LEN];
400  float transRate, sizeInMb, timeInSec;
401  int status;
402 
403 
404  if ( ( status = splitPathByKey( objPath, myDir, MAX_NAME_LEN, myFile, MAX_NAME_LEN, '/' ) ) < 0 ) {
406  "printTiming: splitPathByKey for %s error, status = %d",
407  objPath, status );
408  return status;
409  }
410 
411  diffTime.tv_sec = endTime->tv_sec - startTime->tv_sec;
412  diffTime.tv_usec = endTime->tv_usec - startTime->tv_usec;
413 
414  if ( diffTime.tv_usec < 0 ) {
415  diffTime.tv_sec --;
416  diffTime.tv_usec += 1000000;
417  }
418 
419  timeInSec = ( float ) diffTime.tv_sec + ( ( float ) diffTime.tv_usec /
420  1000000.0 );
421 
422  if ( fileSize < 0 ) {
423  /* may be we can find it from the local file */
424 
425  if ( localFile != NULL ) {
426  fileSize = getFileSize( localFile );
427  }
428  }
429 
430 
431  if ( fileSize <= 0 ) {
432  transRate = 0.0;
433  sizeInMb = 0.0;
434  }
435  else {
436  sizeInMb = ( float ) fileSize / 1048576.0;
437  if ( timeInSec == 0.0 ) {
438  transRate = 0.0;
439  }
440  else {
441  transRate = sizeInMb / timeInSec;
442  }
443  }
444 
445  if ( fileSize < 0 ) {
446  fprintf( stdout,
447  " %-25.25s %.3f sec\n",
448  myFile, timeInSec );
449  }
450  else {
451  fprintf( stdout,
452  " %-25.25s %10.3f MB | %.3f sec | %d thr | %6.3f MB/s\n",
453  myFile, sizeInMb, timeInSec, conn->transStat.numThreads, transRate );
454  }
455 
456  return 0;
457 }
458 
459 int
460 printTime( char *objPath, struct timeval *startTime,
461  struct timeval *endTime ) {
462  struct timeval diffTime;
463  char myDir[MAX_NAME_LEN], myFile[MAX_NAME_LEN];
464  float timeInSec;
465  int status;
466 
467 
468  if ( ( status = splitPathByKey( objPath, myDir, MAX_NAME_LEN, myFile, MAX_NAME_LEN, '/' ) ) < 0 ) {
470  "printTime: splitPathByKey for %s error, status = %d",
471  objPath, status );
472  return status;
473  }
474 
475  diffTime.tv_sec = endTime->tv_sec - startTime->tv_sec;
476  diffTime.tv_usec = endTime->tv_usec - startTime->tv_usec;
477 
478  if ( diffTime.tv_usec < 0 ) {
479  diffTime.tv_sec --;
480  diffTime.tv_usec += 1000000;
481  }
482  timeInSec = ( float ) diffTime.tv_sec + ( ( float ) diffTime.tv_usec /
483  1000000.0 );
484 
485  fprintf( stdout, " %-25.25s %.3f sec\n", myFile, timeInSec );
486 
487  return 0;
488 }
489 
490 int
491 printNoSync( char *objPath, rodsLong_t fileSize, char *reason ) {
492  char myDir[MAX_NAME_LEN], myFile[MAX_NAME_LEN];
493  float sizeInMb;
494  int status;
495 
496 
497  if ( ( status = splitPathByKey( objPath, myDir, MAX_NAME_LEN, myFile, MAX_NAME_LEN, '/' ) ) < 0 ) {
498  rstrcpy( myFile, objPath, MAX_NAME_LEN );
499  }
500 
501  if ( fileSize <= 0 ) {
502  sizeInMb = 0.0;
503  }
504  else {
505  sizeInMb = ( float ) fileSize / 1048576.0;
506  }
507 
508  fprintf( stdout,
509  " %-25.25s %10.3f MB --- %s no sync required \n", myFile, sizeInMb, reason );
510 
511  return 0;
512 }
513 
514 int
515 queryDataObjAcl( rcComm_t *conn, char *dataId, char *zoneHint, genQueryOut_t **genQueryOut ) { // JMC - bacport 4516
516  genQueryInp_t genQueryInp;
517  int status;
518  char tmpStr[MAX_NAME_LEN];
519 
520  if ( dataId == NULL || genQueryOut == NULL ) {
521  return USER__NULL_INPUT_ERR;
522  }
523 
524  memset( &genQueryInp, 0, sizeof( genQueryInp_t ) );
525 
526  if ( zoneHint != NULL ) { // JMC - bacport 4516
527  addKeyVal( &genQueryInp.condInput, ZONE_KW, zoneHint );
528  }
529 
530  addInxIval( &genQueryInp.selectInp, COL_USER_NAME, 1 );
531  addInxIval( &genQueryInp.selectInp, COL_USER_ZONE, 1 );
532  addInxIval( &genQueryInp.selectInp, COL_DATA_ACCESS_NAME, 1 );
533 
534  snprintf( tmpStr, MAX_NAME_LEN, " = '%s'", dataId );
535 
536  addInxVal( &genQueryInp.sqlCondInp, COL_DATA_ACCESS_DATA_ID, tmpStr );
537 
538  snprintf( tmpStr, MAX_NAME_LEN, "='%s'", "access_type" );
539 
540  /* Currently necessary since other namespaces exist in the token table */
541  addInxVal( &genQueryInp.sqlCondInp, COL_DATA_TOKEN_NAMESPACE, tmpStr );
542 
543  genQueryInp.maxRows = MAX_SQL_ROWS;
544 
545  status = rcGenQuery( conn, &genQueryInp, genQueryOut );
546 
547  return status;
548 
549 }
550 
551 int
552 queryCollAclSpecific( rcComm_t *conn, char *collName, char *zoneHint,
553  genQueryOut_t **genQueryOut ) {
554  genQueryOut_t *myGenQueryOut;
555  int status;
556  specificQueryInp_t specificQueryInp;
557 
558  if ( collName == NULL || genQueryOut == NULL ) {
559  return USER__NULL_INPUT_ERR;
560  }
561 
562  myGenQueryOut = *genQueryOut =
563  ( genQueryOut_t * ) malloc( sizeof( genQueryOut_t ) );
564  memset( myGenQueryOut, 0, sizeof( genQueryOut_t ) );
565 
566  memset( &specificQueryInp, 0, sizeof( specificQueryInp_t ) );
567  if ( zoneHint != NULL ) {
568  addKeyVal( &specificQueryInp.condInput, ZONE_KW, zoneHint );
569  }
570 
571  specificQueryInp.maxRows = MAX_SQL_ROWS;
572  specificQueryInp.continueInx = 0;
573  specificQueryInp.sql = "ShowCollAcls";
574  specificQueryInp.args[0] = collName;
575  status = rcSpecificQuery( conn, &specificQueryInp, genQueryOut );
576  return status;
577 }
578 
579 
580 int
581 queryCollAcl( rcComm_t *conn, char *collName, char *zoneHint, genQueryOut_t **genQueryOut ) { // JMC - bacport 4516
582  genQueryInp_t genQueryInp;
583  genQueryOut_t *myGenQueryOut;
584  int status;
585  char tmpStr[MAX_NAME_LEN];
586 
587  if ( collName == NULL || genQueryOut == NULL ) {
588  return USER__NULL_INPUT_ERR;
589  }
590 
591  memset( &genQueryInp, 0, sizeof( genQueryInp_t ) );
592 
593  myGenQueryOut = *genQueryOut =
594  ( genQueryOut_t * ) malloc( sizeof( genQueryOut_t ) );
595  memset( myGenQueryOut, 0, sizeof( genQueryOut_t ) );
596 
597  clearGenQueryInp( &genQueryInp );
598 
599  if ( zoneHint != NULL ) { // JMC - bacport 4516
600  addKeyVal( &genQueryInp.condInput, ZONE_KW, zoneHint );
601  }
602 
603  addInxIval( &genQueryInp.selectInp, COL_COLL_USER_NAME, 1 );
604  addInxIval( &genQueryInp.selectInp, COL_COLL_USER_ZONE, 1 );
605 
606  addInxIval( &genQueryInp.selectInp, COL_COLL_ACCESS_NAME, 1 );
607 
608  snprintf( tmpStr, MAX_NAME_LEN, "='%s'", "access_type" );
609 
610  /* Currently necessary since other namespaces exist in the token table */
611  addInxVal( &genQueryInp.sqlCondInp, COL_COLL_TOKEN_NAMESPACE, tmpStr );
612 
613  snprintf( tmpStr, MAX_NAME_LEN, " = '%s'", collName );
614  addInxVal( &genQueryInp.sqlCondInp, COL_COLL_NAME, tmpStr );
615 
616  genQueryInp.maxRows = MAX_SQL_ROWS;
617 
618  status = rcGenQuery( conn, &genQueryInp, genQueryOut );
619 
620  return status;
621 
622 }
623 
624 int
625 queryCollInheritance( rcComm_t *conn, char *collName,
626  genQueryOut_t **genQueryOut ) {
627  genQueryInp_t genQueryInp;
628  genQueryOut_t *myGenQueryOut;
629  int status;
630  char tmpStr[MAX_NAME_LEN];
631 
632  if ( collName == NULL || genQueryOut == NULL ) {
633  return USER__NULL_INPUT_ERR;
634  }
635 
636  memset( &genQueryInp, 0, sizeof( genQueryInp_t ) );
637 
638  myGenQueryOut = *genQueryOut =
639  ( genQueryOut_t * ) malloc( sizeof( genQueryOut_t ) );
640  memset( myGenQueryOut, 0, sizeof( genQueryOut_t ) );
641 
642  clearGenQueryInp( &genQueryInp );
643 
644  addInxIval( &genQueryInp.selectInp, COL_COLL_INHERITANCE, 1 );
645 
646  snprintf( tmpStr, MAX_NAME_LEN, " = '%s'", collName );
647  addInxVal( &genQueryInp.sqlCondInp, COL_COLL_NAME, tmpStr );
648 
649  genQueryInp.maxRows = MAX_SQL_ROWS;
650 
651  status = rcGenQuery( conn, &genQueryInp, genQueryOut );
652 
653  return status;
654 
655 }
656 
657 int
659  collSqlResult_t *collSqlResult ) {
660  genQueryOut_t *myGenQueryOut;
661  sqlResult_t *collName, *collType, *collInfo1, *collInfo2, *collOwner,
662  *collCreateTime, *collModifyTime, *tmpSqlResult;
663 
664  if ( genQueryOut == NULL || ( myGenQueryOut = *genQueryOut ) == NULL ||
665  collSqlResult == NULL ) {
666  return USER__NULL_INPUT_ERR;
667  }
668 
669  collSqlResult->rowCnt = myGenQueryOut->rowCnt;
670  collSqlResult->attriCnt = myGenQueryOut->attriCnt;
671  collSqlResult->continueInx = myGenQueryOut->continueInx;
672  collSqlResult->totalRowCount = myGenQueryOut->totalRowCount;
673 
674  if ( ( collName = getSqlResultByInx( myGenQueryOut, COL_COLL_NAME ) ) == NULL ) {
676  "genQueryOutToCollRes: getSqlResultByInx for COL_COLL_NAME failed" );
677  return UNMATCHED_KEY_OR_INDEX;
678  }
679  else {
680  collSqlResult->collName = *collName;
681  }
682 
683  if ( ( collType = getSqlResultByInx( myGenQueryOut, COL_COLL_TYPE ) ) == NULL ) {
684  /* should inherit parent's specColl */
685  setSqlResultValue( &collSqlResult->collType, COL_COLL_NAME,
686  INHERIT_PAR_SPEC_COLL_STR, myGenQueryOut->rowCnt );
687  setSqlResultValue( &collSqlResult->collInfo1, COL_COLL_INFO1, "",
688  myGenQueryOut->rowCnt );
689  setSqlResultValue( &collSqlResult->collInfo2, COL_COLL_INFO2, "",
690  myGenQueryOut->rowCnt );
691  setSqlResultValue( &collSqlResult->collOwner, COL_COLL_OWNER_NAME, "",
692  myGenQueryOut->rowCnt );
694  "", myGenQueryOut->rowCnt );
696  "", myGenQueryOut->rowCnt );
697  /* myGenQueryOut could came from rcQuerySpecColl call */
698  if ( ( tmpSqlResult = getSqlResultByInx( myGenQueryOut, COL_DATA_NAME ) )
699  != NULL ) {
700  if ( tmpSqlResult->value != NULL ) {
701  free( tmpSqlResult->value );
702  }
703  }
704  if ( ( tmpSqlResult = getSqlResultByInx( myGenQueryOut, COL_D_CREATE_TIME ) )
705  != NULL ) {
706  if ( tmpSqlResult->value != NULL ) {
707  free( tmpSqlResult->value );
708  }
709  }
710  if ( ( tmpSqlResult = getSqlResultByInx( myGenQueryOut, COL_D_MODIFY_TIME ) )
711  != NULL ) {
712  if ( tmpSqlResult->value != NULL ) {
713  free( tmpSqlResult->value );
714  }
715  }
716  if ( ( tmpSqlResult = getSqlResultByInx( myGenQueryOut, COL_DATA_SIZE ) )
717  != NULL ) {
718  if ( tmpSqlResult->value != NULL ) {
719  free( tmpSqlResult->value );
720  }
721  }
722  }
723  else {
724  collSqlResult->collType = *collType;
725  if ( ( collInfo1 = getSqlResultByInx( myGenQueryOut, COL_COLL_INFO1 ) ) ==
726  NULL ) {
728  "genQueryOutToCollRes: getSqlResultByInx COL_COLL_INFO1 failed" );
729  return UNMATCHED_KEY_OR_INDEX;
730  }
731  else {
732  collSqlResult->collInfo1 = *collInfo1;
733  }
734  if ( ( collInfo2 = getSqlResultByInx( myGenQueryOut, COL_COLL_INFO2 ) ) ==
735  NULL ) {
737  "genQueryOutToCollRes: getSqlResultByInx COL_COLL_INFO2 failed" );
738  return UNMATCHED_KEY_OR_INDEX;
739  }
740  else {
741  collSqlResult->collInfo2 = *collInfo2;
742  }
743  if ( ( collOwner = getSqlResultByInx( myGenQueryOut,
744  COL_COLL_OWNER_NAME ) ) == NULL ) {
746  "genQueryOutToCollRes: getSqlResultByInx COL_COLL_OWNER_NAME failed" );
747  return UNMATCHED_KEY_OR_INDEX;
748  }
749  else {
750  collSqlResult->collOwner = *collOwner;
751  }
752  if ( ( collCreateTime = getSqlResultByInx( myGenQueryOut,
753  COL_COLL_CREATE_TIME ) ) == NULL ) {
755  "genQueryOutToCollRes: getSqlResultByInx COL_COLL_CREATE_TIME failed" );
756  return UNMATCHED_KEY_OR_INDEX;
757  }
758  else {
759  collSqlResult->collCreateTime = *collCreateTime;
760  }
761  if ( ( collModifyTime = getSqlResultByInx( myGenQueryOut,
762  COL_COLL_MODIFY_TIME ) ) == NULL ) {
764  "genQueryOutToCollRes: getSqlResultByInx COL_COLL_MODIFY_TIME failed" );
765  return UNMATCHED_KEY_OR_INDEX;
766  }
767  else {
768  collSqlResult->collModifyTime = *collModifyTime;
769  }
770  }
771 
772  free( *genQueryOut );
773  *genQueryOut = NULL;
774  return 0;
775 }
776 
777 int
778 setSqlResultValue( sqlResult_t *sqlResult, int attriInx, char *valueStr,
779  int rowCnt ) {
780  if ( sqlResult == NULL || rowCnt <= 0 ) {
781  return 0;
782  }
783 
784  sqlResult->attriInx = attriInx;
785  if ( valueStr == NULL ) {
786  sqlResult->len = 1;
787  }
788  else {
789  sqlResult->len = strlen( valueStr ) + 1;
790  }
791  if ( sqlResult->len == 1 ) {
792  sqlResult->value = ( char * )malloc( rowCnt );
793  memset( sqlResult->value, 0, rowCnt );
794  }
795  else {
796  int i;
797  char *tmpPtr;
798  tmpPtr = sqlResult->value = ( char * )malloc( rowCnt * sqlResult->len );
799  for ( i = 0; i < rowCnt; i++ ) {
800  rstrcpy( tmpPtr, valueStr, sqlResult->len );
801  tmpPtr += sqlResult->len;
802  }
803  }
804  return 0;
805 }
806 
807 int
809  if ( collSqlResult == NULL ) {
810  return USER__NULL_INPUT_ERR;
811  }
812 
813  if ( collSqlResult->collName.value != NULL ) {
814  free( collSqlResult->collName.value );
815  }
816  if ( collSqlResult->collType.value != NULL ) {
817  free( collSqlResult->collType.value );
818  }
819  if ( collSqlResult->collInfo1.value != NULL ) {
820  free( collSqlResult->collInfo1.value );
821  }
822  if ( collSqlResult->collInfo2.value != NULL ) {
823  free( collSqlResult->collInfo2.value );
824  }
825  if ( collSqlResult->collOwner.value != NULL ) {
826  free( collSqlResult->collOwner.value );
827  }
828  if ( collSqlResult->collCreateTime.value != NULL ) {
829  free( collSqlResult->collCreateTime.value );
830  }
831  if ( collSqlResult->collModifyTime.value != NULL ) {
832  free( collSqlResult->collModifyTime.value );
833  }
834 
835  memset( collSqlResult, 0, sizeof( collSqlResult_t ) );
836 
837  return 0;
838 }
839 
840 
841 int
843  if ( dataObjSqlResult == NULL ) {
844  return USER__NULL_INPUT_ERR;
845  }
846 
847  if ( dataObjSqlResult->collName.value != NULL ) {
848  free( dataObjSqlResult->collName.value );
849  }
850  if ( dataObjSqlResult->dataName.value != NULL ) {
851  free( dataObjSqlResult->dataName.value );
852  }
853  if ( dataObjSqlResult->dataMode.value != NULL ) {
854  free( dataObjSqlResult->dataMode.value );
855  }
856  if ( dataObjSqlResult->dataSize.value != NULL ) {
857  free( dataObjSqlResult->dataSize.value );
858  }
859  if ( dataObjSqlResult->createTime.value != NULL ) {
860  free( dataObjSqlResult->createTime.value );
861  }
862  if ( dataObjSqlResult->modifyTime.value != NULL ) {
863  free( dataObjSqlResult->modifyTime.value );
864  }
865  if ( dataObjSqlResult->chksum.value != NULL ) {
866  free( dataObjSqlResult->chksum.value );
867  }
868  if ( dataObjSqlResult->replStatus.value != NULL ) {
869  free( dataObjSqlResult->replStatus.value );
870  }
871  if ( dataObjSqlResult->dataId.value != NULL ) {
872  free( dataObjSqlResult->dataId.value );
873  }
874  if ( dataObjSqlResult->resource.value != NULL ) {
875  free( dataObjSqlResult->resource.value );
876  }
877  if ( dataObjSqlResult->resc_id.value != NULL ) {
878  free( dataObjSqlResult->resc_id.value );
879  }
880  if ( dataObjSqlResult->resc_hier.value != NULL ) {
881  free( dataObjSqlResult->resc_hier.value );
882  }
883  if ( dataObjSqlResult->phyPath.value != NULL ) {
884  free( dataObjSqlResult->phyPath.value );
885  }
886  if ( dataObjSqlResult->ownerName.value != NULL ) {
887  free( dataObjSqlResult->ownerName.value );
888  }
889  if ( dataObjSqlResult->replNum.value != NULL ) {
890  free( dataObjSqlResult->replNum.value );
891  }
892  if ( dataObjSqlResult->dataType.value != NULL ) {
893  free( dataObjSqlResult->dataType.value );
894  }
895  memset( dataObjSqlResult, 0, sizeof( dataObjSqlResult_t ) );
896 
897  return 0;
898 }
899 
900 int
902  dataObjSqlResult_t *dataObjSqlResult ) {
903  genQueryOut_t *myGenQueryOut;
904  sqlResult_t *collName, *dataName, *dataSize, *dataMode, *createTime,
905  *modifyTime, *chksum, *replStatus, *dataId, *resource, *resc_hier, *phyPath,
906  *ownerName, *replNum, *dataType;
907  if ( genQueryOut == NULL || ( myGenQueryOut = *genQueryOut ) == NULL ||
908  dataObjSqlResult == NULL ) {
909  return USER__NULL_INPUT_ERR;
910  }
911 
912  dataObjSqlResult->rowCnt = myGenQueryOut->rowCnt;
913  dataObjSqlResult->attriCnt = myGenQueryOut->attriCnt;
914  dataObjSqlResult->continueInx = myGenQueryOut->continueInx;
915  dataObjSqlResult->totalRowCount = myGenQueryOut->totalRowCount;
916 
917  if ( ( collName = getSqlResultByInx( myGenQueryOut, COL_COLL_NAME ) ) == NULL ) {
919  "genQueryOutToDataObjRes: getSqlResultByInx for COL_COLL_NAME failed" );
920  return UNMATCHED_KEY_OR_INDEX;
921  }
922  else {
923  dataObjSqlResult->collName = *collName;
924  }
925 
926  if ( ( dataName = getSqlResultByInx( myGenQueryOut, COL_DATA_NAME ) ) == NULL ) {
928  "genQueryOutToDataObjRes: getSqlResultByInx for COL_DATA_NAME failed" );
929  return UNMATCHED_KEY_OR_INDEX;
930  }
931  else {
932  dataObjSqlResult->dataName = *dataName;
933  }
934 
935  if ( ( dataMode = getSqlResultByInx( myGenQueryOut, COL_DATA_MODE ) ) == NULL ) {
936  setSqlResultValue( &dataObjSqlResult->dataMode, COL_DATA_MODE, "",
937  myGenQueryOut->rowCnt );
938  }
939  else {
940  dataObjSqlResult->dataMode = *dataMode;
941  }
942 
943  if ( ( dataSize = getSqlResultByInx( myGenQueryOut, COL_DATA_SIZE ) ) == NULL ) {
944  setSqlResultValue( &dataObjSqlResult->dataSize, COL_DATA_SIZE, "-1",
945  myGenQueryOut->rowCnt );
946  }
947  else {
948  dataObjSqlResult->dataSize = *dataSize;
949  }
950 
951  if ( ( createTime = getSqlResultByInx( myGenQueryOut, COL_D_CREATE_TIME ) )
952  == NULL ) {
953  setSqlResultValue( &dataObjSqlResult->createTime, COL_D_CREATE_TIME,
954  "", myGenQueryOut->rowCnt );
955  }
956  else {
957  dataObjSqlResult->createTime = *createTime;
958  }
959 
960  if ( ( modifyTime = getSqlResultByInx( myGenQueryOut, COL_D_MODIFY_TIME ) )
961  == NULL ) {
962  setSqlResultValue( &dataObjSqlResult->modifyTime, COL_D_MODIFY_TIME,
963  "", myGenQueryOut->rowCnt );
964  }
965  else {
966  dataObjSqlResult->modifyTime = *modifyTime;
967  }
968 
969  if ( ( dataId = getSqlResultByInx( myGenQueryOut, COL_D_DATA_ID ) )
970  == NULL ) {
971  setSqlResultValue( &dataObjSqlResult->dataId, COL_D_DATA_ID,
972  "", myGenQueryOut->rowCnt );
973  }
974  else {
975  dataObjSqlResult->dataId = *dataId;
976  }
977 
978  if ( ( chksum = getSqlResultByInx( myGenQueryOut, COL_D_DATA_CHECKSUM ) )
979  == NULL ) {
980  setSqlResultValue( &dataObjSqlResult->chksum, COL_D_DATA_CHECKSUM,
981  "", myGenQueryOut->rowCnt );
982  }
983  else {
984  dataObjSqlResult->chksum = *chksum;
985  }
986 
987  if ( ( replStatus = getSqlResultByInx( myGenQueryOut, COL_D_REPL_STATUS ) )
988  == NULL ) {
989  setSqlResultValue( &dataObjSqlResult->replStatus, COL_D_REPL_STATUS,
990  "", myGenQueryOut->rowCnt );
991  }
992  else {
993  dataObjSqlResult->replStatus = *replStatus;
994  }
995 
996  if ( ( resource = getSqlResultByInx( myGenQueryOut, COL_D_RESC_NAME ) )
997  == NULL ) {
998  setSqlResultValue( &dataObjSqlResult->resource, COL_D_RESC_NAME,
999  "", myGenQueryOut->rowCnt );
1000  }
1001  else {
1002  dataObjSqlResult->resource = *resource;
1003  }
1004  if ( ( resc_hier = getSqlResultByInx( myGenQueryOut, COL_D_RESC_HIER ) )
1005  == NULL ) {
1006  setSqlResultValue( &dataObjSqlResult->resc_hier, COL_D_RESC_HIER,
1007  "", myGenQueryOut->rowCnt );
1008  }
1009  else {
1010  dataObjSqlResult->resc_hier = *resc_hier;
1011  }
1012 
1013 
1014  if ( ( dataType = getSqlResultByInx( myGenQueryOut, COL_DATA_TYPE_NAME ) )
1015  == NULL ) {
1016  setSqlResultValue( &dataObjSqlResult->dataType, COL_DATA_TYPE_NAME,
1017  "", myGenQueryOut->rowCnt );
1018  }
1019  else {
1020  dataObjSqlResult->dataType = *dataType;
1021  }
1022 
1023  if ( ( phyPath = getSqlResultByInx( myGenQueryOut, COL_D_DATA_PATH ) )
1024  == NULL ) {
1025  setSqlResultValue( &dataObjSqlResult->phyPath, COL_D_DATA_PATH,
1026  "", myGenQueryOut->rowCnt );
1027  }
1028  else {
1029  dataObjSqlResult->phyPath = *phyPath;
1030  }
1031 
1032  if ( ( ownerName = getSqlResultByInx( myGenQueryOut, COL_D_OWNER_NAME ) )
1033  == NULL ) {
1034  setSqlResultValue( &dataObjSqlResult->ownerName, COL_D_OWNER_NAME,
1035  "", myGenQueryOut->rowCnt );
1036  }
1037  else {
1038  dataObjSqlResult->ownerName = *ownerName;
1039  }
1040 
1041  if ( ( replNum = getSqlResultByInx( myGenQueryOut, COL_DATA_REPL_NUM ) )
1042  == NULL ) {
1043  setSqlResultValue( &dataObjSqlResult->replNum, COL_DATA_REPL_NUM,
1044  "", myGenQueryOut->rowCnt );
1045  }
1046  else {
1047  dataObjSqlResult->replNum = *replNum;
1048  }
1049 
1050  free( *genQueryOut );
1051  *genQueryOut = NULL;
1052 
1053  return 0;
1054 }
1055 
1056 int
1057 rclOpenCollection( rcComm_t *conn, char *collection, int flags,
1058  collHandle_t *collHandle ) {
1059  rodsObjStat_t *rodsObjStatOut = NULL;
1060  int status;
1061 
1062  if ( conn == NULL || collection == NULL || collHandle == NULL ) {
1063  rodsLog( LOG_ERROR,
1064  "rclOpenCollection: NULL conn, collection or collHandle input" );
1065  return USER__NULL_INPUT_ERR;
1066  }
1067 
1068  if ( ( flags & INCLUDE_CONDINPUT_IN_QUERY ) == 0 ) {
1069  /* preserve collHandle->>dataObjInp.condInput if != 0 */
1070  memset( collHandle, 0, sizeof( collHandle_t ) );
1071  }
1072  rstrcpy( collHandle->dataObjInp.objPath, collection, MAX_NAME_LEN );
1073  status = rcObjStat( conn, &collHandle->dataObjInp, &rodsObjStatOut );
1074 
1075 
1076  if ( status < 0 ) {
1077  return status;
1078  }
1079 
1080  if ( rodsObjStatOut->objType != COLL_OBJ_T ) {
1081  free( rodsObjStatOut );
1082  return CAT_UNKNOWN_COLLECTION;
1083  }
1084 
1085  replSpecColl( rodsObjStatOut->specColl, &collHandle->dataObjInp.specColl );
1086  if ( rodsObjStatOut->specColl != NULL &&
1087  rodsObjStatOut->specColl->collClass != STRUCT_FILE_COLL &&
1088  strlen( rodsObjStatOut->specColl->objPath ) > 0 ) {
1089  /* save the linked path */
1090  rstrcpy( collHandle->linkedObjPath, rodsObjStatOut->specColl->objPath,
1091  MAX_NAME_LEN );
1092  };
1093 
1094  collHandle->rodsObjStat = rodsObjStatOut;
1095 
1096  collHandle->state = COLL_OPENED;
1097  collHandle->flags = flags;
1098  /* the collection exist. now query the data in it */
1099  status = rclInitQueryHandle( &collHandle->queryHandle, conn );
1100  if ( status < 0 ) {
1101  return status;
1102  }
1103 
1104  return 0;
1105 }
1106 
1107 int
1109  collEnt_t *collEnt ) {
1110  int status;
1111 
1112  collHandle->queryHandle.conn = conn; /* in case it changed */
1113  status = readCollection( collHandle, collEnt );
1114 
1115  return status;
1116 }
1117 
1118 int
1119 readCollection( collHandle_t *collHandle, collEnt_t *collEnt ) {
1120  int status = 0;
1121  int savedStatus = 0;
1122  collMetaInfo_t collMetaInfo;
1123  dataObjMetaInfo_t dataObjMetaInfo;
1124  queryHandle_t *queryHandle = &collHandle->queryHandle;
1125 
1126  if ( queryHandle == NULL || collHandle == NULL || collEnt == NULL ) {
1127  rodsLog( LOG_ERROR,
1128  "rclReadCollection: NULL queryHandle or collHandle input" );
1129  return USER__NULL_INPUT_ERR;
1130  }
1131 
1132  memset( collEnt, 0, sizeof( collEnt_t ) );
1133 
1134  if ( collHandle->state == COLL_CLOSED ) {
1135  return CAT_NO_ROWS_FOUND;
1136  }
1137 
1138  if ( ( collHandle->flags & DATA_QUERY_FIRST_FG ) == 0 ) {
1139  /* recursive - coll first, dataObj second */
1140  if ( collHandle->state == COLL_OPENED ) {
1141  status = genCollResInColl( queryHandle, collHandle );
1142  if ( status < 0 && status != CAT_NO_ROWS_FOUND ) {
1143  rodsLog( LOG_ERROR, "genCollResInColl in readCollection failed with status %d", status );
1144  }
1145  }
1146 
1147  if ( collHandle->state == COLL_COLL_OBJ_QUERIED ) {
1148  memset( &collMetaInfo, 0, sizeof( collMetaInfo ) );
1149  status = getNextCollMetaInfo( collHandle, collEnt );
1150  if ( status >= 0 ) {
1151  return status;
1152  }
1153  else {
1154  if ( status != CAT_NO_ROWS_FOUND ) {
1155  rodsLog( LOG_ERROR,
1156  "rclReadCollection: getNextCollMetaInfo error for %s. status = %d",
1157  collHandle->dataObjInp.objPath, status );
1158  }
1159  if ( collHandle->dataObjInp.specColl == NULL ) {
1160  clearGenQueryInp( &collHandle->genQueryInp );
1161  }
1162  }
1163  status = genDataResInColl( queryHandle, collHandle );
1164  if ( status < 0 && status != CAT_NO_ROWS_FOUND ) {
1165  rodsLog( LOG_ERROR, "genDataResInColl in readCollection failed with status %d", status );
1166  }
1167  }
1168  if ( collHandle->state == COLL_DATA_OBJ_QUERIED ) {
1169  memset( &dataObjMetaInfo, 0, sizeof( dataObjMetaInfo ) );
1170  status = getNextDataObjMetaInfo( collHandle, collEnt );
1171 
1172  if ( status >= 0 ) {
1173  return status;
1174  }
1175  else {
1176  if ( status != CAT_NO_ROWS_FOUND ) {
1177  rodsLog( LOG_ERROR,
1178  "rclReadCollection: getNextDataObjMetaInfo error for %s. status = %d",
1179  collHandle->dataObjInp.objPath, status );
1180  }
1181  /* cleanup */
1182  if ( collHandle->dataObjInp.specColl == NULL ) {
1183  clearGenQueryInp( &collHandle->genQueryInp );
1184  }
1185  /* Nothing else to do. cleanup */
1186  collHandle->state = COLL_CLOSED;
1187  }
1188  return status;
1189  }
1190  }
1191  else {
1192  if ( collHandle->state == COLL_OPENED ) {
1193  status = genDataResInColl( queryHandle, collHandle );
1194  if ( status < 0 && status != CAT_NO_ROWS_FOUND ) {
1195  savedStatus = status;
1196  }
1197 
1198  }
1199 
1200  if ( collHandle->state == COLL_DATA_OBJ_QUERIED ) {
1201  memset( &dataObjMetaInfo, 0, sizeof( dataObjMetaInfo ) );
1202  status = getNextDataObjMetaInfo( collHandle, collEnt );
1203 
1204  if ( status >= 0 ) {
1205  return status;
1206  }
1207  else {
1208  if ( status != CAT_NO_ROWS_FOUND ) {
1209  rodsLog( LOG_ERROR,
1210  "rclReadCollection: getNextDataObjMetaInfo error for %s. status = %d",
1211  collHandle->dataObjInp.objPath, status );
1212  }
1213  /* cleanup */
1214  if ( collHandle->dataObjInp.specColl == NULL ) {
1215  clearGenQueryInp( &collHandle->genQueryInp );
1216  }
1217  }
1218 
1219  status = genCollResInColl( queryHandle, collHandle );
1220  if ( status < 0 && status != CAT_NO_ROWS_FOUND ) {
1221  savedStatus = status;
1222  }
1223 
1224  }
1225 
1226  if ( collHandle->state == COLL_COLL_OBJ_QUERIED ) {
1227  memset( &collMetaInfo, 0, sizeof( collMetaInfo ) );
1228  status = getNextCollMetaInfo( collHandle, collEnt );
1229  if ( status < 0 ) {
1230  if ( status != CAT_NO_ROWS_FOUND ) {
1231  rodsLog( LOG_ERROR,
1232  "rclReadCollection: getNextCollMetaInfo error for %s. status = %d",
1233  collHandle->dataObjInp.objPath, status );
1234  }
1235  /* cleanup */
1236  if ( collHandle->dataObjInp.specColl == NULL ) {
1237  clearGenQueryInp( &collHandle->genQueryInp );
1238  }
1239  /* Nothing else to do. cleanup */
1240  collHandle->state = COLL_CLOSED;
1241  }
1242 
1243  if ( savedStatus < 0 ) {
1244  return savedStatus;
1245  }
1246  else {
1247  return status;
1248  }
1249 
1250  }
1251  }
1252  return CAT_NO_ROWS_FOUND;
1253 }
1254 
1255 
1256 int
1257 genCollResInColl( queryHandle_t *queryHandle, collHandle_t *collHandle ) {
1258  genQueryOut_t *genQueryOut = NULL;
1259  int status = 0;
1260 
1261  /* query for sub-collections */
1262  if ( collHandle->dataObjInp.specColl != NULL ) {
1263  if ( collHandle->dataObjInp.specColl->collClass == LINKED_COLL ) {
1264  memset( &collHandle->genQueryInp, 0, sizeof( genQueryInp_t ) );
1265  status = queryCollInColl( queryHandle,
1266  collHandle->linkedObjPath, collHandle->flags & ( ~RECUR_QUERY_FG ),
1267  &collHandle->genQueryInp, &genQueryOut );
1268  }
1269  else {
1270  if ( strlen( collHandle->linkedObjPath ) > 0 ) {
1271  rstrcpy( collHandle->dataObjInp.objPath,
1272  collHandle->linkedObjPath, MAX_NAME_LEN );
1273  }
1274  addKeyVal( &collHandle->dataObjInp.condInput,
1275  SEL_OBJ_TYPE_KW, "collection" );
1276  collHandle->dataObjInp.openFlags = 0; /* start over */
1277  status = ( *queryHandle->querySpecColl )(
1278  ( rcComm_t * ) queryHandle->conn, &collHandle->dataObjInp,
1279  &genQueryOut );
1280  }
1281  }
1282  else {
1283  memset( &collHandle->genQueryInp, 0, sizeof( genQueryInp_t ) );
1284  status = queryCollInColl( queryHandle,
1285  collHandle->dataObjInp.objPath, collHandle->flags,
1286  &collHandle->genQueryInp, &genQueryOut );
1287  }
1288 
1289  collHandle->rowInx = 0;
1290  collHandle->state = COLL_COLL_OBJ_QUERIED;
1291  if ( status >= 0 ) {
1292  status = genQueryOutToCollRes( &genQueryOut,
1293  &collHandle->collSqlResult );
1294  }
1295  else if ( status != CAT_NO_ROWS_FOUND ) {
1296  rodsLog( LOG_ERROR,
1297  "genCollResInColl: query collection error for %s. status = %d",
1298  collHandle->dataObjInp.objPath, status );
1299  }
1300  freeGenQueryOut( &genQueryOut );
1301  return status;
1302 }
1303 
1304 int
1305 genDataResInColl( queryHandle_t *queryHandle, collHandle_t *collHandle ) {
1306  genQueryOut_t *genQueryOut = NULL;
1307  int status = 0;
1308 
1309  if ( collHandle->dataObjInp.specColl != NULL ) {
1310  if ( collHandle->dataObjInp.specColl->collClass == LINKED_COLL ) {
1311  memset( &collHandle->genQueryInp, 0, sizeof( genQueryInp_t ) );
1312  status = queryDataObjInColl( queryHandle,
1313  collHandle->linkedObjPath, collHandle->flags & ( ~RECUR_QUERY_FG ),
1314  &collHandle->genQueryInp, &genQueryOut,
1315  &collHandle->dataObjInp.condInput );
1316  }
1317  else {
1318  if ( strlen( collHandle->linkedObjPath ) > 0 ) {
1319  rstrcpy( collHandle->dataObjInp.objPath,
1320  collHandle->linkedObjPath, MAX_NAME_LEN );
1321  }
1322  addKeyVal( &collHandle->dataObjInp.condInput,
1323  SEL_OBJ_TYPE_KW, "dataObj" );
1324  collHandle->dataObjInp.openFlags = 0; /* start over */
1325  status = ( *queryHandle->querySpecColl )
1326  ( ( rcComm_t * ) queryHandle->conn,
1327  &collHandle->dataObjInp, &genQueryOut );
1328  }
1329  }
1330  else {
1331  memset( &collHandle->genQueryInp, 0, sizeof( genQueryInp_t ) );
1332  status = queryDataObjInColl( queryHandle,
1333  collHandle->dataObjInp.objPath, collHandle->flags,
1334  &collHandle->genQueryInp, &genQueryOut,
1335  &collHandle->dataObjInp.condInput );
1336  }
1337 
1338  collHandle->rowInx = 0;
1339  collHandle->state = COLL_DATA_OBJ_QUERIED;
1340  if ( status >= 0 ) {
1341  status = genQueryOutToDataObjRes( &genQueryOut,
1342  &collHandle->dataObjSqlResult );
1343  }
1344  else if ( status != CAT_NO_ROWS_FOUND ) {
1345  rodsLog( LOG_ERROR,
1346  "genDataResInColl: query dataObj error for %s. status = %d",
1347  collHandle->dataObjInp.objPath, status );
1348  }
1349  freeGenQueryOut( &genQueryOut );
1350  return status;
1351 }
1352 
1353 int
1355  return clearCollHandle( collHandle, 1 );
1356 }
1357 
1358 int
1359 clearCollHandle( collHandle_t *collHandle, int freeSpecColl ) {
1360  if ( collHandle == NULL ) {
1361  return 0;
1362  }
1363  if ( collHandle->dataObjInp.specColl == NULL ) {
1364  clearGenQueryInp( &collHandle->genQueryInp );
1365  }
1366  if ( freeSpecColl != 0 && collHandle->dataObjInp.specColl != NULL ) {
1367  free( collHandle->dataObjInp.specColl );
1368  }
1369  if ( collHandle->rodsObjStat != NULL ) {
1370  freeRodsObjStat( collHandle->rodsObjStat );
1371  collHandle->rodsObjStat = NULL;
1372  }
1373  clearKeyVal( &collHandle->dataObjInp.condInput );
1374  memset( &collHandle->dataObjInp, 0, sizeof( dataObjInp_t ) );
1375 
1376  clearDataObjSqlResult( &collHandle->dataObjSqlResult );
1377  clearCollSqlResult( &collHandle->collSqlResult );
1378 
1379  collHandle->state = COLL_CLOSED;
1380  collHandle->rowInx = 0;
1381 
1382  return 0;
1383 }
1384 
1385 int
1386 getNextCollMetaInfo( collHandle_t *collHandle, collEnt_t *outCollEnt ) {
1387  char *value;
1388  int len;
1389  char *collType, *collInfo1, *collInfo2;
1390  int status = 0;
1391  queryHandle_t *queryHandle = &collHandle->queryHandle;
1392  dataObjInp_t *dataObjInp = &collHandle->dataObjInp;
1393  genQueryInp_t *genQueryInp = &collHandle->genQueryInp;
1394  collSqlResult_t *collSqlResult = &collHandle->collSqlResult;
1395 
1396  if ( outCollEnt == NULL ) {
1397  return USER__NULL_INPUT_ERR;
1398  }
1399 
1400  memset( outCollEnt, 0, sizeof( collEnt_t ) );
1401 
1402  outCollEnt->objType = COLL_OBJ_T;
1403  if ( collHandle->rowInx >= collSqlResult->rowCnt ) {
1404  genQueryOut_t *genQueryOut = NULL;
1405  int continueInx = collSqlResult->continueInx;
1406  clearCollSqlResult( collSqlResult );
1407 
1408  if ( continueInx > 0 ) {
1409  /* More to come */
1410 
1411  if ( dataObjInp->specColl != NULL ) {
1412  dataObjInp->openFlags = continueInx;
1413  status = ( *queryHandle->querySpecColl )(
1414  ( rcComm_t * ) queryHandle->conn, dataObjInp, &genQueryOut );
1415  }
1416  else {
1417  genQueryInp->continueInx = continueInx;
1418  status = ( *queryHandle->genQuery )(
1419  ( rcComm_t * ) queryHandle->conn, genQueryInp, &genQueryOut );
1420  }
1421  if ( status < 0 ) {
1422  collHandle->rowInx = 0;
1423  genQueryInp->continueInx = 0;
1424  collSqlResult->continueInx = 0;
1425  freeGenQueryOut( &genQueryOut );
1426  return status;
1427  }
1428  else {
1429  status = genQueryOutToCollRes( &genQueryOut, collSqlResult );
1430  if ( status < 0 ) {
1431  rodsLog( LOG_ERROR, "genQueryOutToCollRes in getNextCollMetaInfo failed with status %d", status );
1432  }
1433  collHandle->rowInx = 0;
1434  free( genQueryOut );
1435  }
1436  }
1437  else {
1438  return CAT_NO_ROWS_FOUND;
1439  }
1440  }
1441  value = collSqlResult->collName.value;
1442  len = collSqlResult->collName.len;
1443  outCollEnt->collName = &value[len * ( collHandle->rowInx )];
1444 
1445  value = collSqlResult->collOwner.value;
1446  len = collSqlResult->collOwner.len;
1447  outCollEnt->ownerName = &value[len * ( collHandle->rowInx )];
1448 
1449  value = collSqlResult->collCreateTime.value;
1450  len = collSqlResult->collCreateTime.len;
1451  outCollEnt->createTime = &value[len * ( collHandle->rowInx )];
1452 
1453  value = collSqlResult->collModifyTime.value;
1454  len = collSqlResult->collModifyTime.len;
1455  outCollEnt->modifyTime = &value[len * ( collHandle->rowInx )];
1456 
1457  value = collSqlResult->collType.value;
1458  len = collSqlResult->collType.len;
1459  collType = &value[len * ( collHandle->rowInx )];
1460 
1461  if ( *collType != '\0' ) {
1462  value = collSqlResult->collInfo1.value;
1463  len = collSqlResult->collInfo1.len;
1464  collInfo1 = &value[len * ( collHandle->rowInx )];
1465 
1466  value = collSqlResult->collInfo2.value;
1467  len = collSqlResult->collInfo2.len;
1468  collInfo2 = &value[len * ( collHandle->rowInx )];
1469 
1470  if ( strcmp( collType, INHERIT_PAR_SPEC_COLL_STR ) == 0 ) {
1471  if ( dataObjInp->specColl == NULL ) {
1472  rodsLog( LOG_ERROR,
1473  "getNextCollMetaInfo: parent specColl is NULL for %s",
1474  outCollEnt->collName );
1475  outCollEnt->specColl.collClass = NO_SPEC_COLL;
1476  }
1477  else {
1478  outCollEnt->specColl = *dataObjInp->specColl;
1479  }
1480  status = 0;
1481  }
1482  else {
1483  status = resolveSpecCollType( collType, outCollEnt->collName,
1484  collInfo1, collInfo2, &outCollEnt->specColl );
1485  }
1486  }
1487  else {
1488  outCollEnt->specColl.collClass = NO_SPEC_COLL;
1489  status = 0;
1490  }
1491  ( collHandle->rowInx ) ++;
1492  return status;
1493 }
1494 
1496  queryHandle_t* _query_handle,
1497  rodsLong_t _resc_id,
1498  char* _resc_hier ) {
1499  if( !_query_handle ) {
1500  rodsLog(
1501  LOG_ERROR,
1502  "null query_handle ptr");
1504  }
1505 
1506  if( !_resc_hier ) {
1507  rodsLog(
1508  LOG_ERROR,
1509  "null resc_hier ptr");
1511  }
1512 
1513  if( _resc_id <= 0 ) {
1514  rodsLog(
1515  LOG_ERROR,
1516  "resc_id is invalid");
1517  return SYS_INVALID_INPUT_PARAM;
1518  }
1519 
1520  get_hier_inp_t inp;
1521  inp.resc_id_ = _resc_id;
1522 
1523  get_hier_out_t* out = NULL;
1524 
1525  // due to client-server blending of query handles and
1526  // point of call. sometimes its on the server, sometimes
1527  // it is called from the client.
1528  int status = _query_handle->getHierForId(
1529  _query_handle->conn,
1530  &inp,
1531  &out );
1532  if( status < 0 ) {
1533  return status;
1534  }
1535 
1536  if(out) {
1537  rstrcpy( _resc_hier, out->hier_, MAX_NAME_LEN );
1538  }
1539  else {
1541  }
1542 
1543  return 0;
1544 } // get_resc_hier_from_leaf_id
1545 
1546 int
1547 getNextDataObjMetaInfo( collHandle_t *collHandle, collEnt_t *outCollEnt ) {
1548  int status;
1549  char *value;
1550  int len;
1551  char *replStatus, *dataId;
1552  int dataIdLen, replStatusLen;
1553  queryHandle_t *queryHandle = &collHandle->queryHandle;
1554  dataObjInp_t *dataObjInp = &collHandle->dataObjInp;
1555  genQueryInp_t *genQueryInp = &collHandle->genQueryInp;
1556  dataObjSqlResult_t *dataObjSqlResult = &collHandle->dataObjSqlResult;
1557  rodsObjStat_t *rodsObjStat = collHandle->rodsObjStat;
1558  char *prevdataId;
1559  int selectedInx = -1;
1560 
1561  if ( outCollEnt == NULL ) {
1562  return USER__NULL_INPUT_ERR;
1563  }
1564  prevdataId = collHandle->prevdataId;
1565  memset( outCollEnt, 0, sizeof( collEnt_t ) );
1566  outCollEnt->objType = DATA_OBJ_T;
1567  if ( collHandle->rowInx >= dataObjSqlResult->rowCnt ) {
1568  genQueryOut_t *genQueryOut = NULL;
1569  int continueInx = dataObjSqlResult->continueInx;
1570  clearDataObjSqlResult( dataObjSqlResult );
1571 
1572  if ( continueInx > 0 ) {
1573  /* More to come */
1574 
1575  if ( dataObjInp->specColl != NULL ) {
1576  dataObjInp->openFlags = continueInx;
1577  status = ( *queryHandle->querySpecColl )(
1578  ( rcComm_t * ) queryHandle->conn, dataObjInp, &genQueryOut );
1579  }
1580  else {
1581  genQueryInp->continueInx = continueInx;
1582  status = ( *queryHandle->genQuery )(
1583  ( rcComm_t * ) queryHandle->conn, genQueryInp, &genQueryOut );
1584  }
1585  if ( status < 0 ) {
1586  collHandle->rowInx = 0;
1587  genQueryInp->continueInx = 0;
1588  dataObjSqlResult->continueInx = 0;
1589  freeGenQueryOut( &genQueryOut );
1590  return status;
1591  }
1592  else {
1593  status = genQueryOutToDataObjRes( &genQueryOut,
1594  dataObjSqlResult );
1595  if ( status < 0 ) {
1596  rodsLogError( LOG_ERROR, status, "genQueryOut failed in %s.", __PRETTY_FUNCTION__ );
1597  }
1598  collHandle->rowInx = 0;
1599  free( genQueryOut );
1600  }
1601  }
1602  else {
1603  return CAT_NO_ROWS_FOUND;
1604  }
1605  }
1606 
1607  dataId = dataObjSqlResult->dataId.value;
1608  dataIdLen = dataObjSqlResult->dataId.len;
1609  replStatus = dataObjSqlResult->replStatus.value;
1610  replStatusLen = dataObjSqlResult->replStatus.len;
1611 
1612  if ( strlen( dataId ) > 0 && ( collHandle->flags & NO_TRIM_REPL_FG ) == 0 ) {
1613  int i;
1614  int gotCopy = 0;
1615 
1616  /* rsync type query ask for dataId. Others don't. Need to
1617  * screen out dup copies */
1618 
1619  for ( i = collHandle->rowInx; i < dataObjSqlResult->rowCnt; i++ ) {
1620  if ( selectedInx < 0 ) {
1621  /* nothing selected yet. pick this if different */
1622  if ( strcmp( prevdataId, &dataId[dataIdLen * i] ) != 0 ) {
1623  rstrcpy( prevdataId, &dataId[dataIdLen * i], NAME_LEN );
1624  selectedInx = i;
1625  if ( atoi( &dataId[dataIdLen * i] ) != 0 ) {
1626  gotCopy = 1;
1627  }
1628  }
1629  }
1630  else {
1631  /* skip i to the next object */
1632  if ( strcmp( prevdataId, &dataId[dataIdLen * i] ) != 0 ) {
1633  break;
1634  }
1635  if ( gotCopy == 0 &&
1636  atoi( &replStatus[replStatusLen * i] ) > 0 ) {
1637  /* pick a good copy */
1638  selectedInx = i;
1639  gotCopy = 1;
1640  }
1641  }
1642  }
1643  if ( selectedInx < 0 ) {
1644  return CAT_NO_ROWS_FOUND;
1645  }
1646 
1647  collHandle->rowInx = i;
1648  }
1649  else {
1650  selectedInx = collHandle->rowInx;
1651  collHandle->rowInx++;
1652  }
1653 
1654  value = dataObjSqlResult->collName.value;
1655  len = dataObjSqlResult->collName.len;
1656  outCollEnt->collName = &value[len * selectedInx];
1657 
1658  value = dataObjSqlResult->dataName.value;
1659  len = dataObjSqlResult->dataName.len;
1660  outCollEnt->dataName = &value[len * selectedInx];
1661 
1662  value = dataObjSqlResult->dataMode.value;
1663  len = dataObjSqlResult->dataMode.len;
1664  outCollEnt->dataMode = atoi( &value[len * selectedInx] );
1665 
1666  value = dataObjSqlResult->dataSize.value;
1667  len = dataObjSqlResult->dataSize.len;
1668  outCollEnt->dataSize = strtoll( &value[len * selectedInx], 0, 0 );
1669 
1670  value = dataObjSqlResult->createTime.value;
1671  len = dataObjSqlResult->createTime.len;
1672  outCollEnt->createTime = &value[len * selectedInx];
1673 
1674  value = dataObjSqlResult->modifyTime.value;
1675  len = dataObjSqlResult->modifyTime.len;
1676  outCollEnt->modifyTime = &value[len * selectedInx];
1677 
1678  outCollEnt->dataId = &dataId[dataIdLen * selectedInx];
1679 
1680  outCollEnt->replStatus = atoi( &replStatus[replStatusLen *
1681  selectedInx] );
1682 
1683  value = dataObjSqlResult->replNum.value;
1684  len = dataObjSqlResult->replNum.len;
1685  outCollEnt->replNum = atoi( &value[len * selectedInx] );
1686 
1687  value = dataObjSqlResult->chksum.value;
1688  len = dataObjSqlResult->chksum.len;
1689  outCollEnt->chksum = &value[len * selectedInx];
1690 
1691  value = dataObjSqlResult->dataType.value;
1692  len = dataObjSqlResult->dataType.len;
1693  outCollEnt->dataType = &value[len * selectedInx];
1694 
1695  if ( rodsObjStat->specColl != NULL ) {
1696  outCollEnt->specColl = *rodsObjStat->specColl;
1697  }
1698  if ( rodsObjStat->specColl != NULL &&
1700  outCollEnt->resource = rodsObjStat->specColl->resource;
1701  outCollEnt->ownerName = rodsObjStat->ownerName;
1702  outCollEnt->replStatus = NEWLY_CREATED_COPY;
1703  outCollEnt->resc_hier = rodsObjStat->specColl->rescHier;
1704  }
1705  else {
1706  value = dataObjSqlResult->resource.value;
1707  len = dataObjSqlResult->resource.len;
1708  outCollEnt->resource = &value[len * selectedInx];
1709 
1710  value = dataObjSqlResult->resc_hier.value;
1711  len = dataObjSqlResult->resc_hier.len;
1712  outCollEnt->resc_hier = &value[len * selectedInx];
1713 
1714  value = dataObjSqlResult->ownerName.value;
1715  len = dataObjSqlResult->ownerName.len;
1716  outCollEnt->ownerName = &value[len * selectedInx];
1717  }
1718 
1719  value = dataObjSqlResult->phyPath.value;
1720  len = dataObjSqlResult->phyPath.len;
1721  outCollEnt->phyPath = &value[len * selectedInx];
1722 
1723  return 0;
1724 }
1725 
1726 int
1728  int queryFlags;
1729 
1730  if ( rodsArgs->veryLongOption == True ) {
1731  queryFlags = VERY_LONG_METADATA_FG;
1732  }
1733  else if ( rodsArgs->longOption == True ) {
1734  queryFlags = LONG_METADATA_FG;
1735  }
1736  else {
1737  queryFlags = 0;
1738  }
1739 
1740  return queryFlags;
1741 }
1742 
1743 int
1745  if ( queryHandle == NULL || conn == NULL ) {
1746  return USER__NULL_INPUT_ERR;
1747  }
1748 
1749  queryHandle->conn = conn;
1750  queryHandle->connType = RC_COMM;
1751  queryHandle->querySpecColl = ( funcPtr ) rcQuerySpecColl;
1752  queryHandle->genQuery = ( funcPtr ) rcGenQuery;
1753  queryHandle->getHierForId = ( funcPtr ) rcGetHierFromLeafId;
1754 
1755  return 0;
1756 }
1757 
1758 int
1759 freeCollEnt( collEnt_t *collEnt ) {
1760  if ( collEnt == NULL ) {
1761  return 0;
1762  }
1763 
1764  clearCollEnt( collEnt );
1765 
1766  free( collEnt );
1767 
1768  return 0;
1769 }
1770 
1771 int
1773  if ( collEnt == NULL ) {
1774  return 0;
1775  }
1776 
1777  if ( collEnt->collName != NULL ) {
1778  free( collEnt->collName );
1779  }
1780  if ( collEnt->dataName != NULL ) {
1781  free( collEnt->dataName );
1782  }
1783  if ( collEnt->dataId != NULL ) {
1784  free( collEnt->dataId );
1785  }
1786  if ( collEnt->createTime != NULL ) {
1787  free( collEnt->createTime );
1788  }
1789  if ( collEnt->modifyTime != NULL ) {
1790  free( collEnt->modifyTime );
1791  }
1792  if ( collEnt->chksum != NULL ) {
1793  free( collEnt->chksum );
1794  }
1795  if ( collEnt->resource != NULL ) {
1796  free( collEnt->resource );
1797  }
1798  if ( collEnt->resc_hier != NULL ) {
1799  free( collEnt->resc_hier );
1800  }
1801  if ( collEnt->phyPath != NULL ) {
1802  free( collEnt->phyPath );
1803  }
1804  if ( collEnt->ownerName != NULL ) {
1805  free( collEnt->ownerName );
1806  }
1807  if ( collEnt->dataType != NULL ) {
1808  free( collEnt->dataType );
1809  }
1810  return 0;
1811 }
1812 
1813 
1814 int
1815 myChmod( char *inPath, uint dataMode ) {
1816  if ( dataMode < 0100 ) {
1817  return 0;
1818  }
1819 
1820  if ( Myumask == INIT_UMASK_VAL ) {
1821  Myumask = umask( 0022 );
1822  umask( Myumask );
1823  }
1824 
1825  int error_code = chmod( inPath, dataMode & 0777 & ~( Myumask ) );
1826  int errsav = errno;
1827  if ( error_code != 0 ) {
1828  rodsLog( LOG_ERROR, "chmod failed for [%s] in myChmod with error code [%s]", inPath, strerror( errsav ) );
1829  }
1830 
1831  return 0;
1832 }
1833 
1834 char *
1836  char *zoneHint;
1837  int i;
1838 
1839  if ( genQueryInp == NULL ) {
1840  return NULL;
1841  }
1842 
1843  if ( ( zoneHint = getValByKey( &genQueryInp->condInput, ZONE_KW ) ) != NULL ) {
1844  return zoneHint;
1845  }
1846 
1847  for ( i = 0; i < genQueryInp->sqlCondInp.len; i++ ) {
1848  int inx = genQueryInp->sqlCondInp.inx[i];
1849  if ( inx == COL_COLL_NAME ||
1850  inx == COL_COLL_PARENT_NAME ||
1851  inx == COL_ZONE_NAME ) {
1852  char *tmpPtr;
1853  zoneHint = genQueryInp->sqlCondInp.value[i];
1854  if (strcmp(zoneHint, NON_ROOT_COLL_CHECK_STR)) {
1855  if ( ( tmpPtr = strchr( zoneHint, '/' ) ) != NULL ) {
1856  zoneHint = tmpPtr;
1857  }
1858  return zoneHint;
1859  }
1860  }
1861  }
1862  return NULL;
1863 }
1864 
1865 /* getZoneType - get the ZoneType of inZoneName. icatZone is the icat
1866  * to query.
1867  */
1868 int
1869 getZoneType( rcComm_t *conn, char *icatZone, char *inZoneName,
1870  char *outZoneType ) {
1871  genQueryInp_t genQueryInp;
1872  genQueryOut_t *genQueryOut = NULL;
1873  int status;
1874  sqlResult_t *zoneType;
1875  char tmpStr[MAX_NAME_LEN];
1876 
1877  if ( inZoneName == NULL || outZoneType == NULL ) {
1878  return USER__NULL_INPUT_ERR;
1879  }
1880 
1881  memset( &genQueryInp, 0, sizeof( genQueryInp ) );
1882  if ( icatZone != NULL && strlen( icatZone ) > 0 ) {
1883  addKeyVal( &genQueryInp.condInput, ZONE_KW, icatZone );
1884  }
1885  addInxIval( &genQueryInp.selectInp, COL_ZONE_NAME, 1 );
1886  addInxIval( &genQueryInp.selectInp, COL_ZONE_TYPE, 1 );
1887 
1888  snprintf( tmpStr, MAX_NAME_LEN, " = '%s'", inZoneName );
1889 
1890  addInxVal( &genQueryInp.sqlCondInp, COL_ZONE_NAME, tmpStr );
1891 
1892  genQueryInp.maxRows = MAX_SQL_ROWS;
1893 
1894  status = rcGenQuery( conn, &genQueryInp, &genQueryOut );
1895 
1896  if ( status < 0 ) {
1897  return status;
1898  }
1899 
1900  if ( ( zoneType = getSqlResultByInx( genQueryOut, COL_ZONE_TYPE ) ) == NULL ) {
1902  "getZoneInfo: getSqlResultByInx for COL_ZONE_TYPE failed" );
1903  return UNMATCHED_KEY_OR_INDEX;
1904  }
1905 
1906  rstrcpy( outZoneType, zoneType->value, MAX_NAME_LEN );
1907 
1908  freeGenQueryOut( &genQueryOut );
1909 
1910  return 0;
1911 }
1912 
1913 /* getCollSizeForProgStat - Calculate the totalNumFiles and totalFileSize and
1914  * put it in the operProgress struct.
1915  * Note that operProgress->totalNumFiles and operProgress->totalFileSize
1916  * needs to be initialized since it can be a recursive operation and
1917  * cannot be initialized in this routine.
1918  */
1919 int
1920 getCollSizeForProgStat( rcComm_t *conn, char *srcColl,
1921  operProgress_t *operProgress ) {
1922  int status = 0;
1923  collHandle_t collHandle;
1924  collEnt_t collEnt;
1925 
1926  status = rclOpenCollection( conn, srcColl, RECUR_QUERY_FG,
1927  &collHandle );
1928 
1929  if ( status < 0 ) {
1930  rodsLog( LOG_ERROR,
1931  "getCollSizeForProgStat: rclOpenCollection of %s error. status = %d",
1932  srcColl, status );
1933  return status;
1934  }
1935 
1936  while ( ( status = rclReadCollection( conn, &collHandle, &collEnt ) ) >= 0 ) {
1937  if ( collEnt.objType == DATA_OBJ_T ) {
1938  operProgress->totalNumFiles++;
1939  operProgress->totalFileSize += collEnt.dataSize;
1940  }
1941  else if ( collEnt.objType == COLL_OBJ_T ) {
1942  if ( collEnt.specColl.collClass != NO_SPEC_COLL ) {
1943  /* the child is a spec coll. need to drill down */
1944  status = getCollSizeForProgStat( conn, collEnt.collName,
1945  operProgress );
1946  if ( status < 0 && status != CAT_NO_ROWS_FOUND ) {
1947  return status;
1948  }
1949  }
1950  }
1951  }
1952  if ( status == CAT_NO_ROWS_FOUND ) {
1953  return 0;
1954  }
1955  else {
1956  return status;
1957  }
1958 }
1959 
1960 /* getDirSizeForProgStat - Calculate the totalNumFiles and totalFileSize and
1961  * put it in the operProgress struct.
1962  * Note that operProgress->totalNumFiles and operProgress->totalFileSize
1963  * needs to be initialized since it can be a recursive operation and
1964  * cannot be initialized in this routine.
1965  */
1966 int
1967 getDirSizeForProgStat( rodsArguments_t *rodsArgs, char *srcDir,
1968  operProgress_t *operProgress ) {
1969  using namespace boost::filesystem;
1970  int status = 0;
1971  char srcChildPath[MAX_NAME_LEN];
1972 
1973  try {
1974  if ( ! irods::is_path_valid_for_recursion(rodsArgs, srcDir) )
1975  {
1976  return 0;
1977  }
1978  } catch ( const irods::exception& _e ) {
1980  return USER_INPUT_PATH_ERR;
1981  }
1982 
1983  path srcDirPath( srcDir );
1984  if ( !exists( srcDirPath ) || !is_directory( srcDirPath ) ) {
1985  rodsLog( LOG_ERROR,
1986  "getDirSizeForProgStat: opendir local dir error for %s, errno = %d\n",
1987  srcDir, errno );
1988  return USER_INPUT_PATH_ERR;
1989  }
1990 
1991  directory_iterator end_itr; // default construction yields past-the-end
1992  for ( directory_iterator itr( srcDirPath ); itr != end_itr; ++itr ) {
1993  path p = itr->path();
1994  snprintf( srcChildPath, MAX_NAME_LEN, "%s", p.c_str() );
1995 
1996  try {
1997  if ( ! irods::is_path_valid_for_recursion(rodsArgs, srcChildPath) )
1998  {
1999  return 0;
2000  } // JMC cppcheck - resource
2001  } catch ( const irods::exception& _e ) {
2003  return USER_INPUT_PATH_ERR;
2004  }
2005 
2006  if ( !exists( p ) ) {
2007  rodsLog( LOG_ERROR,
2008  "getDirSizeForProgStat: stat error for %s, errno = %d\n",
2009  srcChildPath, errno );
2010  return USER_INPUT_PATH_ERR;
2011  }
2012  else if ( is_regular_file( p ) ) {
2013  operProgress->totalNumFiles++;
2014  operProgress->totalFileSize += file_size( p );
2015  }
2016  else if ( is_directory( p ) ) {
2017  status = getDirSizeForProgStat( rodsArgs, srcChildPath,
2018  operProgress );
2019  if ( status < 0 ) {
2020  return status;
2021  }
2022 
2023  }
2024  }
2025 
2026  return status;
2027 }
2028 
2029 /* iCommandProgStat - the guiProgressCallback for icommand
2030  */
2033  using namespace boost::filesystem;
2034  char myDir[MAX_NAME_LEN], myFile[MAX_NAME_LEN];
2035  int status;
2036  time_t myTime;
2037  struct tm *mytm;
2038  char timeStr[TIME_LEN];
2039 
2040  if ( strchr( operProgress->curFileName, '/' ) == NULL ) {
2041  /* relative path */
2042  rstrcpy( myFile, operProgress->curFileName, MAX_NAME_LEN );
2043  }
2044  else if ( ( status = splitPathByKey( operProgress->curFileName,
2045  myDir, MAX_NAME_LEN, myFile, MAX_NAME_LEN, '/' ) ) < 0 ) {
2047  "iCommandProgStat: splitPathByKey for %s error, status = %d",
2048  operProgress->curFileName, status );
2049  return NULL;
2050  }
2051 
2052  myTime = time( 0 );
2053  mytm = localtime( &myTime );
2054  getLocalTimeStr( mytm, timeStr );
2055  if ( operProgress->flag == 0 ) {
2056  printf(
2057  "%-lld/%-lld - %5.2f%% of files done ",
2058  operProgress->totalNumFilesDone, operProgress->totalNumFiles,
2059  VERIFY_DIV
2060  ( operProgress->totalNumFilesDone, operProgress->totalNumFiles ) *
2061  100.0 );
2062  printf( "%-.3f/%-.3f MB - %5.2f%% of file sizes done\n",
2063  ( float ) operProgress->totalFileSizeDone / 1048576.0,
2064  ( float ) operProgress->totalFileSize / 1048576.0,
2065  VERIFY_DIV
2066  ( operProgress->totalFileSizeDone, operProgress->totalFileSize ) *
2067  100.0 );
2068  printf( "Processing %s - %-.3f MB %s\n", myFile,
2069  ( float ) operProgress->curFileSize / 1048576.0, timeStr );
2070  }
2071  else if ( operProgress->flag == 1 ) {
2072  printf( "%s - %-.3f/%-.3f MB - %5.2f%% done %s\n", myFile,
2073  ( float ) operProgress->curFileSizeDone / 1048576.0,
2074  ( float ) operProgress->curFileSize / 1048576.0,
2075  VERIFY_DIV
2076  ( operProgress->curFileSizeDone, operProgress->curFileSize ) *
2077  100.0, timeStr );
2078  /* done. don't print again */
2079  if ( operProgress->curFileSizeDone == operProgress->curFileSize ) {
2080  operProgress->flag = 2;
2081  }
2082  }
2083  return NULL;
2084 }
2085 
2086 int
2088  int len;
2089 
2090  if ( collHandle->rodsObjStat->specColl != NULL &&
2091  ( len = strlen( collHandle->linkedObjPath ) ) > 0 ) {
2092  }
2093  else {
2094  len = strlen( collHandle->dataObjInp.objPath );
2095  }
2096  return len;
2097 }
2098 
2099 int
2100 rmSubDir( char *mydir ) {
2101  using namespace boost::filesystem;
2102  int status = 0;
2103  int savedStatus = 0;
2104  char childPath[MAX_NAME_LEN];
2105 
2106  path srcDirPath( mydir );
2107  if ( !exists( srcDirPath ) || !is_directory( srcDirPath ) ) {
2108  status = USER_INPUT_PATH_ERR - errno;
2110  "rmSubDir: opendir local dir error for %s", mydir );
2111  return status;
2112  }
2113  directory_iterator end_itr; // default construction yields past-the-end
2114  for ( directory_iterator itr( srcDirPath ); itr != end_itr; ++itr ) {
2115  path p = itr->path();
2116  snprintf( childPath, MAX_NAME_LEN, "%s",
2117  p.c_str() );
2118  if ( !exists( p ) ) {
2119  savedStatus = USER_INPUT_PATH_ERR - errno;
2120  rodsLogError( LOG_ERROR, savedStatus,
2121  "rmSubDir: stat error for %s", childPath );
2122  continue;
2123  }
2124  if ( is_directory( p ) ) {
2125  status = rmSubDir( childPath );
2126  if ( status < 0 ) {
2127  savedStatus = USER_INPUT_PATH_ERR - errno;
2129  "rmSubDir: rmSubDir error for %s ", childPath );
2130  }
2131  if ( rmdir( childPath ) != 0 ) {
2132  savedStatus = USER_INPUT_PATH_ERR - errno;
2134  "rmSubDir: rmdir error for %s ", childPath );
2135  }
2136  continue;
2137  }
2138  else {
2139  savedStatus = USER_INPUT_PATH_ERR - errno;
2141  "rmSubDir: %s is not a dir", childPath );
2142  continue;
2143  }
2144  }
2145  return savedStatus;
2146 }
2147 
2148 int
2149 rmFilesInDir( char *mydir ) {
2150  using namespace boost::filesystem;
2151  int status = 0;
2152  int savedStatus = 0;
2153  char childPath[MAX_NAME_LEN];
2154 
2155  path srcDirPath( mydir );
2156  if ( !exists( srcDirPath ) || !is_directory( srcDirPath ) ) {
2157  status = USER_INPUT_PATH_ERR - errno;
2159  "rmFilesInDir: opendir local dir error for %s", mydir );
2160  return status;
2161  }
2162  directory_iterator end_itr; // default construction yields past-the-end
2163  for ( directory_iterator itr( srcDirPath ); itr != end_itr; ++itr ) {
2164  path p = itr->path();
2165  snprintf( childPath, MAX_NAME_LEN, "%s",
2166  p.c_str() );
2167  if ( !exists( p ) ) {
2168  savedStatus = USER_INPUT_PATH_ERR - errno;
2169  rodsLogError( LOG_ERROR, savedStatus,
2170  "rmFilesInDir: stat error for %s", childPath );
2171  continue;
2172  }
2173  if ( is_regular_file( p ) ) {
2174  unlink( childPath );
2175  }
2176  else {
2177  continue;
2178  }
2179  }
2180  return savedStatus;
2181 }
2182 int
2183 getNumFilesInDir( const char *mydir ) {
2184  using namespace boost::filesystem;
2185  int status = 0;
2186  int savedStatus = 0;
2187  char childPath[MAX_NAME_LEN];
2188  int count = 0;
2189 
2190  path srcDirPath( mydir );
2191  if ( !exists( srcDirPath ) || !is_directory( srcDirPath ) ) {
2192  status = USER_INPUT_PATH_ERR - errno;
2194  "getNumFilesInDir: opendir local dir error for %s", mydir );
2195  return status;
2196  }
2197  directory_iterator end_itr; // default construction yields past-the-end
2198  for ( directory_iterator itr( srcDirPath ); itr != end_itr; ++itr ) {
2199  path p = itr->path();
2200  snprintf( childPath, MAX_NAME_LEN, "%s",
2201  p.c_str() );
2202  if ( !exists( p ) ) {
2203  savedStatus = USER_INPUT_PATH_ERR - errno;
2204  rodsLogError( LOG_ERROR, savedStatus,
2205  "getNumFilesInDir: stat error for %s", childPath );
2206  continue;
2207  }
2208  if ( is_regular_file( p ) ) {
2209  count++;
2210  }
2211  else {
2212  continue;
2213  }
2214 
2215  }
2216  return count;
2217 }
2218 
2220 readPathnamePatterns( char *buf, int buflen ) {
2221  if ( buf == NULL || buflen <= 0 ) {
2222  return NULL;
2223  }
2224 
2225  /* Allocate and initialize the return structure */
2226  pathnamePatterns_t *pp = ( pathnamePatterns_t* )malloc( sizeof( pathnamePatterns_t ) );
2227  if ( pp == NULL ) {
2228  rodsLog( LOG_NOTICE, "readPathnamePatterns: could not allocate pp struct" );
2229  return NULL;
2230  }
2231 
2232  /* copy the passed in buffer since we'll be
2233  manipulating it */
2234  pp->pattern_buf = ( char* )malloc( buflen + 1 );
2235  if ( pp->pattern_buf == NULL ) {
2236  rodsLog( LOG_NOTICE, "readPathnamePatterns: could not allocate pattern buffer" );
2237  free(pp);
2238  return NULL;
2239  }
2240  memcpy( pp->pattern_buf, buf, buflen );
2241  pp->pattern_buf[buflen] = '\n';
2242 
2243  /* Get the addresses of the patterns in the buffer.
2244  They'll be delimited by newlines. */
2245  std::vector<char *> patterns_vector;
2246  bool beginning_of_line = true;
2247  for ( int i = 0; i < buflen; i++ ) {
2248  if ( pp->pattern_buf[i] == '\n' ) {
2249  pp->pattern_buf[i] = '\0';
2250  beginning_of_line = true;
2251  }
2252  else if (beginning_of_line) {
2253  beginning_of_line = false;
2254  if ( pp->pattern_buf[i] != '#' ) {
2255  patterns_vector.push_back(pp->pattern_buf + i);
2256  }
2257  }
2258  }
2259  pp->num_patterns = patterns_vector.size();
2260 
2261  /* now allocate a string array for the patterns, and
2262  make each array element point to a pattern string
2263  in place in the buffer */
2264  if (pp->num_patterns > 0) {
2265  pp->patterns = ( char** )malloc( sizeof( char* ) * pp->num_patterns );
2266  if ( pp->patterns == NULL ) {
2267  rodsLog( LOG_NOTICE, "readPathnamePatterns: could not allocate pattern array" );
2268  free(pp->pattern_buf);
2269  free(pp);
2270  return NULL;
2271  }
2272  memcpy(pp->patterns, &patterns_vector[0], pp->num_patterns * sizeof(char*));
2273  }
2274  else {
2275  pp->patterns = NULL;
2276  }
2277 
2278  return pp;
2279 }
2280 
2281 void
2283  if ( pp == NULL ) {
2284  return;
2285  }
2286 
2287  if ( pp->patterns ) {
2288  free( pp->patterns );
2289  }
2290  if ( pp->pattern_buf ) {
2291  free( pp->pattern_buf );
2292  }
2293  free( pp );
2294 }
2295 
2296 int
2297 matchPathname( pathnamePatterns_t *pp, char *name, char *dirname ) {
2298  int index;
2299  char pathname[MAX_NAME_LEN];
2300  char *pattern;
2301 
2302  if ( pp == NULL || name == NULL || dirname == NULL ) {
2303  return 0;
2304  }
2305 
2306  /* If the pattern starts with '/', try to match the full path.
2307  Otherwise, just match name. */
2308  for ( index = 0; index < pp->num_patterns; index++ ) {
2309  pattern = pp->patterns[index];
2310  if ( *pattern == '/' ) {
2311  /* a directory pattern */
2312  snprintf( pathname, MAX_NAME_LEN, "%s/%s", dirname, name );
2313  if ( fnmatch( pattern, pathname, FNM_PATHNAME ) == 0 ) {
2314  rodsLog( LOG_DEBUG, "matchPathname: match name %s with pattern %s",
2315  pathname, pattern );
2316  /* we have a match */
2317  return 1;
2318  }
2319  }
2320  else {
2321  if ( fnmatch( pattern, name, 0 ) == 0 ) {
2322  rodsLog( LOG_DEBUG, "matchPathname: match name %s with pattern %s",
2323  name, pattern );
2324  /* we have a match */
2325  return 1;
2326  }
2327  }
2328  }
2329 
2330  return 0;
2331 }
2332 
2333 /* resolveRodsTarget - based on srcPath and destPath, fill in targPath.
2334  * oprType -
2335  * MOVE_OPR - do not create the target coll or dir because rename will
2336  * take care of it.
2337  * RSYNC_OPR - uses the destPath and the targPath if the src is a
2338  * collection
2339  * All other oprType will be treated as normal.
2340  */
2341 int
2342 resolveRodsTarget( rcComm_t *conn, rodsPathInp_t *rodsPathInp, int oprType ) {
2343  rodsPath_t *srcPath, *destPath;
2344  char srcElement[MAX_NAME_LEN], destElement[MAX_NAME_LEN];
2345  int status;
2346  int srcInx;
2347  rodsPath_t *targPath;
2348 
2349  if ( rodsPathInp == NULL ) {
2350  rodsLog( LOG_ERROR,
2351  "resolveRodsTarget: NULL rodsPathInp input" );
2352  return USER__NULL_INPUT_ERR;
2353  }
2354 
2355  if ( rodsPathInp->srcPath == NULL ) {
2356  rodsLog( LOG_ERROR,
2357  "resolveRodsTarget: NULL rodsPathInp->srcPath input" );
2358  return USER__NULL_INPUT_ERR;
2359  }
2360 
2361  if ( rodsPathInp->destPath == NULL ) {
2362  rodsLog( LOG_ERROR,
2363  "resolveRodsTarget: NULL rodsPathInp->destPath input" );
2364  return USER__NULL_INPUT_ERR;
2365  }
2366 
2367  destPath = rodsPathInp->destPath;
2368  if ( destPath->objState == UNKNOWN_ST ) {
2369  getRodsObjType( conn, destPath );
2370  }
2371 
2372  for ( srcInx = 0; srcInx < rodsPathInp->numSrc; srcInx++ ) {
2373  srcPath = &rodsPathInp->srcPath[srcInx];
2374  targPath = &rodsPathInp->targPath[srcInx];
2375 
2376  /* we don't do wild card yet */
2377 
2378  if ( srcPath->objState == UNKNOWN_ST ) {
2379  getRodsObjType( conn, srcPath );
2380  if ( srcPath->objState == NOT_EXIST_ST ) {
2381  rodsLog( LOG_ERROR,
2382  "resolveRodsTarget: srcPath %s does not exist",
2383  srcPath->outPath );
2384  return USER_INPUT_PATH_ERR;
2385  }
2386  }
2387 
2388  if ( destPath->objType >= UNKNOWN_FILE_T &&
2389  strcmp( destPath->outPath, STDOUT_FILE_NAME ) == 0 ) {
2390  /* pipe to stdout */
2391  if ( srcPath->objType != DATA_OBJ_T ) {
2392  rodsLog( LOG_ERROR,
2393  "resolveRodsTarget: src %s is the wrong type for dest -",
2394  srcPath->outPath );
2395  return USER_INPUT_PATH_ERR;
2396  }
2397  *targPath = *destPath;
2398  targPath->objType = LOCAL_FILE_T;
2399  }
2400  else if ( srcPath->objType == DATA_OBJ_T ||
2401  srcPath->objType == LOCAL_FILE_T ) {
2402  /* file type source */
2403 
2404  if ( ( destPath->objType == COLL_OBJ_T ||
2405  destPath->objType == LOCAL_DIR_T ) &&
2406  destPath->objState == EXIST_ST ) {
2407  if ( destPath->objType <= COLL_OBJ_T ) {
2408  targPath->objType = DATA_OBJ_T;
2409  }
2410  else {
2411  targPath->objType = LOCAL_FILE_T;
2412  }
2413 
2414  /* collection */
2415  getLastPathElement( srcPath->inPath, srcElement );
2416  if ( strlen( srcElement ) > 0 ) {
2417  snprintf( targPath->outPath, MAX_NAME_LEN, "%s/%s",
2418  destPath->outPath, srcElement );
2419  if ( destPath->objType <= COLL_OBJ_T ) {
2420  getRodsObjType( conn, destPath );
2421  }
2422  }
2423  else {
2424  rstrcpy( targPath->outPath, destPath->outPath,
2425  MAX_NAME_LEN );
2426  }
2427  }
2428  else if ( destPath->objType == DATA_OBJ_T ||
2429  destPath->objType == LOCAL_FILE_T || rodsPathInp->numSrc == 1 ) {
2430  *targPath = *destPath;
2431  if ( destPath->objType <= COLL_OBJ_T ) {
2432  targPath->objType = DATA_OBJ_T;
2433  }
2434  else {
2435  targPath->objType = LOCAL_FILE_T;
2436  }
2437  }
2438  else {
2440  "resolveRodsTarget: target %s does not exist",
2441  destPath->outPath );
2442  return USER_FILE_DOES_NOT_EXIST;
2443  }
2444  }
2445  else if ( srcPath->objType == COLL_OBJ_T ||
2446  srcPath->objType == LOCAL_DIR_T ) {
2447  /* directory type source */
2448 
2449  if ( destPath->objType <= COLL_OBJ_T ) {
2450  targPath->objType = COLL_OBJ_T;
2451  }
2452  else {
2453  targPath->objType = LOCAL_DIR_T;
2454  }
2455 
2456  if ( destPath->objType == DATA_OBJ_T ||
2457  destPath->objType == LOCAL_FILE_T ) {
2458  rodsLog( LOG_ERROR,
2459  "resolveRodsTarget: input destPath %s is a datapath",
2460  destPath->outPath );
2461  return USER_INPUT_PATH_ERR;
2462  }
2463  else
2464  {
2465  // Issue 3997: First, find out if the destination is a
2466  // non-existent collection, and create it if necessary.
2467  if (destPath->objState != EXIST_ST && destPath->objType <= COLL_OBJ_T &&
2468  oprType != MOVE_OPR && rodsPathInp->numSrc != 1)
2469  {
2470  // mkColl changes the values in destPath, so repopulate the structure
2471  status = mkColl( conn, destPath->outPath );
2472  if ( status < 0 ) {
2473  rodsLog( LOG_ERROR,
2474  "resolveRodsTarget: Could not create collection %s", destPath->outPath );
2475  return status;
2476  }
2477  getRodsObjType( conn, destPath );
2478  }
2479  if ( ( destPath->objType == COLL_OBJ_T ||
2480  destPath->objType == LOCAL_DIR_T ) &&
2481  destPath->objState == EXIST_ST ) {
2482  /* the collection exist */
2483  getLastPathElement( srcPath->inPath, srcElement );
2484  if ( strlen( srcElement ) > 0 ) {
2485  if ( rodsPathInp->numSrc == 1 && oprType == RSYNC_OPR ) {
2486  getLastPathElement( destPath->inPath, destElement );
2487  /* RSYNC_OPR. Just use the same path */
2488  if ( strlen( destElement ) > 0 ) {
2489  rstrcpy( targPath->outPath, destPath->outPath,
2490  MAX_NAME_LEN );
2491  }
2492  }
2493  if ( targPath->outPath[0] == '\0' ) {
2494  snprintf( targPath->outPath, MAX_NAME_LEN, "%s/%s",
2495  destPath->outPath, srcElement );
2496  /* make the collection */
2497  if ( destPath->objType == COLL_OBJ_T ) {
2498 
2499  /* rename does not need to mkColl */
2500  if ( oprType != MOVE_OPR ) {
2501  // destPath is a collection
2502 
2503  // Issue 4057: When destPath is a collection (and we already know it
2504  // exists in this block), make sure targPath is made if it is a collection.
2505  if (targPath->objType == COLL_OBJ_T)
2506  {
2507  if ((status = mkColl( conn, targPath->outPath )) == 0)
2508  {
2509  targPath->objState = EXIST_ST;
2510  }
2511  }
2512  }
2513  else {
2514  status = 0;
2515  }
2516  }
2517  else {
2518  #ifdef windows_platform
2519  status = iRODSNt_mkdir( targPath->outPath, 0750 );
2520  #else
2521  status = mkdir( targPath->outPath, 0750 );
2522  #endif
2523  if ( status < 0 && errno == EEXIST ) {
2524  status = 0;
2525  }
2526  }
2527  if ( status < 0 ) {
2529  "resolveRodsTarget: mkColl/mkdir for %s,status=%d",
2530  targPath->outPath, status );
2531  return status;
2532  }
2533  }
2534  }
2535  else {
2536  rstrcpy( targPath->outPath, destPath->outPath,
2537  MAX_NAME_LEN );
2538  }
2539  }
2540  else {
2541  /* dest coll does not exist */
2542  if ( destPath->objType <= COLL_OBJ_T ) {
2543  if ( oprType != MOVE_OPR ) {
2544  /* rename does not need to mkColl */
2545  status = mkColl( conn, destPath->outPath );
2546  }
2547  else {
2548  status = 0;
2549  }
2550  }
2551  else {
2552  /* use destPath. targPath->outPath not defined.
2553  * status = mkdir (targPath->outPath, 0750); */
2554  #ifdef windows_platform
2555  status = iRODSNt_mkdir( destPath->outPath, 0750 );
2556  #else
2557  status = mkdir( destPath->outPath, 0750 );
2558  #endif
2559  }
2560  if ( status < 0 ) {
2561  return status;
2562  }
2563  if ( rodsPathInp->numSrc == 1 ) {
2564  rstrcpy( targPath->outPath, destPath->outPath,
2565  MAX_NAME_LEN );
2566  }
2567  else {
2569  "resolveRodsTarget: target %s does not exist",
2570  destPath->outPath );
2571  return USER_FILE_DOES_NOT_EXIST;
2572  }
2573  }
2574  targPath->objState = EXIST_ST;
2575  }
2576  }
2577  else { /* should not be here */
2578  if ( srcPath->objState == NOT_EXIST_ST ) {
2579  rodsLog( LOG_ERROR,
2580  "resolveRodsTarget: source %s does not exist",
2581  srcPath->outPath );
2582  }
2583  else {
2584  rodsLog( LOG_ERROR,
2585  "resolveRodsTarget: cannot handle objType %d for srcPath %s",
2586  srcPath->objType, srcPath->outPath );
2587  }
2588  return USER_INPUT_PATH_ERR;
2589  }
2590  }
2591  return 0;
2592 }
COL_DATA_TYPE_NAME
#define COL_DATA_TYPE_NAME
Definition: rodsGenQuery.h:168
QueryHandle
Definition: miscUtil.h:81
DataObjSqlResult::dataType
sqlResult_t dataType
Definition: miscUtil.h:53
COL_USER_ZONE
#define COL_USER_ZONE
Definition: rodsGenQuery.h:134
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
specificQueryInp_t::maxRows
int maxRows
Definition: specificQuery.h:13
collHandle_t::dataObjSqlResult
dataObjSqlResult_t dataObjSqlResult
Definition: miscUtil.h:106
MAX_SQL_ROWS
#define MAX_SQL_ROWS
Definition: rodsGenQuery.h:16
RESC_NAME_KW
#define RESC_NAME_KW
Definition: rodsKeyWdDef.h:19
rcComm_t
Definition: rcConnect.h:95
LONG_METADATA_FG
#define LONG_METADATA_FG
Definition: miscUtil.h:90
NULL
#define NULL
Definition: rodsDef.h:70
collHandle_t::prevdataId
char prevdataId[64]
Definition: miscUtil.h:109
collHandle_t::collSqlResult
collSqlResult_t collSqlResult
Definition: miscUtil.h:107
getNextDataObjMetaInfo
int getNextDataObjMetaInfo(collHandle_t *collHandle, collEnt_t *outCollEnt)
Definition: miscUtil.cpp:1547
RodsPath::rodsObjStat
rodsObjStat_t * rodsObjStat
Definition: rodsPath.h:27
True
#define True
Definition: parseCommandLine.h:11
COL_DATA_REPL_NUM
#define COL_DATA_REPL_NUM
Definition: rodsGenQuery.h:166
mkColl
int mkColl(rcComm_t *conn, char *collection)
Definition: miscUtil.cpp:31
addKeyVal
int addKeyVal(keyValPair_t *condInput, const char *keyWord, const char *value)
Definition: rcMisc.cpp:789
GenQueryOut::totalRowCount
int totalRowCount
Definition: rodsGenQuery.h:71
COL_COLL_USER_ZONE
#define COL_COLL_USER_ZONE
Definition: rodsGenQuery.h:357
getOpenedCollLen
int getOpenedCollLen(collHandle_t *collHandle)
Definition: miscUtil.cpp:2087
getLocalTimeStr
int getLocalTimeStr(struct tm *mytm, char *timeStr)
Definition: rcMisc.cpp:1630
pathnamePatterns_t::num_patterns
int num_patterns
Definition: miscUtil.h:137
COL_D_REPL_STATUS
#define COL_D_REPL_STATUS
Definition: rodsGenQuery.h:175
SYS_INTERNAL_NULL_INPUT_ERR
@ SYS_INTERNAL_NULL_INPUT_ERR
Definition: rodsErrorTable.h:92
setQueryInpForData
int setQueryInpForData(int flags, genQueryInp_t *genQueryInp)
Definition: miscUtil.cpp:364
UNKNOWN_ST
@ UNKNOWN_ST
Definition: rodsType.h:47
GenQueryInp::continueInx
int continueInx
Definition: rodsGenQuery.h:28
queryCollInColl
int queryCollInColl(queryHandle_t *queryHandle, char *collection, int flags, genQueryInp_t *genQueryInp, genQueryOut_t **genQueryOut)
Definition: miscUtil.cpp:282
getNumFilesInDir
int getNumFilesInDir(const char *mydir)
Definition: miscUtil.cpp:2183
printNoSync
int printNoSync(char *objPath, rodsLong_t fileSize, char *reason)
Definition: miscUtil.cpp:491
RodsPath::chksum
char chksum[64]
Definition: rodsPath.h:26
DataObjInp::openFlags
int openFlags
Definition: dataObjInpOut.h:68
get_resc_hier_from_leaf_id
int get_resc_hier_from_leaf_id(queryHandle_t *_query_handle, rodsLong_t _resc_id, char *_resc_hier)
Definition: miscUtil.cpp:1495
CollEnt::resource
char * resource
Definition: miscUtil.h:125
NEWLY_CREATED_COPY
#define NEWLY_CREATED_COPY
Definition: objInfo.h:115
DataObjSqlResult::modifyTime
sqlResult_t modifyTime
Definition: miscUtil.h:43
OperProgress::flag
int flag
Definition: guiProgressCallback.h:9
COL_COLL_INHERITANCE
#define COL_COLL_INHERITANCE
Definition: rodsGenQuery.h:194
rodsArguments_t
Definition: parseCommandLine.h:14
clearCollEnt
int clearCollEnt(collEnt_t *collEnt)
Definition: miscUtil.cpp:1772
CollInp
Definition: dataObjInpOut.h:157
COL_D_RESC_HIER
#define COL_D_RESC_HIER
Definition: rodsGenQuery.h:184
DataObjSqlResult::replStatus
sqlResult_t replStatus
Definition: miscUtil.h:45
UNMATCHED_KEY_OR_INDEX
@ UNMATCHED_KEY_OR_INDEX
Definition: rodsErrorTable.h:244
SqlResult::attriInx
int attriInx
Definition: rodsGenQuery.h:62
DataObjInp::specColl
specColl_t * specColl
Definition: dataObjInpOut.h:73
DataObjSqlResult::continueInx
int continueInx
Definition: miscUtil.h:36
SpecColl::resource
char resource[64]
Definition: objInfo.h:83
clearDataObjSqlResult
int clearDataObjSqlResult(dataObjSqlResult_t *dataObjSqlResult)
Definition: miscUtil.cpp:842
queryCollAclSpecific
int queryCollAclSpecific(rcComm_t *conn, char *collName, char *zoneHint, genQueryOut_t **genQueryOut)
Definition: miscUtil.cpp:552
rodsObjStat::dataId
char dataId[64]
Definition: objStat.h:12
DataObjSqlResult::resc_id
sqlResult_t resc_id
Definition: miscUtil.h:48
rcObjStat
int rcObjStat(rcComm_t *conn, dataObjInp_t *dataObjInp, rodsObjStat_t **rodsObjStatOut)
Definition: rcObjStat.cpp:65
INHERIT_PAR_SPEC_COLL_STR
#define INHERIT_PAR_SPEC_COLL_STR
Definition: objInfo.h:70
UNKNOWN_OBJ_T
@ UNKNOWN_OBJ_T
Definition: rodsType.h:37
resolveSpecCollType
int resolveSpecCollType(char *type, char *collection, char *collInfo1, char *collInfo2, specColl_t *specColl)
Definition: rcMisc.cpp:3127
DataObjSqlResult::chksum
sqlResult_t chksum
Definition: miscUtil.h:44
CollEnt::replNum
int replNum
Definition: miscUtil.h:115
UNKNOWN_FILE_T
@ UNKNOWN_FILE_T
Definition: rodsType.h:40
irods_stacktrace.hpp
RodsPathInp
Definition: rodsPath.h:33
CATALOG_ALREADY_HAS_ITEM_BY_THAT_NAME
@ CATALOG_ALREADY_HAS_ITEM_BY_THAT_NAME
Definition: rodsErrorTable.h:424
collHandle_t
Definition: miscUtil.h:97
OperProgress::curFileSize
rodsLong_t curFileSize
Definition: guiProgressCallback.h:15
CollEnt::collName
char * collName
Definition: miscUtil.h:119
DataObjSqlResult::phyPath
sqlResult_t phyPath
Definition: miscUtil.h:50
specificQueryInp_t::continueInx
int continueInx
Definition: specificQuery.h:14
setQueryFlag
int setQueryFlag(rodsArguments_t *rodsArgs)
Definition: miscUtil.cpp:1727
irods_exception.hpp
DataObjSqlResult::dataMode
sqlResult_t dataMode
Definition: miscUtil.h:40
COL_COLL_OWNER_NAME
#define COL_COLL_OWNER_NAME
Definition: rodsGenQuery.h:191
GenQueryInp
Definition: rodsGenQuery.h:24
OperProgress::curFileSizeDone
rodsLong_t curFileSizeDone
Definition: guiProgressCallback.h:16
irods::experimental::administration::client::v1::exists
auto exists(rcComm_t &conn, const user &user) -> bool
Definition: user_administration.cpp:359
queryDataObjAcl
int queryDataObjAcl(rcComm_t *conn, char *dataId, char *zoneHint, genQueryOut_t **genQueryOut)
Definition: miscUtil.cpp:515
DataObjSqlResult::collName
sqlResult_t collName
Definition: miscUtil.h:38
pid_age.p
p
Definition: pid_age.py:13
CollEnt::dataSize
rodsLong_t dataSize
Definition: miscUtil.h:118
OperProgress::totalFileSize
rodsLong_t totalFileSize
Definition: guiProgressCallback.h:11
OperProgress::totalFileSizeDone
rodsLong_t totalFileSizeDone
Definition: guiProgressCallback.h:13
matchPathname
int matchPathname(pathnamePatterns_t *pp, char *name, char *dirname)
Definition: miscUtil.cpp:2297
freePathnamePatterns
void freePathnamePatterns(pathnamePatterns_t *pp)
Definition: miscUtil.cpp:2282
USER_FILE_DOES_NOT_EXIST
@ USER_FILE_DOES_NOT_EXIST
Definition: rodsErrorTable.h:241
RodsPath::inPath
char inPath[(1024+64)]
Definition: rodsPath.h:23
rodsObjStat::ownerName
char ownerName[64]
Definition: objStat.h:14
QueryHandle::getHierForId
funcPtr getHierForId
Definition: miscUtil.h:86
getRodsObjType
int getRodsObjType(rcComm_t *conn, rodsPath_t *rodsPath)
Definition: miscUtil.cpp:200
RodsPath::objState
objStat_t objState
Definition: rodsPath.h:20
NO_TRIM_REPL_FG
#define NO_TRIM_REPL_FG
Definition: miscUtil.h:94
specificQueryInp_t::args
char * args[10]
Definition: specificQuery.h:10
rclCloseCollection
int rclCloseCollection(collHandle_t *collHandle)
Definition: miscUtil.cpp:1354
DATA_QUERY_FIRST_FG
#define DATA_QUERY_FIRST_FG
Definition: miscUtil.h:93
collHandle_t::state
collState_t state
Definition: miscUtil.h:98
DataObjSqlResult::ownerName
sqlResult_t ownerName
Definition: miscUtil.h:51
collHandle_t::linkedObjPath
char linkedObjPath[(1024+64)]
Definition: miscUtil.h:108
rcCollCreate
int rcCollCreate(rcComm_t *conn, collInp_t *collCreateInp)
Definition: rcCollCreate.cpp:58
CollSqlResult::collOwner
sqlResult_t collOwner
Definition: miscUtil.h:22
InxValPair::inx
int * inx
Definition: objInfo.h:215
STRUCT_FILE_COLL
@ STRUCT_FILE_COLL
Definition: objInfo.h:47
rcGlobalExtern.h
RodsPathInp::srcPath
rodsPath_t * srcPath
Definition: rodsPath.h:35
INIT_UMASK_VAL
#define INIT_UMASK_VAL
Definition: miscUtil.h:12
pathnamePatterns_t::pattern_buf
char * pattern_buf
Definition: miscUtil.h:135
freeCollEnt
int freeCollEnt(collEnt_t *collEnt)
Definition: miscUtil.cpp:1759
addInxVal
int addInxVal(inxValPair_t *inxValPair, int inx, const char *value)
Definition: rcMisc.cpp:921
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
generate_iadmin_commands_for_41_to_42_upgrade.name
name
Definition: generate_iadmin_commands_for_41_to_42_upgrade.py:23
RodsPath::objType
objType_t objType
Definition: rodsPath.h:19
SYS_INVALID_INPUT_PARAM
@ SYS_INVALID_INPUT_PARAM
Definition: rodsErrorTable.h:195
COL_D_DATA_CHECKSUM
#define COL_D_DATA_CHECKSUM
Definition: rodsGenQuery.h:177
printTiming
int printTiming(rcComm_t *conn, char *objPath, rodsLong_t fileSize, char *localFile, struct timeval *startTime, struct timeval *endTime)
Definition: miscUtil.cpp:396
GenQueryInp::selectInp
inxIvalPair_t selectInp
Definition: rodsGenQuery.h:53
GenQueryInp::maxRows
int maxRows
Definition: rodsGenQuery.h:25
specificQueryInp_t::condInput
keyValPair_t condInput
Definition: specificQuery.h:17
CollEnt::dataId
char * dataId
Definition: miscUtil.h:121
COL_D_OWNER_NAME
#define COL_D_OWNER_NAME
Definition: rodsGenQuery.h:173
RSYNC_OPR
#define RSYNC_OPR
Definition: dataObjInpOut.h:180
OperProgress::curFileName
char curFileName[MAX_NAME_LEN]
Definition: guiProgressCallback.h:14
specificQueryInp_t
Definition: specificQuery.h:8
COL_ZONE_TYPE
#define COL_ZONE_TYPE
Definition: rodsGenQuery.h:124
DataObjSqlResult::rowCnt
int rowCnt
Definition: miscUtil.h:34
InxValPair::value
char ** value
Definition: objInfo.h:216
COL_COLL_MODIFY_TIME
#define COL_COLL_MODIFY_TIME
Definition: rodsGenQuery.h:197
CollEnt::replStatus
int replStatus
Definition: miscUtil.h:116
COL_COLL_USER_NAME
#define COL_COLL_USER_NAME
Definition: rodsGenQuery.h:356
RodsPath::dataId
char dataId[64]
Definition: rodsPath.h:25
CollSqlResult::collName
sqlResult_t collName
Definition: miscUtil.h:18
DataObjSqlResult::dataSize
sqlResult_t dataSize
Definition: miscUtil.h:41
DataObjSqlResult::resource
sqlResult_t resource
Definition: miscUtil.h:47
NON_ROOT_COLL_CHECK_STR
const char NON_ROOT_COLL_CHECK_STR[]
Definition: miscUtil.cpp:28
getLastPathElement
int getLastPathElement(char *inPath, char *lastElement)
Definition: rodsPath.cpp:444
freeRodsObjStat
int freeRodsObjStat(rodsObjStat_t *rodsObjStat)
Definition: rcMisc.cpp:3537
getZoneHintForGenQuery
char * getZoneHintForGenQuery(genQueryInp_t *genQueryInp)
Definition: miscUtil.cpp:1835
OperProgress::totalNumFilesDone
rodsLong_t totalNumFilesDone
Definition: guiProgressCallback.h:12
COLL_OBJ_T
@ COLL_OBJ_T
Definition: rodsType.h:39
COL_DATA_NAME
#define COL_DATA_NAME
Definition: rodsGenQuery.h:165
RodsPathInp::targPath
rodsPath_t * targPath
Definition: rodsPath.h:37
CollSqlResult::collCreateTime
sqlResult_t collCreateTime
Definition: miscUtil.h:23
DataObjSqlResult::resc_hier
sqlResult_t resc_hier
Definition: miscUtil.h:49
COLL_COLL_OBJ_QUERIED
@ COLL_COLL_OBJ_QUERIED
Definition: miscUtil.h:72
CollSqlResult::collModifyTime
sqlResult_t collModifyTime
Definition: miscUtil.h:24
collHandle_t::queryHandle
queryHandle_t queryHandle
Definition: miscUtil.h:103
mkdirForFilePath
int mkdirForFilePath(char *filePath)
Definition: miscUtil.cpp:157
queryDataObjInColl
int queryDataObjInColl(queryHandle_t *queryHandle, char *collection, int flags, genQueryInp_t *genQueryInp, genQueryOut_t **genQueryOut, keyValPair_t *condInput)
Definition: miscUtil.cpp:324
MOVE_OPR
#define MOVE_OPR
Definition: dataObjInpOut.h:179
COL_DATA_ACCESS_NAME
#define COL_DATA_ACCESS_NAME
Definition: rodsGenQuery.h:273
RodsPathInp::destPath
rodsPath_t * destPath
Definition: rodsPath.h:36
CAT_UNKNOWN_COLLECTION
@ CAT_UNKNOWN_COLLECTION
Definition: rodsErrorTable.h:429
LINKED_COLL
@ LINKED_COLL
Definition: objInfo.h:49
transferStat_t::numThreads
int numThreads
Definition: objInfo.h:292
COL_D_RESC_NAME
#define COL_D_RESC_NAME
Definition: rodsGenQuery.h:171
COLL_DATA_OBJ_QUERIED
@ COLL_DATA_OBJ_QUERIED
Definition: miscUtil.h:71
getSqlResultByInx
sqlResult_t * getSqlResultByInx(genQueryOut_t *genQueryOut, int attriInx)
Definition: rcMisc.cpp:1387
LOG_DEBUG
#define LOG_DEBUG
Definition: rodsLog.h:23
DataObjSqlResult::totalRowCount
int totalRowCount
Definition: miscUtil.h:37
GenQueryOut::continueInx
int continueInx
Definition: rodsGenQuery.h:70
COL_COLL_TOKEN_NAMESPACE
#define COL_COLL_TOKEN_NAMESPACE
Definition: rodsGenQuery.h:280
CollEnt::phyPath
char * phyPath
Definition: miscUtil.h:127
get_hier_from_leaf_id.h
COL_D_MODIFY_TIME
#define COL_D_MODIFY_TIME
Definition: rodsGenQuery.h:182
specificQueryInp_t::sql
char * sql
Definition: specificQuery.h:9
queryCollInheritance
int queryCollInheritance(rcComm_t *conn, char *collName, genQueryOut_t **genQueryOut)
Definition: miscUtil.cpp:625
readCollection
int readCollection(collHandle_t *collHandle, collEnt_t *collEnt)
Definition: miscUtil.cpp:1119
TIME_LEN
#define TIME_LEN
Definition: rodsDef.h:54
GenQueryInp::condInput
keyValPair_t condInput
Definition: rodsGenQuery.h:52
rcGenQuery
int rcGenQuery(rcComm_t *conn, genQueryInp_t *genQueryInp, genQueryOut_t **genQueryOut)
Definition: rcGenQuery.cpp:89
clearCollSqlResult
int clearCollSqlResult(collSqlResult_t *collSqlResult)
Definition: miscUtil.cpp:808
getZoneType
int getZoneType(rcComm_t *conn, char *icatZone, char *inZoneName, char *outZoneType)
Definition: miscUtil.cpp:1869
COL_USER_NAME
#define COL_USER_NAME
Definition: rodsGenQuery.h:132
COL_DATA_TOKEN_NAMESPACE
#define COL_DATA_TOKEN_NAMESPACE
Definition: rodsGenQuery.h:274
CollEnt
Definition: miscUtil.h:113
OperProgress::totalNumFiles
rodsLong_t totalNumFiles
Definition: guiProgressCallback.h:10
COL_D_CREATE_TIME
#define COL_D_CREATE_TIME
Definition: rodsGenQuery.h:181
CollEnt::specColl
specColl_t specColl
Definition: miscUtil.h:130
GenQueryInp::sqlCondInp
inxValPair_t sqlCondInp
Definition: rodsGenQuery.h:56
RC_COMM
@ RC_COMM
Definition: miscUtil.h:76
resolveRodsTarget
int resolveRodsTarget(rcComm_t *conn, rodsPathInp_t *rodsPathInp, int oprType)
Definition: miscUtil.cpp:2342
DataObjInp
Definition: dataObjInpOut.h:65
rodsObjStat::objSize
rodsLong_t objSize
Definition: objStat.h:9
OBJ_PATH_DOES_NOT_EXIST
@ OBJ_PATH_DOES_NOT_EXIST
Definition: rodsErrorTable.h:279
collHandle_t::dataObjInp
dataObjInp_t dataObjInp
Definition: miscUtil.h:105
getCollSizeForProgStat
int getCollSizeForProgStat(rcComm_t *conn, char *srcColl, operProgress_t *operProgress)
Definition: miscUtil.cpp:1920
VERIFY_DIV
#define VERIFY_DIV(_v1_, _v2_)
Definition: miscUtil.cpp:24
DataObjSqlResult::replNum
sqlResult_t replNum
Definition: miscUtil.h:52
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
rodsObjStat::objType
objType_t objType
Definition: objStat.h:10
COL_ZONE_NAME
#define COL_ZONE_NAME
Definition: rodsGenQuery.h:123
addInxIval
int addInxIval(inxIvalPair_t *inxIvalPair, int inx, int value)
Definition: rcMisc.cpp:883
collHandle_t::rodsObjStat
rodsObjStat_t * rodsObjStat
Definition: miscUtil.h:102
COLL_OPENED
@ COLL_OPENED
Definition: miscUtil.h:70
get_hier_out_t
Definition: get_hier_from_leaf_id.h:12
genQueryOutToDataObjRes
int genQueryOutToDataObjRes(genQueryOut_t **genQueryOut, dataObjSqlResult_t *dataObjSqlResult)
Definition: miscUtil.cpp:901
INCLUDE_CONDINPUT_IN_QUERY
#define INCLUDE_CONDINPUT_IN_QUERY
Definition: miscUtil.h:95
GenQueryOut
Definition: rodsGenQuery.h:67
SEL_OBJ_TYPE_KW
#define SEL_OBJ_TYPE_KW
Definition: rodsKeyWdDef.h:71
DataObjSqlResult::createTime
sqlResult_t createTime
Definition: miscUtil.h:42
collHandle_t::genQueryInp
genQueryInp_t genQueryInp
Definition: miscUtil.h:104
RodsPath::size
rodsLong_t size
Definition: rodsPath.h:21
collType
ReIterableType collType(Res *coll)
Definition: functions.cpp:323
COL_COLL_PARENT_NAME
#define COL_COLL_PARENT_NAME
Definition: rodsGenQuery.h:190
CollSqlResult::rowCnt
int rowCnt
Definition: miscUtil.h:14
CollSqlResult::collInfo2
sqlResult_t collInfo2
Definition: miscUtil.h:21
get_irods_version.value
dictionary value
Definition: get_irods_version.py:27
CollEnt::modifyTime
char * modifyTime
Definition: miscUtil.h:123
printTime
int printTime(char *objPath, struct timeval *startTime, struct timeval *endTime)
Definition: miscUtil.cpp:460
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
SpecColl::rescHier
char rescHier[(1024+64)]
Definition: objInfo.h:84
GenQueryOut::attriCnt
int attriCnt
Definition: rodsGenQuery.h:69
NO_SPEC_COLL
@ NO_SPEC_COLL
Definition: objInfo.h:46
zoneHint
char zoneHint[(1024+64)]
Definition: lsUtil.cpp:13
mkCollR
int mkCollR(rcComm_t *conn, char *startColl, char *destColl)
Definition: miscUtil.cpp:51
splitPathByKey
int splitPathByKey(const char *srcPath, char *dir, size_t maxDirLen, char *file, size_t maxFileLen, char key)
Definition: stringOpr.cpp:222
getNextCollMetaInfo
int getNextCollMetaInfo(collHandle_t *collHandle, collEnt_t *outCollEnt)
Definition: miscUtil.cpp:1386
rodsLog.h
GenQueryOut::rowCnt
int rowCnt
Definition: rodsGenQuery.h:68
get_hier_inp_t::resc_id_
rodsLong_t resc_id_
Definition: get_hier_from_leaf_id.h:9
OperProgress
Definition: guiProgressCallback.h:7
genAllInCollQCond
int genAllInCollQCond(char *collection, char *collQCond)
Definition: miscUtil.cpp:262
rmdirR
int rmdirR(char *startDir, char *destDir)
Definition: miscUtil.cpp:174
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
CollEnt::dataMode
uint dataMode
Definition: miscUtil.h:117
COLL_CLOSED
@ COLL_CLOSED
Definition: miscUtil.h:69
CollSqlResult::attriCnt
int attriCnt
Definition: miscUtil.h:15
getFileSize
rodsLong_t getFileSize(char *path)
Definition: rcMisc.cpp:74
RECUR_QUERY_FG
#define RECUR_QUERY_FG
Definition: miscUtil.h:92
rodsObjStat::dataMode
uint dataMode
Definition: objStat.h:11
COL_COLL_TYPE
#define COL_COLL_TYPE
Definition: rodsGenQuery.h:198
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
InxValPair::len
int len
Definition: objInfo.h:214
DATA_OBJ_T
@ DATA_OBJ_T
Definition: rodsType.h:38
CollSqlResult::totalRowCount
int totalRowCount
Definition: miscUtil.h:17
CollEnt::dataName
char * dataName
Definition: miscUtil.h:120
DataObjSqlResult
Definition: miscUtil.h:33
queryCollAcl
int queryCollAcl(rcComm_t *conn, char *collName, char *zoneHint, genQueryOut_t **genQueryOut)
Definition: miscUtil.cpp:581
DataObjSqlResult::attriCnt
int attriCnt
Definition: miscUtil.h:35
QueryHandle::genQuery
funcPtr genQuery
Definition: miscUtil.h:85
genDataResInColl
int genDataResInColl(queryHandle_t *queryHandle, collHandle_t *collHandle)
Definition: miscUtil.cpp:1305
RodsPath::outPath
char outPath[(1024+64)]
Definition: rodsPath.h:24
SqlResult::value
char * value
Definition: rodsGenQuery.h:64
genCollResInColl
int genCollResInColl(queryHandle_t *queryHandle, collHandle_t *collHandle)
Definition: miscUtil.cpp:1257
myChmod
int myChmod(char *inPath, uint dataMode)
Definition: miscUtil.cpp:1815
CollSqlResult::continueInx
int continueInx
Definition: miscUtil.h:16
rodsObjStat::chksum
char chksum[64]
Definition: objStat.h:13
collHandle_t::flags
int flags
Definition: miscUtil.h:100
rclReadCollection
int rclReadCollection(rcComm_t *conn, collHandle_t *collHandle, collEnt_t *collEnt)
Definition: miscUtil.cpp:1108
genQueryOutToCollRes
int genQueryOutToCollRes(genQueryOut_t **genQueryOut, collSqlResult_t *collSqlResult)
Definition: miscUtil.cpp:658
rmSubDir
int rmSubDir(char *mydir)
Definition: miscUtil.cpp:2100
RETURN_TOTAL_ROW_COUNT
#define RETURN_TOTAL_ROW_COUNT
Definition: rodsGenQuery.h:86
RodsPath::objMode
uint objMode
Definition: rodsPath.h:22
rcGetHierFromLeafId
int rcGetHierFromLeafId(rcComm_t *, get_hier_inp_t *, get_hier_out_t **)
Definition: rcGetHierFromLeafId.cpp:6
DataObjSqlResult::dataName
sqlResult_t dataName
Definition: miscUtil.h:39
rodsClient.h
CollMetaInfo
Definition: miscUtil.h:27
rmFilesInDir
int rmFilesInDir(char *mydir)
Definition: miscUtil.cpp:2149
CAT_NO_ROWS_FOUND
@ CAT_NO_ROWS_FOUND
Definition: rodsErrorTable.h:423
SqlResult
Definition: rodsGenQuery.h:61
rodsArguments_t::veryLongOption
int veryLongOption
Definition: parseCommandLine.h:60
setSqlResultValue
int setSqlResultValue(sqlResult_t *sqlResult, int attriInx, char *valueStr, int rowCnt)
Definition: miscUtil.cpp:778
CollSqlResult
Definition: miscUtil.h:13
VERY_LONG_METADATA_FG
#define VERY_LONG_METADATA_FG
Definition: miscUtil.h:91
readPathnamePatterns
pathnamePatterns_t * readPathnamePatterns(char *buf, int buflen)
Definition: miscUtil.cpp:2220
COL_COLL_NAME
#define COL_COLL_NAME
Definition: rodsGenQuery.h:189
LOCAL_DIR_T
@ LOCAL_DIR_T
Definition: rodsType.h:42
rodsLogError
void rodsLogError(int level, int errCode, char *formatStr,...)
Definition: rodsLog.cpp:422
RodsPathInp::numSrc
int numSrc
Definition: rodsPath.h:34
rclInitQueryHandle
int rclInitQueryHandle(queryHandle_t *queryHandle, rcComm_t *conn)
Definition: miscUtil.cpp:1744
CollEnt::dataType
char * dataType
Definition: miscUtil.h:129
QueryHandle::conn
void * conn
Definition: miscUtil.h:82
irods::exception
Definition: irods_exception.hpp:15
replSpecColl
int replSpecColl(specColl_t *inSpecColl, specColl_t **outSpecColl)
Definition: rcMisc.cpp:778
SqlResult::len
int len
Definition: rodsGenQuery.h:63
rodsArguments_t::longOption
int longOption
Definition: parseCommandLine.h:56
clearCollHandle
int clearCollHandle(collHandle_t *collHandle, int freeSpecColl)
Definition: miscUtil.cpp:1359
rcComm_t::transStat
transferStat_t transStat
Definition: rcConnect.h:108
CollEnt::objType
objType_t objType
Definition: miscUtil.h:114
CollInp::collName
char collName[(1024+64)]
Definition: dataObjInpOut.h:158
COL_COLL_CREATE_TIME
#define COL_COLL_CREATE_TIME
Definition: rodsGenQuery.h:196
rodsObjStat
Definition: objStat.h:8
Myumask
static uint Myumask
Definition: miscUtil.cpp:26
EXIST_ST
@ EXIST_ST
Definition: rodsType.h:49
mkdirR
int mkdirR(char *startDir, char *destDir, int mode)
Definition: miscUtil.cpp:106
ZONE_KW
#define ZONE_KW
Definition: rodsKeyWdDef.h:80
iCommandProgStat
guiProgressCallback iCommandProgStat(operProgress_t *operProgress)
Definition: miscUtil.cpp:2032
clearRodsPath
void clearRodsPath(rodsPath_t *rodsPath)
Definition: rodsPath.cpp:481
QueryHandle::connType
connType_t connType
Definition: miscUtil.h:83
DataObjMetaInfo
Definition: miscUtil.h:56
rodsObjStat::specColl
specColl_t * specColl
Definition: objStat.h:18
irods_path_recursion.hpp
RodsPath
Definition: rodsPath.h:18
get_hier_inp_t
Definition: get_hier_from_leaf_id.h:8
getDirSizeForProgStat
int getDirSizeForProgStat(rodsArguments_t *rodsArgs, char *srcDir, operProgress_t *operProgress)
Definition: miscUtil.cpp:1967
miscUtil.h
mode
int mode
Definition: filesystem.cpp:104
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
COL_D_DATA_PATH
#define COL_D_DATA_PATH
Definition: rodsGenQuery.h:172
LOCAL_FILE_T
@ LOCAL_FILE_T
Definition: rodsType.h:41
COL_COLL_INFO1
#define COL_COLL_INFO1
Definition: rodsGenQuery.h:199
DataObjInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:74
QueryHandle::querySpecColl
funcPtr querySpecColl
Definition: miscUtil.h:84
freeGenQueryOut
int freeGenQueryOut(genQueryOut_t **genQueryOut)
Definition: rcMisc.cpp:1133
NOT_EXIST_ST
@ NOT_EXIST_ST
Definition: rodsType.h:48
NAME_LEN
#define NAME_LEN
Definition: rodsDef.h:55
KeyValPair
Definition: objInfo.h:120
DEFAULT_DIR_MODE
#define DEFAULT_DIR_MODE
Definition: objInfo.h:241
pathnamePatterns_t
Definition: miscUtil.h:134
clearKeyVal
int clearKeyVal(keyValPair_t *condInput)
Definition: rcMisc.cpp:1047
rcSpecificQuery
int rcSpecificQuery(rcComm_t *conn, specificQueryInp_t *specificQueryInp, genQueryOut_t **genQueryOut)
Definition: rcSpecificQuery.cpp:49
SpecColl::objPath
char objPath[(1024+64)]
Definition: objInfo.h:80
rclOpenCollection
int rclOpenCollection(rcComm_t *conn, char *collection, int flags, collHandle_t *collHandle)
Definition: miscUtil.cpp:1057
buf
static char buf[64+50+1]
Definition: rsAuthRequest.cpp:21
manual_cleanup.out
out
Definition: manual_cleanup.py:29
USER_INPUT_PATH_ERR
@ USER_INPUT_PATH_ERR
Definition: rodsErrorTable.h:248
CollEnt::createTime
char * createTime
Definition: miscUtil.h:122
guiProgressCallback
void(* guiProgressCallback)(operProgress_t *operProgress)
Definition: guiProgressCallback.h:19
COL_DATA_SIZE
#define COL_DATA_SIZE
Definition: rodsGenQuery.h:169
CollEnt::resc_hier
char * resc_hier
Definition: miscUtil.h:126
CollSqlResult::collType
sqlResult_t collType
Definition: miscUtil.h:19
clearGenQueryInp
void clearGenQueryInp(void *voidInp)
Definition: rcMisc.cpp:1118
DataObjSqlResult::dataId
sqlResult_t dataId
Definition: miscUtil.h:46
COL_COLL_INFO2
#define COL_COLL_INFO2
Definition: rodsGenQuery.h:200
CollEnt::ownerName
char * ownerName
Definition: miscUtil.h:128
COL_DATA_ACCESS_DATA_ID
#define COL_DATA_ACCESS_DATA_ID
Definition: rodsGenQuery.h:276
UNIX_FILE_MKDIR_ERR
@ UNIX_FILE_MKDIR_ERR
Definition: rodsErrorTable.h:310
CollEnt::chksum
char * chksum
Definition: miscUtil.h:124
STDOUT_FILE_NAME
#define STDOUT_FILE_NAME
Definition: rodsPath.h:16
GenQueryInp::options
int options
Definition: rodsGenQuery.h:34
COL_COLL_ACCESS_NAME
#define COL_COLL_ACCESS_NAME
Definition: rodsGenQuery.h:279
CollSqlResult::collInfo1
sqlResult_t collInfo1
Definition: miscUtil.h:20
rodsLong_t
long long rodsLong_t
Definition: rodsType.h:32
SpecColl::collClass
specCollClass_t collClass
Definition: objInfo.h:77
rcQuerySpecColl
int rcQuerySpecColl(rcComm_t *conn, dataObjInp_t *querySpecCollInp, genQueryOut_t **genQueryOut)
Definition: rcQuerySpecColl.cpp:33
COL_D_DATA_ID
#define COL_D_DATA_ID
Definition: rodsGenQuery.h:163
USER__NULL_INPUT_ERR
@ USER__NULL_INPUT_ERR
Definition: rodsErrorTable.h:247
COL_DATA_MODE
#define COL_DATA_MODE
Definition: rodsGenQuery.h:183
pathnamePatterns_t::patterns
char ** patterns
Definition: miscUtil.h:136
collHandle_t::rowInx
int rowInx
Definition: miscUtil.h:101