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 <9pclient.h>
15 CFsys* fsmount(int fd, char *aname)
18 CFsys* nsmount(char *name, char *aname)
21 CFid* fsroot(CFsys *fsys)
24 void fsunmount(CFsys *fsys)
30 CFsys* nsinit(char *name)
33 int fsversion(CFsys *fsys, int msize, char *version, int nversion)
36 CFid* fsauth(CFsys *fsys, char *uname, char *aname)
39 CFid* fsattach(CFsys *fsys, CFid *afid, char *uname, char *aname)
42 void fssetroot(CFsys *fsys, CFid *fid)
45 void fsclose(CFid *fid)
48 CFid* fscreate(CFsys *fs, char *path, int mode, ulong perm)
51 CFid* fsopen(CFsys *fs, char *path, int mode)
54 long fspread(CFid *fid, void *buf, long n, vlong offset)
57 long fspwrite(CFid *fid, void *buf, long n, vlong offset)
60 long fsread(CFid *fid, void *buf, long n)
63 long fsreadn(CFid *fid, void *buf, long n)
66 long fswrite(CFid *fid, void *buf, long n)
69 vlong fsseek(CFid *Fid, vlong n, int type)
72 long fsdirread(CFid *fid, Dir **d)
75 long fsdirreadall(CFid *fid, Dir **d)
78 Dir* fsdirstat(CFsys *fs, char *path)
81 Dir* fsdirfstat(CFid *fid)
84 int fsdirwstat(CFsys *fs, char *path, Dir *d)
87 int fsdirfwstat(CFid *fid, Dir *d)
90 int fsopenfd(CFsys *fs, char *path, int mode)
93 CFsys* nsopen(char *name, char *aname, char *path, int mode)
97 library helps client programs interact with 9P servers.
101 represents a connection to a 9P server.
104 represents an active fid on some connection;
108 A new connection to a 9P server is typically established by
113 initializes a new 9P conversation on the open file descriptor
116 connects to a service named
118 in the current name space directory
121 Both attach to the root of the file system
122 using the attach name
127 corresponding to this root.
136 provide more detailed control over the file system connection
144 corresponding to a 9P conversation on the file descriptor
148 to initialize the connection.
150 does the same for name space services.
154 transaction to establish
155 maximum message size and 9P version.
159 transaction, returning the new auth fid.
163 can then be used to run the authentication protocol over the fid.)
167 transaction to connect to the root of a file tree served by the server.
171 to establish identity.
173 sets the root fid used by
179 which evaluate rooted path names.
182 is no longer needed, it should be clunked by calling
184 and then considered freed.
185 Similarly, when the connection to the server is no longer needed,
186 it should be closed by calling
188 which will take care of calling
190 on the current root fid.
191 Once all fids have been clunked
193 the connection has been closed
194 (the order is not important),
195 the allocated structures will be freed and the
196 file descriptor corresponding to the connection
200 Fids are not reference counted: when
202 is called, the clunk transaction and freeing of storage
208 establish new fids using the
220 argument is evaluated relative to the
228 The path is parsed as a slash-separated sequence of path elements,
229 as on Unix and Plan 9.
230 Elements that are empty or
235 Once opened, these fids can be read and written using
246 The library maintains an offset for each fid,
247 analagous to the offset maintained by the kernel for each open file descriptor.
251 read and write from this offset, and update it after successful calls.
257 arguments are used as in
266 is identical to calling
273 repeatedly to obtain exactly
275 bytes of data, unless it encounters end-of-file or an error.
277 Reading an open a directory returns directory entries encoded as described in
282 and then parses the encoded entries into an array of
285 storing a pointer to the array in
287 and returning the number of entries.
289 is similar but reads the entire directory.
290 The returned pointer should be freed with
294 when no longer needed.
308 structure returned by
314 when no longer needed.
323 but operate on paths relative to the file system root
331 opens a file on the 9P server
332 for reading or writing but returns a Unix file descriptor
333 instead of a fid structure.
334 The file descriptor is actually one end of a
336 A proxy process on the other end is ferrying data
337 between the pipe and the 9P fid.
338 Because of the implementation as a pipe,
339 the only signal of a read or write error is the closing of the pipe.
340 The file descriptor remains valid even after the
345 opens a single file on a name space server: it runs
351 .B \*9/src/lib9pclient
362 should use a special version string to distinguish between
365 and servers that do not.
367 The interface does not provide access to the
373 on already-established fids.