3 CFid, CFsys, fsinit, fsmount, fsroot, fssetroot, fsunmount, nsinit, nsmount, fsversion, fsauth, fsattach, fsclose, fscreate, fsfcreate, fsremove, fsfremove, fsaccess, fsdirread, fsdirreadall, fsdirstat, fsdirfstat, fsdirwstat, fsdirfwstat, fsopen, fsfopen, nsopen, fsopenfd, fspread, fspwrite, fsread, fsreadn, fsseek, fswrite, fsprint, fsvprint \- 9P client library
11 .B #include <thread.h>
13 .B #include <9pclient.h>
17 CFsys* fsmount(int fd, char *aname)
20 CFsys* nsmount(char *name, char *aname)
23 CFid* fsroot(CFsys *fsys)
26 void fsunmount(CFsys *fsys)
32 CFsys* nsinit(char *name)
35 int fsversion(CFsys *fsys, int msize, char *version, int nversion)
38 CFid* fsauth(CFsys *fsys, char *uname, char *aname)
41 CFid* fsattach(CFsys *fsys, CFid *afid, char *uname, char *aname)
44 void fssetroot(CFsys *fsys, CFid *fid)
47 void fsclose(CFid *fid)
50 CFid* fscreate(CFsys *fs, char *path, int mode, ulong perm)
53 int fsfcreate(CFid *fid, char *path, int mode, ulong perm)
56 int fsremove(CFSys *fs, char *path)
59 int fsfremove(CFid *fid)
62 int fsaccess(CFsys *fs, char *path, int amode)
65 CFid* fsopen(CFsys *fs, char *path, int mode)
68 int fsfopen(CFid *fid, char *path, int mode)
71 long fspread(CFid *fid, void *buf, long n, vlong offset)
74 long fspwrite(CFid *fid, void *buf, long n, vlong offset)
77 long fsread(CFid *fid, void *buf, long n)
80 long fsreadn(CFid *fid, void *buf, long n)
83 long fswrite(CFid *fid, void *buf, long n)
86 int fsprint(CFid *fid, char *fmt, ...)
89 int fsvprint(CFid *fid, char *fmt, ...)
92 vlong fsseek(CFid *Fid, vlong n, int type)
98 long fsdirread(CFid *fid, Dir **d)
101 long fsdirreadall(CFid *fid, Dir **d)
104 Dir* fsdirstat(CFsys *fs, char *path)
107 Dir* fsdirfstat(CFid *fid)
110 int fsdirwstat(CFsys *fs, char *path, Dir *d)
113 int fsdirfwstat(CFid *fid, Dir *d)
116 int fsopenfd(CFsys *fs, char *path, int mode)
119 CFsys* nsopen(char *name, char *aname, char *path, int mode)
122 extern int chatty9pclient;
125 extern int eofkill9pclient;
129 library helps client programs interact with 9P servers.
133 represents a connection to a 9P server.
136 represents an active fid on some connection;
140 A new connection to a 9P server is typically established by
145 initializes a new 9P conversation on the open file descriptor
148 connects to a service named
150 in the current name space directory
153 Both attach to the root of the file system
154 using the attach name
159 corresponding to this root.
168 provide more detailed control over the file system connection
176 corresponding to a 9P conversation on the file descriptor
180 to initialize the connection.
182 does the same for name space services.
186 transaction to establish
187 maximum message size and 9P version.
191 transaction, returning the new auth fid.
195 can then be used to run the authentication protocol over the fid.)
199 transaction to connect to the root of a file tree served by the server.
203 to establish identity.
205 sets the root fid used by
211 which evaluate rooted path names.
214 is no longer needed, it should be clunked by calling
216 and then considered freed.
217 Similarly, when the connection to the server is no longer needed,
218 it should be closed by calling
220 which will take care of calling
222 on the current root fid.
223 Once all fids have been clunked
225 the connection has been closed
226 (the order is not important),
227 the allocated structures will be freed and the
228 file descriptor corresponding to the connection
232 Fids are not reference counted: when
234 is called, the clunk transaction and freeing of storage
238 can be used to clunk fids that are not open for I/O.
243 establish new fids using the
255 argument is evaluated relative to the
263 The path is parsed as a slash-separated sequence of path elements,
264 as on Unix and Plan 9.
265 Elements that are empty or
272 walks from a fid to a given name
274 The name may be nil, corresponding to a walk with no names.
275 Otherwise the name is taken as a slash-separated sequence
284 transactions using the passed fid argument,
285 which should have been obtained by calling
288 Once opened, fids can be read and written using
299 The library maintains an offset for each fid,
300 analagous to the offset maintained by the kernel for each open file descriptor.
304 read and write from this offset, and update it after successful calls.
310 arguments are used as in
319 is identical to calling
326 repeatedly to obtain exactly
328 bytes of data, unless it encounters end-of-file or an error.
335 transactions include in their replies an updated qid for the
336 fid being manipulated.
338 returns the most recent qid returned by one of these transactions
345 removes the named path.
347 removes the path corresponding to an open
350 Reading an open a directory returns directory entries encoded as described in
368 and then parses the encoded entries into an array of
371 storing a pointer to the array in
373 and returning the number of entries.
375 is similar but reads the entire directory.
376 The returned pointer should be freed with
380 when no longer needed.
394 structure returned by
400 when no longer needed.
409 but operate on paths relative to the file system root
417 opens a file on the 9P server
418 for reading or writing but returns a Unix file descriptor
419 instead of a fid structure.
420 The file descriptor is actually one end of a
422 A proxy process on the other end is ferrying data
423 between the pipe and the 9P fid.
424 Because of the implementation as a pipe,
425 the only signal of a read or write error is the closing of the pipe.
426 The file descriptor remains valid even after the
431 opens a single file on a name space server: it runs
439 flag is set, the library prints all 9P messages
443 flag is set, the library calls
447 when it detects EOF on a 9P connection.
449 .B \*9/src/lib9pclient
460 should use a special version string to distinguish between
463 and servers that do not.
465 The interface does not provide access to the
471 on already-established fids.