ninep

package module
v0.0.0-...-4950cc4 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2019 License: ISC Imports: 16 Imported by: 0

README

NINEP

GoDoc Build Status

Package ninep serves network filesystems using the 9P2000.L protocol. The package provides types and routines for implementing 9P2000.L servers and clients.

WARNING: This software is new, experimental, and under heavy development. The documentation is lacking, if any. There are almost no tests. The APIs and source code layout can change in any moment. Do not trust it. Use it at your own risk.A

You have been warned

References

  • 9P2000.L protocol overview
  • VirtFS -- A virtualization aware File System pass-through, Jujjuri et al, 2010.
  • Plan 9 from Bell Labs - Section 5 - Plan 9 File Protocol, 9P, Plan 9 Manual, 4nd edition, 2002.
  • v9fs: Plan 9 Resource Sharing for Linux
  • Plan 9 Remote Resource Protocol Unix Extension experimental-draft-9P2000-unix-extension, Van Hensbergen, 2009.

Authors

See list of CONTRIBUTORS who participated in this project.

License

This project is licensed under the ISC license - see the LICENSE file for details.

Documentation

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
}

Client represents a 9P2000.L client. There may be multiple outstanding calls associated with a single client, and a client may be used by multiple goroutines simultaneously.

func Dial

func Dial(ctx context.Context, network, address string, opts ...Option) (*Client, error)

Dial connects to an 9P2000.L server at the specified network address.

The provided Context must be non-nil. If the context expires before the connection is complete, an error is returned. Once successfully connected, any expiration of the context will not affect the connection.

func NewClient

func NewClient(rwc io.ReadWriteCloser, opts ...Option) (*Client, error)

NewClient returns a new client to handle requests to the set of services at the other end of the connection.

func (*Client) Attach

func (c *Client) Attach(auth *Fid, export, username string, uid int) (*Fid, error)

Attach introduces a new user to the server, and establishes Fid as the root for that user on the file tree selected by export.

func (*Client) Auth

func (c *Client) Auth(export, username string, uid int) (*Fid, error)

Auth initiates an authentication handshake for the given user and root path. An error is returned if authentication is not required. If successful, the returned afid is used to read/write the authentication handshake (protocol does not specify what is read/written), and afid is presented in the attach.

func (*Client) Close

func (c *Client) Close() error

Close calls the underlying connection's Close method. If the connection is already shutting down, an error is returned.

type Fid

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

Fid structures are intended to represent a remote file descriptor in a 9P connection

func (*Fid) Close

func (f *Fid) Close() error

Close informs the file server that the current file represented by fid is no longer needed by the client.

func (*Fid) Create

func (f *Fid) Create(name string, flags int, perm os.FileMode) error

Create asks the file server to create a new file with the name supplied, in the directory represented by fid, and requires write permission in the directory.

Finally, the newly created file is opened according to perm, and fid will represent the newly opened file.

func (f *Fid) Link(oldname, newname string) error

func (*Fid) Mkdir

func (f *Fid) Mkdir(name string, perm os.FileMode) error

Mkdir asks the file server to create a new directory with the name supplied, in the directory represented by fid, and requires write permission in the directory.

func (*Fid) Mknod

func (f *Fid) Mknod(name string, perm os.FileMode, major, minor uint32) error

func (*Fid) Num

func (f *Fid) Num() uint32

Num returns the numerical fid identifier.

func (*Fid) Open

func (f *Fid) Open(flags int) error

Open opens the file represented by fid with specified flags (os.O_RDONLY etc.). If successful, it can be used for I/O.

func (*Fid) ReadAt

func (f *Fid) ReadAt(p []byte, offset int64) (int, error)
func (f *Fid) ReadLink(name string) (string, error)

func (*Fid) Remove

func (f *Fid) Remove() error

Remove asks the file server both to remove the file represented by fid and to close the fid, even if the remove fails. This request will fail if the client does not have write permission in the parent directory.

It is correct to consider remove to be a clunk with the side effect of removing the file if permissions allow.

func (*Fid) Rename

func (f *Fid) Rename(oldpath, newpath string) error

func (*Fid) Stat

func (f *Fid) Stat() (os.FileInfo, error)

Stat returns information about a file represented by fid. Execute (search) permission is required on all of the directories in path that lead to the file.

func (*Fid) Sync

func (f *Fid) Sync() error

func (*Fid) Walk

func (f *Fid) Walk(names ...string) (*Fid, error)

func (*Fid) WriteAt

func (f *Fid) WriteAt(p []byte, offset int64) (int, error)

type Option

type Option func(interface{}) error

Option sets Server or Client options such as logging, max message size etc.

func WithMaxMessageSize

func WithMaxMessageSize(size uint32) Option

type Server

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

func NewServer

func NewServer(fs posix.FileSystem, opts ...Option) *Server

func (*Server) Listen

func (s *Server) Listen(listener net.Listener) (err error)

Directories

Path Synopsis
Package binary implements little-endian translation between 9P types and byte sequences.
Package binary implements little-endian translation between 9P types and byte sequences.
Package proto provides the definitions and functions used to implement the 9P protocol.
Package proto provides the definitions and functions used to implement the 9P protocol.

Jump to

Keyboard shortcuts

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