lib9p

package module
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: 0BSD Imports: 12 Imported by: 0

Documentation

Overview

Package lib9p is a 9P2000 library to implement 9P servers. For detailed information on 9P protocol, consult the protocol's documentation.

To use this package, implement the FS interface, and create a Server struct by calling NewServer with the FS, and then call *Server.Serve. The server listens to r specified by the argument of NewServer and writes responses to w. It does not assume network connection, and can be used with any io.Reader/io.Writer. If the server is to serve via a tcp connection, write something like the following code:

l, err := net.Listen("tcp", "localhost:5640")
if err != nil {
	log.Fatal(err)
}
for {
	conn, err := l.Accept()
	if err != nil {
		log.Print(err)
	}
	s := lib9p.NewServer(fsys) // fsys is user defined *FS.
	go s.Serve(context.Background(), conn, conn)
}

OpenFile method of FS interface is similar to that of os.OpenFile, but it takes as argument OpenMode instead of integer flag. And it does not create file even if the specified file does not exists. The returned value is File, not fs.File.

A File is the representation of a file of the exported file system. It is almost identical to fs.File, but the Stat method returns the *FileInfo struct instead of fs.FileInfo interface. The difference of *FileInfo and fs.FileInfo is that the Sys method of *FileInfo returns the underlying *Stat struct as a value of any, while I can't asume anything on Stat of fs.FileInfo. This ensures the type safety.

Index

Constants

View Source
const (
	Tversion MsgType = 100
	Rversion         = 101
	Tauth            = 102
	Rauth            = 103
	Tattach          = 104
	Rattach          = 105
	Terror           = 106 /* illegal */
	Rerror           = 107
	Tflush           = 108
	Rflush           = 109
	Twalk            = 110
	Rwalk            = 111
	Topen            = 112
	Ropen            = 113
	Tcreate          = 114
	Rcreate          = 115
	Tread            = 116
	Rread            = 117
	Twrite           = 118
	Rwrite           = 119
	Tclunk           = 120
	Rclunk           = 121
	Tremove          = 122
	Rremove          = 123
	Tstat            = 124
	Rstat            = 125
	Twstat           = 126
	Rwstat           = 127
	Tmax             = 128
)
View Source
const (
	OREAD  OpenMode = 0
	OWRITE          = 1
	ORDWR           = 2
	OEXEC           = 3

	OTRUNC  = 16
	ORCLOSE = 64
)
View Source
const (
	// Exactly one of O_RDONLY, O_WRONLY, or O_RDWR must be specified.
	O_RDONLY int = os.O_RDONLY // open the file read-only.
	O_WRONLY int = os.O_WRONLY // open the file write-only.
	O_RDWR   int = os.O_RDWR   // open the file read-write.
	// The remaining values may be or'ed in to control behavior.
	O_APPEND int = os.O_APPEND // append data to the file when writing.
	O_CREATE int = os.O_CREATE // create a new file if none exists.
	O_EXCL   int = os.O_EXCL   // used with O_CREATE, file must not exist.
	O_SYNC   int = os.O_SYNC   // open for synchronous I/O.
	O_TRUNC  int = os.O_TRUNC  // truncate regular writable file when opened.
)
View Source
const (
	QTDIR     QidType = 0x80 /* type bit for directories */
	QTAPPEND          = 0x40 /* type bit for append only files */
	QTEXCL            = 0x20 /* type bit for exclusive use files */
	QTMOUNT           = 0x10 /* type bit for mounted channel */
	QTAUTH            = 0x08 /* type bit for authentication file */
	QTTMP             = 0x04 /* type bit for non-backed-up file */
	QTSYMLINK         = 0x02 /* type bit for symbolic link */
	QTFILE            = 0x00 /* type bits for plain file */
)
View Source
const (
	AEXEC fs.FileMode = 1 << iota
	AWRITE
	AREAD
)

These consts are used to record the access mode to a file. This is derived from plan9's lib9p, but I think this is not needed.

View Source
const IOHDRSZ = 23

