p9

package
v0.0.0-...-522126a Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package p9 is a 9P2000.L implementation.

Index

Constants

View Source
const (
	// NoTag is a sentinel used to indicate no valid tag.
	NoTag Tag = math.MaxUint16

	// NoFID is a sentinel used to indicate no valid FID.
	NoFID FID = math.MaxUint32

	// NoUID is a sentinel used to indicate no valid UID.
	NoUID UID = math.MaxUint32

	// NoGID is a sentinel used to indicate no valid GID.
	NoGID GID = math.MaxUint32
)
View Source
const (
	MsgTlerror      MsgType = 6
	MsgRlerror              = 7
	MsgTstatfs              = 8
	MsgRstatfs              = 9
	MsgTlopen               = 12
	MsgRlopen               = 13
	MsgTlcreate             = 14
	MsgRlcreate             = 15
	MsgTsymlink             = 16
	MsgRsymlink             = 17
	MsgTmknod               = 18
	MsgRmknod               = 19
	MsgTrename              = 20
	MsgRrename              = 21
	MsgTreadlink            = 22
	MsgRreadlink            = 23
	MsgTgetattr             = 24
	MsgRgetattr             = 25
	MsgTsetattr             = 26
	MsgRsetattr             = 27
	MsgTxattrwalk           = 30
	MsgRxattrwalk           = 31
	MsgTxattrcreate         = 32
	MsgRxattrcreate         = 33
	MsgTreaddir             = 40
	MsgRreaddir             = 41
	MsgTfsync               = 50
	MsgRfsync               = 51
	MsgTlink                = 70
	MsgRlink                = 71
	MsgTmkdir               = 72
	MsgRmkdir               = 73
	MsgTrenameat            = 74
	MsgRrenameat            = 75
	MsgTunlinkat            = 76
	MsgRunlinkat            = 77
	MsgTversion             = 100
	MsgRversion             = 101
	MsgTauth                = 102
	MsgRauth                = 103
	MsgTattach              = 104
	MsgRattach              = 105
	MsgTflush               = 108
	MsgRflush               = 109
	MsgTwalk                = 110
	MsgRwalk                = 111
	MsgTread                = 116
	MsgRread                = 117
	MsgTwrite               = 118
	MsgRwrite               = 119
	MsgTclunk               = 120
	MsgRclunk               = 121
	MsgTremove              = 122
	MsgRremove              = 123
	MsgTflushf              = 124
	MsgRflushf              = 125
	MsgTwalkgetattr         = 126
	MsgRwalkgetattr         = 127
	MsgTucreate             = 128
	MsgRucreate             = 129
	MsgTumkdir              = 130
	MsgRumkdir              = 131
	MsgTumknod              = 132
	MsgRumknod              = 133
	MsgTusymlink            = 134
	MsgRusymlink            = 135
	MsgTlconnect            = 136
	MsgRlconnect            = 137
	MsgTallocate            = 138
	MsgRallocate            = 139
	MsgTchannel             = 250
	MsgRchannel             = 251
)

MsgType declarations.

View Source
const (

	// DefaultMessageSize is a sensible default.
	DefaultMessageSize uint32 = 64 << 10
)

Variables

View Source
var ErrBadVersionString = errors.New("bad version string")

ErrBadVersionString indicates that the version string is malformed or unsupported.

View Source
var ErrNoValidMessage = errors.New("buffer contained no valid message")

ErrNoValidMessage indicates no valid message could be decoded.

View Source
var ErrOutOfFIDs = errors.New("out of FIDs -- messages lost?")

ErrOutOfFIDs indicates no more FIDs are available.

View Source
var ErrOutOfTags = errors.New("out of tags -- messages lost?")

ErrOutOfTags indicates no tags are available.

View Source
var ErrUnexpectedTag = errors.New("unexpected tag in response")

ErrUnexpectedTag indicates a response with an unexpected tag was received.

View Source
var ErrVersionsExhausted = errors.New("exhausted all versions to negotiate")

ErrVersionsExhausted indicates that all versions to negotiate have been exhausted.

Functions

func CanOpen

func CanOpen(mode FileMode) bool

CanOpen returns whether this file open can be opened, read and written to.

This includes everything except symlinks and sockets.

func ExtractErrno

func ExtractErrno(err error) syscall.Errno

ExtractErrno extracts a syscall.Errno from a error, best effort.

func HighestVersionString

func HighestVersionString() string

HighestVersionString returns the highest possible version string that a client may request or a server may support.

func StatToAttr

func StatToAttr(s *syscall.Stat_t, req AttrMask) (Attr, AttrMask)

StatToAttr converts a Linux syscall stat structure to an Attr.

func VersionSupportsAnonymous

func VersionSupportsAnonymous(v uint32) bool

VersionSupportsAnonymous returns true if version v supports Tlconnect with the AnonymousSocket mode. This predicate must be checked by clients before attempting to use the AnonymousSocket Tlconnect mode.

func VersionSupportsConnect

func VersionSupportsConnect(v uint32) bool

VersionSupportsConnect returns true if version v supports the Tlconnect message. This predicate must be checked by clients before attempting to make a Tlconnect request. If Tlconnect messages are not supported, Tlopen should be used.

func VersionSupportsMultiUser

func VersionSupportsMultiUser(v uint32) bool

VersionSupportsMultiUser returns true if version v supports multi-user fake directory permissions and ID values.

func VersionSupportsOpenTruncateFlag

func VersionSupportsOpenTruncateFlag(v uint32) bool

VersionSupportsOpenTruncateFlag returns true if version v supports passing the OpenTruncate flag to Tlopen.

func VersionSupportsTflushf

func VersionSupportsTflushf(v uint32) bool

VersionSupportsTflushf returns true if version v supports the Tflushf message. This predicate must be checked by clients before attempting to make a Tflushf request. If this predicate returns false, then clients may safely no-op.

Types

type AllocateMode

type AllocateMode struct {
	KeepSize      bool
	PunchHole     bool
	NoHideStale   bool
	CollapseRange bool
	ZeroRange     bool
	InsertRange   bool
	Unshare       bool
}

AllocateMode are possible modes to p9.File.Allocate().

func (*AllocateMode) Decode

func (a *AllocateMode) Decode(b *buffer)

Decode implements encoder.Decode.

func (*AllocateMode) Encode

func (a *AllocateMode) Encode(b *buffer)

Encode implements encoder.Encode.

func (*AllocateMode) ToLinux

func (a *AllocateMode) ToLinux() uint32

ToLinux converts to a value compatible with fallocate(2)'s mode.

type Attacher

type Attacher interface {
	// Attach returns a new File.
	//
	// The client-side attach will be translate to a series of walks from
	// the file returned by this Attach call.
	Attach() (File, error)
}

Attacher is provided by the server.

type Attr

type Attr struct {
	Mode             FileMode
	UID              UID
	GID              GID
	NLink            uint64
	RDev             uint64
	Size             uint64
	BlockSize        uint64
	Blocks           uint64
	ATimeSeconds     uint64
	ATimeNanoSeconds uint64
	MTimeSeconds     uint64
	MTimeNanoSeconds uint64
	CTimeSeconds     uint64
	CTimeNanoSeconds uint64
	BTimeSeconds     uint64
	BTimeNanoSeconds uint64
	Gen              uint64
	DataVersion      uint64
}

Attr is a set of attributes for getattr.

func (*Attr) Apply

func (a *Attr) Apply(mask SetAttrMask, attr SetAttr)

Apply applies this to the given Attr.

func (*Attr) Decode

func (a *Attr) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Attr) Encode

func (a *Attr) Encode(b *buffer)

Encode implements encoder.Encode.

func (Attr) String

func (a Attr) String() string

String implements fmt.Stringer.

type AttrMask

type AttrMask struct {
	Mode        bool
	NLink       bool
	UID         bool
	GID         bool
	RDev        bool
	ATime       bool
	MTime       bool
	CTime       bool
	INo         bool
	Size        bool
	Blocks      bool
	BTime       bool
	Gen         bool
	DataVersion bool
}

AttrMask is a mask of attributes for getattr.

func AttrMaskAll

func AttrMaskAll() AttrMask

AttrMaskAll returns an AttrMask with all fields masked.

func (AttrMask) Contains

func (a AttrMask) Contains(b AttrMask) bool

Contains returns true if a contains all of the attributes masked as b.

