styx: aqwari.net/net/styx/internal/styxfile Index | Files

package styxfile

import "aqwari.net/net/styx/internal/styxfile"

Package styxfile provides helper routines and interfaces for serving 9P files from Go types.

Index

Package Files

dir.go dumb.go file.go mode.go seeker.go

Variables

var ErrNoSeek = errors.New("file does not support seeking")

ErrNoSeek is returned when a given type does not support writing to any offset other than its current position after previous reads and writes.

var ErrNotSupported = errors.New("not supported")

ErrNotSupported is returned when a given type does not implement the necessary functionality to complete a given read/write operation.

var ErrSmallRead = errors.New("Tread count too small for dir stat")

ErrSmallRead is returned when a client's Tread request on a directory does not request enough bytes to hold at least one Stat structure.

func Mode9P Uses

func Mode9P(mode os.FileMode) uint32

Mode9P converts an os.FileMode to a 9P mode mask

func ModeOS Uses

func ModeOS(perm uint32) os.FileMode

FileMode converts a 9P mode mask to an os.FileMode.

func QidType Uses

func QidType(mode uint32) uint8

QidType selects the first byte of a 9P mode mask, and is suitable for use in a Qid's type field.

func SetDeadline Uses

func SetDeadline(file Interface, t time.Time) error

SetDeadline sets read/write deadlines for a file, if the type supports it.

func Stat Uses

func Stat(buf []byte, file Interface, name string, qid styxproto.Qid) (styxproto.Stat, error)

Stat produces a styxproto.Stat from an open file. If the value provides a Stat method matching that of os.File, that is used. Otherwise, the styxfile package determines the file's attributes based on other characteristics.

type Directory Uses

type Directory interface {
    Readdir(n int) ([]os.FileInfo, error)
}

Types implementing the Directory interface can be made into 9P files by the NewDir function. This provides an easy way, for example, to provide directory listings from an *os.File.

type Interface Uses

type Interface interface {
    io.ReaderAt
    io.WriterAt
    io.Closer
}

Interface describes the methods a type must implement to be used as a file by a 9P file server. The New function converts types that implement some, but not all of these methods into types that do.

func New Uses

func New(rwc interface{}) (Interface, error)

New creates a new Interface that reads and writes to and from rwc. The type of rwc determines the implementation selected by New; if rwc already implements Interface, it is used as-is. If some methods are missing, wrapper types are used to implement missing functionality. If the provided type cannot be adapted into an Interface, New returns a non-nil error.

func NewDir Uses

func NewDir(dir Directory, abspath string, pool *qidpool.Pool) Interface

NewDir creates a new Interface that converts the return value of a Directory's Readdir method into 9P Stat structures.

Package styxfile imports 10 packages (graph) and is imported by 3 packages. Updated 2018-04-27. Refresh now. Tools for package owners.