Documentation ¶
Overview ¶
The srv package provides definitions and functions used to implement a 9P2000 file client.
Index ¶
- type Client
- func (clnt *Client) Attach(afid *Fid, user g9p.User, aname string) (*Fid, error)
- func (clnt *Client) Auth(user g9p.User, aname string) (*Fid, error)
- func (clnt *Client) Clunk(fid *Fid) (err error)
- func (clnt *Client) Create(fid *Fid, name string, perm uint32, mode uint8, ext string) error
- func (clnt *Client) FCreate(path string, perm uint32, mode uint8) (*File, error)
- func (clnt *Client) FOpen(path string, mode uint8) (*File, error)
- func (clnt *Client) FRemove(path string) error
- func (clnt *Client) FStat(path string) (*g9p.Dir, error)
- func (clnt *Client) FWalk(path string) (*Fid, error)
- func (client *Client) Msize() uint32
- func (clnt *Client) Open(fid *Fid, mode uint8) error
- func (clnt *Client) Remove(fid *Fid) error
- func (clnt *Client) Stat(fid *Fid) (*g9p.Dir, error)
- func (clnt *Client) Unmount()
- func (client *Client) Wait() (err error)
- func (clnt *Client) Walk(fid *Fid, newfid *Fid, wnames []string) ([]g9p.Qid, error)
- func (clnt *Client) Wstat(fid *Fid, dir *g9p.Dir) error
- type Fid
- type File
- func (file *File) Close() error
- func (file *File) Read(buf []byte) (int, error)
- func (file *File) ReadAt(buf []byte, offset uint64) (int, error)
- func (file *File) Readdir(num int) ([]*g9p.Dir, error)
- func (file *File) Readn(buf []byte, offset uint64) (int, error)
- func (file *File) Write(buf []byte) (int, error)
- func (file *File) WriteAt(buf []byte, offset uint64) (int, error)
- func (file *File) Writen(buf []byte, offset uint64) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
The Client 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 NewClient ¶
NewClient creates a client object for the 9p server connected to by c. It negotiates the dialect and msize for the connection. Returns a Client object, or Error.
func (*Client) 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 (*Client) Auth ¶
Creates an authentication fid for the specified user. Returns the fid, if successful, or an Error.
func (*Client) Create ¶
Creates a file in the directory associated with the fid. Returns nil if the operation is successful.
func (*Client) FCreate ¶
Creates and opens a named file. Returns the file if the operation is successful, or an Error.
func (*Client) Open ¶
Opens the file associated with the fid. Returns nil if the operation is successful.
func (*Client) Remove ¶
Removes the file associated with the Fid. Returns nil if the operation is successful.
type Fid ¶
type Fid struct { Client *Client // Client the fid belongs to Iounit uint32 g9p.Qid // The Qid description for the file Mode uint8 // Open mode (one of g9p.O* values) (if file is open) Fid uint32 // Fid number g9p.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) Write ¶
Writes up to len(buf) bytes to a file. Returns the number of bytes written, or an Error.