func (*AttrMask) Decode

func (a *AttrMask) Decode(b *buffer)

Decode implements encoder.Decode.

func (AttrMask) Empty

func (a AttrMask) Empty() bool

Empty returns true if no fields are masked.

func (*AttrMask) Encode

func (a *AttrMask) Encode(b *buffer)

Encode implements encoder.Encode.

func (AttrMask) String

func (a AttrMask) String() string

String implements fmt.Stringer.

type Client

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

Client is at least a 9P2000.L client.

func NewClient

func NewClient(socket *unet.Socket, messageSize uint32, version string) (*Client, error)

NewClient creates a new client. It performs a Tversion exchange with the server to assert that messageSize is ok to use.

If NewClient succeeds, ownership of socket is transferred to the new Client.

func (*Client) Attach

func (c *Client) Attach(name string) (File, error)

Attach attaches to a server.

Note that authentication is not currently supported.

func (*Client) Close

func (c *Client) Close()

Close closes the underlying socket and channels.

func (*Client) Version

func (c *Client) Version() uint32

Version returns the negotiated 9P2000.L.Google version number.

type ConnectFlags

type ConnectFlags uint32

ConnectFlags is the mode passed to Connect operations.

These correspond to bits sent over the wire.

const (
	// StreamSocket is a Tlconnect flag indicating SOCK_STREAM mode.
	StreamSocket ConnectFlags = 0

	// DgramSocket is a Tlconnect flag indicating SOCK_DGRAM mode.
	DgramSocket ConnectFlags = 1

	// SeqpacketSocket is a Tlconnect flag indicating SOCK_SEQPACKET mode.
	SeqpacketSocket ConnectFlags = 2

	// AnonymousSocket is a Tlconnect flag indicating that the mode does not
	// matter and that the requester will accept any socket type.
	AnonymousSocket ConnectFlags = 3
)

type DefaultWalkGetAttr

type DefaultWalkGetAttr struct{}

DefaultWalkGetAttr implements File.WalkGetAttr to return ENOSYS for server-side Files.

func (DefaultWalkGetAttr) WalkGetAttr

func (DefaultWalkGetAttr) WalkGetAttr([]string) ([]QID, File, AttrMask, Attr, error)

WalkGetAttr implements File.WalkGetAttr.

type Dirent

type Dirent struct {
	// QID is the entry QID.
	QID QID

	// Offset is the offset in the directory.
	//
	// This will be communicated back the original caller.
	Offset uint64

	// Type is the 9P type.
	Type QIDType

	// Name is the name of the entry (i.e. basename).
	Name string
}

Dirent is used for readdir.

func (*Dirent) Decode

func (d *Dirent) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Dirent) Encode

func (d *Dirent) Encode(b *buffer)

Encode implements encoder.Encode.

func (Dirent) String

func (d Dirent) String() string

String implements fmt.Stringer.

type ErrBadResponse

type ErrBadResponse struct {
	Got  MsgType
	Want MsgType
}

ErrBadResponse indicates the response didn't match the request.

func (*ErrBadResponse) Error

func (e *ErrBadResponse) Error() string

Error returns a highly descriptive error.

type ErrInvalidMsgType

type ErrInvalidMsgType struct {
	MsgType
}

ErrInvalidMsgType is returned when an unsupported message type is found.

func (*ErrInvalidMsgType) Error

func (e *ErrInvalidMsgType) Error() string

Error returns a useful string.

type ErrMessageTooLarge

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

ErrMessageTooLarge indicates the size was larger than reasonable.

func (*ErrMessageTooLarge) Error

func (e *ErrMessageTooLarge) Error() string

Error returns a sensible error.

type ErrSocket

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

ErrSocket is returned in cases of a socket issue.

This may be treated differently than other errors.

type FID

type FID uint64

FID is a file identifier.

type FSStat

type FSStat struct {
	// Type is the filesystem type.
	Type uint32

	// BlockSize is the blocksize.
	BlockSize uint32

	// Blocks is the number of blocks.
	Blocks uint64

	// BlocksFree is the number of free blocks.
	BlocksFree uint64

	// BlocksAvailable is the number of blocks *available*.
	BlocksAvailable uint64

	// Files is the number of files available.
	Files uint64

	// FilesFree is the number of free file nodes.
	FilesFree uint64

	// FSID is the filesystem ID.
	FSID uint64

	// NameLength is the maximum name length.
	NameLength uint32
}

FSStat is used by statfs.

func (*FSStat) Decode

func (f *FSStat) Decode(b *buffer)

Decode implements encoder.Decode.

func (*FSStat) Encode

func (f *FSStat) Encode(b *buffer)

Encode implements encoder.Encode.

type File

type File interface {
	// Walk walks to the path components given in names.
	//
	// Walk returns QIDs in the same order that the names were passed in.
	//
	// An empty list of arguments should return a copy of the current file.
	//
	// On the server, Walk has a read concurrency guarantee.
	Walk(names []string) ([]QID, File, error)

	// WalkGetAttr walks to the next file and returns its maximal set of
	// attributes.
	//
	// Server-side p9.Files may return syscall.ENOSYS to indicate that Walk
	// and GetAttr should be used separately to satisfy this request.
	//
	// On the server, WalkGetAttr has a read concurrency guarantee.
	WalkGetAttr([]string) ([]QID, File, AttrMask, Attr, error)

	// StatFS returns information about the file system associated with
	// this file.
	//
	// On the server, StatFS has no concurrency guarantee.
	StatFS() (FSStat, error)

	// GetAttr returns attributes of this node.
	//
	// On the server, GetAttr has a read concurrency guarantee.
	GetAttr(req AttrMask) (QID, AttrMask, Attr, error)

	// SetAttr sets attributes on this node.
	//
	// On the server, SetAttr has a write concurrency guarantee.
	SetAttr(valid SetAttrMask, attr SetAttr) error

	// Allocate allows the caller to directly manipulate the allocated disk space
	// for the file. See fallocate(2) for more details.
	Allocate(mode AllocateMode, offset, length uint64) error

	// Close is called when all references are dropped on the server side,
	// and Close should be called by the client to drop all references.
	//
	// For server-side implementations of Close, the error is ignored.
	//
	// Close must be called even when Open has not been called.
	//
	// On the server, Close has no concurrency guarantee.
	Close() error

	// Open must be called prior to using Read, Write or Readdir. Once Open
	// is called, some operations, such as Walk, will no longer work.
	//
	// On the client, Open should be called only once. The fd return is
	// optional, and may be nil.
	//
	// On the server, Open has a read concurrency guarantee. If an *fd.FD
	// is provided, ownership now belongs to the caller. Open is guaranteed
	// to be called only once.
	//
	// N.B. The server must resolve any lazy paths when open is called.
	// After this point, read and write may be called on files with no
	// deletion check, so resolving in the data path is not viable.
	Open(flags OpenFlags) (*fd.FD, QID, uint32, error)

	// Read reads from this file. Open must be called first.
	//
	// This may return io.EOF in addition to syscall.Errno values.
	//
	// On the server, ReadAt has a read concurrency guarantee. See Open for
	// additional requirements regarding lazy path resolution.
	ReadAt(p []byte, offset uint64) (int, error)

	// Write writes to this file. Open must be called first.
	//
	// This may return io.EOF in addition to syscall.Errno values.
	//
	// On the server, WriteAt has a read concurrency guarantee. See Open
	// for additional requirements regarding lazy path resolution.
	WriteAt(p []byte, offset uint64) (int, error)

	// FSync syncs this node. Open must be called first.
	//
	// On the server, FSync has a read concurrency guarantee.
	FSync() error

	// Create creates a new regular file and opens it according to the
	// flags given. This file is already Open.
	//
	// N.B. On the client, the returned file is a reference to the current
	// file, which now represents the created file. This is not the case on
	// the server. These semantics are very subtle and can easily lead to
	// bugs, but are a consequence of the 9P create operation.
	//
	// See p9.File.Open for a description of *fd.FD.
	//
	// On the server, Create has a write concurrency guarantee.
	Create(name string, flags OpenFlags, permissions FileMode, uid UID, gid GID) (*fd.FD, File, QID, uint32, error)

	// Mkdir creates a subdirectory.
	//
	// On the server, Mkdir has a write concurrency guarantee.
	Mkdir(name string, permissions FileMode, uid UID, gid GID) (QID, error)

	// Symlink makes a new symbolic link.
	//
	// On the server, Symlink has a write concurrency guarantee.
	Symlink(oldName string, newName string, uid UID, gid GID) (QID, error)

	// Link makes a new hard link.
	//
	// On the server, Link has a write concurrency guarantee.
	Link(target File, newName string) error

	// Mknod makes a new device node.
	//
	// On the server, Mknod has a write concurrency guarantee.
	Mknod(name string, mode FileMode, major uint32, minor uint32, uid UID, gid GID) (QID, error)

	// Rename renames the file.
	//
	// Rename will never be called on the server, and RenameAt will always
	// be used instead.
	Rename(newDir File, newName string) error

	// RenameAt renames a given file to a new name in a potentially new
	// directory.
	//
	// oldName must be a name relative to this file, which must be a
	// directory. newName is a name relative to newDir.
	//
	// On the server, RenameAt has a global concurrency guarantee.
	RenameAt(oldName string, newDir File, newName string) error

	// UnlinkAt the given named file.
	//
	// name must be a file relative to this directory.
	//
	// Flags are implementation-specific (e.g. O_DIRECTORY), but are
	// generally Linux unlinkat(2) flags.
	//
	// On the server, UnlinkAt has a write concurrency guarantee.
	UnlinkAt(name string, flags uint32) error

	// Readdir reads directory entries.
	//
	// This may return io.EOF in addition to syscall.Errno values.
	//
	// On the server, Readdir has a read concurrency guarantee.
	Readdir(offset uint64, count uint32) ([]Dirent, error)

	// Readlink reads the link target.
	//
	// On the server, Readlink has a read concurrency guarantee.
	Readlink() (string, error)

	// Flush is called prior to Close.
	//
	// Whereas Close drops all references to the file, Flush cleans up the
	// file state. Behavior is implementation-specific.
	//
	// Flush is not related to flush(9p). Flush is an extension to 9P2000.L,
	// see version.go.
	//
	// On the server, Flush has a read concurrency guarantee.
	Flush() error

	// Connect establishes a new host-socket backed connection with a
	// socket. A File does not need to be opened before it can be connected
	// and it can be connected to multiple times resulting in a unique
	// *fd.FD each time. In addition, the lifetime of the *fd.FD is
	// independent from the lifetime of the p9.File and must be managed by
	// the caller.
	//
	// The returned FD must be non-blocking.
	//
	// Flags indicates the requested type of socket.
	//
	// On the server, Connect has a read concurrency guarantee.
	Connect(flags ConnectFlags) (*fd.FD, error)

	// Renamed is called when this node is renamed.
	//
	// This may not fail. The file will hold a reference to its parent
	// within the p9 package, and is therefore safe to use for the lifetime
	// of this File (until Close is called).
	//
	// This method should not be called by clients, who should use the
	// relevant Rename methods. (Although the method will be a no-op.)
	//
	// On the server, Renamed has a global concurrency guarantee.
	Renamed(newDir File, newName string)
}

