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