g9pc

package
v0.0.0-...-f3d8a94 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

The srv package provides definitions and functions used to implement a 9P2000 file client.

Index

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 Mount

func Mount(netw, addr, aname string, user g9p.User, log g9p.Logger) (*Client, error)

Connects to a file server and attaches to it as the specified user.

func NewClient

func NewClient(c io.ReadWriteCloser, msize uint32, dotu bool, log g9p.Logger) (*Client, error)

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

func (clnt *Client) Attach(afid *Fid, user g9p.User, aname string) (*Fid, error)

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

func (clnt *Client) Auth(user g9p.User, aname string) (*Fid, error)

Creates an authentication fid for the specified user. Returns the fid, if successful, or an Error.

func (*Client) Clunk

func (clnt *Client) Clunk(fid *Fid) (err error)

Clunks a fid. Returns nil if successful.

func (*Client) Create

func (clnt *Client) Create(fid *Fid, name string, perm uint32, mode uint8, ext string) error

Creates a file in the directory associated with the fid. Returns nil if the operation is successful.

func (*Client) FCreate

func (clnt *Client) FCreate(path string, perm uint32, mode uint8) (*File, error)

Creates and opens a named file. Returns the file if the operation is successful, or an Error.

func (*Client) FOpen

func (clnt *Client) FOpen(path string, mode uint8) (*File, error)

Opens a named file. Returns the opened file, or an Error.

func (*Client) FRemove

func (clnt *Client) FRemove(path string) error

Removes the named file. Returns nil if the operation is successful.

func (*Client) FStat

func (clnt *Client) FStat(path string) (*g9p.Dir, error)

Returns the metadata for a named file, or an Error.

func (*Client) FWalk

func (clnt *Client) FWalk(path string) (*Fid, error)

Walks to a named file. Returns a Fid associated with the file, or an Error.

func (*Client) Msize

func (client *Client) Msize() uint32

func (*Client) Open

func (clnt *Client) Open(fid *Fid, mode uint8) error

Opens the file associated with the fid. Returns nil if the operation is successful.

func (*Client) Remove

func (clnt *Client) Remove(fid *Fid) error

Removes the file associated with the Fid. Returns nil if the operation is successful.

func (*Client) Stat

func (clnt *Client) Stat(fid *Fid) (*g9p.Dir, error)

Returns the metadata for the file associated with the Fid, or an Error.

func (*Client) Unmount

func (clnt *Client) Unmount()

Closes the connection to the file sever.

func (*Client) Wait

func (client *Client) Wait() (err error)

func (*Client) Walk

func (clnt *Client) Walk(fid *Fid, newfid *Fid, wnames []string) ([]g9p.Qid, error)

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.

func (*Client) Wstat

func (clnt *Client) Wstat(fid *Fid, dir *g9p.Dir) error

Modifies the data of the file associated with the Fid, or an Error.

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

func (*Fid) BRead

func (fid *Fid) BRead(offset uint64, count int) ([]byte, error)

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 (*Fid) ReadAt

func (fid *Fid) ReadAt(buf []byte, offset uint64) (int, error)

func (*Fid) WriteAt

func (fid *Fid) WriteAt(data []byte, offset uint64) (int, error)

Write up to len(data) bytes starting from offset. Returns the number of bytes written, or an Error.

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) Close

func (file *File) Close() error

Closes a file. Returns nil if successful.

func (*File) Read

func (file *File) Read(buf []byte) (int, error)

Reads up to len(buf) bytes from the File. Returns the number of bytes read, or an Error.

func (*File) ReadAt

func (file *File) ReadAt(buf []byte, offset uint64) (int, error)

Reads up to len(buf) bytes from the file starting from offset. Returns the number of bytes read, or an Error.

func (*File) Readdir

func (file *File) Readdir(num int) ([]*g9p.Dir, error)

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

func (file *File) Readn(buf []byte, offset uint64) (int, error)

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

func (file *File) Write(buf []byte) (int, error)

Writes up to len(buf) bytes to a file. Returns the number of bytes written, or an Error.

func (*File) WriteAt

func (file *File) WriteAt(buf []byte, offset uint64) (int, error)

Writes up to len(buf) bytes starting from offset. Returns the number of bytes written, or an Error.

func (*File) Writen

func (file *File) Writen(buf []byte, offset uint64) (int, error)

Writes exactly len(buf) bytes starting from offset. Returns the number of bytes written. If Error is returned the number of bytes can be less than len(buf).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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