File is a set of operations corresponding to a single node.

Note that on the server side, the server logic places constraints on concurrent operations to make things easier. This may reduce the need for complex, error-prone locking and logic in the backend. These are documented for each method.

There are three different types of guarantees provided:

none: There is no concurrency guarantee. The method may be invoked concurrently with any other method on any other file.

read: The method is guaranteed to be exclusive of any write or global operation that is mutating the state of the directory tree starting at this node. For example, this means creating new files, symlinks, directories or renaming a directory entry (or renaming in to this target), but the method may be called concurrently with other read methods.

write: The method is guaranteed to be exclusive of any read, write or global operation that is mutating the state of the directory tree starting at this node, as described in read above. There may however, be other write operations executing concurrently on other components in the directory tree.

global: The method is guaranteed to be exclusive of any read, write or global operation.

type FileMode

type FileMode uint32

FileMode are flags corresponding to file modes.

These correspond to bits sent over the wire. These also correspond to mode_t bits.

const (
	// FileModeMask is a mask of all the file mode bits of FileMode.
	FileModeMask FileMode = 0170000

	// ModeSocket is an (unused) mode bit for a socket.
	ModeSocket FileMode = 0140000

	// ModeSymlink is a mode bit for a symlink.
	ModeSymlink FileMode = 0120000

	// ModeRegular is a mode bit for regular files.
	ModeRegular FileMode = 0100000

	// ModeBlockDevice is a mode bit for block devices.
	ModeBlockDevice FileMode = 060000

	// ModeDirectory is a mode bit for directories.
	ModeDirectory FileMode = 040000

	// ModeCharacterDevice is a mode bit for a character device.
	ModeCharacterDevice FileMode = 020000

	// ModeNamedPipe is a mode bit for a named pipe.
	ModeNamedPipe FileMode = 010000

	// Read is a mode bit indicating read permission.
	Read FileMode = 04

	// Write is a mode bit indicating write permission.
	Write FileMode = 02

	// Exec is a mode bit indicating exec permission.
	Exec FileMode = 01

	// AllPermissions is a mask with rwx bits set for user, group and others.
	AllPermissions FileMode = 0777

	// Sticky is a mode bit indicating sticky directories.
	Sticky FileMode = 01000
)

func ModeFromOS

func ModeFromOS(mode os.FileMode) FileMode

ModeFromOS returns a FileMode from an os.FileMode.

func (FileMode) FileType

func (m FileMode) FileType() FileMode

FileType returns the file mode without the permission bits.

func (FileMode) IsBlockDevice

func (m FileMode) IsBlockDevice() bool

IsBlockDevice returns true if m represents a character device.

func (FileMode) IsCharacterDevice

func (m FileMode) IsCharacterDevice() bool

IsCharacterDevice returns true if m represents a character device.

func (FileMode) IsDir

func (m FileMode) IsDir() bool

IsDir returns true if m represents a directory.

func (FileMode) IsExecutable

func (m FileMode) IsExecutable() bool

IsExecutable returns true if m represents a file that can be executed.

func (FileMode) IsNamedPipe

func (m FileMode) IsNamedPipe() bool

IsNamedPipe returns true if m represents a named pipe.

func (FileMode) IsReadable

func (m FileMode) IsReadable() bool

IsReadable returns true if m represents a file that can be read.

func (FileMode) IsRegular

func (m FileMode) IsRegular() bool

IsRegular returns true if m is a regular file.

func (FileMode) IsSocket

func (m FileMode) IsSocket() bool

IsSocket returns true if m represents a socket.

func (m FileMode) IsSymlink() bool

IsSymlink returns true if m represents a symlink.

func (FileMode) IsWritable

func (m FileMode) IsWritable() bool

IsWritable returns true if m represents a file that can be written to.

func (FileMode) OSMode

func (m FileMode) OSMode() os.FileMode

OSMode converts a p9.FileMode to an os.FileMode.

func (FileMode) Permissions

func (m FileMode) Permissions() FileMode

Permissions returns just the permission bits of the mode.

func (FileMode) QIDType

func (m FileMode) QIDType() QIDType

QIDType is the most significant byte of the FileMode word, to be used as the Type field of p9.QID.

func (FileMode) Writable

func (m FileMode) Writable() FileMode

Writable returns the mode with write bits added.

type GID

type GID uint32

GID represents a group ID.

func (GID) Ok

func (gid GID) Ok() bool

Ok returns true if gid is not NoGID.

type MsgType

type MsgType uint8

MsgType is a type identifier.

type OpenFlags

type OpenFlags uint32

OpenFlags is the mode passed to Open and Create operations.

These correspond to bits sent over the wire.

const (
	// ReadOnly is a Tlopen and Tlcreate flag indicating read-only mode.
	ReadOnly OpenFlags = 0

	// WriteOnly is a Tlopen and Tlcreate flag indicating write-only mode.
	WriteOnly OpenFlags = 1

	// ReadWrite is a Tlopen flag indicates read-write mode.
	ReadWrite OpenFlags = 2

	// OpenFlagsModeMask is a mask of valid OpenFlags mode bits.
	OpenFlagsModeMask OpenFlags = 3

	// OpenTruncate is a Tlopen flag indicating that the opened file should be
	// truncated.
	OpenTruncate OpenFlags = 01000
)

func (OpenFlags) OSFlags

func (o OpenFlags) OSFlags() int

