dat.h 4.0 KB

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