00001
00002
00003
00004
00005
00006 #include "syncMountedColl.h"
00007 #include "rodsLog.h"
00008 #include "icatDefines.h"
00009 #include "objMetaOpr.h"
00010 #include "collection.h"
00011 #include "resource.h"
00012 #include "rsGlobalExtern.h"
00013 #include "rcGlobalExtern.h"
00014 #include "reGlobalsExtern.h"
00015 #include "miscServerFunct.h"
00016 #include "apiHeaderAll.h"
00017
00018 int
00019 rsSyncMountedColl (rsComm_t *rsComm, dataObjInp_t *syncMountedCollInp)
00020 {
00021 int status;
00022 rodsObjStat_t *rodsObjStatOut = NULL;
00023 dataObjInp_t myDataObjInp;
00024 int remoteFlag;
00025 rodsServerHost_t *rodsServerHost;
00026
00027 status = collStat (rsComm, syncMountedCollInp, &rodsObjStatOut);
00028 if (status < 0 || NULL == rodsObjStatOut) return status;
00029
00030 if (rodsObjStatOut->specColl == NULL) {
00031 freeRodsObjStat (rodsObjStatOut);
00032 rodsLog (LOG_ERROR,
00033 "rsSyncMountedColl: %s not a mounted collection",
00034 syncMountedCollInp->objPath);
00035 return (SYS_COLL_NOT_MOUNTED_ERR);
00036 }
00037
00038 bzero (&myDataObjInp, sizeof (myDataObjInp));
00039 rstrcpy (myDataObjInp.objPath, rodsObjStatOut->specColl->objPath,
00040 MAX_NAME_LEN);
00041 remoteFlag = getAndConnRemoteZone (rsComm, &myDataObjInp, &rodsServerHost,
00042 REMOTE_OPEN);
00043
00044 if (remoteFlag < 0) {
00045 return (remoteFlag);
00046 } else if (remoteFlag == REMOTE_HOST) {
00047 status = rcSyncMountedColl (rodsServerHost->conn,
00048 syncMountedCollInp);
00049 } else {
00050 status = _rsSyncMountedColl (rsComm, rodsObjStatOut->specColl,
00051 syncMountedCollInp->oprType);
00052 }
00053
00054 freeRodsObjStat (rodsObjStatOut);
00055
00056 return (status);
00057 }
00058
00059 int
00060 _rsSyncMountedColl (rsComm_t *rsComm, specColl_t *specColl, int oprType)
00061 {
00062 int status;
00063
00064 if (getStructFileType (specColl) >= 0) {
00065 structFileOprInp_t structFileOprInp;
00066 rescInfo_t *rescInfo;
00067
00068 if (strlen (specColl->resource) == 0) {
00069
00070 return (0);
00071 }
00072
00073 memset (&structFileOprInp, 0, sizeof (structFileOprInp));
00074 status = resolveResc (specColl->resource, &rescInfo);
00075
00076 if (status < 0) {
00077 rodsLog (LOG_NOTICE,
00078 "_rsSyncMountedColl: resolveResc error for %s, status = %d",
00079 specColl->resource, status);
00080 return (status);
00081 }
00082 rstrcpy (structFileOprInp.addr.hostAddr, rescInfo->rescLoc, NAME_LEN);
00083 structFileOprInp.oprType = oprType;
00084 structFileOprInp.specColl = specColl;
00085 status = rsStructFileSync (rsComm, &structFileOprInp);
00086 } else {
00087 status = SYS_COLL_NOT_MOUNTED_ERR;
00088 }
00089
00090 return (status);
00091 }
00092