OSFlags converts a p9.OpenFlags to an int compatible with open(2).

func (OpenFlags) String

func (o OpenFlags) String() string

String implements fmt.Stringer.

type QID

type QID struct {
	// Type is the highest order byte of the file mode.
	Type QIDType

	// Version is an arbitrary server version number.
	Version uint32

	// Path is a unique server identifier for this path (e.g. inode).
	Path uint64
}

QID is a unique file identifier.

This may be embedded in other requests and responses.

func (*QID) Decode

func (q *QID) Decode(b *buffer)

Decode implements encoder.Decode.

func (*QID) Encode

func (q *QID) Encode(b *buffer)

Encode implements encoder.Encode.

func (QID) String

func (q QID) String() string

String implements fmt.Stringer.

type QIDGenerator

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

QIDGenerator is a simple generator for QIDs that atomically increments Path values.

func (*QIDGenerator) Get

func (q *QIDGenerator) Get(t QIDType) QID

Get returns a new 9P unique ID with a unique Path given a QID type.

While the 9P spec allows Version to be incremented every time the file is modified, we currently do not use the Version member for anything. Hence, it is set to 0.

type QIDType

type QIDType uint8

QIDType represents the file type for QIDs.

QIDType corresponds to the high 8 bits of a Plan 9 file mode.

const (
	// TypeDir represents a directory type.
	TypeDir QIDType = 0x80

	// TypeAppendOnly represents an append only file.
	TypeAppendOnly QIDType = 0x40

	// TypeExclusive represents an exclusive-use file.
	TypeExclusive QIDType = 0x20

	// TypeMount represents a mounted channel.
	TypeMount QIDType = 0x10

	// TypeAuth represents an authentication file.
	TypeAuth QIDType = 0x08

	// TypeTemporary represents a temporary file.
	TypeTemporary QIDType = 0x04

	// TypeSymlink represents a symlink.
	TypeSymlink QIDType = 0x02

	// TypeLink represents a hard link.
	TypeLink QIDType = 0x01

	// TypeRegular represents a regular file.
	TypeRegular QIDType = 0x00
)

type Rallocate

type Rallocate struct {
}

Rallocate is an allocate response.

func (*Rallocate) Decode

func (*Rallocate) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rallocate) Encode

func (*Rallocate) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rallocate) String

func (r *Rallocate) String() string

String implements fmt.Stringer.

func (*Rallocate) Type

func (*Rallocate) Type() MsgType

Type implements message.Type.

type Rattach

type Rattach struct {
	QID
}

Rattach is an attach response.

func (*Rattach) String

func (r *Rattach) String() string

String implements fmt.Stringer.

func (*Rattach) Type

func (*Rattach) Type() MsgType

Type implements message.Type.

type Rauth

type Rauth struct {
	QID
}

Rauth is an authentication response.

Encode, Decode and Length are inherited directly from QID.

func (*Rauth) String

func (r *Rauth) String() string

String implements fmt.Stringer.

func (*Rauth) Type

func (*Rauth) Type() MsgType

Type implements message.Type.

type Rchannel

type Rchannel struct {
	Offset uint64
	Length uint64
	// contains filtered or unexported fields
}

Rchannel is the channel response.

func (*Rchannel) Decode

func (r *Rchannel) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rchannel) Encode

func (r *Rchannel) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rchannel) FilePayload

func (f *Rchannel) FilePayload() *fd.FD

FilePayload returns the file payload.

func (*Rchannel) SetFilePayload

func (f *Rchannel) SetFilePayload(file *fd.FD)

SetFilePayload sets the received file.

func (*Rchannel) String

func (r *Rchannel) String() string

String implements fmt.Stringer.

func (*Rchannel) Type

func (*Rchannel) Type() MsgType

Type implements message.Type.

type Rclunk

type Rclunk struct {
}

Rclunk is a close response.

func (*Rclunk) Decode

func (*Rclunk) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rclunk) Encode

func (*Rclunk) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rclunk) String

func (r *Rclunk) String() string

String implements fmt.Stringer.

func (*Rclunk) Type

func (*Rclunk) Type() MsgType

Type implements message.Type.

type ReadWriterFile

type ReadWriterFile struct {
	File   File
	Offset uint64
}

ReadWriterFile wraps a File and implements io.ReadWriter, io.ReaderAt, and io.WriterAt.

func (*ReadWriterFile) Read

func (r *ReadWriterFile) Read(p []byte) (int, error)

Read implements part of the io.ReadWriter interface.

func (*ReadWriterFile) ReadAt

func (r *ReadWriterFile) ReadAt(p []byte, offset int64) (int, error)

ReadAt implements the io.ReaderAt interface.

func (*ReadWriterFile) Write

func (r *ReadWriterFile) Write(p []byte) (int, error)

Write implements part of the io.ReadWriter interface.

func (*ReadWriterFile) WriteAt

func (r *ReadWriterFile) WriteAt(p []byte, offset int64) (int, error)

WriteAt implements the io.WriteAt interface.

type Rflush

type Rflush struct {
}

Rflush is a flush response.

func (*Rflush) Decode

func (*Rflush) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rflush) Encode

func (*Rflush) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rflush) String

func (r *Rflush) String() string

String implements fmt.Stringer.

func (*Rflush) Type

func (*Rflush) Type() MsgType

Type implements message.Type.

type Rflushf

type Rflushf struct {
}

Rflushf is a flush file response.

func (*Rflushf) Decode

func (*Rflushf) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rflushf) Encode

func (*Rflushf) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rflushf) String

func (*Rflushf) String() string

String implements fmt.Stringer.

func (*Rflushf) Type

func (*Rflushf) Type() MsgType

Type implements message.Type.

type Rfsync

type Rfsync struct {
}

Rfsync is an fsync response.

func (*Rfsync) Decode

func (*Rfsync) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rfsync) Encode

func (*Rfsync) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rfsync) String

func (r *Rfsync) String() string

String implements fmt.Stringer.

func (*Rfsync) Type

func (*Rfsync) Type() MsgType

Type implements message.Type.

type Rgetattr

type Rgetattr struct {
	// Valid indicates which fields are valid.
	Valid AttrMask

	// QID is the QID for this file.
	QID

	// Attr is the set of attributes.
	Attr Attr
}

Rgetattr is a getattr response.

func (*Rgetattr) Decode

func (r *Rgetattr) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rgetattr) Encode

func (r *Rgetattr) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rgetattr) String

func (r *Rgetattr) String() string

String implements fmt.Stringer.

func (*Rgetattr) Type

func (*Rgetattr) Type() MsgType

Type implements message.Type.

type Rlconnect

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

Rlconnect is a connect response.

func (*Rlconnect) Decode

func (r *Rlconnect) Decode(*buffer)

Decode implements encoder.Decode.

func (*Rlconnect) Encode

func (r *Rlconnect) Encode(*buffer)

Encode implements encoder.Encode.

func (*Rlconnect) FilePayload

func (f *Rlconnect) FilePayload() *fd.FD

FilePayload returns the file payload.

func (*Rlconnect) SetFilePayload

func (f *Rlconnect) SetFilePayload(file *fd.FD)

SetFilePayload sets the received file.

func (*Rlconnect) String

func (r *Rlconnect) String() string

String implements fmt.Stringer.

func (*Rlconnect) Type

func (*Rlconnect) Type() MsgType

Type implements message.Type.

type Rlcreate

type Rlcreate struct {
	Rlopen
}

Rlcreate is a create response.

The Encode, Decode, etc. methods are inherited from Rlopen.

func (*Rlcreate) FilePayload

func (f *Rlcreate) FilePayload() *fd.FD

FilePayload returns the file payload.

func (*Rlcreate) SetFilePayload

func (f *Rlcreate) SetFilePayload(file *fd.FD)

SetFilePayload sets the received file.

func (*Rlcreate) String

func (r *Rlcreate) String() string

String implements fmt.Stringer.

func (*Rlcreate) Type

func (*Rlcreate) Type() MsgType

Type implements message.Type.

type Rlerror

type Rlerror struct {
	Error uint32
}

Rlerror is an error response.

Note that this replaces the error code used in 9p.

func (*Rlerror) Decode

func (r *Rlerror) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rlerror) Encode

func (r *Rlerror) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rlerror) String

func (r *Rlerror) String() string

String implements fmt.Stringer.

