Documentation ¶
Overview ¶
9P2000 implementation.
Index ¶
- Constants
- Variables
- func Respond(ctx context.Context, r *Req, err error)
- func SendMsg(msg Msg, w io.Writer) error
- type AuthFile
- type CreaterFS
- type DirEntry
- type ExportFS
- type FS
- type Fid
- type FidPool
- type File
- type FileInfo
- type FileMode
- type Msg
- type MsgType
- type OpenMode
- type Qid
- type QidType
- type RAttach
- type RAuth
- type RClunk
- type RCreate
- type RError
- type RFlush
- type ROpen
- type RRead
- type RRemove
- type RStat
- type RVersion
- type RWStat
- type RWalk
- type RWrite
- type ReadDirFile
- type RemoverFS
- type RemoverFile
- type Req
- type ReqPool
- type Server
- type Stat
- type TAttach
- type TAuth
- type TClunk
- type TCreate
- type TFlush
- type TOpen
- type TRead
- type TRemove
- type TStat
- type TVersion
- type TWStat
- type TWalk
- type TWrite
- type WriterFile
- type WriterStatFile
Constants ¶
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 )
const ( OREAD OpenMode = 0 OWRITE = 1 ORDWR = 2 OEXEC = 3 OTRUNC = 16 ORCLOSE = 64 )
-1 = not open
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 */ )
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.
const NOFID = ^uint32(0)
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 ¶
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 ¶
func Respond ¶ added in v0.1.0
Respond Responds to the request r with the message r.Ofcall if err is nil, or if err is not nil, with the Rerror with the error message. If r is nil, or both r.Ofcall and err are nil it panics.
Types ¶
type AuthFile ¶
AuthFile is a file allocated by Tauth messages.
type CreaterFS ¶ added in v0.3.0
type ExportFS ¶ added in v0.2.1
type ExportFS struct {
FS
}
exportFS is a wrapper of FS to export it as fs.FS.
type FS ¶
type FS interface { // OpenFile opens file named name with omode. OpenFile(name string, omode OpenMode) (File, error) }
FS is an file system to be exported by 9P server.
type Fid ¶
type Fid struct { Fid uint32 OMode OpenMode /* -1 = not open */ File File // The associated File. Uid string // The user id derived from the attach message. // contains filtered or unexported fields }
Fid represents the fid defined by 9P
type FidPool ¶
type FidPool struct {
// contains filtered or unexported fields
}
FidPool is a pool of Fid. It is used to track the fid in the file system the server is exporting.
type File ¶
File is an open file.
type FileInfo ¶
type FileInfo struct {
Stat Stat
}
FileInfo is a struct returned by File.Stat(). This struct is needed because of the name collision: Stat.Name and FileInfo.Name.
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 }
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.
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.
type RAttach ¶
type RAuth ¶
type RCreate ¶
type RError ¶
type ROpen ¶
type RRead ¶
type RStat ¶
type RVersion ¶
type RWalk ¶
type RWrite ¶
type ReadDirFile ¶
ReadDirFile is a directory. Note that non-directory file can implement this. In this case, ReadDir should return an error.
type RemoverFile ¶
TODO: I think Remove should be implemented by the FS's method.
type Req ¶
type Req struct { Tag uint16 Srv *Server Ifcall Msg Ofcall Msg Fid *Fid Afid *Fid Oldreq *Req Cancel context.CancelFunc // contains filtered or unexported fields }
Req represents each requests.
type ReqPool ¶
type ReqPool struct {
// contains filtered or unexported fields
}
ReqPool is the pool of Reqs the server is dealing with.
type Server ¶
type Server struct { // Auth is called when Tauth message arrives. // If authentication is desired, the Auth functions should // set Req.Afid.Qid and Req.Ofcall.Qid. // If this is nil, no authentication is performed. Auth func(context.Context, *Req) // contains filtered or unexported fields }
Server is a 9P server
func NewServer ¶
NewServer creates a Server and runs listener and speaker goroutines. It reads incoming messages from r and writes responses to w.
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
NewStat converts a byte array of stat from a 9P message into Stat struct.
func (*Stat) Size ¶ added in v0.3.0
size returns the size of marshaled stat in bytes excluding the size field itself.
type TAttach ¶
type TAuth ¶
type TClunk ¶
type TCreate ¶
type TFlush ¶
type TOpen ¶
type TRead ¶
type TRemove ¶
type TStat ¶
type TVersion ¶
type TWStat ¶
type TWalk ¶
type TWrite ¶
Source Files ¶
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. |
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. |