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)  

mcollUtil.cpp
Go to the documentation of this file.
1 
3 #include "rodsPath.h"
4 #include "rodsErrorTable.h"
5 #include "rodsLog.h"
6 #include "mcollUtil.h"
7 #include "miscUtil.h"
8 #include "rcGlobalExtern.h"
9 
10 /* redefine of some input option */
11 #define syncCacheDir sizeFlag
12 #define purgeCacheDir physicalPath
13 int
14 mcollUtil( rcComm_t *conn, rodsEnv *myRodsEnv, rodsArguments_t *myRodsArgs,
15  rodsPathInp_t *rodsPathInp ) {
16  rodsPath_t *destPath, *srcPath;
17  dataObjInp_t dataObjOprInp;
18 
19  if ( rodsPathInp == NULL ) {
20  return USER__NULL_INPUT_ERR;
21  }
22 
23  int savedStatus = initCondForMcoll( myRodsEnv, myRodsArgs, &dataObjOprInp );
24  if ( savedStatus < 0 ) {
25  return savedStatus;
26  }
27 
28  for ( int i = 0; i < rodsPathInp->numSrc; i++ ) {
29  int status;
30  if ( myRodsArgs->mountCollection == True ) {
31  destPath = &rodsPathInp->destPath[i]; /* iRODS path */
32  srcPath = &rodsPathInp->srcPath[i]; /* file Path */
33 
34  getRodsObjType( conn, destPath );
35 
36  addKeyVal( &dataObjOprInp.condInput, FILE_PATH_KW,
37  srcPath->outPath );
38  rstrcpy( dataObjOprInp.objPath, destPath->outPath, MAX_NAME_LEN );
39  status = rcPhyPathReg( conn, &dataObjOprInp );
40  }
41  else if ( myRodsArgs->unmount == True ) { /* unmount */
42  srcPath = &rodsPathInp->srcPath[i]; /* file Path */
43 
44  getRodsObjType( conn, srcPath );
45 
46  rstrcpy( dataObjOprInp.objPath, srcPath->outPath, MAX_NAME_LEN );
47  status = rcPhyPathReg( conn, &dataObjOprInp );
48  }
49  else if ( myRodsArgs->syncCacheDir == True ||
50  myRodsArgs->purgeCacheDir == True ) { /* sync or purge */
51  srcPath = &rodsPathInp->srcPath[i]; /* file Path */
52 
53  getRodsObjType( conn, srcPath );
54 
55  rstrcpy( dataObjOprInp.objPath, srcPath->outPath, MAX_NAME_LEN );
56  status = rcSyncMountedColl( conn, &dataObjOprInp );
57  }
58  else {
60  }
61 
62  /* XXXX may need to return a global status */
63  if ( status < 0 &&
66  "imcoll error" );
67  savedStatus = status;
68  }
69  }
70  return savedStatus;
71 }
72 
73 int
74 initCondForMcoll( rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs,
75  dataObjInp_t *dataObjOprInp ) {
76  if ( dataObjOprInp == NULL ) {
78  "initCondForReg: NULL dataObjOprInp input" );
79  return USER__NULL_INPUT_ERR;
80  }
81 
82  memset( dataObjOprInp, 0, sizeof( dataObjInp_t ) );
83 
84  if ( rodsArgs == NULL ) {
85  return USER_INPUT_OPTION_ERR;
86  }
87 
88  if ( rodsArgs->collection == True ) {
89  addKeyVal( &dataObjOprInp->condInput, COLLECTION_KW, "" );
90  }
91 
92  if ( rodsArgs->purgeCacheDir == True ) {
93  dataObjOprInp->oprType =
94  dataObjOprInp->oprType | PURGE_STRUCT_FILE_CACHE;
95  }
96 
97  if ( rodsArgs->unmount == True ) {
98  addKeyVal( &dataObjOprInp->condInput,
100  }
101  else if ( rodsArgs->mountCollection == True ) {
102  char *mountType = rodsArgs->mountType;
103  if ( strcmp( mountType, "h" ) == 0 ||
104  strcmp( mountType, "haaw" ) == 0 ) {
105  addKeyVal( &dataObjOprInp->condInput,
107  }
108  else if ( strcmp( mountType, "m" ) == 0 ||
109  strcmp( mountType, "msso" ) == 0 ) {
110  addKeyVal( &dataObjOprInp->condInput,
112  /* XXXXX need to add "msso structFile" token */
113  addKeyVal( &dataObjOprInp->condInput, DATA_TYPE_KW, MSSO_DT_STR );
114  }
115  else if ( strcmp( mountType, "t" ) == 0 ||
116  strcmp( mountType, "tar" ) == 0 ) {
117  addKeyVal( &dataObjOprInp->condInput,
119  /* XXXXX need to add "tar structFile" token */
120  addKeyVal( &dataObjOprInp->condInput, DATA_TYPE_KW, TAR_DT_STR );
121  }
122  else if ( strcmp( mountType, "f" ) == 0 ||
123  strcmp( mountType, "filesystem" ) == 0 ) {
124  /* the collection is a filesystem mount point */
125  addKeyVal( &dataObjOprInp->condInput,
127  }
128  else if ( strcmp( mountType, "l" ) == 0 ||
129  strcmp( mountType, "link" ) == 0 ) {
130  /* the collection is a softlink point */
131  addKeyVal( &dataObjOprInp->condInput,
133  }
134  }
135  else if ( rodsArgs->purgeCacheDir == True ) {
136  dataObjOprInp->oprType =
137  dataObjOprInp->oprType | PURGE_STRUCT_FILE_CACHE;
138  }
139  else if ( rodsArgs->syncCacheDir != True ) {
140  /* should not be here */
141  rodsLog( LOG_ERROR, "initCondForMcoll: -U or -m must be used. " );
142  return USER_INPUT_OPTION_ERR;
143  }
144 
145  if ( rodsArgs->resource == True ) {
146  if ( rodsArgs->resourceString == NULL ) {
148  "initCondForReg: NULL resourceString error" );
149  return USER__NULL_INPUT_ERR;
150  }
151  else {
152  addKeyVal( &dataObjOprInp->condInput, DEST_RESC_NAME_KW,
153  rodsArgs->resourceString );
154  }
155  }
156  else if ( myRodsEnv != NULL && strlen( myRodsEnv->rodsDefResource ) > 0 ) {
157  addKeyVal( &dataObjOprInp->condInput, DEST_RESC_NAME_KW,
158  myRodsEnv->rodsDefResource );
159  }
160 
161  return 0;
162 }
163 
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
DataObjInp::objPath
char objPath[(1024+64)]
Definition: dataObjInpOut.h:66
rcComm_t
Definition: rcConnect.h:95
NULL
#define NULL
Definition: rodsDef.h:70
True
#define True
Definition: parseCommandLine.h:11
addKeyVal
int addKeyVal(keyValPair_t *condInput, const char *keyWord, const char *value)
Definition: rcMisc.cpp:789
rodsPath.h
LINK_POINT_STR
#define LINK_POINT_STR
Definition: objInfo.h:69
rodsArguments_t
Definition: parseCommandLine.h:14
rodsArguments_t::mountType
char * mountType
Definition: parseCommandLine.h:62
UNMOUNT_STR
#define UNMOUNT_STR
Definition: objInfo.h:74
HAAW_STRUCT_FILE_STR
#define HAAW_STRUCT_FILE_STR
Definition: objInfo.h:66
mcollUtil.h
RodsPathInp
Definition: rodsPath.h:33
TAR_DT_STR
#define TAR_DT_STR
Definition: objInfo.h:28
rcPhyPathReg
int rcPhyPathReg(rcComm_t *conn, dataObjInp_t *phyPathRegInp)
Definition: rcPhyPathReg.cpp:71
rodsArguments_t::collection
int collection
Definition: parseCommandLine.h:31
TAR_STRUCT_FILE_STR
#define TAR_STRUCT_FILE_STR
Definition: objInfo.h:67
rodsArguments_t::resource
int resource
Definition: parseCommandLine.h:86
rcGlobalExtern.h
RodsPathInp::srcPath
rodsPath_t * srcPath
Definition: rodsPath.h:35
mcollUtil
int mcollUtil(rcComm_t *conn, rodsEnv *myRodsEnv, rodsArguments_t *myRodsArgs, rodsPathInp_t *rodsPathInp)
Definition: mcollUtil.cpp:14
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
DATA_TYPE_KW
#define DATA_TYPE_KW
Definition: rodsKeyWdDef.h:23
MOUNT_POINT_STR
#define MOUNT_POINT_STR
Definition: objInfo.h:68
DEST_RESC_NAME_KW
#define DEST_RESC_NAME_KW
Definition: rodsKeyWdDef.h:20
rcSyncMountedColl
int rcSyncMountedColl(rcComm_t *conn, dataObjInp_t *syncMountedCollInp)
Definition: rcSyncMountedColl.cpp:40
RodsPathInp::destPath
rodsPath_t * destPath
Definition: rodsPath.h:36
COLLECTION_KW
#define COLLECTION_KW
Definition: rodsKeyWdDef.h:61
DataObjInp
Definition: dataObjInpOut.h:65
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
COLLECTION_TYPE_KW
#define COLLECTION_TYPE_KW
Definition: rodsKeyWdDef.h:67
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
rodsLog.h
rodsArguments_t::resourceString
char * resourceString
Definition: parseCommandLine.h:87
MSSO_DT_STR
#define MSSO_DT_STR
Definition: objInfo.h:32
MSSO_STRUCT_FILE_STR
#define MSSO_STRUCT_FILE_STR
Definition: objInfo.h:71
rodsEnv::rodsDefResource
char rodsDefResource[64]
Definition: getRodsEnv.h:17
rodsArguments_t::mountCollection
int mountCollection
Definition: parseCommandLine.h:61
RodsPath::outPath
char outPath[(1024+64)]
Definition: rodsPath.h:24
DataObjInp::oprType
int oprType
Definition: dataObjInpOut.h:72
CAT_NO_ROWS_FOUND
@ CAT_NO_ROWS_FOUND
Definition: rodsErrorTable.h:423
rodsArguments_t::unmount
int unmount
Definition: parseCommandLine.h:106
USER_INPUT_OPTION_ERR
@ USER_INPUT_OPTION_ERR
Definition: rodsErrorTable.h:249
PURGE_STRUCT_FILE_CACHE
#define PURGE_STRUCT_FILE_CACHE
Definition: syncMountedColl.h:8
rodsLogError
void rodsLogError(int level, int errCode, char *formatStr,...)
Definition: rodsLog.cpp:422
RodsPathInp::numSrc
int numSrc
Definition: rodsPath.h:34
rodsErrorTable.h
RodsPath
Definition: rodsPath.h:18
miscUtil.h
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
DataObjInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:74
rodsEnv
Definition: getRodsEnv.h:8
FILE_PATH_KW
#define FILE_PATH_KW
Definition: rodsKeyWdDef.h:28
getRodsObjType
int getRodsObjType(rcComm_t *conn, rodsPath_t *rodsPath)
Definition: miscUtil.cpp:200
initCondForMcoll
int initCondForMcoll(rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs, dataObjInp_t *dataObjOprInp)
Definition: mcollUtil.cpp:74
USER__NULL_INPUT_ERR
@ USER__NULL_INPUT_ERR
Definition: rodsErrorTable.h:247