func (*Rlerror) Type

func (*Rlerror) Type() MsgType

Type implements message.Type.

type Rlink struct {
}

Rlink is a link response.

func (*Rlink) Decode

func (*Rlink) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rlink) Encode

func (*Rlink) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rlink) String

func (r *Rlink) String() string

String implements fmt.Stringer.

func (*Rlink) Type

func (*Rlink) Type() MsgType

Type implements message.Type.

type Rlopen

type Rlopen struct {
	// QID is the file's QID.
	QID QID

	// IoUnit is the recommended I/O unit.
	IoUnit uint32
	// contains filtered or unexported fields
}

Rlopen is a open response.

func (*Rlopen) Decode

func (r *Rlopen) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rlopen) Encode

func (r *Rlopen) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rlopen) FilePayload

func (f *Rlopen) FilePayload() *fd.FD

FilePayload returns the file payload.

func (*Rlopen) SetFilePayload

func (f *Rlopen) SetFilePayload(file *fd.FD)

SetFilePayload sets the received file.

func (*Rlopen) String

func (r *Rlopen) String() string

String implements fmt.Stringer.

func (*Rlopen) Type

func (*Rlopen) Type() MsgType

Type implements message.Type.

type Rmkdir

type Rmkdir struct {
	// QID is the resulting QID.
	QID QID
}

Rmkdir is a mkdir response.

func (*Rmkdir) Decode

func (r *Rmkdir) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rmkdir) Encode

func (r *Rmkdir) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rmkdir) String

func (r *Rmkdir) String() string

String implements fmt.Stringer.

func (*Rmkdir) Type

func (*Rmkdir) Type() MsgType

Type implements message.Type.

type Rmknod

type Rmknod struct {
	// QID is the resulting QID.
	QID QID
}

Rmknod is a mknod response.

func (*Rmknod) Decode

func (r *Rmknod) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rmknod) Encode

func (r *Rmknod) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rmknod) String

func (r *Rmknod) String() string

String implements fmt.Stringer.

func (*Rmknod) Type

func (*Rmknod) Type() MsgType

Type implements message.Type.

type Rread

type Rread struct {
	// Data is the resulting data.
	Data []byte
}

Rread is the response for a Tread.

func (*Rread) Decode

func (r *Rread) Decode(b *buffer)

Decode implements encoder.Decode.

Data is automatically decoded via Payload.

func (*Rread) Encode

func (r *Rread) Encode(b *buffer)

Encode implements encoder.Encode.

Data is automatically encoded via Payload.

func (*Rread) FixedSize

func (*Rread) FixedSize() uint32

FixedSize implements payloader.FixedSize.

func (*Rread) Payload

func (r *Rread) Payload() []byte

Payload implements payloader.Payload.

func (*Rread) SetPayload

func (r *Rread) SetPayload(p []byte)

SetPayload implements payloader.SetPayload.

func (*Rread) String

func (r *Rread) String() string

String implements fmt.Stringer.

func (*Rread) Type

func (*Rread) Type() MsgType

Type implements message.Type.

type Rreaddir

type Rreaddir struct {
	// Count is the byte limit.
	//
	// This should always be set from the Treaddir request.
	Count uint32

	// Entries are the resulting entries.
	//
	// This may be constructed in decode.
	Entries []Dirent
	// contains filtered or unexported fields
}

Rreaddir is a readdir response.

func (*Rreaddir) Decode

func (r *Rreaddir) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rreaddir) Encode

func (r *Rreaddir) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rreaddir) FixedSize

func (*Rreaddir) FixedSize() uint32

FixedSize implements payloader.FixedSize.

func (*Rreaddir) Payload

func (r *Rreaddir) Payload() []byte

Payload implements payloader.Payload.

func (*Rreaddir) SetPayload

func (r *Rreaddir) SetPayload(p []byte)

SetPayload implements payloader.SetPayload.

func (*Rreaddir) String

func (r *Rreaddir) String() string

String implements fmt.Stringer.

func (*Rreaddir) Type

func (*Rreaddir) Type() MsgType

Type implements message.Type.

type Rreadlink struct {
	// Target is the symlink target.
	Target string
}

Rreadlink is a readlink response.

func (*Rreadlink) Decode

func (r *Rreadlink) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rreadlink) Encode

func (r *Rreadlink) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rreadlink) String

func (r *Rreadlink) String() string

String implements fmt.Stringer.

func (*Rreadlink) Type

func (*Rreadlink) Type() MsgType

Type implements message.Type.

type Rremove

type Rremove struct {
}

Rremove is a remove response.

func (*Rremove) Decode

func (*Rremove) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rremove) Encode

func (*Rremove) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rremove) String

func (r *Rremove) String() string

String implements fmt.Stringer.

func (*Rremove) Type

func (*Rremove) Type() MsgType

Type implements message.Type.

type Rrename

type Rrename struct {
}

Rrename is a rename response.

func (*Rrename) Decode

func (*Rrename) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rrename) Encode

func (*Rrename) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rrename) String

func (r *Rrename) String() string

String implements fmt.Stringer.

func (*Rrename) Type

func (*Rrename) Type() MsgType

Type implements message.Type.

type Rrenameat

type Rrenameat struct {
}

Rrenameat is a rename response.

func (*Rrenameat) Decode

func (*Rrenameat) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rrenameat) Encode

func (*Rrenameat) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rrenameat) String

func (r *Rrenameat) String() string

String implements fmt.Stringer.

func (*Rrenameat) Type

func (*Rrenameat) Type() MsgType

Type implements message.Type.

type Rsetattr

type Rsetattr struct {
}

Rsetattr is a setattr response.

func (*Rsetattr) Decode

func (*Rsetattr) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rsetattr) Encode

func (*Rsetattr) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rsetattr) String

func (r *Rsetattr) String() string

String implements fmt.Stringer.

func (*Rsetattr) Type

func (*Rsetattr) Type() MsgType

Type implements message.Type.

type Rstatfs

type Rstatfs struct {
	// FSStat is the stat result.
	FSStat FSStat
}

Rstatfs is the response for a Tstatfs.

func (*Rstatfs) Decode

func (r *Rstatfs) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rstatfs) Encode

func (r *Rstatfs) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rstatfs) String

func (r *Rstatfs) String() string

String implements fmt.Stringer.

func (*Rstatfs) Type

func (*Rstatfs) Type() MsgType

Type implements message.Type.

type Rsymlink struct {
	// QID is the new symlink's QID.
	QID QID
}

Rsymlink is a symlink response.

func (*Rsymlink) Decode

func (r *Rsymlink) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rsymlink) Encode

func (r *Rsymlink) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rsymlink) String

func (r *Rsymlink) String() string

String implements fmt.Stringer.

func (*Rsymlink) Type

func (*Rsymlink) Type() MsgType

Type implements message.Type.

type Rucreate

type Rucreate struct {
	Rlcreate
}

Rucreate is a file creation response.

func (*Rucreate) FilePayload

func (f *Rucreate) FilePayload() *fd.FD

FilePayload returns the file payload.

func (*Rucreate) SetFilePayload

func (f *Rucreate) SetFilePayload(file *fd.FD)

SetFilePayload sets the received file.

func (*Rucreate) String

func (r *Rucreate) String() string

String implements fmt.Stringer.

func (*Rucreate) Type

func (*Rucreate) Type() MsgType

Type implements message.Type.

type Rumkdir

type Rumkdir struct {
	Rmkdir
}

Rumkdir is a umkdir response.

func (*Rumkdir) String

func (r *Rumkdir) String() string

String implements fmt.Stringer.

func (*Rumkdir) Type

func (*Rumkdir) Type() MsgType

Type implements message.Type.

type Rumknod

type Rumknod struct {
	Rmknod
}

Rumknod is a umknod response.

func (*Rumknod) String

func (r *Rumknod) String() string

String implements fmt.Stringer.

func (*Rumknod) Type

func (*Rumknod) Type() MsgType

Type implements message.Type.

type Runlinkat

type Runlinkat struct {
}

Runlinkat is an unlink response.

func (*Runlinkat) Decode

func (*Runlinkat) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Runlinkat) Encode

func (*Runlinkat) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Runlinkat) String

func (r *Runlinkat) String() string

String implements fmt.Stringer.

func (*Runlinkat) Type

func (*Runlinkat) Type() MsgType

