int initDataObjInfoForRepl (rsComm_t *rsComm, dataObjInfo_t *destDataObjInfo, dataObjInfo_t *srcDataObjInfo, rescInfo_t *destRescInfo, char *destRescGroupName) { memset (destDataObjInfo, 0, sizeof (dataObjInfo_t)); *destDataObjInfo = *srcDataObjInfo; destDataObjInfo->filePath[0] = '\0'; rstrcpy (destDataObjInfo->rescName, destRescInfo->rescName, NAME_LEN); destDataObjInfo->replNum = destDataObjInfo->dataId = 0; destDataObjInfo->rescInfo = destRescInfo; if (destRescGroupName != NULL && strlen (destRescGroupName) > 0) { rstrcpy (destDataObjInfo->rescGroupName, destRescGroupName, NAME_LEN); } else if (strlen (destDataObjInfo->rescGroupName) > 0) { /* need to verify whether destRescInfo belongs to * destDataObjInfo->rescGroupName */ if (getRescInGrp (rsComm, destRescInfo->rescName, destDataObjInfo->rescGroupName, NULL) < 0) { /* destResc is not in destRescGrp */ destDataObjInfo->rescGroupName[0] = '\0'; } } return (0); }
int irsPhyPathReg (rsComm_t *rsComm, dataObjInp_t *phyPathRegInp) { int status; rescGrpInfo_t *rescGrpInfo = NULL; rodsServerHost_t *rodsServerHost = NULL; int remoteFlag; int rescCnt; rodsHostAddr_t addr; char *tmpStr = NULL; char *rescGroupName = NULL; rescInfo_t *tmpRescInfo = NULL; if ((tmpStr = getValByKey (&phyPathRegInp->condInput, COLLECTION_TYPE_KW)) != NULL && strcmp (tmpStr, UNMOUNT_STR) == 0) { status = unmountFileDir (rsComm, phyPathRegInp); return (status); } else if (tmpStr != NULL && (strcmp (tmpStr, HAAW_STRUCT_FILE_STR) == 0 || strcmp (tmpStr, TAR_STRUCT_FILE_STR) == 0)) { status = structFileReg (rsComm, phyPathRegInp); return (status); } else if (tmpStr != NULL && strcmp (tmpStr, LINK_POINT_STR) == 0) { status = linkCollReg (rsComm, phyPathRegInp); return (status); } status = getRescInfo (rsComm, NULL, &phyPathRegInp->condInput, &rescGrpInfo); if (status < 0) { rodsLog (LOG_ERROR, "rsPhyPathReg: getRescInfo error for %s, status = %d", phyPathRegInp->objPath, status); return (status); } rescCnt = getRescCnt (rescGrpInfo); if (rescCnt != 1) { rodsLog (LOG_ERROR, "rsPhyPathReg: The input resource is not unique for %s", phyPathRegInp->objPath); return (SYS_INVALID_RESC_TYPE); } if ((rescGroupName = getValByKey (&phyPathRegInp->condInput, RESC_GROUP_NAME_KW)) != NULL) { status = getRescInGrp (rsComm, rescGrpInfo->rescInfo->rescName, rescGroupName, &tmpRescInfo); if (status < 0) { rodsLog (LOG_ERROR, "rsPhyPathReg: resc %s not in rescGrp %s for %s", rescGrpInfo->rescInfo->rescName, rescGroupName, phyPathRegInp->objPath); return SYS_UNMATCHED_RESC_IN_RESC_GRP; } } memset (&addr, 0, sizeof (addr)); rstrcpy (addr.hostAddr, rescGrpInfo->rescInfo->rescLoc, LONG_NAME_LEN); remoteFlag = resolveHost (&addr, &rodsServerHost); if (remoteFlag == LOCAL_HOST) { status = _rsPhyPathReg (rsComm, phyPathRegInp, rescGrpInfo, rodsServerHost); } else if (remoteFlag == REMOTE_HOST) { status = remotePhyPathReg (rsComm, phyPathRegInp, rodsServerHost); } else { if (remoteFlag < 0) { return (remoteFlag); } else { rodsLog (LOG_ERROR, "rsPhyPathReg: resolveHost returned unrecognized value %d", remoteFlag); return (SYS_UNRECOGNIZED_REMOTE_FLAG); } } return (status); }