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