3 CFid, CFsys, fsinit, fsmount, fsroot, fssetroot, fsunmount, nsinit, nsmount, fsversion, fsauth, fsattach, fsclose, fscreate, fsremove, fsfremove, fsaccess, fsdirread, fsdirreadall, fsdirstat, fsdirfstat, fsdirwstat, fsdirfwstat, fsopen, 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 fsremove(CFSys *fs, char *path)
56 int fsfremove(CFid *fid)
59 int fsaccess(CFsys *fs, char *path, int amode)
62 CFid* fsopen(CFsys *fs, char *path, int mode)
65 long fspread(CFid *fid, void *buf, long n, vlong offset)
68 long fspwrite(CFid *fid, void *buf, long n, vlong offset)
71 long fsread(CFid *fid, void *buf, long n)
74 long fsreadn(CFid *fid, void *buf, long n)
77 long fswrite(CFid *fid, void *buf, long n)
80 int fsprint(CFid *fid, char *fmt, ...)
83 int fsvprint(CFid *fid, char *fmt, ...)
86 vlong fsseek(CFid *Fid, vlong n, int type)
89 long fsdirread(CFid *fid, Dir **d)
92 long fsdirreadall(CFid *fid, Dir **d)
95 Dir* fsdirstat(CFsys *fs, char *path)
98 Dir* fsdirfstat(CFid *fid)
101 int fsdirwstat(CFsys *fs, char *path, Dir *d)
104 int fsdirfwstat(CFid *fid, Dir *d)
107 int fsopenfd(CFsys *fs, char *path, int mode)
110 CFsys* nsopen(char *name, char *aname, char *path, int mode)
114 library helps client programs interact with 9P servers.
118 represents a connection to a 9P server.
121 represents an active fid on some connection;
125 A new connection to a 9P server is typically established by
130 initializes a new 9P conversation on the open file descriptor
133 connects to a service named
135 in the current name space directory
138 Both attach to the root of the file system
139 using the attach name
144 corresponding to this root.
153 provide more detailed control over the file system connection
161 corresponding to a 9P conversation on the file descriptor
165 to initialize the connection.
167 does the same for name space services.
171 transaction to establish
172 maximum message size and 9P version.
176 transaction, returning the new auth fid.
180 can then be used to run the authentication protocol over the fid.)
184 transaction to connect to the root of a file tree served by the server.
188 to establish identity.
190 sets the root fid used by
196 which evaluate rooted path names.
199 is no longer needed, it should be clunked by calling
201 and then considered freed.
202 Similarly, when the connection to the server is no longer needed,
203 it should be closed by calling
205 which will take care of calling
207 on the current root fid.
208 Once all fids have been clunked
210 the connection has been closed
211 (the order is not important),
212 the allocated structures will be freed and the
213 file descriptor corresponding to the connection
217 Fids are not reference counted: when
219 is called, the clunk transaction and freeing of storage
225 establish new fids using the
237 argument is evaluated relative to the
245 The path is parsed as a slash-separated sequence of path elements,
246 as on Unix and Plan 9.
247 Elements that are empty or
252 Once opened, these fids can be read and written using
263 The library maintains an offset for each fid,
264 analagous to the offset maintained by the kernel for each open file descriptor.
268 read and write from this offset, and update it after successful calls.
274 arguments are used as in
283 is identical to calling
290 repeatedly to obtain exactly
292 bytes of data, unless it encounters end-of-file or an error.
298 removes the named path.
300 removes the path corresponding to an open
303 Reading an open a directory returns directory entries encoded as described in
321 and then parses the encoded entries into an array of
324 storing a pointer to the array in
326 and returning the number of entries.
328 is similar but reads the entire directory.
329 The returned pointer should be freed with
333 when no longer needed.
347 structure returned by
353 when no longer needed.
362 but operate on paths relative to the file system root
370 opens a file on the 9P server
371 for reading or writing but returns a Unix file descriptor
372 instead of a fid structure.
373 The file descriptor is actually one end of a
375 A proxy process on the other end is ferrying data
376 between the pipe and the 9P fid.
377 Because of the implementation as a pipe,
378 the only signal of a read or write error is the closing of the pipe.
379 The file descriptor remains valid even after the
384 opens a single file on a name space server: it runs
390 .B \*9/src/lib9pclient
401 should use a special version string to distinguish between
404 and servers that do not.
406 The interface does not provide access to the
412 on already-established fids.