lib9p

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: 0BSD Imports: 12 Imported by: 0

Documentation

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
)

-1 = not open

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
)
View Source
const IOHDRSZ = 23

Ample room for Twrite/Rread header (iounit). 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)
View Source
const NOTAG = ^uint16(0)

Variables

View Source
var (
	ErrBotch      = fmt.Errorf("bocchi")
	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

This section is empty.

Types

type AuthFile

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

func (*AuthFile) Close

func (af *AuthFile) Close() error

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 Client

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

func NewClient

func NewClient(mSize uint32, uname string, r io.Reader, w io.Writer) *Client

func (*Client) Attach

func (c *Client) Attach(ctx context.Context, tag uint16, fid, afid uint32, uname, aname string) (Qid, error)

func (*Client) Auth

func (c *Client) Auth(ctx context.Context, tag uint16, afid uint32, uname, aname string) (Qid, error)

func (*Client) Clunk

func (c *Client) Clunk(ctx context.Context, tag uint16, fid uint32) error

func (*Client) Create

func (c *Client) Create(ctx context.Context, tag uint16, fid uint32, name string, perm FileMode, mode OpenMode) (Qid, uint32, error)

func (*Client) Flush

func (c *Client) Flush(ctx context.Context, tag, oldtag uint16) error

func (*Client) Open

func (c *Client) Open(ctx context.Context, tag uint16, fid uint32, mode OpenMode) (qid Qid, iounit uint32, err error)

func (*Client) Read

func (c *Client) Read(ctx context.Context, tag uint16, fid uint32, offset uint64, count uint32) (data []byte, err error)

func (*Client) Remove

func (c *Client) Remove(ctx context.Context, tag uint16, fid uint32) error

func (*Client) Stat

func (c *Client) Stat(ctx context.Context, tag uint16, fid uint32) (*Stat, error)

func (*Client) Stop

func (c *Client) Stop()

func (*Client) Version

func (c *Client) Version(ctx context.Context, tag uint16, mSize uint32, version string) (uint32, string, error)

func (*Client) Walk

func (c *Client) Walk(ctx context.Context, tag uint16, fid, newFid uint32, wname []string) (wqid []Qid, err error)

func (*Client) Write

func (c *Client) Write(ctx context.Context, tag uint16, fid uint32, offset uint64, count uint32, data []byte) (uint32, error)

func (*Client) Wstat

func (c *Client) Wstat(ctx context.Context, tag uint16, fid uint32, stat *Stat) error

type ClientFS

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

func Mount

func Mount(r io.Reader, w io.Writer, uname, aname string) (fs *ClientFS, err error)

func (*ClientFS) Open

func (fsys *ClientFS) Open(name string) (File, error)

func (*ClientFS) OpenFile

func (fsys *ClientFS) OpenFile(name string, omode OpenMode, perm fs.FileMode) (File, error)

type ClientFile

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

ClientFile is File for Client.

func (*ClientFile) Close

func (cf *ClientFile) Close() error

Don't use closed file.

func (*ClientFile) Read

func (cf *ClientFile) Read(b []byte) (int, error)

func (*ClientFile) Stat

func (cf *ClientFile) Stat() (*FileInfo, error)

type CreaterFile

type CreaterFile interface {
	File
	// Create creates a file named name in this directory.
	// It sets the owner of newly created file to the specified uid,
	// and file mode to the specified perm.
	Create(name string, uid string, mode OpenMode, perm FileMode) (File, error)
}

type DirEntry

type DirEntry = FileInfo

func (*DirEntry) Info

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

type FS

type FS interface {
	OpenFile(name string, omode OpenMode, perm fs.FileMode) (File, error)
}

type Fid

type Fid struct {
	Fid   uint32
	OMode OpenMode /* -1 = not open */

	File File
	Uid  string
	// contains filtered or unexported fields
}

func (*Fid) String

func (f *Fid) String() string

type FidPool

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

func (*FidPool) String

func (pool *FidPool) String() string

type File

type File interface {
	Stat() (*FileInfo, error)
	Close() error
	io.Reader
}

type FileInfo

type FileInfo struct {
	Stat Stat
}

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) Qid

func (fi *FileInfo) Qid() Qid

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 Msg

type Msg interface {
	// Size returns the size field of message.
	Size() uint32
	// Type returns the type field of message.
	Type() MsgType
	// Tag returns the tag of message.
	Tag() uint16
	SetTag(uint16)

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

Msg represents any kind of message of 9P. It defines methods for common fields.

type MsgType

type MsgType uint8

type OpenMode

type OpenMode int8 // defined by 9P

type Qid

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

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 {
	// contains filtered or unexported fields
}

func (*RAttach) Qid

func (msg *RAttach) Qid() Qid

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) Tag

