#include #include #include "mount.h" #include "fhandle.h" #define MAXFH 2048 FH entries = 0; FtpFhStruct list[MAXFH]; // Get an FH out of the NFS file handle FH GETFH(char *a) { FH ret; memcpy (&ret, a, sizeof (FH)); return ret; } void COPYFH(char *a, char *b) { memcpy(a,b,sizeof (FH)); } void SETFH(char *a,int b) { memcpy(a,&(b),sizeof (FH)); } // Return the FtpFh structure given a FH. FtpFh GetFtpFh(FH fh) { static int startflag = 0; char * uname; printf("\tGetFtpFh: fh: %d\n", fh); if (fh < 0) { fh = - (fh + 1); if (fh < rootentries) { uname = ConnList_GetUsername(rootlist[fh].connlist, rootlist[fh].connindex); printf("user name: %s\n", uname); return rootlist+fh; } printf("Error fh greater than rootentries %d\n", rootentries); return NULL; } if (fh > entries) { printf("Error fh greater than entries %d\n", entries); return NULL; } if (list[fh%MAXFH].fh != fh) { printf("Error fh doesn't match index\n"); return NULL; } uname = ConnList_GetUsername(list[fh%MAXFH].connlist, list[fh%MAXFH].connindex); return list+(fh%MAXFH); } // Make a new file handle. FtpFh CreateFtpFh(char *name, FtpFh dirftpfh) { FtpFh ret = list + (entries % MAXFH); printf("\tCreateFtpFh: name: %s dirftpfh: %d\n", name, dirftpfh); if (strlen(dirftpfh->fullpath)) sprintf(ret->fullpath,"%s/%s", dirftpfh->fullpath, name); else sprintf(ret->fullpath,"%s", name); ret->fh = entries % MAXFH; ret->connlist = dirftpfh->connlist; ret->connindex = dirftpfh->connindex; ret->root = dirftpfh; ret->valid = 1; entries++; return ret; }