exportfs.h 2.4 KB

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