Package styxfile provides helper routines and interfaces for serving 9P files from Go types.
- func Mode9P(mode os.FileMode) uint32
- func ModeOS(perm uint32) os.FileMode
- func QidType(mode uint32) uint8
- func SetDeadline(file Interface, t time.Time) error
- func Stat(buf byte, file Interface, name string, qid styxproto.Qid) (styxproto.Stat, error)
- type Directory
- type Interface
ErrNoSeek is returned when a given type does not support writing to any offset other than its current position after previous reads and writes.
ErrNotSupported is returned when a given type does not implement the necessary functionality to complete a given read/write operation.
ErrSmallRead is returned when a client's Tread request on a directory does not request enough bytes to hold at least one Stat structure.
FileMode converts a 9P mode mask to an os.FileMode.
QidType selects the first byte of a 9P mode mask, and is suitable for use in a Qid's type field.
func SetDeadline ¶
SetDeadline sets read/write deadlines for a file, if the type supports it.
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.
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.
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.
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.