client

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2024 License: 0BSD Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanPath added in v0.9.1

func CleanPath(name string) string

CleanPath cleans name. It first call path.Clean(name) and then delete trailing ".." elements.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a client side of the 9P conversation.

func NewClient

func NewClient(ctx context.Context, mSize uint32, uname string, r io.Reader, w io.Writer) *Client

NewClient creates a Client and prepare to transact with a server via r and w. It runs several goroutines to handle requests. And the returned client should be stopped by cancelling ctx afterwards.

func (*Client) Attach

func (c *Client) Attach(tag uint16, fid, afid uint32, uname, aname string) (lib9p.Qid, error)

func (*Client) Auth

func (c *Client) Auth(tag uint16, afid uint32, uname, aname string) (lib9p.Qid, error)

func (*Client) Clunk

func (c *Client) Clunk(tag uint16, fid uint32) error

func (*Client) Create

func (c *Client) Create(tag uint16, fid uint32, name string, perm lib9p.FileMode, mode lib9p.OpenMode) (lib9p.Qid, uint32, error)

func (*Client) Flush

func (c *Client) Flush(tag, oldtag uint16) error

func (*Client) Open

func (c *Client) Open(tag uint16, fid uint32, mode lib9p.OpenMode) (qid lib9p.Qid, iounit uint32, err error)

func (*Client) Read

func (c *Client) Read(tag uint16, fid uint32, offset uint64, count uint32) (data []byte, err error)

Read doesn't return io.EOF at the end of file, but returns empty data and nil error.

func (*Client) Remove

func (c *Client) Remove(tag uint16, fid uint32) error

func (*Client) Stat

func (c *Client) Stat(tag uint16, fid uint32) (*lib9p.Stat, error)

func (*Client) Version

func (c *Client) Version(tag uint16, msize uint32, version string) (uint32, string, error)

Version sends Tversion message to the server and returns the resulting data of Rversion or non nil error if any. This function and other Tmessage functions don't have a context.Contex as their argument. The caller can call *Client.Flush to cancel a pending request if the connection to the server is helthy. And even if the connection has some problem sending/recieving, there is no way to cancel blocking reads/writes. In this case, the caller can close the connection.

func (*Client) Walk

func (c *Client) Walk(tag uint16, fid, newfid uint32, wnames []string) (wqid []lib9p.Qid, err error)

func (*Client) Write

func (c *Client) Write(tag uint16, fid uint32, offset uint64, count uint32, data []byte) (uint32, error)

func (*Client) Wstat

func (c *Client) Wstat(tag uint16, fid uint32, stat *lib9p.Stat) error

type FS added in v0.5.0

type FS struct {
	// contains filtered or unexported fields
}

FS represents the file system the client imports.

func Mount

func Mount(ctx context.Context, r io.Reader, w io.Writer, uname, aname string) (fs *FS, err error)

Mount initiates a 9P session and returns the resulting file system. The 9P session is established by writing to w and reading from r. When fs is not needed anymore, ctx should be canceled to stop the underlying client's goroutines. If non-nil error is returned, underlying client is stopped by this function, and there is no need to cancel ctx.

func (*FS) OpenFile added in v0.5.0

func (fsys *FS) OpenFile(name string, flag int) (lib9p.File, error)

OpenFile opens the file named name in fsys with omode. If the file does not exist, it create it with perm. The flag bits which are not implemeted by the library are just ignored.

type File added in v0.5.0

type File struct {
	// contains filtered or unexported fields
}

File is a File for Client.

func (*File) Close added in v0.5.0

func (cf *File) Close() error

Don't use closed file.

func (*File) Read added in v0.5.0

func (cf *File) Read(b []byte) (int, error)

func (*File) ReadDir added in v0.5.0

func (cf *File) ReadDir(n int) ([]fs.DirEntry, error)

func (*File) Stat added in v0.5.0

func (cf *File) Stat() (*lib9p.FileInfo, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL