ratfs.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. #include <u.h>
  10. #include <libc.h>
  11. #include <auth.h>
  12. #include <fcall.h>
  13. #include <bio.h>
  14. enum {
  15. MAXRPC = 8192,
  16. Qroot = 1, /* fixed QID's */
  17. Qallow,
  18. Qdelay,
  19. Qblock,
  20. Qdial,
  21. Qdeny,
  22. Qtrusted,
  23. Qctl,
  24. Qdummy,
  25. Qaddr, /* Qid's for "ip" & "account" subdirs (Qaddr-99) */
  26. Qtrustedfile = 100, /* Qid's for trusted files (100-999)*/
  27. Qaddrfile = 1000, /* Qid's for address files (> 1000) */
  28. /* type codes in node.d.type */
  29. Directory = 0, /* normal directory */
  30. Addrdir, /* contains "ip" and "account" directories */
  31. IPaddr, /* contains IP address "files" */
  32. Acctaddr, /* contains Account address "files" */
  33. Trusted, /* contains trusted IP files */
  34. Trustedperm, /* permanently trusted IP pseudo-file */
  35. Trustedtemp, /* temporarily trusted IP pseudo-file */
  36. Ctlfile, /* ctl file under root */
  37. Dummynode, /* place holder for Address pseudo-files */
  38. };
  39. typedef struct Fid Fid;
  40. typedef struct Node Node;
  41. typedef struct Address Address;
  42. typedef struct Cidraddr Cidraddr;
  43. typedef struct Keyword Keyword;
  44. /* an active fid */
  45. struct Fid
  46. {
  47. int fid;
  48. int dirindex;
  49. Node *node; /* current position in path */
  50. int busy;
  51. int open; /* directories only */
  52. char *name;
  53. char *uid;
  54. Fid *next;
  55. };
  56. struct Cidraddr
  57. {
  58. uint32_t ipaddr; /* CIDR base addr */
  59. uint32_t mask; /* CIDR mask */
  60. };
  61. /* an address is either an account name (domain!user) or Ip address */
  62. struct Address
  63. {
  64. char *name; /* from the control file */
  65. Cidraddr ip; /* CIDR Address */
  66. };
  67. /* Fids point to either a directory or pseudo-file */
  68. struct Node
  69. {
  70. Dir d; /* d.name, d.uid, d.gid, d.muid are atoms */
  71. int count;
  72. int allocated; /* number of Address structs allocated */
  73. uint32_t baseqid; /* base of Qid's in this set */
  74. Node *parent; /* points to self in root node*/
  75. Node *sibs; /* 0 in Ipaddr and Acctaddr dirs */
  76. union {
  77. Node *children; /* type == Directory || Addrdir || Trusted */
  78. Address *addrs; /* type == Ipaddr || Acctaddr */
  79. Cidraddr ip; /* type == Trustedfile */
  80. };
  81. };
  82. struct Keyword {
  83. char *name;
  84. int code;
  85. };
  86. Node *root; /* root of directory tree */
  87. Node dummy; /* dummy node for fid's pointing to an Address */
  88. int srvfd; /* fd for 9fs */
  89. uchar rbuf[IOHDRSZ+MAXRPC+1];
  90. int debugfd;
  91. char *ctlfile;
  92. char *conffile;
  93. long lastconftime;
  94. long lastctltime;
  95. int trustedqid;
  96. char* atom(char*);
  97. void cidrparse(Cidraddr*, char*);
  98. void cleantrusted(void);
  99. Node* dirwalk(char*, Node*);
  100. int dread(Fid*, int);
  101. void fatal(char*, ...);
  102. Node* finddir(int);
  103. int findkey(char*, Keyword*);
  104. void getconf(void);
  105. int hread(Fid*, int);
  106. void io(void);
  107. Node* newnode(Node*, char*, ushort, int, uint32_t);
  108. void printfid(Fid*);
  109. void printnode(Node*);
  110. void printtree(Node*);
  111. void reload(void);
  112. char* subslash(char*);
  113. char* walk(char*, Fid*);