portdat.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990
  1. /*
  2. * fundamental constants and types of the implementation
  3. * changing any of these changes the layout on disk
  4. */
  5. #define SUPER_ADDR 2 /* block address of superblock */
  6. #define ROOT_ADDR 3 /* block address of root directory */
  7. #ifdef OLD
  8. /*
  9. * compatible on disk with the old 32-bit file server.
  10. * this lets people run this kernel on their old file systems.
  11. */
  12. #define NAMELEN 28 /* max size of file name components */
  13. #define NDBLOCK 6 /* number of direct blocks in Dentry */
  14. #define NIBLOCK 2 /* max depth of indirect blocks */
  15. typedef long Off; /* file offsets & sizes, in bytes & blocks */
  16. #else /* OLD */
  17. /* the glorious new, incompatible (on disk) 64-bit world */
  18. /* keeping NAMELEN ≤ 50 bytes permits 3 Dentrys per mag disk sector */
  19. #define NAMELEN 56 /* max size of file name components */
  20. #define NDBLOCK 6 /* number of direct blocks in Dentry */
  21. #define NIBLOCK 4 /* max depth of indirect blocks */
  22. /*
  23. * file offsets & sizes, in bytes & blocks. typically long or vlong.
  24. * vlong is used in the code where would be needed if Off were just long.
  25. */
  26. typedef vlong Off;
  27. #endif /* OLD */
  28. /* constants that don't affect disk layout */
  29. #define MAXDAT 8192 /* max allowable data message */
  30. #define MAXMSG 128 /* max size protocol message sans data */
  31. #define OFFMSG 60 /* offset of msg in buffer */
  32. #define C0a 59 /* time constants for filters */
  33. #define C0b 60
  34. #define C1a 599
  35. #define C1b 600
  36. #define C2a 5999
  37. #define C2b 6000
  38. /* more fundamental types */
  39. typedef vlong Wideoff; /* type to widen Off to for printing; ≥ as wide as Off */
  40. typedef short Userid; /* signed internal representation of user-id */
  41. typedef long Timet; /* in seconds since epoch */
  42. typedef vlong Devsize; /* in bytes */
  43. /*
  44. * tunable parameters
  45. */
  46. enum {
  47. Maxword = 200, /* max bytes per command-line word */
  48. };
  49. #define NDRIVE 16 /* size of drive structure */
  50. #define NTLOCK 200 /* number of active file Tlocks */
  51. #define LRES 3 /* profiling resolution */
  52. #define NATTID 10 /* the last 10 ID's in attaches */
  53. /*
  54. * derived constants
  55. */
  56. #define BUFSIZE (RBUFSIZE-sizeof(Tag))
  57. #define DIRPERBUF (BUFSIZE/sizeof(Dentry))
  58. #define INDPERBUF (BUFSIZE/sizeof(Off))
  59. #define FEPERBUF ((BUFSIZE-sizeof(Super1)-sizeof(Off))/sizeof(Off))
  60. #define SMALLBUF (MAXMSG)
  61. #define LARGEBUF (MAXMSG+MAXDAT+256)
  62. #define RAGAP (300*1024)/BUFSIZE /* readahead parameter */
  63. #define CEPERBK ((BUFSIZE-BKPERBLK*sizeof(Off))/\
  64. (sizeof(Centry)*BKPERBLK))
  65. #define BKPERBLK 10
  66. typedef struct Alarm Alarm;
  67. typedef struct Auth Auth;
  68. typedef struct Conf Conf;
  69. typedef struct Label Label;
  70. typedef struct Lock Lock;
  71. typedef struct Mach Mach;
  72. typedef struct QLock QLock;
  73. typedef struct Ureg Ureg;
  74. typedef struct User User;
  75. typedef struct Fbuf Fbuf;
  76. typedef struct Super1 Super1;
  77. typedef struct Superb Superb;
  78. typedef struct Filsys Filsys;
  79. typedef struct Startsb Startsb;
  80. typedef struct Dentry Dentry;
  81. typedef struct Tag Tag;
  82. typedef struct Talarm Talarm;
  83. typedef struct Uid Uid;
  84. typedef struct Device Device;
  85. typedef struct Qid9p1 Qid9p1;
  86. typedef struct Iobuf Iobuf;
  87. typedef struct Wpath Wpath;
  88. typedef struct File File;
  89. typedef struct Chan Chan;
  90. typedef struct Cons Cons;
  91. typedef struct Time Time;
  92. typedef struct Tm Tm;
  93. typedef struct Rtc Rtc;
  94. typedef struct Hiob Hiob;
  95. typedef struct RWlock RWlock;
  96. typedef struct Msgbuf Msgbuf;
  97. typedef struct Queue Queue;
  98. typedef struct Command Command;
  99. typedef struct Flag Flag;
  100. typedef struct Bp Bp;
  101. typedef struct Rabuf Rabuf;
  102. typedef struct Rendez Rendez;
  103. typedef struct Filter Filter;
  104. typedef ulong Float;
  105. typedef struct Tlock Tlock;
  106. typedef struct Cache Cache;
  107. typedef struct Centry Centry;
  108. typedef struct Bucket Bucket;
  109. #pragma incomplete Auth
  110. #pragma incomplete Ureg
  111. struct Lock
  112. {
  113. ulong* sbsem; /* addr of sync bus semaphore */
  114. ulong pc;
  115. ulong sr;
  116. };
  117. struct Rendez
  118. {
  119. Lock;
  120. User* p;
  121. };
  122. struct Filter
  123. {
  124. ulong count; /* count and old count kept separate */
  125. ulong oldcount; /* so interrput can read them */
  126. int c1; /* time const multiplier */
  127. int c2; /* time const divider */
  128. int c3; /* scale for printing */
  129. Float filter; /* filter */
  130. };
  131. struct QLock
  132. {
  133. Lock; /* to use object */
  134. User* head; /* next process waiting for object */
  135. User* tail; /* last process waiting for object */
  136. char* name; /* for diagnostics */
  137. int locked; /* flag, is locked */
  138. };
  139. struct RWlock
  140. {
  141. int nread;
  142. QLock wr;
  143. QLock rd;
  144. };
  145. /*
  146. * send/recv queue structure
  147. */
  148. struct Queue
  149. {
  150. Lock; /* to manipulate values */
  151. int size; /* size of queue */
  152. int loc; /* circular pointer */
  153. int count; /* how many in queue */
  154. User* rhead; /* process's waiting for send */
  155. User* rtail;
  156. User* whead; /* process's waiting for recv */
  157. User* wtail;
  158. void* args[1]; /* list of saved pointers, [->size] */
  159. };
  160. struct Tag
  161. {
  162. short pad; /* make tag end at a long boundary */
  163. short tag;
  164. Off path;
  165. };
  166. struct Device
  167. {
  168. uchar type;
  169. uchar init;
  170. Device* link; /* link for mcat/mlev/mirror */
  171. Device* dlink; /* link all devices */
  172. void* private;
  173. Devsize size;
  174. union
  175. {
  176. struct /* wren, ide, (l)worm in targ */
  177. {
  178. int ctrl; /* disks only */
  179. int targ;
  180. int lun; /* wren only */
  181. } wren;
  182. struct /* mcat mlev mirror */
  183. {
  184. Device* first;
  185. Device* last;
  186. int ndev;
  187. } cat;
  188. struct /* cw */
  189. {
  190. Device* c; /* cache device */
  191. Device* w; /* worm device */
  192. Device* ro; /* dump - readonly */
  193. } cw;
  194. struct /* juke */
  195. {
  196. Device* j; /* (robotics, worm drives) - wrens */
  197. Device* m; /* (sides) - r or l devices */
  198. } j;
  199. struct /* ro */
  200. {
  201. Device* parent;
  202. } ro;
  203. struct /* fworm */
  204. {
  205. Device* fw;
  206. } fw;
  207. struct /* part */
  208. {
  209. Device* d;
  210. long base; /* percentages */
  211. long size;
  212. } part;
  213. struct /* byte-swapped */
  214. {
  215. Device* d;
  216. } swab;
  217. };
  218. };
  219. typedef struct Sidestarts {
  220. Devsize sstart; /* blocks before start of side */
  221. Devsize s1start; /* blocks before start of next side */
  222. } Sidestarts;
  223. struct Rabuf
  224. {
  225. union
  226. {
  227. struct
  228. {
  229. Device* dev;
  230. Off addr;
  231. };
  232. Rabuf* link;
  233. };
  234. };
  235. /* user-visible Qid, from <libc.h> */
  236. typedef
  237. struct Qid
  238. {
  239. uvlong path; /* Off */
  240. ulong vers; /* should be Off */
  241. uchar type;
  242. } Qid;
  243. /* bits in Qid.type */
  244. #define QTDIR 0x80 /* type bit for directories */
  245. #define QTAPPEND 0x40 /* type bit for append only files */
  246. #define QTEXCL 0x20 /* type bit for exclusive use files */
  247. #define QTMOUNT 0x10 /* type bit for mounted channel */
  248. #define QTAUTH 0x08 /* type bit for authentication file */
  249. #define QTFILE 0x00 /* plain file */
  250. /* DONT TOUCH, this is the disk structure */
  251. struct Qid9p1
  252. {
  253. Off path; /* was long */
  254. ulong version; /* should be Off */
  255. };
  256. struct Hiob
  257. {
  258. Iobuf* link;
  259. Lock;
  260. };
  261. struct Chan
  262. {
  263. char type; /* major driver type i.e. Dev* */
  264. int (*protocol)(Msgbuf*); /* version */
  265. int msize; /* version */
  266. char whochan[50];
  267. char whoname[NAMELEN];
  268. void (*whoprint)(Chan*);
  269. ulong flags;
  270. int chan; /* overall channel number, mostly for printing */
  271. int nmsgs; /* outstanding messages, set under flock -- for flush */
  272. Timet whotime;
  273. Filter work;
  274. Filter rate;
  275. int nfile; /* used by cmd_files */
  276. RWlock reflock;
  277. Chan* next; /* link list of chans */
  278. Queue* send;
  279. Queue* reply;
  280. uchar authinfo[64];
  281. void* ifc;
  282. void* pdata;
  283. };
  284. struct Filsys
  285. {
  286. char* name; /* name of filsys */
  287. char* conf; /* symbolic configuration */
  288. Device* dev; /* device that filsys is on */
  289. int flags;
  290. #define FREAM (1<<0) /* mkfs */
  291. #define FRECOVER (1<<1) /* install last dump */
  292. #define FEDIT (1<<2) /* modified */
  293. };
  294. struct Startsb
  295. {
  296. char* name;
  297. Off startsb;
  298. };
  299. struct Time
  300. {
  301. Timet lasttoy;
  302. Timet bias;
  303. Timet offset;
  304. };
  305. /*
  306. * array of qids that are locked
  307. */
  308. struct Tlock
  309. {
  310. Device* dev;
  311. Timet time;
  312. Off qpath;
  313. File* file;
  314. };
  315. struct Cons
  316. {
  317. ulong flags; /* overall flags for all channels */
  318. QLock; /* generic qlock for mutex */
  319. int uid; /* botch -- used to get uid on cons_create */
  320. int gid; /* botch -- used to get gid on cons_create */
  321. int nuid; /* number of uids */
  322. int ngid; /* number of gids */
  323. Off offset; /* used to read files, c.f. fchar */
  324. int chano; /* generator for channel numbers */
  325. Chan* chan; /* console channel */
  326. Filsys* curfs; /* current filesystem */
  327. int profile; /* are we profiling? */
  328. long* profbuf;
  329. ulong minpc;
  330. ulong maxpc;
  331. ulong nprofbuf;
  332. long nlarge; /* number of large message buffers */
  333. long nsmall; /* ... small ... */
  334. long nwormre; /* worm read errors */
  335. long nwormwe; /* worm write errors */
  336. long nwormhit; /* worm read cache hits */
  337. long nwormmiss; /* worm read cache non-hits */
  338. int noage; /* dont update cache age, dump and check */
  339. long nwrenre; /* disk read errors */
  340. long nwrenwe; /* disk write errors */
  341. long nreseq; /* cache bucket resequence */
  342. Filter work[3]; /* thruput in messages */
  343. Filter rate[3]; /* thruput in bytes */
  344. Filter bhit[3]; /* getbufs that hit */
  345. Filter bread[3]; /* getbufs that miss and read */
  346. Filter brahead[3]; /* messages to readahead */
  347. Filter binit[3]; /* getbufs that miss and dont read */
  348. };
  349. struct File
  350. {
  351. QLock;
  352. Qid qid;
  353. Wpath* wpath;
  354. Chan* cp; /* null means a free slot */
  355. Tlock* tlock; /* if file is locked */
  356. File* next; /* in cp->flist */
  357. Filsys* fs;
  358. Off addr;
  359. long slot; /* ordinal # of Dentry with a directory block */
  360. Off lastra; /* read ahead address */
  361. ulong fid;
  362. Userid uid;
  363. Auth *auth;
  364. char open;
  365. #define FREAD 1
  366. #define FWRITE 2
  367. #define FREMOV 4
  368. Off doffset; /* directory reading */
  369. ulong dvers;
  370. long dslot;
  371. };
  372. struct Wpath
  373. {
  374. Wpath* up; /* pointer upwards in path */
  375. Off addr; /* directory entry addr */
  376. long slot; /* directory entry slot */
  377. short refs; /* number of files using this structure */
  378. };
  379. struct Iobuf
  380. {
  381. QLock;
  382. Device* dev;
  383. Iobuf* fore; /* for lru */
  384. Iobuf* back; /* for lru */
  385. char* iobuf; /* only active while locked */
  386. char* xiobuf; /* "real" buffer pointer */
  387. Off addr;
  388. int flags;
  389. };
  390. struct Uid
  391. {
  392. Userid uid; /* user id */
  393. Userid lead; /* leader of group */
  394. Userid *gtab; /* group table */
  395. int ngrp; /* number of group entries */
  396. char name[NAMELEN]; /* user name */
  397. };
  398. /* DONT TOUCH, this is the disk structure */
  399. struct Dentry
  400. {
  401. char name[NAMELEN];
  402. Userid uid;
  403. Userid gid;
  404. ushort mode;
  405. #define DALLOC 0x8000
  406. #define DDIR 0x4000
  407. #define DAPND 0x2000
  408. #define DLOCK 0x1000
  409. #define DREAD 0x4
  410. #define DWRITE 0x2
  411. #define DEXEC 0x1
  412. Userid muid;
  413. Qid9p1 qid;
  414. Off size;
  415. Off dblock[NDBLOCK];
  416. Off iblocks[NIBLOCK];
  417. long atime;
  418. long mtime;
  419. };
  420. /* DONT TOUCH, this is the disk structure */
  421. struct Super1
  422. {
  423. Off fstart;
  424. Off fsize;
  425. Off tfree;
  426. Off qidgen; /* generator for unique ids */
  427. /*
  428. * Stuff for WWC device
  429. */
  430. Off cwraddr; /* cfs root addr */
  431. Off roraddr; /* dump root addr */
  432. Off last; /* last super block addr */
  433. Off next; /* next super block addr */
  434. #ifdef AUTOSWAB
  435. vlong magic; /* for byte-order detection */
  436. /* in memory only, not on disk (maybe) */
  437. int flags;
  438. #endif
  439. };
  440. /* DONT TOUCH, this is the disk structure */
  441. struct Fbuf
  442. {
  443. Off nfree;
  444. Off free[FEPERBUF];
  445. };
  446. /* DONT TOUCH, this is the disk structure */
  447. struct Superb
  448. {
  449. Fbuf fbuf;
  450. Super1;
  451. };
  452. struct Label
  453. {
  454. ulong pc;
  455. ulong sp;
  456. };
  457. struct Alarm
  458. {
  459. Lock;
  460. Alarm* next;
  461. int busy;
  462. int dt; /* in ticks */
  463. void (*f)(Alarm*, void*);
  464. void* arg;
  465. };
  466. struct Talarm
  467. {
  468. Lock;
  469. User *list;
  470. };
  471. struct Conf
  472. {
  473. ulong nmach; /* processors */
  474. ulong nproc; /* processes */
  475. ulong mem; /* total physical bytes of memory */
  476. ulong sparemem; /* memory left for check/dump and chans */
  477. ulong nalarm; /* alarms */
  478. ulong nuid; /* distinct uids */
  479. ulong nserve; /* server processes */
  480. ulong nfile; /* number of fid -- system wide */
  481. ulong nwpath; /* number of active paths, derived from nfile */
  482. ulong gidspace; /* space for gid names -- derived from nuid */
  483. ulong nlgmsg; /* number of large message buffers */
  484. ulong nsmmsg; /* number of small message buffers */
  485. Off recovcw; /* recover addresses */
  486. Off recovro;
  487. Off firstsb;
  488. Off recovsb;
  489. ulong nauth; /* number of Auth structs */
  490. uchar nodump; /* no periodic dumps */
  491. uchar ripoff;
  492. uchar dumpreread; /* read and compare in dump copy */
  493. short minuteswest; /* minutes west of Greenwich */
  494. short dsttime; /* dst correction */
  495. ulong npage0; /* total physical pages of memory */
  496. ulong npage1; /* total physical pages of memory */
  497. ulong base0; /* base of bank 0 */
  498. ulong base1; /* base of bank 1 */
  499. ulong idedma; /* flag: use DMA & RWM on IDE disks? */
  500. };
  501. /*
  502. * message buffers
  503. * 2 types, large and small
  504. */
  505. /* flags from cpu kernel; not implemented in fs kernel yet */
  506. enum {
  507. Bipck = (1<<6), /* ip checksum */
  508. Budpck = (1<<3), /* udp checksum */
  509. Btcpck = (1<<4), /* tcp checksum */
  510. Bpktck = (1<<5), /* packet checksum */
  511. };
  512. struct Msgbuf
  513. {
  514. short count;
  515. short flags;
  516. #define LARGE (1<<0)
  517. #define FREE (1<<1)
  518. #define BFREE (1<<2)
  519. #define BTRACE (1<<7)
  520. #define Mbrcvbuf (1<<15) /* to free, call (*free)(this) */
  521. Chan* chan;
  522. Msgbuf* next;
  523. ulong param;
  524. int category;
  525. uchar* data; /* rp or wp: current processing point */
  526. uchar* xdata; /* base of allocation */
  527. /* added for cpu kernel compatibility - geoff */
  528. void (*free)(Msgbuf *);
  529. };
  530. /*
  531. * message buffer categories
  532. */
  533. enum
  534. {
  535. Mxxx = 0,
  536. Mbreply1,
  537. Mbreply2,
  538. Mbreply3,
  539. Mbreply4,
  540. Mbarp1,
  541. Mbarp2,
  542. Mbip1,
  543. Mbip2,
  544. Mbip3,
  545. Mbil1,
  546. Mbil2,
  547. Mbil3,
  548. Mbil4,
  549. Mbilauth,
  550. Maeth1,
  551. Maeth2,
  552. Maeth3,
  553. Mbeth1,
  554. Mbeth2,
  555. Mbeth3,
  556. Mbeth4,
  557. Mbsntp,
  558. MAXCAT,
  559. };
  560. struct Mach
  561. {
  562. int machno; /* physical id of processor */
  563. int mmask; /* 1<<m->machno */
  564. Timet ticks; /* of the clock since boot time */
  565. int lights; /* light lights, this processor */
  566. User* proc; /* current process on this processor */
  567. Label sched; /* scheduler wakeup */
  568. Lock alarmlock; /* access to alarm list */
  569. void* alarm; /* alarms bound to this clock */
  570. void (*intr)(Ureg*, ulong); /* pending interrupt */
  571. User* intrp; /* process that was interrupted */
  572. ulong cause; /* arg to intr */
  573. Ureg* ureg; /* arg to intr */
  574. #ifdef CPU
  575. int loopconst;
  576. Lock apictimerlock;
  577. int cpumhz;
  578. uvlong cyclefreq; /* Frequency of user readable cycle counter */
  579. uvlong cpuhz;
  580. int cpuidax;
  581. int cpuiddx;
  582. char cpuidid[16];
  583. char* cpuidtype;
  584. int havetsc;
  585. int havepge;
  586. uvlong tscticks;
  587. #endif
  588. uchar stack[1];
  589. };
  590. #define MAXSTACK 16000
  591. #define NHAS 300
  592. struct User
  593. {
  594. Label sched;
  595. Mach* mach; /* machine running this proc */
  596. User* rnext; /* next process in run queue */
  597. User* qnext; /* next process on queue for a QLock */
  598. void (*start)(void); /* startup function */
  599. char* text; /* name of this process */
  600. void* arg;
  601. Filter time[3]; /* cpu time used */
  602. int exiting;
  603. int pid;
  604. int state;
  605. Rendez tsleep;
  606. Timet twhen;
  607. Rendez *trend;
  608. User *tlink;
  609. int (*tfn)(void*);
  610. struct
  611. {
  612. ulong pc[NHAS]; /* list of pcs for locks this process has */
  613. QLock* q[NHAS];/* list of locks this process has */
  614. QLock* want; /* lock waiting */
  615. } has;
  616. uchar stack[MAXSTACK];
  617. };
  618. #define PRINTSIZE 256
  619. struct
  620. {
  621. Lock;
  622. int machs;
  623. int exiting;
  624. } active;
  625. struct Command
  626. {
  627. char* arg0;
  628. char* help;
  629. void (*func)(int, char*[]);
  630. };
  631. struct Flag
  632. {
  633. char* arg0;
  634. char* help;
  635. ulong flag;
  636. };
  637. struct Tm
  638. {
  639. /* see ctime(3) */
  640. int sec;
  641. int min;
  642. int hour;
  643. int mday;
  644. int mon;
  645. int year;
  646. int wday;
  647. int yday;
  648. int isdst;
  649. };
  650. struct Rtc
  651. {
  652. int sec;
  653. int min;
  654. int hour;
  655. int mday;
  656. int mon;
  657. int year;
  658. };
  659. typedef struct
  660. {
  661. /* constants during a given truncation */
  662. Dentry *d;
  663. Iobuf *p; /* the block containing *d */
  664. int uid;
  665. Off newsize;
  666. Off lastblk; /* last data block of file to keep */
  667. /* variables */
  668. Off relblk; /* # of current data blk within file */
  669. int pastlast; /* have we walked past lastblk? */
  670. int err;
  671. } Truncstate;
  672. /*
  673. * cw device
  674. */
  675. /* DONT TOUCH, this is the disk structure */
  676. struct Cache
  677. {
  678. Off maddr; /* cache map addr */
  679. Off msize; /* cache map size in buckets */
  680. Off caddr; /* cache addr */
  681. Off csize; /* cache size */
  682. Off fsize; /* current size of worm */
  683. Off wsize; /* max size of the worm */
  684. Off wmax; /* highwater write */
  685. Off sbaddr; /* super block addr */
  686. Off cwraddr; /* cw root addr */
  687. Off roraddr; /* dump root addr */
  688. Timet toytime; /* somewhere convienent */
  689. Timet time;
  690. };
  691. /* DONT TOUCH, this is the disk structure */
  692. struct Centry
  693. {
  694. ushort age;
  695. short state;
  696. Off waddr; /* worm addr */
  697. };
  698. /* DONT TOUCH, this is the disk structure */
  699. struct Bucket
  700. {
  701. long agegen; /* generator for ages in this bkt */
  702. Centry entry[CEPERBK];
  703. };
  704. /*
  705. * scsi i/o
  706. */
  707. enum
  708. {
  709. SCSIread = 0,
  710. SCSIwrite = 1,
  711. };
  712. /*
  713. * Process states
  714. */
  715. enum
  716. {
  717. Dead = 0,
  718. Moribund,
  719. Zombie,
  720. Ready,
  721. Scheding,
  722. Running,
  723. Queueing,
  724. Sending,
  725. Recving,
  726. MMUing,
  727. Exiting,
  728. Inwait,
  729. Wakeme,
  730. Broken,
  731. };
  732. /*
  733. * Lights
  734. */
  735. enum
  736. {
  737. Lreal = 0, /* blink in clock interrupt */
  738. Lintr, /* on while in interrupt */
  739. Lpanic, /* in panic */
  740. Lcwmap, /* in cw lookup */
  741. };
  742. /*
  743. * devnone block numbers
  744. */
  745. enum
  746. {
  747. Cwio1 = 1,
  748. Cwio2,
  749. Cwxx1,
  750. Cwxx2,
  751. Cwxx3,
  752. Cwxx4,
  753. Cwdump1,
  754. Cwdump2,
  755. Cuidbuf,
  756. Cckbuf,
  757. };
  758. /*
  759. * error codes generated from the file server
  760. */
  761. enum
  762. {
  763. Ebadspc = 1,
  764. Efid,
  765. Echar,
  766. Eopen,
  767. Ecount,
  768. Ealloc,
  769. Eqid,
  770. Eaccess,
  771. Eentry,
  772. Emode,
  773. Edir1,
  774. Edir2,
  775. Ephase,
  776. Eexist,
  777. Edot,
  778. Eempty,
  779. Ebadu,
  780. Enoattach,
  781. Ewstatb,
  782. Ewstatd,
  783. Ewstatg,
  784. Ewstatl,
  785. Ewstatm,
  786. Ewstato,
  787. Ewstatp,
  788. Ewstatq,
  789. Ewstatu,
  790. Ewstatv,
  791. Ename,
  792. Ewalk,
  793. Eronly,
  794. Efull,
  795. Eoffset,
  796. Elocked,
  797. Ebroken,
  798. Eauth,
  799. Eauth2,
  800. Efidinuse,
  801. Etoolong,
  802. Econvert,
  803. Eversion,
  804. Eauthdisabled,
  805. Eauthnone,
  806. Eauthfile,
  807. Eedge,
  808. MAXERR
  809. };
  810. /*
  811. * device types
  812. */
  813. enum
  814. {
  815. Devnone = 0,
  816. Devcon, /* console */
  817. Devwren, /* scsi disk drive */
  818. Devworm, /* scsi video drive */
  819. Devlworm, /* scsi video drive (labeled) */
  820. Devfworm, /* fake read-only device */
  821. Devjuke, /* jukebox */
  822. Devcw, /* cache with worm */
  823. Devro, /* readonly worm */
  824. Devmcat, /* multiple cat devices */
  825. Devmlev, /* multiple interleave devices */
  826. Devil, /* internet link */
  827. Devpart, /* partition */
  828. Devfloppy, /* floppy drive */
  829. Devide, /* IDE drive */
  830. Devswab, /* swab data between mem and device */
  831. Devmirr, /* mirror devices */
  832. Devmarvsata, /* Marvell sata disk drive */
  833. MAXDEV
  834. };
  835. /*
  836. * tags on block
  837. */
  838. /* DONT TOUCH, this is in disk structures */
  839. /* also, the order from Tdir to Tind4 (Tmaxind) is exploited in indirck() */
  840. enum
  841. {
  842. Tnone = 0,
  843. Tsuper, /* the super block */
  844. #ifdef OLD
  845. Tdir, /* directory contents */
  846. Tind1, /* points to blocks */
  847. Tind2, /* points to Tind1 */
  848. #else
  849. Tdirold,
  850. Tind1old,
  851. Tind2old,
  852. #endif
  853. Tfile, /* file contents */
  854. Tfree, /* in free list */
  855. Tbuck, /* cache fs bucket */
  856. Tvirgo, /* fake worm virgin bits */
  857. Tcache, /* cw cache things */
  858. Tconfig, /* configuration block */
  859. #ifndef OLD
  860. /* Tdir & indirect blocks are last to allow for greater depth */
  861. Tdir, /* directory contents */
  862. Tind1, /* points to blocks */
  863. Tind2, /* points to Tind1 */
  864. Tind3, /* points to Tind2 */
  865. Tind4, /* points to Tind3 */
  866. Maxtind,
  867. #endif
  868. MAXTAG,
  869. #ifdef OLD
  870. Tmaxind = Tind2,
  871. #else
  872. Tmaxind = Maxtind - 1,
  873. #endif
  874. };
  875. /*
  876. * flags to getbuf
  877. */
  878. enum
  879. {
  880. Bread = (1<<0), /* read the block if miss */
  881. Bprobe = (1<<1), /* return null if miss */
  882. Bmod = (1<<2), /* buffer is dirty, needs writing */
  883. Bimm = (1<<3), /* write immediately on putbuf */
  884. Bres = (1<<4), /* reserved, never renamed */
  885. };
  886. extern register Mach* m;
  887. extern register User* u;
  888. extern Talarm talarm;
  889. Conf conf;
  890. Cons cons;
  891. #define MACHP(n) ((Mach*)(MACHADDR+n*BY2PG))
  892. #pragma varargck type "Z" Device*
  893. #pragma varargck type "T" Timet
  894. #pragma varargck type "I" uchar*
  895. #pragma varargck type "E" uchar*
  896. #pragma varargck type "W" Filter*
  897. #pragma varargck type "G" int
  898. extern int (*fsprotocol[])(Msgbuf*);
  899. extern Rendez dawnrend;