3 CFid, CFsys, fsinit, fsmount, fsroot, fssetroot, fsunmount, nsmount, fsversion, fsauth, fsattach, fsclose, fscreate, fsdirread, fsdirreadall, fsdirstat, fsdirfstat, fsdirwstat, fsdirfwstat, fsopen, fsopenfd, fspread, fspwrite, fsread, fsreadn, 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 int fsversion(CFsys *fsys, int msize, char *version, int nversion)
33 CFid* fsauth(CFsys *fsys, char *uname, char *aname)
36 CFid* fsattach(CFsys *fsys, CFid *afid, char *uname, char *aname)
39 void fssetroot(CFsys *fsys, CFid *fid)
42 void fsclose(CFid *fid)
45 CFid* fscreate(CFsys *fs, char *path, int mode, ulong perm)
48 CFid* fsopen(CFsys *fs, char *path, int mode)
51 long fspread(CFid *fid, void *buf, long n, vlong offset)
54 long fspwrite(CFid *fid, void *buf, long n, vlong offset)
57 long fsread(CFid *fid, void *buf, long n)
60 long fsreadn(CFid *fid, void *buf, long n)
63 long fswrite(CFid *fid, void *buf, long n)
66 vlong fsseek(CFid *Fid, vlong n, int type)
69 long fsdirread(CFid *fid, Dir **d)
72 long fsdirreadall(CFid *fid, Dir **d)
75 Dir* fsdirstat(CFsys *fs, char *path)
78 Dir* fsdirfstat(CFid *fid)
81 int fsdirwstat(CFsys *fs, char *path, Dir *d)
84 int fsdirfwstat(CFid *fid, Dir *d)
87 int fsopenfd(CFsys *fs, char *path, int mode)
91 library helps client programs interact with 9P servers.
95 represents a connection to a 9P server.
98 represents an active fid on some connection;
102 A new connection to a 9P server is typically established by
107 initializes a new 9P conversation on the open file descriptor
110 connects to a service named
112 in the current name space directory
115 Both attach to the root of the file system
116 using the attach name
121 corresponding to this root.
129 provide more detailed control over the file system connection
137 corresponding to a 9P conversation on the file descriptor
142 transaction to establish
143 maximum message size and 9P version.
147 transaction, returning the new auth fid.
151 can then be used to run the authentication protocol over the fid.)
155 transaction to connect to the root of a file tree served by the server.
159 to establish identity.
161 sets the root fid used by
167 which evaluate rooted path names.
170 is no longer needed, it should be clunked by calling
172 and then considered freed.
173 Similarly, when the connection to the server is no longer needed,
174 it should be closed by calling
176 which will take care of calling
178 on the current root fid.
179 Once all fids have been clunked
181 the connection has been closed
182 (the order is not important),
183 the allocated structures will be freed and the
184 file descriptor corresponding to the connection
188 Fids are not reference counted: when
190 is called, the clunk transaction and freeing of storage
196 establish new fids using the
208 argument is evaluated relative to the
216 The path is parsed as a slash-separated sequence of path elements,
217 as on Unix and Plan 9.
218 Elements that are empty or
223 Once opened, these fids can be read and written using
234 The library maintains an offset for each fid,
235 analagous to the offset maintained by the kernel for each open file descriptor.
239 read and write from this offset, and update it after successful calls.
245 arguments are used as in
254 is identical to calling
261 repeatedly to obtain exactly
263 bytes of data, unless it encounters end-of-file or an error.
265 Reading an open a directory returns directory entries encoded as described in
270 and then parses the encoded entries into an array of
273 storing a pointer to the array in
275 and returning the number of entries.
277 is similar but reads the entire directory.
278 The returned pointer should be freed with
282 when no longer needed.
296 structure returned by
302 when no longer needed.
311 but operate on paths relative to the file system root
319 opens a file on the 9P server
320 for reading or writing but returns a Unix file descriptor
321 instead of a fid structure.
322 The file descriptor is actually one end of a
324 A proxy process on the other end is ferrying data
325 between the pipe and the 9P fid.
326 Because of the implementation as a pipe,
327 the only signal of a read or write error is the closing of the pipe.
328 The file descriptor remains valid even after the
332 .B \*9/src/lib9pclient
338 should use a special version string to distinguish between
341 and servers that do not.
343 The interface does not provide access to the
349 on already-established fids.