IOHDRSZ is the ample room for Twrite/Rread header.

  • Twrite: size[4] type[1] Tag[2] fid[4] offset[8] count[4] = 23
  • Rread: size[4] type[1] Tag[2] count[4] = 11

In Plan9, this const is 24.

View Source
const NOFID = ^uint32(0)

NOFID is used in afid field of Tattach message when no authentication is required.

View Source
const NOTAG = ^uint16(0)

The Tag used by version messages. The client can use it, when establishing a connection, to override Tag matching in version messages.

Variables

View Source
var (
	ErrBotch      = fmt.Errorf("botch")
	ErrPerm       = fmt.Errorf("permission denied")
	ErrOperation  = fmt.Errorf("operation not supported")
	ErrDupTag     = fmt.Errorf("duplicate tag")
	ErrUnknownFid = fmt.Errorf("unknown fid")
	ErrDupFid     = fmt.Errorf("duplicate fid")
	ErrNotFound   = fmt.Errorf("not found")
)

Functions

func ModeToFlag added in v0.10.1

func ModeToFlag(m OpenMode) int

ModeToFlag converts OpenMode (OREAD etc.) to open flag (O_RDONLY etc.). ORCLOSE is not implemented and ignored silently. O_APPEND, O_CREATE, O_EXCL, O_SYNC can't be specified.

func SendMsg added in v0.1.0

func SendMsg(msg Msg, w io.Writer) error

SendMsg send a 9P message to w

Types

type AuthFile

type AuthFile struct {
	Qid    Qid
	Uname  string
	Aname  string
	AuthOK bool
	W      io.Writer
	R      io.Reader
}

An AuthFile is a file allocated by Auth function of Server struct. If authentication is desired, Auth member of Server struct must be set and it should set an AuthFile ready to Read/Write via R/W member.

func (*AuthFile) Close

func (af *AuthFile) Close() error

Close closes af and its underlying reader/writer if they implement io.Closer. TODO: should I left W/R not closed?

func (*AuthFile) Read

func (af *AuthFile) Read(p []byte) (int, error)

func (*AuthFile) Stat

func (af *AuthFile) Stat() (*FileInfo, error)

func (*AuthFile) Write

func (af *AuthFile) Write(p []byte) (int, error)

type CreatorFS added in v0.11.0

type CreatorFS interface {
	FS
	// Create creates a file named name.
	// It sets the owner of newly created file to the specified uid,
	// and file mode to the specified perm.
	//
	// Create should reject attempts to create names that do not satisfy
	// fs.ValidPath(name), returning a *fs.PathError with Err set to
	// fs.ErrInvalid.
	Create(name string, uid string, mode OpenMode, perm FileMode) (File, error)
}

type DirEntry

type DirEntry = FileInfo

A DirEntry is returned by File.ReadDir.

func (*DirEntry) Info

func (de *DirEntry) Info() (fs.FileInfo, error)

func (*DirEntry) Type added in v0.2.0

func (de *DirEntry) Type() fs.FileMode

type ExportFS added in v0.2.1

type ExportFS struct {
	FS
}

An ExportFS is a wrapper of FS to export it as an fs.FS.

func (ExportFS) Open added in v0.2.1

func (fsys ExportFS) Open(name string) (fs.File, error)

type ExportFile added in v0.5.0

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

An ExportFile is a wrapper of File to export it as an fs.File.

func (ExportFile) Close added in v0.5.0

func (f ExportFile) Close() error

func (ExportFile) Read added in v0.5.0

func (f ExportFile) Read(p []byte) (n int, err error)

func (ExportFile) ReadDir added in v0.5.0

func (f ExportFile) ReadDir(n int) ([]fs.DirEntry, error)

func (ExportFile) Stat added in v0.5.0

func (f ExportFile) Stat() (fs.FileInfo, error)

type FS

