3 CFid, CFsys, fsinit, fsmount, fsroot, fssetroot, fsunmount, nsinit, nsmount, fsversion, fsauth, fsattach, fsclose, fscreate, fsdirread, fsdirreadall, fsdirstat, fsdirfstat, fsdirwstat, fsdirfwstat, fsopen, nsopen, fsopenfd, fspread, fspwrite, fsread, fsreadn, fsseek, fswrite \- 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 CFid* fsopen(CFsys *fs, char *path, int mode)
56 long fspread(CFid *fid, void *buf, long n, vlong offset)
59 long fspwrite(CFid *fid, void *buf, long n, vlong offset)
62 long fsread(CFid *fid, void *buf, long n)
65 long fsreadn(CFid *fid, void *buf, long n)
68 long fswrite(CFid *fid, void *buf, long n)
71 vlong fsseek(CFid *Fid, vlong n, int type)
74 long fsdirread(CFid *fid, Dir **d)
77 long fsdirreadall(CFid *fid, Dir **d)
80 Dir* fsdirstat(CFsys *fs, char *path)
83 Dir* fsdirfstat(CFid *fid)
86 int fsdirwstat(CFsys *fs, char *path, Dir *d)
89 int fsdirfwstat(CFid *fid, Dir *d)
92 int fsopenfd(CFsys *fs, char *path, int mode)
95 CFsys* nsopen(char *name, char *aname, char *path, int mode)
99 library helps client programs interact with 9P servers.
103 represents a connection to a 9P server.
106 represents an active fid on some connection;
110 A new connection to a 9P server is typically established by
115 initializes a new 9P conversation on the open file descriptor
118 connects to a service named
120 in the current name space directory
123 Both attach to the root of the file system
124 using the attach name
129 corresponding to this root.
138 provide more detailed control over the file system connection
146 corresponding to a 9P conversation on the file descriptor
150 to initialize the connection.
152 does the same for name space services.
156 transaction to establish
157 maximum message size and 9P version.
161 transaction, returning the new auth fid.
165 can then be used to run the authentication protocol over the fid.)
169 transaction to connect to the root of a file tree served by the server.
173 to establish identity.
175 sets the root fid used by
181 which evaluate rooted path names.
184 is no longer needed, it should be clunked by calling
186 and then considered freed.
187 Similarly, when the connection to the server is no longer needed,
188 it should be closed by calling
190 which will take care of calling
192 on the current root fid.
193 Once all fids have been clunked
195 the connection has been closed
196 (the order is not important),
197 the allocated structures will be freed and the
198 file descriptor corresponding to the connection
202 Fids are not reference counted: when
204 is called, the clunk transaction and freeing of storage
210 establish new fids using the
222 argument is evaluated relative to the
230 The path is parsed as a slash-separated sequence of path elements,
231 as on Unix and Plan 9.
232 Elements that are empty or
237 Once opened, these fids can be read and written using
248 The library maintains an offset for each fid,
249 analagous to the offset maintained by the kernel for each open file descriptor.
253 read and write from this offset, and update it after successful calls.
259 arguments are used as in
268 is identical to calling
275 repeatedly to obtain exactly
277 bytes of data, unless it encounters end-of-file or an error.
279 Reading an open a directory returns directory entries encoded as described in
284 and then parses the encoded entries into an array of
287 storing a pointer to the array in
289 and returning the number of entries.
291 is similar but reads the entire directory.
292 The returned pointer should be freed with
296 when no longer needed.
310 structure returned by
316 when no longer needed.
325 but operate on paths relative to the file system root
333 opens a file on the 9P server
334 for reading or writing but returns a Unix file descriptor
335 instead of a fid structure.
336 The file descriptor is actually one end of a
338 A proxy process on the other end is ferrying data
339 between the pipe and the 9P fid.
340 Because of the implementation as a pipe,
341 the only signal of a read or write error is the closing of the pipe.
342 The file descriptor remains valid even after the
347 opens a single file on a name space server: it runs
353 .B \*9/src/lib9pclient
364 should use a special version string to distinguish between
367 and servers that do not.
369 The interface does not provide access to the
375 on already-established fids.