9 #pragma src "/sys/src/lib9p"
15 * Maps from ulongs to void*s.
17 typedef struct Intmap Intmap;
19 Intmap* allocmap(void (*inc)(void*));
20 void freemap(Intmap*, void (*destroy)(void*));
21 void* lookupkey(Intmap*, ulong);
22 void* insertkey(Intmap*, ulong, void*);
23 int caninsertkey(Intmap*, ulong, void*);
24 void* deletekey(Intmap*, ulong);
27 * Fid and Request structures.
29 typedef struct Fid Fid;
30 typedef struct Req Req;
31 typedef struct Fidpool Fidpool;
32 typedef struct Reqpool Reqpool;
33 typedef struct File File;
34 typedef struct Filelist Filelist;
35 typedef struct Tree Tree;
36 typedef struct Readdir Readdir;
37 typedef struct Srv Srv;
42 int omode; /* -1 = not open */
48 /* below is implementation-specific; don't use */
69 /* below is implementation-specific; don't use */
83 * Pools to maintain Fid <-> fid and Req <-> tag maps.
88 void (*destroy)(Fid*);
94 void (*destroy)(Req*);
98 Fidpool* allocfidpool(void (*destroy)(Fid*));
99 void freefidpool(Fidpool*);
100 Fid* allocfid(Fidpool*, ulong);
101 Fid* lookupfid(Fidpool*, ulong);
103 Fid* removefid(Fidpool*, ulong);
105 Reqpool* allocreqpool(void (*destroy)(Req*));
106 void freereqpool(Reqpool*);
107 Req* allocreq(Reqpool*, ulong);
108 Req* lookupreq(Reqpool*, ulong);
110 Req* removereq(Reqpool*, ulong);
112 typedef int Dirgen(int, Dir*, void*);
113 void dirread9p(Req*, Dirgen*, void*);
124 /* below is implementation-specific; don't use */
134 void (*destroy)(File *file);
136 /* below is implementation-specific; don't use */
142 Tree* alloctree(char*, char*, ulong, void(*destroy)(File*));
143 void freetree(Tree*);
144 File* createfile(File*, char*, char*, ulong, void*);
145 int removefile(File*);
146 void closefile(File*);
147 File* walkfile(File*, char*);
148 Readdir* opendirfile(File*);
149 long readdirfile(Readdir*, uchar*, long);
150 void closedirfile(Readdir*);
153 * Kernel-style command parser
155 typedef struct Cmdbuf Cmdbuf;
156 typedef struct Cmdtab Cmdtab;
157 Cmdbuf* parsecmd(char *a, int n);
158 void respondcmderror(Req*, Cmdbuf*, char*, ...);
159 Cmdtab* lookupcmd(Cmdbuf*, Cmdtab*, int);
161 #pragma varargck argpos respondcmderr 3
172 int index; /* used by client to switch on result */
173 char *cmd; /* command name */
174 int narg; /* expected #args; 0 ==> variadic */
182 void (*destroyfid)(Fid*);
183 void (*destroyreq)(Req*);
188 void (*attach)(Req*);
191 void (*create)(Req*);
194 void (*remove)(Req*);
199 char* (*clone)(Fid*, Fid*);
200 char* (*walk1)(Fid*, char*, Qid*);
206 int leavefdsopen; /* magic for acme win */
207 int foreground; /* run in foreground */
210 /* below is implementation-specific; don't use */
222 void postmountsrv(Srv*, char*, char*, int);
223 int postfd(char*, int);
225 void respond(Req*, char*);
226 void threadpostmountsrv(Srv*, char*, char*, int);
229 * Helper. Assumes user is same as group.
231 int hasperm(File*, char*, int);
233 void* emalloc9p(ulong);
234 void* erealloc9p(void*, ulong);
235 char* estrdup9p(char*);
241 void readstr(Req*, char*);
242 void readbuf(Req*, void*, long);
243 void walkandclone(Req*, char*(*walk1)(Fid*,char*,void*), char*(*clone)(Fid*,Fid*,void*), void*);