00001
00002
00003
00004
00005
00006
00007
00008 #include "fileOpendir.h"
00009 #include "miscServerFunct.h"
00010 #include "rsGlobalExtern.h"
00011
00012
00013 int
00014 rsFileOpendir (rsComm_t *rsComm, fileOpendirInp_t *fileOpendirInp)
00015 {
00016 rodsServerHost_t *rodsServerHost;
00017 int remoteFlag;
00018 int fileInx;
00019 int status;
00020 void *dirPtr = NULL;
00021
00022 remoteFlag = resolveHost (&fileOpendirInp->addr, &rodsServerHost);
00023
00024 if (remoteFlag == LOCAL_HOST) {
00025 status = _rsFileOpendir (rsComm, fileOpendirInp, &dirPtr);
00026 } else if (remoteFlag == REMOTE_HOST) {
00027 status = remoteFileOpendir (rsComm, fileOpendirInp, rodsServerHost);
00028 } else {
00029 if (remoteFlag < 0) {
00030 return (remoteFlag);
00031 } else {
00032 rodsLog (LOG_NOTICE,
00033 "rsFileOpendir: resolveHost returned unrecognized value %d",
00034 remoteFlag);
00035 return (SYS_UNRECOGNIZED_REMOTE_FLAG);
00036 }
00037 }
00038
00039 if (status < 0) {
00040 return (status);
00041 }
00042
00043 fileInx = allocAndFillFileDesc (rodsServerHost, fileOpendirInp->dirName,
00044 fileOpendirInp->fileType, status, 0);
00045 FileDesc[fileInx].driverDep = dirPtr;
00046
00047 return (fileInx);
00048 }
00049
00050 int
00051 remoteFileOpendir (rsComm_t *rsComm, fileOpendirInp_t *fileOpendirInp,
00052 rodsServerHost_t *rodsServerHost)
00053 {
00054 int fileInx;
00055 int status;
00056
00057 if (rodsServerHost == NULL) {
00058 rodsLog (LOG_NOTICE,
00059 "remoteFileOpendir: Invalid rodsServerHost");
00060 return SYS_INVALID_SERVER_HOST;
00061 }
00062
00063 if ((status = svrToSvrConnect (rsComm, rodsServerHost)) < 0) {
00064 return status;
00065 }
00066
00067 fileInx = rcFileOpendir (rodsServerHost->conn, fileOpendirInp);
00068
00069 if (fileInx < 0) {
00070 rodsLog (LOG_NOTICE,
00071 "remoteFileOpendir: rcFileOpendir failed for %s",
00072 fileOpendirInp->dirName);
00073 }
00074
00075 return fileInx;
00076 }
00077
00078
00079
00080
00081 int
00082 _rsFileOpendir (rsComm_t *rsComm, fileOpendirInp_t *fileOpendirInp,
00083 void **dirPtr)
00084 {
00085 int status;
00086
00087
00088
00089
00090
00091 status = fileOpendir (fileOpendirInp->fileType, rsComm,
00092 fileOpendirInp->dirName, dirPtr);
00093
00094 if (status < 0) {
00095 rodsLog (LOG_NOTICE,
00096 "_rsFileOpendir: fileOpendir for %s, status = %d",
00097 fileOpendirInp->dirName, status);
00098 return (status);
00099 }
00100
00101 return (status);
00102 }
00103