type FS interface {
	// OpenFile opens file named name with specified flag (O_RDONLY etc.).
	//
	// When OpenFile returns an error, it should be of type *fs.PathError
	// with the Op field set to "openfile", the Path field set to name,
	// and the Err field describing the problem.
	//
	// Open should reject attempts to open names that do not satisfy
	// fs.ValidPath(name), returning a *fs.PathError with Err set to
	// fs.ErrInvalid or fs.ErrNotExist.
	OpenFile(name string, flag int) (File, error)
}

An FS is an file system to be exported by 9P server.

type File

type File interface {
	Stat() (*FileInfo, error)
	Read([]byte) (int, error)
	Close() error
}

A File is an open file. The interface is similar to that of fs.File, but Stat returns *FileInfo of this package instead of fs.FileInfo.

type FileInfo

type FileInfo struct {
	Stat Stat
}

A FileInfo is a struct returned by File.Stat(). This struct is needed because of the name collision: Stat.Name and FileInfo.Name.

func (*FileInfo) IsDir

func (fi *FileInfo) IsDir() bool

func (*FileInfo) ModTime

func (fi *FileInfo) ModTime() time.Time

func (*FileInfo) Mode

func (fi *FileInfo) Mode() fs.FileMode

func (*FileInfo) Name

func (fi *FileInfo) Name() string

func (*FileInfo) Size

func (fi *FileInfo) Size() int64

func (*FileInfo) Sys

func (fi *FileInfo) Sys() any

Sys returns *Stat

type FileMode

type FileMode = fs.FileMode

type GroupFS added in v0.6.0

type GroupFS interface {
	FS
	// IsGroupLeader reports whether uid is the leader of group.
	IsGroupLeader(group, uid string) bool
	// IsGroupMember reports whether uid is a member of group.
	IsGroupMember(group, uid string) bool
}

A GroupFS is an file system with the notion of group. If an FS does not implement this interface, then the Server assumes that that every group is consists of only one member with the same name as the group itself and he is the leader of that group.

type Msg

type Msg interface {
	// Size returns the size field of message.
	// Size field holds the size of the message in bytes
	// including the 4-byte size field itself.
	Size() uint32
	// Type returns the type field of message.
	Type() MsgType
	// GetTag returns the Tag of message.
	// Tag is the identifier of each message.
	// The Get prefix is to avoid name confliction with the each
	// message's Tag field.
	GetTag() uint16
	// SetTag sets the Tag field of the message.
	SetTag(uint16)

	String() string
	// contains filtered or unexported methods
}

A Msg represents any kind of message of 9P. It defines methods for common fields. For each message type <T>, new<T>([]byte) function parses the byte array of 9P message into the corresponding message struct. For detailed information on each message, consult the documentation of 9P protocol.

func RecvMsg added in v0.1.0

func RecvMsg(r io.Reader) (Msg, error)

RecvMsg recievs a 9P message from r.

type MsgType

type MsgType uint8

A MsgType is Message type defined by 9P.

type OpenMode

type OpenMode int8

An OpenMode is the mode of an open file. This is used by fid structure. If the file is not open, the mode must be -1.

func FlagToMode added in v0.10.1

func FlagToMode(f int) OpenMode

FlugToMode converts open flag (O_RDONLY etc.) to OpenMode (OREAD etc.). O_APPEND, O_CREATE, O_EXCL, O_SYNC are not implemented and ignored silently. ORCLOSE can't be specified.

type Qid

type Qid struct {
	Type QidType // type of the file.
	Vers uint32  // version of the file.
	Path uint64  // uniq number of each file.
}

Qid is the identifier of each file in 9P server.

func (Qid) String

func (q Qid) String() string

type QidType

type QidType uint8

QidType represents the type of Qid.

func FSModeToQidType

func FSModeToQidType(fm fs.FileMode) QidType

type RAttach

type RAttach struct {
	Tag uint16
	Qid Qid
}

func (*RAttach) GetTag added in v0.1.0

func (msg *RAttach) GetTag() uint16

func (*RAttach) SetTag

func (msg *RAttach) SetTag(t uint16)

func (*RAttach) Size

func (msg *RAttach) Size() uint32

func (*RAttach) String

func (msg *RAttach) String() string

func (*RAttach) Type

