1 #pragma src "/sys/src/lib9p"
5 * Maps from ulongs to void*s.
7 typedef struct Intmap Intmap;
9 #pragma incomplete Intmap
11 Intmap* allocmap(void (*inc)(void*));
12 void freemap(Intmap*, void (*destroy)(void*));
13 void* lookupkey(Intmap*, ulong);
14 void* insertkey(Intmap*, ulong, void*);
15 int caninsertkey(Intmap*, ulong, void*);
16 void* deletekey(Intmap*, ulong);
19 * Fid and Request structures.
21 typedef struct Fid Fid;
22 typedef struct Req Req;
23 typedef struct Fidpool Fidpool;
24 typedef struct Reqpool Reqpool;
25 typedef struct File File;
26 typedef struct Filelist Filelist;
27 typedef struct Tree Tree;
28 typedef struct Readdir Readdir;
29 typedef struct Srv Srv;
30 typedef struct Reqqueue Reqqueue;
31 typedef struct Queueelem Queueelem;
33 #pragma incomplete Filelist
34 #pragma incomplete Readdir
38 Queueelem *prev, *next;
54 char omode; /* -1 = not open */
60 /* below is implementation-specific; don't use */
83 /* below is implementation-specific; don't use */
97 * Pools to maintain Fid <-> fid and Req <-> tag maps.
102 void (*destroy)(Fid*);
108 void (*destroy)(Req*);
112 Fidpool* allocfidpool(void (*destroy)(Fid*));
113 void freefidpool(Fidpool*);
114 Fid* allocfid(Fidpool*, ulong);
115 Fid* lookupfid(Fidpool*, ulong);
117 Fid* removefid(Fidpool*, ulong);
119 Reqpool* allocreqpool(void (*destroy)(Req*));
120 void freereqpool(Reqpool*);
121 Req* allocreq(Reqpool*, ulong);
122 Req* lookupreq(Reqpool*, ulong);
124 Req* removereq(Reqpool*, ulong);
126 typedef int Dirgen(int, Dir*, void*);
127 void dirread9p(Req*, Dirgen*, void*);
138 /* below is implementation-specific; don't use */
150 void (*destroy)(File *file);
152 /* below is implementation-specific; don't use */
157 Tree* alloctree(char*, char*, ulong, void(*destroy)(File*));
158 void freetree(Tree*);
159 File* createfile(File*, char*, char*, ulong, void*);
160 int removefile(File*);
161 void closefile(File*);
162 File* walkfile(File*, char*);
163 Readdir* opendirfile(File*);
164 long readdirfile(Readdir*, uchar*, long, long);
165 void closedirfile(Readdir*);
168 * Kernel-style command parser
170 typedef struct Cmdbuf Cmdbuf;
171 typedef struct Cmdtab Cmdtab;
172 Cmdbuf* parsecmd(char *a, int n);
173 void respondcmderror(Req*, Cmdbuf*, char*, ...);
174 Cmdtab* lookupcmd(Cmdbuf*, Cmdtab*, int);
175 #pragma varargck argpos respondcmderr 3
185 int index; /* used by client to switch on result */
186 char *cmd; /* command name */
187 int narg; /* expected #args; 0 ==> variadic */
195 void (*destroyfid)(Fid*);
196 void (*destroyreq)(Req*);
201 void (*attach)(Req*);
204 void (*create)(Req*);
207 void (*remove)(Req*);
212 char* (*clone)(Fid*, Fid*);
213 char* (*walk1)(Fid*, char*, Qid*);
220 /* below is implementation-specific; don't use */
233 Ref sref; /* srvwork procs */
234 Ref rref; /* requests in flight */
236 int spid; /* pid of srv() caller */
238 void (*forker)(void (*)(void*), void*, int);
242 void srvforker(void (*)(void*), void*, int);
243 void threadsrvforker(void (*)(void*), void*, int);
246 void postsrv(Srv*, char*);
247 void postmountsrv(Srv*, char*, char*, int);
248 void postsharesrv(Srv*, char*, char*, char*);
249 void listensrv(Srv*, char*);
251 void threadsrv(Srv*);
252 void threadpostsrv(Srv*, char*);
253 void threadpostmountsrv(Srv*, char*, char*, int);
254 void threadpostsharesrv(Srv*, char*, char*, char*);
255 void threadlistensrv(Srv *s, char *addr);
258 void respond(Req*, char*);
259 void responderror(Req*);
262 * Helper. Assumes user is same as group.
264 int hasperm(File*, char*, int);
266 void* emalloc9p(ulong);
267 void* erealloc9p(void*, ulong);
268 char* estrdup9p(char*);
274 void readstr(Req*, char*);
275 void readbuf(Req*, void*, long);
276 void walkandclone(Req*, char*(*walk1)(Fid*,char*,void*),
277 char*(*clone)(Fid*,Fid*,void*), void*);
281 void authwrite(Req*);
282 void authdestroy(Fid*);
283 int authattach(Req*);
285 void srvacquire(Srv *);
286 void srvrelease(Srv *);
288 Reqqueue* reqqueuecreate(void);
289 void reqqueuepush(Reqqueue*, Req*, void (*)(Req *));
290 void reqqueueflush(Reqqueue*, Req*);
291 void reqqueuefree(Reqqueue*);