9 #pragma src "/sys/src/lib9p"
14 * Maps from ulongs to void*s.
16 typedef struct Intmap Intmap;
18 Intmap* allocmap(void (*inc)(void*));
19 void freemap(Intmap*, void (*destroy)(void*));
20 void* lookupkey(Intmap*, ulong);
21 void* insertkey(Intmap*, ulong, void*);
22 int caninsertkey(Intmap*, ulong, void*);
23 void* deletekey(Intmap*, ulong);
26 * Fid and Request structures.
28 typedef struct Fid Fid;
29 typedef struct Req Req;
30 typedef struct Fidpool Fidpool;
31 typedef struct Reqpool Reqpool;
32 typedef struct File File;
33 typedef struct Filelist Filelist;
34 typedef struct Tree Tree;
35 typedef struct Readdir Readdir;
36 typedef struct Srv Srv;
41 char omode; /* -1 = not open */
47 /* below is implementation-specific; don't use */
68 /* below is implementation-specific; don't use */
82 * Pools to maintain Fid <-> fid and Req <-> tag maps.
87 void (*destroy)(Fid*);
93 void (*destroy)(Req*);
97 Fidpool* allocfidpool(void (*destroy)(Fid*));
98 void freefidpool(Fidpool*);
99 Fid* allocfid(Fidpool*, ulong);
100 Fid* lookupfid(Fidpool*, ulong);
102 Fid* removefid(Fidpool*, ulong);
104 Reqpool* allocreqpool(void (*destroy)(Req*));
105 void freereqpool(Reqpool*);
106 Req* allocreq(Reqpool*, ulong);
107 Req* lookupreq(Reqpool*, ulong);
109 Req* removereq(Reqpool*, ulong);
111 typedef int Dirgen(int, Dir*, void*);
112 void dirread9p(Req*, Dirgen*, void*);
123 /* below is implementation-specific; don't use */
133 void (*destroy)(File *file);
135 /* below is implementation-specific; don't use */
141 Tree* alloctree(char*, char*, ulong, void(*destroy)(File*));
142 void freetree(Tree*);
143 File* createfile(File*, char*, char*, ulong, void*);
144 int removefile(File*);
145 void closefile(File*);
146 File* walkfile(File*, char*);
147 Readdir* opendirfile(File*);
148 long readdirfile(Readdir*, uchar*, long);
149 void closedirfile(Readdir*);
152 * Kernel-style command parser
154 typedef struct Cmdbuf Cmdbuf;
155 typedef struct Cmdtab Cmdtab;
156 Cmdbuf* parsecmd(char *a, int n);
157 void respondcmderror(Req*, Cmdbuf*, char*, ...);
158 Cmdtab* lookupcmd(Cmdbuf*, Cmdtab*, int);
160 #pragma varargck argpos respondcmderr 3
171 int index; /* used by client to switch on result */
172 char *cmd; /* command name */
173 int narg; /* expected #args; 0 ==> variadic */
181 void (*destroyfid)(Fid*);
182 void (*destroyreq)(Req*);
186 void (*attach)(Req*);
189 void (*create)(Req*);
192 void (*remove)(Req*);
197 char* (*clone)(Fid*, Fid*);
198 char* (*walk1)(Fid*, char*, Qid*);
204 int leavefdsopen; /* magic for acme win */
206 /* below is implementation-specific; don't use */
218 void postmountsrv(Srv*, char*, char*, int);
219 int postfd(char*, int);
221 void respond(Req*, char*);
222 void threadpostmountsrv(Srv*, char*, char*, int);
225 * Helper. Assumes user is same as group.
227 int hasperm(File*, char*, int);
229 void* emalloc9p(ulong);
230 void* erealloc9p(void*, ulong);
231 char* estrdup9p(char*);
237 void readstr(Req*, char*);
238 void readbuf(Req*, void*, long);
239 void walkandclone(Req*, char*(*walk1)(Fid*,char*,void*), char*(*clone)(Fid*,Fid*,void*), void*);