func (msg *RAttach) Type() MsgType

type RAuth

type RAuth struct {
	Tag  uint16
	Aqid Qid
}

func (*RAuth) GetTag added in v0.1.0

func (msg *RAuth) GetTag() uint16

func (*RAuth) SetTag

func (msg *RAuth) SetTag(t uint16)

func (*RAuth) Size

func (msg *RAuth) Size() uint32

func (*RAuth) String

func (msg *RAuth) String() string

func (*RAuth) Type

func (msg *RAuth) Type() MsgType

type RClunk

type RClunk struct {
	Tag uint16
}

func (*RClunk) GetTag added in v0.1.0

func (msg *RClunk) GetTag() uint16

func (*RClunk) SetTag

func (msg *RClunk) SetTag(t uint16)

func (*RClunk) Size

func (msg *RClunk) Size() uint32

func (*RClunk) String

func (msg *RClunk) String() string

func (*RClunk) Type

func (msg *RClunk) Type() MsgType

type RCreate

type RCreate struct {
	Tag    uint16
	Qid    Qid
	Iounit uint32
}

func (*RCreate) GetTag added in v0.1.0

func (msg *RCreate) GetTag() uint16

func (*RCreate) SetTag

func (msg *RCreate) SetTag(t uint16)

func (*RCreate) Size

func (msg *RCreate) Size() uint32

func (*RCreate) String

func (msg *RCreate) String() string

func (*RCreate) Type

func (msg *RCreate) Type() MsgType

type RError

type RError struct {
	Tag   uint16
	Ename error
}

func (*RError) GetTag added in v0.1.0

func (msg *RError) GetTag() uint16

func (*RError) SetTag

func (msg *RError) SetTag(t uint16)

func (*RError) Size

func (msg *RError) Size() uint32

func (*RError) String

func (msg *RError) String() string

func (*RError) Type

func (msg *RError) Type() MsgType

type RFlush

type RFlush struct {
	Tag uint16
}

func (*RFlush) GetTag added in v0.1.0

func (msg *RFlush) GetTag() uint16

func (*RFlush) SetTag

func (msg *RFlush) SetTag(t uint16)

func (*RFlush) Size

func (msg *RFlush) Size() uint32

func (*RFlush) String

func (msg *RFlush) String() string

func (*RFlush) Type

func (msg *RFlush) Type() MsgType

type ROpen

type ROpen struct {
	Tag    uint16
	Qid    Qid
	Iounit uint32
}

func (*ROpen) GetTag added in v0.1.0

func (msg *ROpen) GetTag() uint16

func (*ROpen) SetTag

func (msg *ROpen) SetTag(t uint16)

func (*ROpen) Size

func (msg *ROpen) Size() uint32

func (*ROpen) String

func (msg *ROpen) String() string

func (*ROpen) Type

func (msg *ROpen) Type() MsgType

type RRead

type RRead struct {
	Tag   uint16
	Count uint32
	Data  []byte
}

func (*RRead) GetTag added in v0.1.0

func (msg *RRead) GetTag() uint16

func (*RRead) SetTag

func (msg *RRead) SetTag(t uint16)

func (*RRead) Size

func (msg *RRead) Size() uint32

func (*RRead) String

func (msg *RRead) String() string

func (*RRead) Type

func (msg *RRead) Type() MsgType

type RRemove

type RRemove struct {
	Tag uint16
}

func (*RRemove) GetTag added in v0.1.0

func (msg *RRemove) GetTag() uint16

func (*RRemove) SetTag

func (msg *RRemove) SetTag(t uint16)

func (*RRemove) Size

func (msg *RRemove) Size() uint32

func (*RRemove) String

func (msg *RRemove) String() string

func (*RRemove) Type

func (msg *RRemove) Type() MsgType

type RStat

type RStat struct {
	Tag  uint16
	Stat *Stat
}

func (*RStat) GetTag added in v0.1.0

func (msg *RStat) GetTag() uint16

func (*RStat) SetTag

func (msg *RStat) SetTag(t uint16)