Type implements message.Type.

type Rusymlink struct {
	Rsymlink
}

Rusymlink is a usymlink response.

func (*Rusymlink) String

func (r *Rusymlink) String() string

String implements fmt.Stringer.

func (*Rusymlink) Type

func (*Rusymlink) Type() MsgType

Type implements message.Type.

type Rversion

type Rversion struct {
	// MSize is the negotiated size.
	MSize uint32

	// Version is the negotiated version.
	Version string
}

Rversion is a version response.

func (*Rversion) Decode

func (r *Rversion) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rversion) Encode

func (r *Rversion) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rversion) String

func (r *Rversion) String() string

String implements fmt.Stringer.

func (*Rversion) Type

func (*Rversion) Type() MsgType

Type implements message.Type.

type Rwalk

type Rwalk struct {
	// QIDs are the set of QIDs returned.
	QIDs []QID
}

Rwalk is a walk response.

func (*Rwalk) Decode

func (r *Rwalk) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rwalk) Encode

func (r *Rwalk) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rwalk) String

func (r *Rwalk) String() string

String implements fmt.Stringer.

func (*Rwalk) Type

func (*Rwalk) Type() MsgType

Type implements message.Type.

type Rwalkgetattr

type Rwalkgetattr struct {
	// Valid indicates which fields are valid in the Attr below.
	Valid AttrMask

	// Attr is the set of attributes for the last QID (the file walked to).
	Attr Attr

	// QIDs are the set of QIDs returned.
	QIDs []QID
}

Rwalkgetattr is a walk response.

func (*Rwalkgetattr) Decode

func (r *Rwalkgetattr) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rwalkgetattr) Encode

func (r *Rwalkgetattr) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rwalkgetattr) String

func (r *Rwalkgetattr) String() string

String implements fmt.Stringer.

func (*Rwalkgetattr) Type

func (*Rwalkgetattr) Type() MsgType

Type implements message.Type.

type Rwrite

type Rwrite struct {
	// Count indicates the number of bytes successfully written.
	Count uint32
}

Rwrite is the response for a Twrite.

func (*Rwrite) Decode

func (r *Rwrite) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rwrite) Encode

func (r *Rwrite) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rwrite) String

func (r *Rwrite) String() string

String implements fmt.Stringer.

func (*Rwrite) Type

func (*Rwrite) Type() MsgType

Type implements message.Type.

type Rxattrcreate

type Rxattrcreate struct {
}

Rxattrcreate is a xattrcreate response.

func (*Rxattrcreate) Decode

func (r *Rxattrcreate) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rxattrcreate) Encode

func (r *Rxattrcreate) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rxattrcreate) String

func (r *Rxattrcreate) String() string

String implements fmt.Stringer.

func (*Rxattrcreate) Type

func (*Rxattrcreate) Type() MsgType

Type implements message.Type.

type Rxattrwalk

type Rxattrwalk struct {
	// Size is the size of the extended attribute.
	Size uint64
}

Rxattrwalk is a xattrwalk response.

func (*Rxattrwalk) Decode

func (r *Rxattrwalk) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Rxattrwalk) Encode

func (r *Rxattrwalk) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Rxattrwalk) String

func (r *Rxattrwalk) String() string

String implements fmt.Stringer.

func (*Rxattrwalk) Type

func (*Rxattrwalk) Type() MsgType

Type implements message.Type.

type Server

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

Server is a 9p2000.L server.

func NewServer

func NewServer(attacher Attacher) *Server

NewServer returns a new server.

func (*Server) Handle

func (s *Server) Handle(conn *unet.Socket) error

Handle handles a single connection.

func (*Server) Serve

func (s *Server) Serve(serverSocket *unet.ServerSocket) error

Serve handles requests from the bound socket.

The passed serverSocket _must_ be created in packet mode.

type SetAttr

type SetAttr struct {
	Permissions      FileMode
	UID              UID
	GID              GID
	Size             uint64
	ATimeSeconds     uint64
	ATimeNanoSeconds uint64
	MTimeSeconds     uint64
	MTimeNanoSeconds uint64
}

SetAttr specifies a set of attributes for a setattr.

func (*SetAttr) Decode

func (s *SetAttr) Decode(b *buffer)

Decode implements encoder.Decode.

func (*SetAttr) Encode

func (s *SetAttr) Encode(b *buffer)

Encode implements encoder.Encode.

func (SetAttr) String

func (s SetAttr) String() string

String implements fmt.Stringer.

type SetAttrMask

type SetAttrMask struct {
	Permissions        bool
	UID                bool
	GID                bool
	Size               bool
	ATime              bool
	MTime              bool
	CTime              bool
	ATimeNotSystemTime bool
	MTimeNotSystemTime bool
}

SetAttrMask specifies a valid mask for setattr.

func (*SetAttrMask) Decode

func (s *SetAttrMask) Decode(b *buffer)

Decode implements encoder.Decode.

func (SetAttrMask) Empty

func (s SetAttrMask) Empty() bool

Empty returns true if no fields are masked.

func (*SetAttrMask) Encode

func (s *SetAttrMask) Encode(b *buffer)

Encode implements encoder.Encode.

func (SetAttrMask) IsSubsetOf

func (s SetAttrMask) IsSubsetOf(m SetAttrMask) bool

IsSubsetOf returns whether s is a subset of m.

func (SetAttrMask) String

func (s SetAttrMask) String() string

String implements fmt.Stringer.

type Tag

type Tag uint16

Tag is a message tag.

type Tallocate

type Tallocate struct {
	FID    FID
	Mode   AllocateMode
	Offset uint64
	Length uint64
}

Tallocate is an allocate request. This is an extension to 9P protocol, not present in the 9P2000.L standard.

func (*Tallocate) Decode

func (t *Tallocate) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tallocate) Encode

func (t *Tallocate) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tallocate) String

func (t *Tallocate) String() string

String implements fmt.Stringer.

func (*Tallocate) Type

func (*Tallocate) Type() MsgType

Type implements message.Type.

type Tattach

type Tattach struct {
	// FID is the FID to be attached.
	FID FID

	// Auth is the embedded authentication request.
	//
	// See client.Attach for information regarding authentication.
	Auth Tauth
}

Tattach is an attach request.

func (*Tattach) Decode

func (t *Tattach) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tattach) Encode

func (t *Tattach) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tattach) String

func (t *Tattach) String() string

String implements fmt.Stringer.

func (*Tattach) Type

func (*Tattach) Type() MsgType

Type implements message.Type.

type Tauth

type Tauth struct {
	// AuthenticationFID is the FID to attach the authentication result.
	AuthenticationFID FID

	// UserName is the user to attach.
	UserName string

	// AttachName is the attach name.
	AttachName string

	// UserID is the numeric identifier for UserName.
	UID UID
}

Tauth is an authentication request.

func (*Tauth) Decode

func (t *Tauth) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tauth) Encode

func (t *Tauth) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tauth) String

func (t *Tauth) String() string

String implements fmt.Stringer.

func (*Tauth) Type

func (*Tauth) Type() MsgType

Type implements message.Type.

type Tchannel

type Tchannel struct {
	// ID is the channel ID.
	ID uint32

	// Control is 0 if the Rchannel response should provide the flipcall
	// component of the channel, and 1 if the Rchannel response should
	// provide the fdchannel component of the channel.
	Control uint32
}

Tchannel creates a new channel.

func (*Tchannel) Decode

func (t *Tchannel) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tchannel) Encode

func (t *Tchannel) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tchannel) String

func (t *Tchannel) String() string

String implements fmt.Stringer.

func (*Tchannel) Type

func (*Tchannel) Type() MsgType

Type implements message.Type.

type Tclunk

type Tclunk struct {
	// FID is the FID to be closed.
	FID FID
}

Tclunk is a close request.

func (*Tclunk) Decode

func (t *Tclunk) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tclunk) Encode

func (t *Tclunk) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tclunk) String

func (t *Tclunk) String() string

String implements fmt.Stringer.

func (*Tclunk) Type

func (*Tclunk) Type() MsgType

Type implements message.Type.

type Tflush

type Tflush struct {
	// OldTag is the tag to wait on.
	OldTag Tag
}

Tflush is a flush request.

func (*Tflush) Decode

func (t *Tflush) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tflush) Encode

func (t *Tflush) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tflush) String

func (t *Tflush) String() string

