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 long fsdirread(CFid *fid, Dir **d)
69 long fsdirreadall(CFid *fid, Dir **d)
72 Dir* fsdirstat(CFsys *fs, char *path)
75 Dir* fsdirfstat(CFid *fid)
78 int fsdirwstat(CFsys *fs, char *path, Dir *d)
81 int fsdirfwstat(CFid *fid, Dir *d)
84 int fsopenfd(CFsys *fs, char *path, int mode)
88 library helps client programs interact with 9P servers.
92 represents a connection to a 9P server.
95 represents an active fid on some connection;
99 A new connection to a 9P server is typically established by
104 initializes a new 9P conversation on the open file descriptor
107 connects to a service named
109 in the current name space directory
112 Both attach to the root of the file system
113 using the attach name
118 corresponding to this root.
126 provide more detailed control over the file system connection
134 corresponding to a 9P conversation on the file descriptor
139 transaction to establish
140 maximum message size and 9P version.
144 transaction, returning the new auth fid.
148 can then be used to run the authentication protocol over the fid.)
152 transaction to connect to the root of a file tree served by the server.
156 to establish identity.
158 sets the root fid used by
164 which evaluate rooted path names.
167 is no longer needed, it should be clunked by calling
169 and then considered freed.
170 Similarly, when the connection to the server is no longer needed,
171 it should be closed by calling
173 which will take care of calling
175 on the current root fid.
176 Once all fids have been clunked
178 the connection has been closed
179 (the order is not important),
180 the allocated structures will be freed and the
181 file descriptor corresponding to the connection
185 Fids are not reference counted: when
187 is called, the clunk transaction and freeing of storage
193 establish new fids using the
205 argument is evaluated relative to the
213 The path is parsed as a slash-separated sequence of path elements,
214 as on Unix and Plan 9.
215 Elements that are empty or
220 Once opened, these fids can be read and written using
231 The library maintains an offset for each fid,
232 analagous to the offset maintained by the kernel for each open file descriptor.
236 read and write from this offset, and update it after successful calls.
244 is identical to calling
251 repeatedly to obtain exactly
253 bytes of data, unless it encounters end-of-file or an error.
255 Reading an open a directory returns directory entries encoded as described in
260 and then parses the encoded entries into an array of
263 storing a pointer to the array in
265 and returning the number of entries.
267 is similar but reads the entire directory.
268 The returned pointer should be freed with
272 when no longer needed.
286 structure returned by
292 when no longer needed.
301 but operate on paths relative to the file system root
309 opens a file on the 9P server
310 for reading or writing but returns a Unix file descriptor
311 instead of a fid structure.
312 The file descriptor is actually one end of a
314 A proxy process on the other end is ferrying data
315 between the pipe and the 9P fid.
316 Because of the implementation as a pipe,
317 the only signal of a read or write error is the closing of the pipe.
318 The file descriptor remains valid even after the
322 .B /usr/local/plan9/src/lib9pclient
328 should use a special version string to distinguish between
331 and servers that do not.
333 The interface does not provide access to the
339 on already-established fids.