func (*RStat) Size

func (msg *RStat) Size() uint32

func (*RStat) String

func (msg *RStat) String() string

func (*RStat) Type

func (msg *RStat) Type() MsgType

type RVersion

type RVersion struct {
	Tag     uint16
	Msize   uint32
	Version string
}

func (*RVersion) GetTag added in v0.1.0

func (msg *RVersion) GetTag() uint16

func (*RVersion) SetTag

func (msg *RVersion) SetTag(t uint16)

func (*RVersion) Size

func (msg *RVersion) Size() uint32

func (*RVersion) String

func (msg *RVersion) String() string

func (*RVersion) Type

func (msg *RVersion) Type() MsgType

type RWalk

type RWalk struct {
	Tag  uint16
	Qids []Qid
}

func (*RWalk) GetTag added in v0.1.0

func (msg *RWalk) GetTag() uint16

func (*RWalk) SetTag

func (msg *RWalk) SetTag(t uint16)

func (*RWalk) Size

func (msg *RWalk) Size() uint32

func (*RWalk) String

func (msg *RWalk) String() string

func (*RWalk) Type

func (msg *RWalk) Type() MsgType

type RWrite

type RWrite struct {
	Tag   uint16
	Count uint32
}

func (*RWrite) GetTag added in v0.1.0

func (msg *RWrite) GetTag() uint16

func (*RWrite) SetTag

func (msg *RWrite) SetTag(t uint16)

func (*RWrite) Size

func (msg *RWrite) Size() uint32

func (*RWrite) String

func (msg *RWrite) String() string

func (*RWrite) Type

func (msg *RWrite) Type() MsgType

type RWstat added in v0.7.0

type RWstat struct {
	Tag uint16
}

func (*RWstat) GetTag added in v0.7.0

func (msg *RWstat) GetTag() uint16

func (*RWstat) SetTag added in v0.7.0

func (msg *RWstat) SetTag(t uint16)

func (*RWstat) Size added in v0.7.0

func (msg *RWstat) Size() uint32

func (*RWstat) String added in v0.7.0

func (msg *RWstat) String() string

func (*RWstat) Type added in v0.7.0

func (msg *RWstat) Type() MsgType

type ReadDirFile

type ReadDirFile interface {
	File
	ReadDir(n int) ([]fs.DirEntry, error)
}

A ReadDirFile is a directory. Every directory file shoul implement this interface. Non-directory files can implement this. In this case, ReadDir should return an error.

type RemoverFS added in v0.3.0

type RemoverFS interface {
	FS
	Remove(name string) error
}

type Server

type Server struct {

	// Auth function is passed an auth request when a TAuth message arrives
	// If authentication is desired, Auth should
	// set request.Afid.file to an *AuthFile and request.ofcall.Qid, and prepare to
	// authenticate via the Read()/Write() calls to request.Afid.file.
	// Auth should clean up everything it creates when ctx is canceled.
	// If this is nil, no authentication is performed.
	Auth func(ctx context.Context, r *request)
	// contains filtered or unexported fields
}

A Server is a 9P server.

func NewServer

func NewServer(fsys FS) *Server

NewServer creates a Server. It serves fsys with the aname "".

func NewServerMap added in v0.9.1

func NewServerMap(fsmap map[string]FS) *Server

NewServerMap creates a Server. Fsmap is the map of aname-FS pair.

func (*Server) Chatty

func (s *Server) Chatty()

Chatty enables the server's log messages of 9P messages.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, r io.Reader, w io.Writer)

Serve serves 9P conversation.

type Stat

type Stat struct {
	Type  uint16
	Dev   uint32
	Qid   Qid
	Mode  FileMode
	Atime uint32
	Mtime uint32
	//TODO: In 9P protocol Length is unsigned integer.
	Length int64
	Name   string
	Uid    string
	Gid    string
	Muid   string
}

Stat represents the stat defined by 9P.

func NewStat added in v0.3.0

func NewStat(b []byte) *Stat

NewStat converts a byte array of stat from a 9P message into Stat struct.

