00001
00002
00003
00004
00005
00006 #include "fileChmod.h"
00007 #include "miscServerFunct.h"
00008
00009 int
00010 rsFileChmod (rsComm_t *rsComm, fileChmodInp_t *fileChmodInp)
00011 {
00012 rodsServerHost_t *rodsServerHost;
00013 int remoteFlag;
00014 int status;
00015
00016 remoteFlag = resolveHost (&fileChmodInp->addr, &rodsServerHost);
00017 if (remoteFlag == LOCAL_HOST) {
00018 status = _rsFileChmod (rsComm, fileChmodInp);
00019 } else if (remoteFlag == REMOTE_HOST) {
00020 status = remoteFileChmod (rsComm, fileChmodInp, rodsServerHost);
00021 } else {
00022 if (remoteFlag < 0) {
00023 return (remoteFlag);
00024 } else {
00025 rodsLog (LOG_NOTICE,
00026 "rsFileChmod: resolveHost returned unrecognized value %d",
00027 remoteFlag);
00028 return (SYS_UNRECOGNIZED_REMOTE_FLAG);
00029 }
00030 }
00031
00032
00033
00034 return (status);
00035 }
00036
00037 int
00038 remoteFileChmod (rsComm_t *rsComm, fileChmodInp_t *fileChmodInp,
00039 rodsServerHost_t *rodsServerHost)
00040 {
00041 int status;
00042
00043 if (rodsServerHost == NULL) {
00044 rodsLog (LOG_NOTICE,
00045 "remoteFileChmod: Invalid rodsServerHost");
00046 return SYS_INVALID_SERVER_HOST;
00047 }
00048
00049 if ((status = svrToSvrConnect (rsComm, rodsServerHost)) < 0) {
00050 return status;
00051 }
00052
00053
00054 status = rcFileChmod (rodsServerHost->conn, fileChmodInp);
00055
00056 if (status < 0) {
00057 rodsLog (LOG_NOTICE,
00058 "remoteFileOpen: rcFileChmod failed for %s",
00059 fileChmodInp->fileName);
00060 }
00061
00062 return status;
00063 }
00064
00065 int
00066 _rsFileChmod (rsComm_t *rsComm, fileChmodInp_t *fileChmodInp)
00067 {
00068 int status;
00069
00070 status = fileChmod (fileChmodInp->fileType, rsComm, fileChmodInp->fileName,
00071 fileChmodInp->mode);
00072
00073 if (status < 0) {
00074 rodsLog (LOG_NOTICE,
00075 "_rsFileChmod: fileChmod for %s, status = %d",
00076 fileChmodInp->fileName, status);
00077 return (status);
00078 }
00079
00080 return (status);
00081 }