String implements fmt.Stringer.

func (*Tflush) Type

func (*Tflush) Type() MsgType

Type implements message.Type.

type Tflushf

type Tflushf struct {
	// FID is the FID to be flushed.
	FID FID
}

Tflushf is a flush file request, not to be confused with Tflush.

func (*Tflushf) Decode

func (t *Tflushf) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tflushf) Encode

func (t *Tflushf) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tflushf) String

func (t *Tflushf) String() string

String implements fmt.Stringer.

func (*Tflushf) Type

func (*Tflushf) Type() MsgType

Type implements message.Type.

type Tfsync

type Tfsync struct {
	// FID is the fid to sync.
	FID FID
}

Tfsync is an fsync request.

func (*Tfsync) Decode

func (t *Tfsync) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tfsync) Encode

func (t *Tfsync) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tfsync) String

func (t *Tfsync) String() string

String implements fmt.Stringer.

func (*Tfsync) Type

func (*Tfsync) Type() MsgType

Type implements message.Type.

type Tgetattr

type Tgetattr struct {
	// FID is the FID to get attributes for.
	FID FID

	// AttrMask is the set of attributes to get.
	AttrMask AttrMask
}

Tgetattr is a getattr request.

func (*Tgetattr) Decode

func (t *Tgetattr) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tgetattr) Encode

func (t *Tgetattr) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tgetattr) String

func (t *Tgetattr) String() string

String implements fmt.Stringer.

func (*Tgetattr) Type

func (*Tgetattr) Type() MsgType

Type implements message.Type.

type Tlconnect

type Tlconnect struct {
	// FID is the FID to be connected.
	FID FID

	// Flags are the connect flags.
	Flags ConnectFlags
}

Tlconnect is a connect request.

func (*Tlconnect) Decode

func (t *Tlconnect) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tlconnect) Encode

func (t *Tlconnect) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tlconnect) String

func (t *Tlconnect) String() string

String implements fmt.Stringer.

func (*Tlconnect) Type

func (*Tlconnect) Type() MsgType

Type implements message.Type.

type Tlcreate

type Tlcreate struct {
	// FID is the parent FID.
	//
	// This becomes the new file.
	FID FID

	// Name is the file name to create.
	Name string

	// Mode is the open mode (O_RDWR, etc.).
	//
	// Note that flags like O_TRUNC are ignored, as is O_EXCL. All
	// create operations are exclusive.
	OpenFlags OpenFlags

	// Permissions is the set of permission bits.
	Permissions FileMode

	// GID is the group ID to use for creating the file.
	GID GID
}

Tlcreate is a create request.

func (*Tlcreate) Decode

func (t *Tlcreate) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tlcreate) Encode

func (t *Tlcreate) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tlcreate) String

func (t *Tlcreate) String() string

String implements fmt.Stringer.

func (*Tlcreate) Type

func (*Tlcreate) Type() MsgType

Type implements message.Type.

type Tlink struct {
	// Directory is the directory to contain the link.
	Directory FID

	// FID is the target.
	Target FID

	// Name is the new source name.
	Name string
}

Tlink is a link request.

func (*Tlink) Decode

func (t *Tlink) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tlink) Encode

func (t *Tlink) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tlink) String

func (t *Tlink) String() string

String implements fmt.Stringer.

func (*Tlink) Type

func (*Tlink) Type() MsgType

Type implements message.Type.

type Tlopen

type Tlopen struct {
	// FID is the FID to be opened.
	FID FID

	// Flags are the open flags.
	Flags OpenFlags
}

Tlopen is an open request.

func (*Tlopen) Decode

func (t *Tlopen) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tlopen) Encode

func (t *Tlopen) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tlopen) String

func (t *Tlopen) String() string

String implements fmt.Stringer.

func (*Tlopen) Type

func (*Tlopen) Type() MsgType

Type implements message.Type.

type Tmkdir

type Tmkdir struct {
	// Directory is the parent directory.
	Directory FID

	// Name is the new directory name.
	Name string

	// Permissions is the set of permission bits.
	Permissions FileMode

	// GID is the owning group.
	GID GID
}

Tmkdir is a mkdir request.

func (*Tmkdir) Decode

func (t *Tmkdir) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tmkdir) Encode

func (t *Tmkdir) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tmkdir) String

func (t *Tmkdir) String() string

String implements fmt.Stringer.

func (*Tmkdir) Type

func (*Tmkdir) Type() MsgType

Type implements message.Type.

type Tmknod

type Tmknod struct {
	// Directory is the parent directory.
	Directory FID

	// Name is the device name.
	Name string

	// Mode is the device mode and permissions.
	Mode FileMode

	// Major is the device major number.
	Major uint32

	// Minor is the device minor number.
	Minor uint32

	// GID is the device GID.
	GID GID
}

Tmknod is a mknod request.

func (*Tmknod) Decode

func (t *Tmknod) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tmknod) Encode

func (t *Tmknod) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tmknod) String

func (t *Tmknod) String() string

String implements fmt.Stringer.

func (*Tmknod) Type

func (*Tmknod) Type() MsgType

Type implements message.Type.

type Tread

type Tread struct {
	// FID is the FID to read.
	FID FID

	// Offset indicates the file offset.
	Offset uint64

	// Count indicates the number of bytes to read.
	Count uint32
}

Tread is a read request.

func (*Tread) Decode

func (t *Tread) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tread) Encode

func (t *Tread) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tread) String

func (t *Tread) String() string

String implements fmt.Stringer.

func (*Tread) Type

func (*Tread) Type() MsgType

Type implements message.Type.

type Treaddir

type Treaddir struct {
	// Directory is the directory FID to read.
	Directory FID

	// Offset is the offset to read at.
	Offset uint64

	// Count is the number of bytes to read.
	Count uint32
}

Treaddir is a readdir request.

func (*Treaddir) Decode

func (t *Treaddir) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Treaddir) Encode

func (t *Treaddir) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Treaddir) String

func (t *Treaddir) String() string

String implements fmt.Stringer.

func (*Treaddir) Type

func (*Treaddir) Type() MsgType

Type implements message.Type.

type Treadlink struct {
	// FID is the symlink.
	FID FID
}

Treadlink is a readlink request.

func (*Treadlink) Decode

func (t *Treadlink) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Treadlink) Encode

func (t *Treadlink) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Treadlink) String

func (t *Treadlink) String() string

String implements fmt.Stringer.

func (*Treadlink) Type

func (*Treadlink) Type() MsgType

Type implements message.Type.

type Tremove

type Tremove struct {
	// FID is the FID to be removed.
	FID FID
}

Tremove is a remove request.

This will eventually be replaced by Tunlinkat.

func (*Tremove) Decode

func (t *Tremove) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tremove) Encode

func (t *Tremove) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tremove) String

func (t *Tremove) String() string

String implements fmt.Stringer.

func (*Tremove) Type

func (*Tremove) Type() MsgType

Type implements message.Type.

type Trename

type Trename struct {
	// FID is the FID to rename.
	FID FID

	// Directory is the target directory.
	Directory FID

	// Name is the new file name.
	Name string
}

Trename is a rename request.

Note that this generally isn't used anymore, and ideally all rename calls should Trenameat below.

func (*Trename) Decode

func (t *Trename) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Trename) Encode

func (t *Trename) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Trename) String

func (t *Trename) String() string

String implements fmt.Stringer.

func (*Trename) Type

func (*Trename) Type() MsgType

Type implements message.Type.

type Trenameat

type Trenameat struct {
	// OldDirectory is the source directory.
	OldDirectory FID

	// OldName is the source file name.
	OldName string

	// NewDirectory is the target directory.
	NewDirectory FID

	// NewName is the new file name.
	NewName string
}

Trenameat is a rename request.

func (*Trenameat) Decode

func (t *Trenameat) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Trenameat) Encode

func (t *Trenameat) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Trenameat) String

func (t *Trenameat) String() string

String implements fmt.Stringer.

func (*Trenameat) Type

func (*Trenameat) Type() MsgType

Type implements message.Type.

type Tsetattr

type Tsetattr struct {
	// FID is the FID to change.
	FID FID

	// Valid is the set of bits which will be used.
	Valid SetAttrMask

	// SetAttr is the set request.
	SetAttr SetAttr
}

Tsetattr is a setattr request.

func (*Tsetattr) Decode