func (msg *RAttach) Tag() uint16

func (*RAttach) Type

func (msg *RAttach) Type() MsgType

type RAuth

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

func (*RAuth) AQid

func (msg *RAuth) AQid() Qid

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) Tag

func (msg *RAuth) Tag() uint16

func (*RAuth) Type

func (msg *RAuth) Type() MsgType

type RClunk

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

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) Tag

func (msg *RClunk) Tag() uint16

func (*RClunk) Type

func (msg *RClunk) Type() MsgType

type RCreate

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

func (*RCreate) IoUnit

func (msg *RCreate) IoUnit() uint32

func (*RCreate) Qid

func (msg *RCreate) Qid() Qid

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) Tag

func (msg *RCreate) Tag() uint16

func (*RCreate) Type

func (msg *RCreate) Type() MsgType

type RError

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

func (*RError) EName

func (msg *RError) EName() string

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) Tag

func (msg *RError) Tag() uint16

func (*RError) Type

func (msg *RError) Type() MsgType

type RFlush

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

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) Tag

func (msg *RFlush) Tag() uint16

func (*RFlush) Type

func (msg *RFlush) Type() MsgType

type ROpen

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

func (*ROpen) IoUnit

func (msg *ROpen) IoUnit() uint32

func (*ROpen) Qid

func (msg *ROpen) Qid() Qid

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) Tag

func (msg *ROpen) Tag() uint16

func (*ROpen) Type

func (msg *ROpen) Type() MsgType

type RRead

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

func (*RRead) Count

func (msg *RRead) Count() uint32

func (*RRead) Data

func (msg *RRead) Data() []byte

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) Tag

func (msg *RRead) Tag() uint16

func (*RRead) Type

func (msg *RRead) Type() MsgType

type RRemove

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

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) Tag

func (msg *RRemove) Tag() uint16

func (*RRemove) Type

func (msg *RRemove) Type() MsgType

type RStat

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

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) Tag

func (msg *RStat) Tag() uint16

func (*RStat) Type

func (msg *RStat) Type() MsgType

type RVersion

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

func (*RVersion) MSize

func (msg *RVersion) MSize() uint32

func (*RVersion) SetMSize

func (msg *RVersion) SetMSize(s uint32)

func (*RVersion) SetTag

func (msg *RVersion) SetTag(t uint16)

func (*RVersion) SetVersion

func (msg *RVersion) SetVersion(v string)

func (*RVersion) Size

func (msg *RVersion) Size() uint32

func (*RVersion) String

func (msg *RVersion) String() string

func (*RVersion) Tag

func (msg *RVersion) Tag() uint16

func (*RVersion) Type

func (msg *RVersion) Type() MsgType

func (*RVersion) Version

func (msg *RVersion) Version() string

type RWStat

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

func (*RWStat) SetTag

func (msg *RWStat) SetTag(t uint16)

func (*RWStat) Size

func (msg *RWStat) Size() uint32

func (*RWStat) String

func (msg *RWStat) String() string

func (*RWStat) Tag

func (msg *RWStat) Tag() uint16

func (*RWStat) Type

func (msg *RWStat) Type() MsgType

type RWalk

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

func (*RWalk) Qid

func (msg *RWalk) Qid() []Qid

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) Tag

func (msg *RWalk) Tag() uint16

func (*RWalk) Type

func (msg *RWalk) Type() MsgType

type RWrite

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

func (*RWrite) Count

func (msg *RWrite) Count() uint32

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) Tag

func (msg *RWrite) Tag() uint16

func (*RWrite) Type

func (msg *RWrite) Type() MsgType

type ReadDirFile

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

type RemoverFile

type RemoverFile interface {
	File
	Remove() error
}

type Req

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

type ReqPool

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

type Server

type Server struct {
	Auth func(context.Context, *Req)
	// contains filtered or unexported fields
}

func NewServer

func NewServer(fsys FS, mSize uint32, r io.Reader, w io.Writer) *Server

func (*Server) Chatty

func (s *Server) Chatty()

func (*Server) Serve

func (s *Server) Serve(ctx context.Context)

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
}

func (*Stat) String

func (s *Stat) String() string

type TAttach

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

func (*TAttach) AFid

func (msg *TAttach) AFid() uint32

func (*TAttach) AName

func (msg *TAttach) AName() string

func (*TAttach) Fid

func (msg *TAttach) Fid() uint32

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) Tag

func (msg *TAttach) Tag() uint16

