1 /* 2 * exportfs.h - definitions for exporting file server 3 */ 4 5 #define DEBUG if(!dbg){}else fprint 6 #define DFD 9 7 #define fidhash(s) fhash[s%FHASHSIZE] 8 9 typedef struct Fsrpc Fsrpc; 10 typedef struct Fid Fid; 11 typedef struct File File; 12 typedef struct Proc Proc; 13 typedef struct Qidtab Qidtab; 14 15 struct Fsrpc 16 { 17 int busy; /* Work buffer has pending rpc to service */ 18 int pid; /* Pid of slave process executing the rpc */ 19 int canint; /* Interrupt gate */ 20 int flushtag; /* Tag on which to reply to flush */ 21 Fcall work; /* Plan 9 incoming Fcall */ 22 uchar *buf; /* Data buffer */ 23 }; 24 25 struct Fid 26 { 27 int fid; /* system fd for i/o */ 28 File *f; /* File attached to this fid */ 29 int mode; 30 int nr; /* fid number */ 31 int mid; /* Mount id */ 32 Fid *next; /* hash link */ 33 }; 34 35 struct File 36 { 37 char *name; 38 int ref; 39 Qid qid; 40 Qidtab *qidt; 41 int inval; 42 File *parent; 43 File *child; 44 File *childlist; 45 }; 46 47 struct Proc 48 { 49 int pid; 50 int busy; 51 Proc *next; 52 }; 53 54 struct Qidtab 55 { 56 int ref; 57 int type; 58 int dev; 59 vlong path; 60 vlong uniqpath; 61 Qidtab *next; 62 }; 63 64 enum 65 { 66 MAXPROC = 50, 67 FHASHSIZE = 64, 68 Nr_workbufs = 50, 69 Fidchunk = 1000, 70 Npsmpt = 32, 71 Nqidbits = 5, 72 Nqidtab = (1<<Nqidbits), 73 }; 74 75 char Ebadfid[]; 76 char Enotdir[]; 77 char Edupfid[]; 78 char Eopen[]; 79 char Exmnt[]; 80 char Enomem[]; 81 char Emip[]; 82 char Enopsmt[]; 83 84 Extern Fsrpc *Workq; 85 Extern int dbg; 86 Extern File *root; 87 Extern File *psmpt; 88 Extern Fid **fhash; 89 Extern Fid *fidfree; 90 Extern Proc *Proclist; 91 Extern char psmap[Npsmpt]; 92 Extern Qidtab *qidtab[Nqidtab]; 93 Extern ulong messagesize; 94 Extern char Enomem[]; 95 Extern int srvfd; 96 97 /* File system protocol service procedures */ 98 void Xattach(Fsrpc*); 99 void Xauth(Fsrpc*); 100 void Xclunk(Fsrpc*); 101 void Xcreate(Fsrpc*); 102 void Xflush(Fsrpc*); 103 void Xnop(Fsrpc*); 104 void Xremove(Fsrpc*); 105 void Xstat(Fsrpc*); 106 void Xversion(Fsrpc*); 107 void Xwalk(Fsrpc*); 108 void Xwstat(Fsrpc*); 109 void slave(Fsrpc*); 110 111 void reply(Fcall*, Fcall*, char*); 112 Fid *getfid(int); 113 int freefid(int); 114 Fid *newfid(int); 115 Fsrpc *getsbuf(void); 116 void initroot(void); 117 void fatal(char*, ...); 118 char* makepath(File*, char*); 119 File *file(File*, char*); 120 void freefile(File*); 121 void slaveopen(Fsrpc*); 122 void slaveread(Fsrpc*); 123 void slavewrite(Fsrpc*); 124 void blockingslave(void); 125 void reopen(Fid *f); 126 void noteproc(int, char*); 127 void flushaction(void*, char*); 128 void pushfcall(char*); 129 Qidtab* uniqueqid(Dir*); 130 void freeqid(Qidtab*); 131 char* estrdup(char*); 132 void* emallocz(uint); 133 int readmessage(int, char*, int); 134