func (*Stat) Size added in v0.3.0

func (s *Stat) Size() uint16

Size returns the size of marshaled stat in bytes excluding the size field itself.

func (*Stat) String

func (s *Stat) String() string

type TAttach

type TAttach struct {
	Tag   uint16
	Fid   uint32
	Afid  uint32
	Uname string
	Aname string
}

func (*TAttach) GetTag added in v0.1.0

func (msg *TAttach) GetTag() uint16

func (*TAttach) SetTag

func (msg *TAttach) SetTag(t uint16)

func (*TAttach) Size

func (msg *TAttach) Size() uint32

func (*TAttach) String

func (msg *TAttach) String() string

func (*TAttach) Type

func (msg *TAttach) Type() MsgType

type TAuth

type TAuth struct {
	Tag   uint16
	Afid  uint32
	Uname string
	Aname string
}

func (*TAuth) GetTag added in v0.1.0

func (msg *TAuth) GetTag() uint16

func (*TAuth) SetTag

func (msg *TAuth) SetTag(t uint16)

func (*TAuth) Size

func (msg *TAuth) Size() uint32

func (*TAuth) String

func (msg *TAuth) String() string

func (*TAuth) Type

func (msg *TAuth) Type() MsgType

type TClunk

type TClunk struct {
	Tag uint16
	Fid uint32
}

func (*TClunk) GetTag added in v0.1.0

func (msg *TClunk) GetTag() uint16

func (*TClunk) SetTag

func (msg *TClunk) SetTag(t uint16)

func (*TClunk) Size

func (msg *TClunk) Size() uint32

func (*TClunk) String

func (msg *TClunk) String() string

func (*TClunk) Type

func (msg *TClunk) Type() MsgType

type TCreate

type TCreate struct {
	Tag  uint16
	Fid  uint32
	Name string
	Perm FileMode
	Mode OpenMode
}

func (*TCreate) GetTag added in v0.1.0

func (msg *TCreate) GetTag() uint16

func (*TCreate) SetTag

func (msg *TCreate) SetTag(t uint16)

func (*TCreate) Size

func (msg *TCreate) Size() uint32

func (*TCreate) String

func (msg *TCreate) String() string

func (*TCreate) Type

func (msg *TCreate) Type() MsgType

type TFlush

type TFlush struct {
	Tag    uint16
	Oldtag uint16
}

func (*TFlush) GetTag added in v0.1.0

func (msg *TFlush) GetTag() uint16

func (*TFlush) SetTag

func (msg *TFlush) SetTag(t uint16)

func (*TFlush) Size

func (msg *TFlush) Size() uint32

func (*TFlush) String

func (msg *TFlush) String() string

func (*TFlush) Type

func (msg *TFlush) Type() MsgType

type TOpen

type TOpen struct {
	Tag  uint16
	Fid  uint32
	Mode OpenMode
}

func (*TOpen) GetTag added in v0.1.0

func (msg *TOpen) GetTag() uint16

func (*TOpen) SetTag

func (msg *TOpen) SetTag(t uint16)

func (*TOpen) Size

func (msg *TOpen) Size() uint32

func (*TOpen) String

func (msg *TOpen) String() string

func (*TOpen) Type

func (msg *TOpen) Type() MsgType

type TRead

type TRead struct {
	Tag    uint16
	Fid    uint32
	Offset uint64
	Count  uint32
}

func (*TRead) GetTag added in v0.1.0

func (msg *TRead) GetTag() uint16

func (*TRead) SetTag

func (msg *TRead) SetTag(t uint16)

func (*TRead) Size

func (msg *TRead) Size() uint32

func (*TRead) String

func (msg *TRead) String() string

func (*TRead) Type

func (msg *TRead) Type() MsgType

type TRemove

type TRemove struct {
	Tag uint16
	Fid uint32
}

func (*TRemove) GetTag added in v0.1.0

func (msg *TRemove) GetTag() uint16

func (*TRemove) SetTag

func (msg *TRemove) SetTag(t uint16)

func (*TRemove) Size

