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 */
158 Tree* alloctree(char*, char*, ulong, void(*destroy)(File*));
159 void freetree(Tree*);
160 File* createfile(File*, char*, char*, ulong, void*);
161 int removefile(File*);
162 void closefile(File*);
163 File* walkfile(File*, char*);
164 Readdir* opendirfile(File*);
165 long readdirfile(Readdir*, uchar*, long);
166 void closedirfile(Readdir*);
169 * Kernel-style command parser
171 typedef struct Cmdbuf Cmdbuf;
172 typedef struct Cmdtab Cmdtab;
173 Cmdbuf* parsecmd(char *a, int n);
174 void respondcmderror(Req*, Cmdbuf*, char*, ...);
175 Cmdtab* lookupcmd(Cmdbuf*, Cmdtab*, int);
176 #pragma varargck argpos respondcmderr 3
186 int index; /* used by client to switch on result */
187 char *cmd; /* command name */
188 int narg; /* expected #args; 0 ==> variadic */
196 void (*destroyfid)(Fid*);
197 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*);
219 int leavefdsopen; /* magic for acme win */
222 /* below is implementation-specific; don't use */
239 void postmountsrv(Srv*, char*, char*, int);
240 void _postmountsrv(Srv*, char*, char*, int);
241 void postsharesrv(Srv*, char*, char*, char*);
242 void _postsharesrv(Srv*, char*, char*, char*);
243 void listensrv(Srv*, char*);
244 void _listensrv(Srv*, char*);
245 int postfd(char*, int);
246 int sharefd(char*, char*, int);
248 void respond(Req*, char*);
249 void responderror(Req*);
250 void threadpostmountsrv(Srv*, char*, char*, int);
251 void threadpostsharesrv(Srv*, char*, char*, char*);
252 void threadlistensrv(Srv *s, char *addr);
255 * Helper. Assumes user is same as group.
257 int hasperm(File*, char*, int);
259 void* emalloc9p(ulong);
260 void* erealloc9p(void*, ulong);
261 char* estrdup9p(char*);
267 void readstr(Req*, char*);
268 void readbuf(Req*, void*, long);
269 void walkandclone(Req*, char*(*walk1)(Fid*,char*,void*),
270 char*(*clone)(Fid*,Fid*,void*), void*);
274 void authwrite(Req*);
275 void authdestroy(Fid*);
276 int authattach(Req*);
278 extern void (*_forker)(void (*)(void*), void*, int);
280 void srvacquire(Srv *);
281 void srvrelease(Srv *);
283 Reqqueue* reqqueuecreate(void);
284 void reqqueuepush(Reqqueue*, Req*, void (*)(Req *));
285 void reqqueueflush(Reqqueue*, Req*);