func (t *Tsetattr) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tsetattr) Encode

func (t *Tsetattr) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tsetattr) String

func (t *Tsetattr) String() string

String implements fmt.Stringer.

func (*Tsetattr) Type

func (*Tsetattr) Type() MsgType

Type implements message.Type.

type Tstatfs

type Tstatfs struct {
	// FID is the root.
	FID FID
}

Tstatfs is a stat request.

func (*Tstatfs) Decode

func (t *Tstatfs) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tstatfs) Encode

func (t *Tstatfs) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tstatfs) String

func (t *Tstatfs) String() string

String implements fmt.Stringer.

func (*Tstatfs) Type

func (*Tstatfs) Type() MsgType

Type implements message.Type.

type Tsymlink struct {
	// Directory is the directory FID.
	Directory FID

	// Name is the new in the directory.
	Name string

	// Target is the symlink target.
	Target string

	// GID is the owning group.
	GID GID
}

Tsymlink is a symlink request.

func (*Tsymlink) Decode

func (t *Tsymlink) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tsymlink) Encode

func (t *Tsymlink) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tsymlink) String

func (t *Tsymlink) String() string

String implements fmt.Stringer.

func (*Tsymlink) Type

func (*Tsymlink) Type() MsgType

Type implements message.Type.

type Tucreate

type Tucreate struct {
	Tlcreate

	// UID is the UID to use as the effective UID in creation messages.
	UID UID
}

Tucreate is a Tlcreate message that includes a UID.

func (*Tucreate) Decode

func (t *Tucreate) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tucreate) Encode

func (t *Tucreate) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tucreate) String

func (t *Tucreate) String() string

String implements fmt.Stringer.

func (*Tucreate) Type

func (t *Tucreate) Type() MsgType

Type implements message.Type.

type Tumkdir

type Tumkdir struct {
	Tmkdir

	// UID is the UID to use as the effective UID in creation messages.
	UID UID
}

Tumkdir is a Tmkdir message that includes a UID.

func (*Tumkdir) Decode

func (t *Tumkdir) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tumkdir) Encode

func (t *Tumkdir) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tumkdir) String

func (t *Tumkdir) String() string

String implements fmt.Stringer.

func (*Tumkdir) Type

func (t *Tumkdir) Type() MsgType

Type implements message.Type.

type Tumknod

type Tumknod struct {
	Tmknod

	// UID is the UID to use as the effective UID in creation messages.
	UID UID
}

Tumknod is a Tmknod message that includes a UID.

func (*Tumknod) Decode

func (t *Tumknod) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tumknod) Encode

func (t *Tumknod) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tumknod) String

func (t *Tumknod) String() string

String implements fmt.Stringer.

func (*Tumknod) Type

func (t *Tumknod) Type() MsgType

Type implements message.Type.

type Tunlinkat

type Tunlinkat struct {
	// Directory is the originating directory.
	Directory FID

	// Name is the name of the entry to unlink.
	Name string

	// Flags are extra flags (e.g. O_DIRECTORY). These are not interpreted by p9.
	Flags uint32
}

Tunlinkat is an unlink request.

func (*Tunlinkat) Decode

func (t *Tunlinkat) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tunlinkat) Encode

func (t *Tunlinkat) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tunlinkat) String

func (t *Tunlinkat) String() string

String implements fmt.Stringer.

func (*Tunlinkat) Type

func (*Tunlinkat) Type() MsgType

Type implements message.Type.

type Tusymlink struct {
	Tsymlink

	// UID is the UID to use as the effective UID in creation messages.
	UID UID
}

Tusymlink is a Tsymlink message that includes a UID.

func (*Tusymlink) Decode

func (t *Tusymlink) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tusymlink) Encode

func (t *Tusymlink) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tusymlink) String

func (t *Tusymlink) String() string

String implements fmt.Stringer.

func (*Tusymlink) Type

func (t *Tusymlink) Type() MsgType

Type implements message.Type.

type Tversion

type Tversion struct {
	// MSize is the message size to use.
	MSize uint32

	// Version is the version string.
	//
	// For this implementation, this must be 9P2000.L.
	Version string
}

Tversion is a version request.

func (*Tversion) Decode

func (t *Tversion) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Tversion) Encode

func (t *Tversion) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Tversion) String

func (t *Tversion) String() string

String implements fmt.Stringer.

func (*Tversion) Type

func (*Tversion) Type() MsgType

Type implements message.Type.

type Twalk

type Twalk struct {
	// FID is the FID to be walked.
	FID FID

	// NewFID is the resulting FID.
	NewFID FID

	// Names are the set of names to be walked.
	Names []string
}

Twalk is a walk request.

func (*Twalk) Decode

func (t *Twalk) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Twalk) Encode

func (t *Twalk) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Twalk) String

func (t *Twalk) String() string

String implements fmt.Stringer.

func (*Twalk) Type

func (*Twalk) Type() MsgType

Type implements message.Type.

type Twalkgetattr

type Twalkgetattr struct {
	// FID is the FID to be walked.
	FID FID

	// NewFID is the resulting FID.
	NewFID FID

	// Names are the set of names to be walked.
	Names []string
}

Twalkgetattr is a walk request.

func (*Twalkgetattr) Decode

func (t *Twalkgetattr) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Twalkgetattr) Encode

func (t *Twalkgetattr) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Twalkgetattr) String

func (t *Twalkgetattr) String() string

String implements fmt.Stringer.

func (*Twalkgetattr) Type

func (*Twalkgetattr) Type() MsgType

Type implements message.Type.

type Twrite

type Twrite struct {
	// FID is the FID to read.
	FID FID

	// Offset indicates the file offset.
	Offset uint64

	// Data is the data to be written.
	Data []byte
}

Twrite is a write request.

func (*Twrite) Decode

func (t *Twrite) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Twrite) Encode

func (t *Twrite) Encode(b *buffer)

Encode implements encoder.Encode.

This uses the buffer payload to avoid a copy.

func (*Twrite) FixedSize

func (*Twrite) FixedSize() uint32

FixedSize implements payloader.FixedSize.

func (*Twrite) Payload

func (t *Twrite) Payload() []byte

Payload implements payloader.Payload.

func (*Twrite) SetPayload

func (t *Twrite) SetPayload(p []byte)

SetPayload implements payloader.SetPayload.

func (*Twrite) String

func (t *Twrite) String() string

String implements fmt.Stringer.

func (*Twrite) Type

func (*Twrite) Type() MsgType

Type implements message.Type.

type Txattrcreate

type Txattrcreate struct {
	// FID is input/output parameter, it identifies the file on which
	// extended attributes will be set but after successful Rxattrcreate
	// it is used to write the extended attribute value.
	FID FID

	// Name is the attribute name.
	Name string

	// Size of the attribute value. When the FID is clunked it has to match
	// the number of bytes written to the FID.
	AttrSize uint64

	// Linux setxattr(2) flags.
	Flags uint32
}

Txattrcreate prepare to set extended attributes.

func (*Txattrcreate) Decode

func (t *Txattrcreate) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Txattrcreate) Encode

func (t *Txattrcreate) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Txattrcreate) String

func (t *Txattrcreate) String() string

String implements fmt.Stringer.

func (*Txattrcreate) Type

func (*Txattrcreate) Type() MsgType

Type implements message.Type.

type Txattrwalk

type Txattrwalk struct {
	// FID is the FID to check for attributes.
	FID FID

	// NewFID is the new FID associated with the attributes.
	NewFID FID

	// Name is the attribute name.
	Name string
}

Txattrwalk walks extended attributes.

func (*Txattrwalk) Decode

func (t *Txattrwalk) Decode(b *buffer)

Decode implements encoder.Decode.

func (*Txattrwalk) Encode

func (t *Txattrwalk) Encode(b *buffer)

Encode implements encoder.Encode.

func (*Txattrwalk) String

func (t *Txattrwalk) String() string

String implements fmt.Stringer.

func (*Txattrwalk) Type

func (*Txattrwalk) Type() MsgType

Type implements message.Type.

type UID

type UID uint32

UID represents a user ID.

func (UID) Ok

func (uid UID) Ok() bool

Ok returns true if uid is not NoUID.

Directories

Path Synopsis
Package p9test provides standard mocks for p9.
Package p9test provides standard mocks for p9.

Jump to

Keyboard shortcuts

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