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



    This section is empty.


    View Source
    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.

      View Source
      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.

        View Source
        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

          func Mode9P(mode os.FileMode) uint32

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

            func ModeOS

            func ModeOS(perm uint32) os.FileMode

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

              func QidType

              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

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

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

                  func Stat

                  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

                    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

                      type Interface interface {

                        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

                        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

                          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.