func (msg *TRemove) Size() uint32

func (*TRemove) String

func (msg *TRemove) String() string

func (*TRemove) Type

func (msg *TRemove) Type() MsgType

type TStat

type TStat struct {
	Tag uint16
	Fid uint32
}

func (*TStat) GetTag added in v0.1.0

func (msg *TStat) GetTag() uint16

func (*TStat) SetTag

func (msg *TStat) SetTag(t uint16)

func (*TStat) Size

func (msg *TStat) Size() uint32

func (*TStat) String

func (msg *TStat) String() string

func (*TStat) Type

func (msg *TStat) Type() MsgType

type TVersion

type TVersion struct {
	Tag     uint16
	Msize   uint32
	Version string
}

func (*TVersion) GetTag added in v0.1.0

func (msg *TVersion) GetTag() uint16

func (*TVersion) SetTag

func (msg *TVersion) SetTag(t uint16)

func (*TVersion) Size

func (msg *TVersion) Size() uint32

func (*TVersion) String

func (msg *TVersion) String() string

func (*TVersion) Type

func (msg *TVersion) Type() MsgType

type TWalk

type TWalk struct {
	Tag    uint16
	Fid    uint32
	Newfid uint32
	Wnames []string
}

func (*TWalk) GetTag added in v0.1.0

func (msg *TWalk) GetTag() uint16

func (*TWalk) SetTag

func (msg *TWalk) SetTag(t uint16)

func (*TWalk) Size

func (msg *TWalk) Size() uint32

func (*TWalk) String

func (msg *TWalk) String() string

func (*TWalk) Type

func (msg *TWalk) Type() MsgType

type TWrite

type TWrite struct {
	Tag    uint16
	Fid    uint32
	Offset uint64
	Count  uint32
	Data   []byte
}

func (*TWrite) GetTag added in v0.1.0

func (msg *TWrite) GetTag() uint16

func (*TWrite) SetTag

func (msg *TWrite) SetTag(t uint16)

func (*TWrite) Size

func (msg *TWrite) Size() uint32

func (*TWrite) String

func (msg *TWrite) String() string

func (*TWrite) Type

func (msg *TWrite) Type() MsgType

type TWstat added in v0.7.0

type TWstat struct {
	Tag  uint16
	Fid  uint32
	Stat *Stat
}

func (*TWstat) GetTag added in v0.7.0

func (msg *TWstat) GetTag() uint16

func (*TWstat) SetTag added in v0.7.0

func (msg *TWstat) SetTag(t uint16)

func (*TWstat) Size added in v0.7.0

func (msg *TWstat) Size() uint32

func (*TWstat) String added in v0.7.0

func (msg *TWstat) String() string

func (*TWstat) Type added in v0.7.0

func (msg *TWstat) Type() MsgType

type WriterFile

type WriterFile interface {
	File
	Write([]byte) (int, error)
}

A WriterFile is a file with Write method. If the server is to accept Twrite messages, files in this server must implement this interface.

type WriterStatFile

type WriterStatFile interface {
	File
	// WStat sets file Stat to stat.
	// After successful call, the file's Stat() method should return
	// the same Stat as stat.
	// If there is an error, file's status must remain the same as before.
	WStat(stat *Stat) error
}

A WriterStatFile is a file which can modify its attributes such as the permission and the group (Note that changing ownership of a file is prohibited by the protocol).

Directories

Path Synopsis
cmd
diskfs
Diskfs exports the file system on the disk.
Diskfs exports the file system on the disk.
iofs
Iofs exports the file system on the disk.
Iofs exports the file system on the disk.
semfs
Semfs is a semaphore file system.
Semfs is a semaphore file system.
Package diskfs provides a glue layer between OS's file system and 9P file system.
Package diskfs provides a glue layer between OS's file system and 9P file system.
Package iofs provides a glue layer between fs.FS and lib9p.FS The resulting file system is readonly.
Package iofs provides a glue layer between fs.FS and lib9p.FS The resulting file system is readonly.

Jump to

Keyboard shortcuts

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