func (*TAttach) Type

func (msg *TAttach) Type() MsgType

func (*TAttach) UName

func (msg *TAttach) UName() string

type TAuth

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

func (*TAuth) AFid

func (msg *TAuth) AFid() uint32

func (*TAuth) AName

func (msg *TAuth) AName() string

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) Tag

func (msg *TAuth) Tag() uint16

func (*TAuth) Type

func (msg *TAuth) Type() MsgType

func (*TAuth) UName

func (msg *TAuth) UName() string

type TClunk

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

func (*TClunk) Fid

func (msg *TClunk) Fid() uint32

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) Tag

func (msg *TClunk) Tag() uint16

func (*TClunk) Type

func (msg *TClunk) Type() MsgType

type TCreate

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

func (*TCreate) Fid

func (msg *TCreate) Fid() uint32

func (*TCreate) Mode

func (msg *TCreate) Mode() OpenMode

func (*TCreate) Name

func (msg *TCreate) Name() string

func (*TCreate) Perm

func (msg *TCreate) Perm() FileMode

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) Tag

func (msg *TCreate) Tag() uint16

func (*TCreate) Type

func (msg *TCreate) Type() MsgType

type TFlush

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

func (*TFlush) OldTag

func (msg *TFlush) OldTag() 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) Tag

func (msg *TFlush) Tag() uint16

func (*TFlush) Type

func (msg *TFlush) Type() MsgType

type TOpen

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

func (*TOpen) Fid

func (msg *TOpen) Fid() uint32

func (*TOpen) Mode

func (msg *TOpen) Mode() OpenMode

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) Tag

func (msg *TOpen) Tag() uint16

func (*TOpen) Type

func (msg *TOpen) Type() MsgType

type TRead

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

func (*TRead) Count

func (msg *TRead) Count() uint32

func (*TRead) Fid

func (msg *TRead) Fid() uint32

func (*TRead) Offset

func (msg *TRead) Offset() uint64

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) Tag

func (msg *TRead) Tag() uint16

func (*TRead) Type

func (msg *TRead) Type() MsgType

type TRemove

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

func (*TRemove) Fid

func (msg *TRemove) Fid() uint32

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) Tag

func (msg *TRemove) Tag() uint16

func (*TRemove) Type

func (msg *TRemove) Type() MsgType

type TStat

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

func (*TStat) Fid

func (msg *TStat) Fid() uint32

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) Tag

func (msg *TStat) Tag() uint16

func (*TStat) Type

func (msg *TStat) Type() MsgType

type TVersion

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

TVersion represents Tversion message of 9P.

func (*TVersion) MSize

func (msg *TVersion) MSize() uint32

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) Tag

func (msg *TVersion) Tag() uint16

func (*TVersion) Type

func (msg *TVersion) Type() MsgType

func (*TVersion) Version

func (msg *TVersion) Version() string

type TWStat

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

func (*TWStat) Fid

func (msg *TWStat) Fid() uint32

func (*TWStat) SetTag

func (msg *TWStat) SetTag(t uint16)

func (*TWStat) Size

func (msg *TWStat) Size() uint32

func (*TWStat) Stat

func (msg *TWStat) Stat() *Stat

func (*TWStat) String

func (msg *TWStat) String() string

func (*TWStat) Tag

func (msg *TWStat) Tag() uint16

func (*TWStat) Type

func (msg *TWStat) Type() MsgType

type TWalk

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

func (*TWalk) Fid

func (msg *TWalk) Fid() uint32

func (*TWalk) NWName

func (msg *TWalk) NWName() uint16

func (*TWalk) NewFid

func (msg *TWalk) NewFid() uint32

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) Tag

func (msg *TWalk) Tag() uint16

func (*TWalk) Type

func (msg *TWalk) Type() MsgType

func (*TWalk) WName

func (msg *TWalk) WName() []string

type TWrite

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

func (*TWrite) Count

func (msg *TWrite) Count() uint32

func (*TWrite) Data

func (msg *TWrite) Data() []byte

func (*TWrite) Fid

func (msg *TWrite) Fid() uint32

func (*TWrite) Offset

func (msg *TWrite) Offset() uint64

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) Tag

func (msg *TWrite) Tag() uint16

func (*TWrite) Type

func (msg *TWrite) Type() MsgType

type WriterFile

type WriterFile interface {
	File
	io.Writer
}

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
}

Directories

Path Synopsis
cmd
diskfs
Disk exports the file system on the disk.
Disk exports the file system on the disk.
iofs
Disk exports the file system on the disk.
Disk exports the file system on the disk.

Jump to

Keyboard shortcuts

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