Documentation ¶
Overview ¶
The clnt package provides definitions and functions used to implement a 9P2000 file client.
Index ¶
- Constants
- Variables
- type Clnt
- func (clnt *Clnt) Attach(afid *Fid, user p.User, aname string) (*Fid, error)
- func (clnt *Clnt) Auth(user p.User, aname string) (*Fid, error)
- func (clnt *Clnt) Clunk(fid *Fid) (err error)
- func (clnt *Clnt) Create(fid *Fid, name string, perm uint32, mode uint8, ext string) error
- func (clnt *Clnt) FCreate(path string, perm uint32, mode uint8) (*File, error)
- func (clnt *Clnt) FOpen(path string, mode uint8) (*File, error)
- func (clnt *Clnt) FRemove(path string) error
- func (clnt *Clnt) FStat(path string) (*p.Dir, error)
- func (clnt *Clnt) FWalk(path string) (*Fid, error)
- func (clnt *Clnt) FidAlloc() *Fid
- func (clnt *Clnt) FreeFcall(fc *p.Fcall)
- func (clnt *Clnt) NewFcall() *p.Fcall
- func (clnt *Clnt) Open(fid *Fid, mode uint8) error
- func (clnt *Clnt) Read(fid *Fid, offset uint64, count uint32) ([]byte, error)
- func (clnt *Clnt) Remove(fid *Fid) error
- func (clnt *Clnt) ReqAlloc() *Req
- func (clnt *Clnt) ReqFree(req *Req)
- func (clnt *Clnt) Rpc(tc *p.Fcall) (rc *p.Fcall, err error)
- func (clnt *Clnt) Rpcnb(r *Req) error
- func (clnt *Clnt) Stat(fid *Fid) (*p.Dir, error)
- func (clnt *Clnt) TagAlloc(reqchan chan *Req) *Tag
- func (clnt *Clnt) TagFree(tag *Tag)
- func (clnt *Clnt) Unmount()
- func (clnt *Clnt) Walk(fid *Fid, newfid *Fid, wnames []string) ([]p.Qid, error)
- func (clnt *Clnt) Write(fid *Fid, data []byte, offset uint64) (int, error)
- func (clnt *Clnt) Wstat(fid *Fid, dir *p.Dir) error
- type ClntList
- type Fid
- type File
- func (file *File) Close() error
- func (f *File) Fid() *Fid
- func (file *File) Read(buf []byte) (int, error)
- func (file *File) ReadAt(buf []byte, offset int64) (int, error)
- func (file *File) Readdir(num int) ([]*p.Dir, error)
- func (file *File) Readn(buf []byte, offset uint64) (int, error)
- func (f *File) Seek(offset int64, whence int) (int64, error)
- func (file *File) Write(buf []byte) (int, error)
- func (file *File) WriteAt(buf []byte, offset int64) (int, error)
- func (file *File) Writen(buf []byte, offset uint64) (int, error)
- type Req
- type StatsOps
- type Tag
- func (tag *Tag) Attach(fid, afid *Fid, user p.User, aname string) error
- func (tag *Tag) Auth(afid *Fid, user p.User, aname string) error
- func (tag *Tag) Clunk(fid *Fid) error
- func (tag *Tag) Create(fid *Fid, name string, perm uint32, mode uint8, ext string) error
- func (tag *Tag) Open(fid *Fid, mode uint8) error
- func (tag *Tag) Read(fid *Fid, offset uint64, count uint32) error
- func (tag *Tag) Remove(fid *Fid) error
- func (tag *Tag) ReqFree(r *Req)
- func (tag *Tag) Stat(fid *Fid) error
- func (tag *Tag) Walk(fid *Fid, newfid *Fid, wnames []string) error
- func (tag *Tag) Write(fid *Fid, data []byte, offset uint64) error
- func (tag *Tag) Wstat(fid *Fid, dir *p.Dir) error
Constants ¶
const ( DbgPrintFcalls = (1 << iota) // print all 9P messages on stderr DbgPrintPackets // print the raw packets on stderr DbgLogFcalls // keep the last N 9P messages (can be accessed over http) DbgLogPackets // keep the last N 9P messages (can be accessed over http) )
Debug flags
Variables ¶
var DefaultDebuglevel int
var DefaultLogger *p.Logger
var Eisdir = &p.Error{"file is a directory", p.EIO}
var Enegoff = &p.Error{"negative i/o offset", p.EIO}
Functions ¶
This section is empty.
Types ¶
type Clnt ¶
type Clnt struct { sync.Mutex Debuglevel int // =0 don't print anything, >0 print Fcalls, >1 print raw packets Msize uint32 // Maximum size of the 9P messages Dotu bool // If true, 9P2000.u protocol is spoken Root *Fid // Fid that points to the rood directory Id string // Used when printing debug messages Log *p.Logger // contains filtered or unexported fields }
The Clnt type represents a 9P2000 client. The client is connected to a 9P2000 file server and its methods can be used to access and manipulate the files exported by the server.
func Connect ¶
Establishes a new socket connection to the 9P server and creates a client object for it. Negotiates the dialect and msize for the connection. Returns a Clnt object, or Error.
func (*Clnt) Attach ¶
Creates a fid for the specified user that points to the root of the file server's file tree. Returns a Fid pointing to the root, if successful, or an Error.
func (*Clnt) Auth ¶
Creates an authentication fid for the specified user. Returns the fid, if successful, or an Error.
func (*Clnt) Create ¶
Creates a file in the directory associated with the fid. Returns nil if the operation is successful.
func (*Clnt) FCreate ¶
Creates and opens a named file. Returns the file if the operation is successful, or an Error.
func (*Clnt) Open ¶
Opens the file associated with the fid. Returns nil if the operation is successful.
func (*Clnt) Read ¶
Reads count bytes starting from offset from the file associated with the fid. Returns a slice with the data read, if the operation was successful, or an Error.
func (*Clnt) Remove ¶
Removes the file associated with the Fid. Returns nil if the operation is successful.
func (*Clnt) Walk ¶
Starting from the file associated with fid, walks all wnames in sequence and associates the resulting file with newfid. If no wnames were walked successfully, an Error is returned. Otherwise a slice with a Qid for each walked name is returned.
type Fid ¶
type Fid struct { sync.Mutex Clnt *Clnt // Client the fid belongs to Iounit uint32 p.Qid // The Qid description for the file Mode uint8 // Open mode (one of p.O* values) (if file is open) Fid uint32 // Fid number p.User // The user the fid belongs to // contains filtered or unexported fields }
A Fid type represents a file on the server. Fids are used for the low level methods that correspond directly to the 9P2000 message requests
type File ¶
type File struct {
// contains filtered or unexported fields
}
The file is similar to the Fid, but is used in the high-level client interface.
func (*File) Read ¶
Reads up to len(buf) bytes from the File. Returns the number of bytes read, or an Error.
func (*File) ReadAt ¶
Reads up to len(buf) bytes from the file starting from offset. Returns the number of bytes read, or an Error.
func (*File) Readdir ¶
Reads the content of the directory associated with the File. Returns an array of maximum num entries (if num is 0, returns all entries from the directory). If the operation fails, returns an Error.
func (*File) Readn ¶
Reads exactly len(buf) bytes from the File starting from offset. Returns the number of bytes read (could be less than len(buf) if end-of-file is reached), or an Error.
func (*File) Seek ¶
Seek sets the offset for the next Read or Write to offset, interpreted according to whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end. Seek returns the new offset and an error, if any.
Seeking to a negative offset is an error, and results in Enegoff. Seeking to 0 in a directory is only valid if whence is 0. Seek returns Eisdir otherwise.
func (*File) Write ¶
Writes up to len(buf) bytes to a file. Returns the number of bytes written, or an Error.