dat.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. typedef struct Chan Chan;
  2. typedef struct Command Command;
  3. typedef struct Conf Conf;
  4. typedef struct Cons Cons;
  5. typedef struct Devcall Devcall;
  6. #define MAXBUFSIZE (16*1024) /* max. buffer size */
  7. #include "portdat.h"
  8. struct Chan
  9. {
  10. int chan; /* fd request came in on */
  11. QLock rlock, wlock; /* lock for reading/writing messages on chan */
  12. int type;
  13. int flags;
  14. long whotime;
  15. File* flist; /* base of file structures */
  16. Lock flock; /* manipulate flist */
  17. RWLock reflock; /* lock for Tflush */
  18. int msize; /* version */
  19. int authed; /* someone other than ``none'' has authed */
  20. /* 9p1 auth */
  21. uchar chal[8];
  22. uchar rchal[8];
  23. int idoffset;
  24. int idvec;
  25. Lock idlock;
  26. };
  27. /*
  28. * console cons.flag flags
  29. */
  30. enum
  31. {
  32. Fchat = (1<<0), /* print out filesys rpc traffic */
  33. Fuid = (1<<2), /* print out uids */
  34. /* debugging flags for drivers */
  35. };
  36. struct Cons
  37. {
  38. int flags; /* overall flags for all channels */
  39. int uid; /* botch -- used to get uid on cons_create */
  40. int gid; /* botch -- used to get gid on cons_create */
  41. int allow; /* no-protection flag */
  42. long offset; /* used to read files, c.f. fchar */
  43. char* arg; /* pointer to remaining line */
  44. Chan *chan; /* console channel */
  45. Chan *srvchan; /* local server channel */
  46. Filter work; /* thruput in messages */
  47. Filter rate; /* thruput in bytes */
  48. Filter bhit; /* getbufs that hit */
  49. Filter bread; /* getbufs that miss and read */
  50. Filter binit; /* getbufs that miss and dont read */
  51. Filter tags[MAXTAG]; /* reads of each type of block */
  52. };
  53. struct Conf
  54. {
  55. ulong niobuf; /* number of iobufs to allocate */
  56. ulong nuid; /* distinct uids */
  57. ulong uidspace; /* space for uid names -- derrived from nuid */
  58. ulong gidspace; /* space for gid names -- derrived from nuid */
  59. ulong nserve; /* server processes */
  60. ulong nfile; /* number of fid -- system wide */
  61. ulong nwpath; /* number of active paths, derrived from nfile */
  62. ulong bootsize; /* number of bytes reserved for booting */
  63. };
  64. struct Command
  65. {
  66. char *string;
  67. void (*func)(void);
  68. char *args;
  69. };
  70. struct Devcall
  71. {
  72. void (*init)(Device);
  73. void (*ream)(Device);
  74. int (*check)(Device);
  75. long (*super)(Device);
  76. long (*root)(Device);
  77. long (*size)(Device);
  78. int (*read)(Device, long, void*);
  79. int (*write)(Device, long, void*);
  80. };
  81. /*
  82. * device types
  83. */
  84. enum
  85. {
  86. Devnone = 0,
  87. Devwren,
  88. MAXDEV
  89. };
  90. /*
  91. * file systems
  92. */
  93. enum
  94. {
  95. MAXFILSYS = 4
  96. };
  97. /*
  98. * should be in portdat.h
  99. */
  100. #define QPDIR 0x80000000L
  101. #define QPNONE 0
  102. #define QPROOT 1
  103. #define QPSUPER 2
  104. /*
  105. * perm argument in p9 create
  106. */
  107. #define PDIR (1L<<31) /* is a directory */
  108. #define PAPND (1L<<30) /* is append only */
  109. #define PLOCK (1L<<29) /* is locked on open */
  110. #define NOF (-1)
  111. #define FID1 1
  112. #define FID2 2
  113. #define FID3 3
  114. #define SECOND(n) (n)
  115. #define MINUTE(n) (n*SECOND(60))
  116. #define HOUR(n) (n*MINUTE(60))
  117. #define DAY(n) (n*HOUR(24))
  118. #define TLOCK MINUTE(5)
  119. #define CHAT(cp) (chat)
  120. #define QID9P1(a,b) (Qid9p1){a,b}
  121. extern Uid* uid;
  122. extern char* uidspace;
  123. extern short* gidspace;
  124. extern char* errstring[MAXERR];
  125. extern Chan* chans;
  126. extern RWLock mainlock;
  127. extern long boottime;
  128. extern Tlock *tlocks;
  129. extern Device devnone;
  130. extern Filsys filesys[];
  131. extern char service[];
  132. extern char* tagnames[];
  133. extern Conf conf;
  134. extern Cons cons;
  135. extern Command command[];
  136. extern Chan *chan;
  137. extern Devcall devcall[];
  138. extern char *progname;
  139. extern char *procname;
  140. extern long niob;
  141. extern long nhiob;
  142. extern Hiob *hiob;
  143. extern int chat;
  144. extern int writeallow;
  145. extern int wstatallow;
  146. extern int allownone;
  147. extern int noatime;
  148. extern int writegroup;
  149. extern Lock wpathlock;