CFsys*fsmount(int fd, char *aname)
CFsys*nsmount(char *name, char *aname)
CFid* fsroot(CFsys *fsys)
void fsunmount(CFsys *fsys)
int fsversion(CFsys *fsys, int msize, char *version, int nversion)
CFid* fsauth(CFsys *fsys, char *uname, char *aname)
CFid* fsattach(CFsys *fsys, CFid *afid, char *uname, char *aname)
void fssetroot(CFsys *fsys, CFid *fid)
void fsclose(CFid *fid)
CFid* fscreate(CFsys *fs, char *path, int mode, ulong perm)
int fsfcreate(CFid *fid, char *path, int mode, ulong perm)
int fsremove(CFSys *fs, char *path)
int fsfremove(CFid *fid)
int fsaccess(CFsys *fs, char *path, int amode)
CFid* fsopen(CFsys *fs, char *path, int mode)
int fsfopen(CFid *fid, char *path, int mode)
long fspread(CFid *fid, void *buf, long n, vlong offset)
long fspwrite(CFid *fid, void *buf, long n, vlong offset)
long fsread(CFid *fid, void *buf, long n)
long fsreadn(CFid *fid, void *buf, long n)
long fswrite(CFid *fid, void *buf, long n)
int fsprint(CFid *fid, char *fmt, ...)
int fsvprint(CFid *fid, char *fmt, ...)
vlong fsseek(CFid *Fid, vlong n, int type)
Qid fsqid(CFid *fid)
long fsdirread(CFid *fid, Dir **d)
long fsdirreadall(CFid *fid, Dir **d)
Dir* fsdirstat(CFsys *fs, char *path)
Dir* fsdirfstat(CFid *fid)
int fsdirwstat(CFsys *fs, char *path, Dir *d)
int fsdirfwstat(CFid *fid, Dir *d)
int fsopenfd(CFsys *fs, char *path, int mode)
CFsys*nsopen(char *name, char *aname, char *path, int mode)
extern int chatty9pclient;
extern int eofkill9pclient;
9pclient library helps client programs interact with 9P servers.
CFsys* represents a connection to a 9P server.
CFid* represents an active fid on some connection;
A new connection to a 9P server is typically established by
Fsmount initializes a new 9P conversation on the open file descriptor
nsmount connects to a service named
name in the current name space directory
Both attach to the root of the file system
using the attach name
Fsroot returns the
CFid* corresponding to this root.
fssetroot provide more detailed control over the file system connection
Fsinit allocates a new
CFsys* corresponding to a 9P conversation on the file descriptor
fd and then calls
fsversion to initialize the connection.
Nsinit does the same for name space services.
Fsversion executes a
transaction to establish
maximum message size and 9P version.
Fsauth executes an
transaction, returning the new auth fid.
fswrite can then be used to run the authentication protocol over the fid.)
Fsattach executes an
transaction to connect to the root of a file tree served by the server.
afid (which may be nil)
to establish identity.
Fssetroot sets the root fid used by
fsdirwstat, which evaluate rooted path names.
When a fid
is no longer needed, it should be clunked by calling
fsclose and then considered freed.
Similarly, when the connection to the server is no longer needed,
it should be closed by calling
fsunmount, which will take care of calling
fsclose on the current root fid.
Once all fids have been clunked
and the connection has been closed
(the order is not important),
the allocated structures will be freed and the
file descriptor corresponding to the connection
will be closed
Fids are not reference counted: when
fsclose is called, the clunk transaction and freeing of storage
Despite its name,
fsclose can be used to clunk fids that are not open for I/O.
fsopen establish new fids using the
path argument is evaluated relative to the
The path is parsed as a slash-separated sequence of path elements,
as on Unix and Plan 9.
Elements that are empty or
(.) are ignored.
fswalk walks from a fid to a given name
to create a new fid.
The name may be nil, corresponding to a walk with no names.
Otherwise the name is taken as a slash-separated sequence
of path elements.
open transactions using the passed fid argument,
which should have been obtained by calling
Once opened, fids can be read and written using
fspwrite, which execute
The library maintains an offset for each fid,
analagous to the offset maintained by the kernel for each open file descriptor.
fswrite read and write from this offset, and update it after successful calls.
Fsseek sets the offset; the
type arguments are used as in
fspwrite with an
offset of -1
is identical to calling
fsread repeatedly to obtain exactly
n bytes of data, unless it encounters end-of-file or an error.
open transactions include in their replies an updated qid for the
fid being manipulated.
Fsqid returns the most recent qid returned by one of these transactions
for the given fid.
Fsaccess behaves like Unixs
Fsremove removes the named path.
Fsfremove removes the path corresponding to an open
Reading an open a directory returns directory entries encoded as described in
fsvprint are like
but write to
fsread and then parses the encoded entries into an array of
Dir* data structures,
storing a pointer to the array in
*d and returning the number of entries.
Fsdirreadall is similar but reads the entire directory.
The returned pointer should be freed with
when no longer needed.
Dir structure returned by
fsdirfstat should be freed with
when no longer needed.
fsdirwstat are similar to
fsdirfwstat but operate on paths relative to the file system root
Fsopenfd opens a file on the 9P server
for reading or writing but returns a Unix file descriptor
instead of a fid structure.
The file descriptor is actually one end of a
A proxy process on the other end is ferrying data
between the pipe and the 9P fid.
Because of the implementation as a pipe,
the only signal of a read or write error is the closing of the pipe.
The file descriptor remains valid even after the
CFsys is unmounted.
Nsopen opens a single file on a name space server: it runs
fsopen, and then
chatty9pclient flag is set, the library prints all 9P messages
to standard error.
eofkill9pclient flag is set, the library calls
when it detects EOF on a 9P connection.