static int netHostChdir(char *path, struct hostent *hp) { char filename[MAXFILENAMELEN]; char *mp; if (AM_LAST || AM_NEVER) { if (chdir(usePath(path)) == 0) return(0); } if (strstr(path, "/net/") == path) return -1; if (strstr(path, "/tmp_mnt/") == path) return -1; if (hp == NULL) return -1; if ((mp=mountNet_(hp)) == NULL) return -1; sprintf(filename, "%s%s", mp, path); return (chdir(usePath(filename))); }
int mymkdir_ (char *filename, mode_t mode, struct hostent *hp) { char fnamebuf[MAXFILENAMELEN]; int i; char *mp; if (!hp || filename[0] != '/' || AM_NEVER) return (mkdir (usePath (filename), mode)); if (AM_LAST) if ((i = mkdir (usePath (filename), mode)) != -1) return i; if (strstr (filename, "/net/") == filename) return (mkdir (usePath (filename), mode)); if (strstr (filename, "/tmp_mnt/") == filename) return (mkdir (usePath (filename), mode)); if ((mp = mountNet_ (hp)) == NULL) return (mkdir (usePath (filename), mode)); sprintf (fnamebuf, "%s%s", mp, filename); i = mkdir (usePath (fnamebuf), mode); if (i >= 0) return i; return (mkdir (usePath (filename), mode)); }
FILE * myfopen_ (char *filename, char *type, struct hostent * hp) { char fnamebuf[MAXFILENAMELEN]; FILE *fp; char *mp; if (!hp || filename[0] != '/' || AM_NEVER) return (fopen (usePath (filename), type)); if (AM_LAST) if ((fp = fopen (usePath (filename), type)) != NULL) return fp; if (strstr (filename, "/net/") == filename) return (fopen (usePath (filename), type)); if (strstr (filename, "/tmp_mnt/") == filename) return (fopen (usePath (filename), type)); if ((mp = mountNet_ (hp)) == NULL) return (fopen (usePath (filename), type)); sprintf (fnamebuf, "%s%s", mp, filename); fp = fopen (usePath (fnamebuf), type); if (fp != NULL) return fp; return (fopen (usePath (filename), type)); }
void myexecv_(char *filename, char **argv, struct hostent *hp) { char fnamebuf[MAXFILENAMELEN]; char *mp; /*Bug#169, set hp to NULL to let the function do operation directly * and do not try /net and /tmp_mnt */ hp = NULL; if (!hp || filename[0] != '/' || AM_NEVER) { lsfExecv(usePath(filename), argv); return; } if (AM_LAST) { lsfExecv(usePath(filename), argv); return; } if (strstr(filename, "/net/") == filename) { lsfExecv(usePath(filename), argv); return; } if (strstr(filename, "/tmp_mnt/") ==filename) { lsfExecv(usePath(filename), argv); return; } if ((mp=mountNet_(hp)) == NULL) { lsfExecv(usePath(filename), argv); return; } sprintf(fnamebuf, "%s%s", mp, filename); lsfExecv(usePath(fnamebuf), argv); lsfExecv(usePath(filename), argv); }
void myexecv_ (char *filename, char **argv, struct hostent *hp) { char fnamebuf[MAXFILENAMELEN]; char *mp; if (!hp || filename[0] != '/' || AM_NEVER) { lsfExecv (usePath (filename), argv); return; } if (AM_LAST) { lsfExecv (usePath (filename), argv); return; } if (strstr (filename, "/net/") == filename) { lsfExecv (usePath (filename), argv); return; } if (strstr (filename, "/tmp_mnt/") == filename) { lsfExecv (usePath (filename), argv); return; } if ((mp = mountNet_ (hp)) == NULL) { lsfExecv (usePath (filename), argv); return; } sprintf (fnamebuf, "%s%s", mp, filename); lsfExecv (usePath (fnamebuf), argv); lsfExecv (usePath (filename), argv); }
int mymkdir_(char *filename, mode_t mode, struct hostent *hp) { char fnamebuf[MAXFILENAMELEN]; int i; char *mp; /*Bug#169, set hp to NULL to let the function do operation directly * and do not try /net and /tmp_mnt */ hp = NULL; if (!hp || filename[0] != '/' || AM_NEVER) return (mkdir(usePath(filename), mode)); if (AM_LAST) if ((i=mkdir(usePath(filename), mode)) != -1) return i; if (strstr(filename, "/net/") == filename) return (mkdir(usePath(filename), mode)); if (strstr(filename, "/tmp_mnt/") == filename) return (mkdir(usePath(filename), mode)); if ((mp=mountNet_(hp)) == NULL) return (mkdir(usePath(filename), mode)); sprintf(fnamebuf, "%s%s", mp, filename); i = mkdir(usePath(fnamebuf), mode); if (i>=0) return i; return (mkdir(usePath(filename), mode)); }
FILE * myfopen_(char *filename, char *type, struct hostent *hp) { char fnamebuf[MAXFILENAMELEN]; FILE *fp; char *mp; /*Bug#169, set hp to NULL to let the function do operation directly * and do not try /net and /tmp_mnt */ hp = NULL; if (!hp || filename[0] != '/' || AM_NEVER) return (fopen(usePath(filename), type)); if (AM_LAST) if ((fp = fopen(usePath(filename),type)) != NULL) return fp; if (strstr(filename, "/net/") == filename) return (fopen(usePath(filename), type)); if (strstr(filename, "/tmp_mnt/") ==filename) return (fopen(usePath(filename), type)); if ((mp = mountNet_(hp)) == NULL) return (fopen(usePath(filename), type)); sprintf(fnamebuf, "%s%s", mp, filename); fp = fopen(usePath(fnamebuf), type); if (fp != NULL) return fp; return (fopen(usePath(filename), type)); }
int myunlink_(char *filename, struct hostent *hp, int doMount) { char fnamebuf[MAXFILENAMELEN]; int i; char *mp; /*Bug#169, set hp to NULL to let the function do operation directly * and do not try /net and /tmp_mnt */ hp = NULL; if (!hp || filename[0] != '/' || AM_NEVER) return (unlink(usePath(filename))); if (AM_LAST) if ((i=unlink(usePath(filename))) != -1) return(1); if(doMount) { if (strstr(filename, "/net/") == filename) return (unlink(usePath(filename))); if (strstr(filename, "/tmp_mnt/") ==filename) return (unlink(usePath(filename))); if ((mp=mountNet_(hp)) == NULL) { return (1); } sprintf(fnamebuf, "%s%s", mp, filename); i = unlink(usePath(fnamebuf)); if (i>=0) return i; } return (unlink(usePath(filename))); }
int myunlink_ (char *filename, struct hostent *hp, int doMount) { char fnamebuf[MAXFILENAMELEN]; int i; char *mp; if (!hp || filename[0] != '/' || AM_NEVER) return (unlink (usePath (filename))); if (AM_LAST) if ((i = unlink (usePath (filename))) != -1) return (1); if (doMount) { if (strstr (filename, "/net/") == filename) return (unlink (usePath (filename))); if (strstr (filename, "/tmp_mnt/") == filename) return (unlink (usePath (filename))); if ((mp = mountNet_ (hp)) == NULL) { return (1); } sprintf (fnamebuf, "%s%s", mp, filename); i = unlink (usePath (fnamebuf)); if (i >= 0) return i; } return (unlink (usePath (filename))); }
int mychdir_(char *path, struct hostent *hp) { char *goodpath = path; char *sp = NULL; sTab hashSearchPtr; hEnt *hashEntryPtr; static char first = TRUE; char filename[MAXPATHLEN]; /*Bug#169, set hp to NULL to let the function do operation directly * and do not try /net and /tmp_mnt */ hp = NULL; if (path == NULL || strlen(path) == 0 || path[0] != '/' || AM_NEVER) return (chdir(usePath(path))); if (hp != NULL) if (netHostChdir(path, hp) == 0) return 0; if (strstr(path, "/tmp_mnt" ) == path) { sp = path + strlen("/tmp_mnt"); if (chdir(usePath(sp)) == 0) return 0; } else { if (chdir(usePath(path)) == 0) return 0; } if (errno != ENOENT && errno != ENOTDIR) return -1; if (getcwd(filename, sizeof(filename)) == NULL) goto try; sp = getenv("HOME"); if (sp != NULL) chdir(sp); chdir(filename); try: if (path[0] != '/') return -1; if ((goodpath=strstr(path,"/exp/lsf")) != NULL) { if (chdir(usePath(goodpath)) == 0) return 0; } if (strstr(path, "/tmp_mnt" ) == path) { goodpath = path + strlen("/tmp_mnt"); } else { if (chdir(usePath(path)) ==0) return 0; sp = getenv("PWD"); if (tryPwd(path, sp) == 0) return 0; } if (goodpath == NULL) goodpath = strchr(path+1, '/'); else goodpath = strchr(goodpath+1, '/'); if (goodpath != NULL) { if (chdir(usePath(goodpath)) == 0) return 0; } else { return -1; } if (first) { first = FALSE; if (getMap_() != 0) return -1; } hashEntryPtr = h_firstEnt_(&hashTab, &hashSearchPtr); if (hashEntryPtr == NULL) { errno = ENOENT; return -1; } while (hashEntryPtr != NULL) { sprintf(filename, "%s%s", hashEntryPtr->keyname, goodpath); if (chdir(usePath(filename)) == 0) return 0; hashEntryPtr = h_nextEnt_(&hashSearchPtr); } goodpath = strchr(goodpath+1, '/'); if (goodpath == NULL) { return -1; } hashEntryPtr = h_firstEnt_(&hashTab, &hashSearchPtr); while (hashEntryPtr != NULL) { sprintf(filename, "%s%s", hashEntryPtr->keyname, goodpath); if (chdir(usePath(filename)) == 0) return 0; hashEntryPtr = h_nextEnt_(&hashSearchPtr); } if (chdir(usePath(goodpath)) == 0) return 0; if ( strstr(path, "/tmp_mnt" ) != path) return -1; goodpath = path + strlen("/tmp_mnt"); if (*goodpath == '\0') return -1; strcpy(filename, goodpath); sp = strchr(filename+1, '/'); if (sp == NULL) return -1; goodpath = strchr(sp+1, '/'); if (goodpath == NULL) return -1; if ((sp = strchr(goodpath+1, '/')) == NULL) return -1; *goodpath = '\0'; strcat(filename, sp); if (chdir(usePath(filename)) ==0) return 0; if ((sp = strchr(goodpath+1, '/')) == NULL) return (-1); *goodpath = '\0'; strcat(filename, sp); if (chdir(usePath(filename)) ==0) return 0; if (chdir(usePath(path)) == 0) return 0; return -1; } static int tryPwd(char *path, char *pwdpath) { char *PA, *PAPB, *pa, *pb, *pc, *sp1; char filename[MAXFILENAMELEN]; if (pwdpath == NULL) return -1; if (strcmp(pwdpath, "/") == 0) return -1; strcpy(filename, pwdpath); sp1 = strchr(filename+1, '/'); if (sp1 != NULL) *sp1 = '\0'; PA = putstr_(filename); strcpy(filename, pwdpath); if (sp1 != NULL) { sp1 = strchr(sp1+1, '/'); if (sp1 != NULL) *sp1 = '\0'; } PAPB = putstr_(filename); pa = path; pb = strchr(path+1, '/'); if (pb == NULL) pb = pa; pc = strchr(pb+1, '/'); if (pc == NULL) pc = pb; strcpy(filename, PA); strcat(filename, pa); if (chdir(usePath(filename)) == 0) { free(PA); free(PAPB); return 0; } strcpy(filename, PA); strcat(filename, pb); if (chdir(usePath(filename)) == 0) { free(PA); free(PAPB); return 0; } strcpy(filename, PAPB); strcat(filename, pc); if (chdir(usePath(filename)) == 0) { free(PA); free(PAPB); return 0; } strcpy(filename, PAPB); strcat(filename, pb); if (chdir(usePath(filename)) == 0) { free(PA); free(PAPB); return 0; } free(PA); free(PAPB); return -1; }