Documentation
¶
Overview ¶
Package proto provides the definitions and functions used to implement the 9P protocol. The parsing routines within make very few assumptions or decisions, so that it may be used for a wide variety of higher-level packages.
Index ¶
- Constants
- func DecodeRgetattr(buf *binary.Buffer, valid *uint64, st *unix.Stat_t) error
- func EncodeRgetattr(buf *binary.Buffer, valid uint64, st *unix.Stat_t) error
- func EncodeRstatfs(buf *binary.Buffer, st *unix.Statfs_t) error
- func NewUnixMode(mode Mode) uint32
- func Release(fcall ...*Fcall)
- func UnixDirTypeToQidType(typ uint8) uint8
- func UnixFileTypeToQidType(mode uint32) uint8
- type Decoder
- type Encoder
- type Error
- type Fcall
- type Flag
- type Message
- type MessageType
- type Mode
- type Payloader
- type Qid
- type Rclunk
- type Rflush
- type Rfsync
- type Rgetattr
- type Rgetlock
- type Rlattach
- type Rlauth
- type Rlcreate
- type Rlerror
- type Rlink
- type Rlock
- type Rlopen
- type Rmkdir
- type Rmknod
- type Rread
- func (m *Rread) Decode(buf *binary.Buffer)
- func (m Rread) Encode(buf *binary.Buffer)
- func (m Rread) FixedLen() int
- func (m Rread) Len() int
- func (m Rread) MessageType() MessageType
- func (m Rread) Payload() []byte
- func (m *Rread) PutPayload(b []byte)
- func (m *Rread) Reset()
- func (m Rread) String() string
- type Rreaddir
- func (m *Rreaddir) Decode(buf *binary.Buffer)
- func (m Rreaddir) Encode(buf *binary.Buffer)
- func (m Rreaddir) FixedLen() int
- func (m Rreaddir) Len() int
- func (m Rreaddir) MessageType() MessageType
- func (m Rreaddir) Payload() []byte
- func (m *Rreaddir) PutPayload(b []byte)
- func (m *Rreaddir) Reset()
- func (m Rreaddir) String() string
- type Rreadlink
- type Rremove
- type Rrename
- type Rrenameat
- type Rsetattr
- type Rstatfs
- type Rsymlink
- type Runlinkat
- type Rversion
- type Rwalk
- type Rwrite
- type Rxattrcreate
- type Rxattrwalk
- type Tclunk
- type Tflush
- type Tfsync
- type Tgetattr
- type Tgetlock
- type Tlattach
- type Tlauth
- type Tlcreate
- type Tlink
- type Tlock
- type Tlopen
- type Tmkdir
- type Tmknod
- type Tread
- type Treaddir
- type Treadlink
- type Tremove
- type Trename
- type Trenameat
- type Tsetattr
- type Tstatfs
- type Tsymlink
- type Tunlinkat
- type Tversion
- type Twalk
- type Twrite
- func (m *Twrite) Decode(buf *binary.Buffer)
- func (m Twrite) Encode(buf *binary.Buffer)
- func (m Twrite) FixedLen() int
- func (m Twrite) Len() int
- func (m Twrite) MessageType() MessageType
- func (m Twrite) Payload() []byte
- func (m *Twrite) PutPayload(b []byte)
- func (m *Twrite) Reset()
- func (m Twrite) String() string
- type Txattrcreate
- type Txattrwalk
Constants ¶
const ( GetAttrMode = 0x00000001 // Linux chmod(2) mode bits GetAttrNlink = 0x00000002 // New owner, group of the file as described in Linux chown(2). GetAttrUid = 0x00000004 GetAttrGid = 0x00000008 GetAttrRdev = 0x00000010 GetAttrAtime = 0x00000020 // Time of last file access. GetAttrMtime = 0x00000040 // Time of last file modification. GetAttrCtime = 0x00000080 GetAttrIno = 0x00000100 // New file size as handled by Linux truncate(2). GetAttrSize = 0x00000200 GetAttrBlocks = 0x00000400 GetAttrBtime = 0x00000800 GetAttrGen = 0x00001000 GetAttrDataVersion = 0x00002000 GetAttrBasic = 0x000007ff GetAttrAll = 0x00003fff )
Represents getattr mask values.
const ( SetAttrMode = 0x00000001 SetAttrUid = 0x00000002 SetAttrGid = 0x00000004 SetAttrSize = 0x00000008 SetAttrAtime = 0x00000010 SetAttrMtime = 0x00000020 SetAttrCtime = 0x00000040 SetAttrAtimeSet = 0x00000080 SetAttrMtimeSet = 0x00000100 )
Represents setattr mask values.
const ( // FixedReadWriteSize is the length of all fixed-width fields in a // Twrite or Tread message. Twrite and Tread messages are defined as // // size[4] Twrite tag[2] fid[4] offset[8] count[4] data[count] // size[4] Tread tag[2] fid[4] offset[8] count[4] // FixedReadWriteSize = HeaderSize + 4 + 8 + 4 // 23 // MaxDataSize is the maximum data size of a Twrite or Rread message. MaxDataSize = math.MaxInt32 - (FixedReadWriteSize + 1) // ~ 2GB // MaxNameSize is the maximum length of a filename/username in bytes. MaxNameSize = math.MaxUint8 // MaxNames is the maximum allowed number of path elements in a Twalk // request. MaxNames = 16 // MaxMessageSize is the maximum size of a 9P message (Twrite). MaxMessageSize = (FixedReadWriteSize + 1) + MaxDataSize // MinMessageSize is the minimum size of a 9P Message (Twalk). MinMessageSize = HeaderSize + 4 + 4 + 2 + MaxNames*(2+MaxNameSize) // DefaultMaxDataSize is the default maximum data size of a Twrite or // Rread message. DefaultMaxDataSize = 2 * 1024 * 1024 // ~ 2MB // DefaultMaxMessageSize is the default maximum size of a 9P2000.L // message. DefaultMaxMessageSize = (FixedReadWriteSize + 1) + DefaultMaxDataSize // HeaderSize is the number of bytes required for a header. HeaderSize = 7 )
const ( // NoFid is a reserved fid used in a Tattach request for the afid // field, that indicates that the client does not wish to // authenticate the session. NoFid = math.MaxUint32 // NoUid indicates a invalid user id. NoUid = math.MaxUint32 // NoGid indicates a invalid group id. NoGid = math.MaxUint32 // NoTag is the tag for Tversion and Rversion messages. NoTag = math.MaxUint16 )
const ( // ErrMessageTooLarge is returned during the parsing process if a // message exceeds the maximum size negotiated during the // Tversion/Rversion transaction. ErrMessageTooLarge = Error("message too large") // ErrMessageTooSmall is returned during the parsing process if a // message is too small. ErrMessageTooSmall = Error("message too small") )
const ( TypeDirectory = 0x80 TypeAppendOnly = 0x40 TypeExclusive = 0x20 TypeMount = 0x10 TypeAuth = 0x08 TypeTemporary = 0x04 TypeSymlink = 0x02 TypeLink = 0x01 TypeRegular = 0x00 )
Qid type field represents the type of a file (directory, etc.), represented as a bit vector corresponding to the high 8 bits of the file mode word.
const Version = "9P2000.L"
Version defines the protocol version string.
Variables ¶
This section is empty.
Functions ¶
func DecodeRgetattr ¶
DecodeRgetattr decodes information about a file system object. Valid is a bitmask indicating which fields are valid in the response.
func EncodeRgetattr ¶
EncodeRgetattr encodes information about a file system object. Valid is a bitmask indicating which fields are valid in the response.
func EncodeRstatfs ¶
EncodeRstatfs encodes information about a file system. The byte sequence follow pretty closely the fields returned by the Linux statfs(2) system call.
func Release ¶
func Release(fcall ...*Fcall)
Release resets all state and adds all fcalls to their pool.
func UnixDirTypeToQidType ¶
UnixDirTypeToQidType converts an unix directory type.
func UnixFileTypeToQidType ¶
UnixFileTypeToQidType converts an unix file type.
Types ¶
type Decoder ¶
type Decoder struct { MaxMessageSize uint32 // contains filtered or unexported fields }
Decoder manages the receipt of type and data information read from the remote side of a connection.
func NewDecoder ¶
NewDecoder returns a new decoder that decodes from the io.Reader. Msize defines the maximum message size if greater than zero.
func (*Decoder) Decode ¶
Decode decodes the next 9P message from the input stream and stores it in the data represented by the empty interface m. If m is nil, the value will be discarded. Otherwise, the value underlying m must be a pointer to the correct type for the next 9P message received. If the input is at EOF, Decode returns io.EOF and does not modify e.
func (*Decoder) DecodeHeader ¶
func (d *Decoder) DecodeHeader() (MessageType, uint16, error)
DecodeHeader decodes the next 9P header from the input stream. DecodeHeader and Decode must be called in pairs to read 9P messages from the connection.
type Encoder ¶
type Encoder struct { MaxMessageSize uint32 // contains filtered or unexported fields }
Encoder manages the transmission of type and data information to the other side of a connection. Encoder is safe for concurrent use by multiple goroutines.
func NewEncoder ¶
NewEncoder returns a new encoder that will transmit on the io.Writer. Msize defines the maximum message size if greater than zero.
type Fcall ¶
type Fcall struct { // The argument to the 9P function and used to determine the message // type. Tx Message Rx Message // The reply from the function. Err error C chan *Fcall }
Fcall represents an active 9P RPC.
func Alloc ¶
func Alloc(t MessageType) (*Fcall, bool)
Alloc returns a new fcall object from the internal pool. Alloc is safe for use by multiple goroutines simultaneously.
type Flag ¶
type Flag uint32
Flag is the mode passed to Open and Create operations. These correspond to bits sent over the wire.
const ( // FlagModeMask is a mask of valid Flag mode bits. FlagModeMask Flag = 0x3 // FlagReadOnly flag is indicating read-only mode. FlagReadOnly Flag = 0x0 // FlagWriteOnly flag is indicating write-only mode. FlagWriteOnly Flag = 0x1 // FlagReadWrite flag is indicating read-write mode. FlagReadWrite Flag = 0x2 // FlagAppend opens the file in append mode. Before each write, the // file offset is positioned at the end of the file. The // modification of the file offset and the write operation are // performed as a single atomic step. FlagAppend Flag = 0x400 // FlagTruncate is indicating to truncate file when opened, if // possible. FlagTruncate Flag = 0x200 // FlagSync is indicating to open for synchronous I/O. FlagSync Flag = 0x101000 )
type Message ¶
type Message interface { MessageType() MessageType // Len returns the length of the message in bytes. Len() int // Encode encodes to the given binary.Buffer. Encode(*binary.Buffer) // Decode decodes from the given binary.Buffer. Decode(*binary.Buffer) // Reset resets all state. Reset() }
Message represents a 9P message and is used to access fields common to all 9P messages.
type MessageType ¶
type MessageType uint8
MessageType represents a 9P message type identifier.
const ( MessageTversion MessageType = 100 + iota MessageRversion MessageTauth MessageRauth MessageTattach MessageRattach MessageTerror // illegal MessageRerror MessageTflush MessageRflush MessageTwalk MessageRwalk MessageTopen MessageRopen MessageTcreate MessageRcreate MessageTread MessageRread MessageTwrite MessageRwrite MessageTclunk MessageRclunk MessageTremove MessageRremove MessageTstat MessageRstat MessageTwstat MessageRwstat MessageTlauth MessageType = 102 MessageRlauth MessageType = 103 MessageTlattach MessageType = 104 MessageRlattach MessageType = 105 MessageRlerror MessageType = 7 MessageTstatfs MessageType = 8 MessageRstatfs MessageType = 9 MessageTlopen MessageType = 12 MessageRlopen MessageType = 13 MessageTlcreate MessageType = 14 MessageRlcreate MessageType = 15 MessageTsymlink MessageType = 16 MessageRsymlink MessageType = 17 MessageTmknod MessageType = 18 MessageRmknod MessageType = 19 MessageTrename MessageType = 20 MessageRrename MessageType = 21 MessageTreadlink MessageType = 22 MessageRreadlink MessageType = 23 MessageTgetattr MessageType = 24 MessageRgetattr MessageType = 25 MessageTsetattr MessageType = 26 MessageRsetattr MessageType = 27 MessageTxattrwalk MessageType = 30 MessageRxattrwalk MessageType = 31 MessageTxattrcreate MessageType = 32 MessageRxattrcreate MessageType = 33 MessageTreaddir MessageType = 40 MessageRreaddir MessageType = 41 MessageTfsync MessageType = 50 MessageRfsync MessageType = 51 MessageTlock MessageType = 52 MessageRlock MessageType = 53 MessageTgetlock MessageType = 54 MessageRgetlock MessageType = 55 MessageTlink MessageType = 70 MessageRlink MessageType = 71 MessageTmkdir MessageType = 72 MessageRmkdir MessageType = 73 MessageTrenameat MessageType = 74 MessageRrenameat MessageType = 75 MessageTunlinkat MessageType = 76 MessageRunlinkat MessageType = 77 )
Defines message type identifiers.
func (MessageType) String ¶
func (t MessageType) String() string
type Mode ¶
type Mode uint32
Mode are flags corresponding to file modes. These correspond to bits sent over the wire and also to mode_t bits.
const ( // ModeMask is a mask of all the file mode bits of Mode. ModeMask Mode = 0170000 // ModeRegular is a mode bit for regular files. ModeRegular Mode = 0100000 // ModeDirectory is a mode bit for directories. ModeDirectory Mode = 040000 // ModeSymlink is a mode bit for a symlink. ModeSymlink Mode = 0120000 // ModeBlockDevice is a mode bit for block devices. ModeBlockDevice Mode = 060000 // ModeCharacterDevice is a mode bit for a character device. ModeCharacterDevice Mode = 020000 // ModeSocket is an mode bit for a socket. ModeSocket Mode = 0140000 // ModeNamedPipe is a mode bit for a named pipe. ModeNamedPipe Mode = 010000 // ModeGroupID has several special uses. For a directory, it // indicates that BSD semantics is to be used for that directory: // files created there inherit their group ID from the directory, // not from the effective group ID of the creating process, and // directories created there will also get the ModeGroupID bit // set. ModeGroupID Mode = 0x400 ModeUserID Mode = 0x800 ModeSticky Mode = 0x200 ModePerm = 0777 // Unix permission bits )
Flags corresponding to file modes. These correspond to bits sent over the wire and also correspond to mode_t bits.
type Payloader ¶
type Payloader interface { Message // Payload returns the payload for sending. Payload() []byte // PutPayload sets the decoded payload. PutPayload([]byte) // FixedLen returns the length of the message in bytes without the // count-delimited payload. FixedLen() int }
Payloader is a special message which may include an inline payload.
type Qid ¶
type Qid struct { Type uint8 // type of a file (directory, etc) // Version is a version:number for a file. It is incremented every // time a file is modified. By convention, synthetic files usually // have a version number of 0. Traditional files have a version // numb:r that is a hash of their modification time. Version uint32 // Path is an integer unique among all files in the hierarchy. If // a file is deleted and recreated with the same name in the same // directory, the old and new path components of the qids should // be different. Path uint64 }
Qid represents the server's unique identification for the file being accessed. Two files on the same server hierarchy are the same if and only if their qids are the same.
type Rclunk ¶
type Rclunk struct{}
Rclunk message contains a servers response to a Tclunk request.
func (Rclunk) MessageType ¶
func (m Rclunk) MessageType() MessageType
MessageType returns the message type.
type Rflush ¶
type Rflush struct{}
Rflush echoes the tag (not oldtag) of the Tflush message.
func (Rflush) MessageType ¶
func (m Rflush) MessageType() MessageType
MessageType returns the message type.
type Rfsync ¶
type Rfsync struct{}
Rfsync message contains a server's reply to a Tfsync message.
func (Rfsync) MessageType ¶
func (m Rfsync) MessageType() MessageType
MessageType returns the message type.
type Rgetattr ¶
type Rgetattr struct { // Valid is a bitmask indicating which fields are valid in the // response. Valid uint64 *unix.Stat_t }
Rgetattr describes a file system object. The fields follow pretty closely the fields returned by the Linux stat(2) system call.
func (Rgetattr) IsDir ¶
IsDir reports whether m describes a directory. That is, it tests for the ModeDir bit being set in m.
func (Rgetattr) MessageType ¶
func (m Rgetattr) MessageType() MessageType
MessageType returns the message type.
type Rgetlock ¶
Rgetlock message contains a server's reply to a Tgetlock message.
func (Rgetlock) MessageType ¶
func (m Rgetlock) MessageType() MessageType
MessageType returns the message type.
type Rlattach ¶
type Rlattach struct {
Qid
}
Rlattach message contains a server's reply to a Tlattach request. As a result of the attach transaction, the client will have a connection to the root directory of the desired file tree, represented by the returned qid.
func (Rlattach) MessageType ¶
func (m Rlattach) MessageType() MessageType
MessageType returns the message type.
type Rlauth ¶
type Rlauth struct {
Qid
}
Rlauth reply is sent in response to a Tlauth request. If a server does not require authentication, it can reply to a Tlauth message with an Rerror message.
func (Rlauth) MessageType ¶
func (m Rlauth) MessageType() MessageType
MessageType returns the message type.
type Rlcreate ¶
Rlcreate message contains a server's reply to a Tlcreate request. The qid for the new file is returned in the reply.
func (Rlcreate) MessageType ¶
func (m Rlcreate) MessageType() MessageType
MessageType returns the message type.
type Rlerror ¶
type Rlerror struct {
Errno uint32
}
Rlerror message (there is no Tlerror) is used to return an errno number describing the failure of a transaction.
func (Rlerror) MessageType ¶
func (m Rlerror) MessageType() MessageType
MessageType returns the message type.
type Rlink ¶
type Rlink struct{}
Rlink message contains a server's reply to a Tlink message.
func (Rlink) MessageType ¶
func (m Rlink) MessageType() MessageType
MessageType returns the message type.
type Rlock ¶
type Rlock struct {
Status uint8
}
Rlock message contains a server's reply to a Tlock message.
func (Rlock) MessageType ¶
func (m Rlock) MessageType() MessageType
MessageType returns the message type.
type Rlopen ¶
Rlopen message contains a server's reply to a Tlopen request.
func (Rlopen) MessageType ¶
func (m Rlopen) MessageType() MessageType
MessageType returns the message type.
type Rmkdir ¶
type Rmkdir struct {
Qid
}
Rmkdir message contains a server's reply to a Tmkdir message.
func (Rmkdir) MessageType ¶
func (m Rmkdir) MessageType() MessageType
MessageType returns the message type.
type Rmknod ¶
type Rmknod struct {
Qid
}
Rmknod message contains a server's reply to a Tmknod request. The qid for the new device node is returned in the reply.
func (Rmknod) MessageType ¶
func (m Rmknod) MessageType() MessageType
MessageType returns the message type.
type Rread ¶
type Rread struct {
Data []byte
}
Rread message returns the bytes requested by a Tread message.
func (Rread) MessageType ¶
func (m Rread) MessageType() MessageType
MessageType returns the message type.
func (*Rread) PutPayload ¶
PutPayload sets the decoded payload.
type Rreaddir ¶
type Rreaddir struct {
Data []byte
}
Rreaddir message contains a server's reply to a Treaddir message.
func (Rreaddir) MessageType ¶
func (m Rreaddir) MessageType() MessageType
MessageType returns the message type.
func (*Rreaddir) PutPayload ¶
PutPayload sets the decoded payload.
type Rreadlink ¶
type Rreadlink struct {
Target string
}
Rreadlink message contains a server's reply to a Treadlink request.
func (Rreadlink) MessageType ¶
func (m Rreadlink) MessageType() MessageType
MessageType returns the message type.
type Rremove ¶
type Rremove struct{}
Rremove message contains a servers response to a Tremove request. An Rremove message is only sent if the server determined that the requesting user had the proper permissions required for the Tremove to succeed, otherwise Rerror is returned.
func (Rremove) MessageType ¶
func (m Rremove) MessageType() MessageType
MessageType returns the message type.
type Rrename ¶
type Rrename struct{}
Rrename message contains a server's reply to a Trename request.
func (Rrename) MessageType ¶
func (m Rrename) MessageType() MessageType
MessageType returns the message type.
type Rrenameat ¶
type Rrenameat struct{}
Rrenameat message contains a server's reply to a Trenameat message.
func (Rrenameat) MessageType ¶
func (m Rrenameat) MessageType() MessageType
MessageType returns the message type.
type Rsetattr ¶
type Rsetattr struct{}
Rsetattr message contains a server's reply to a Tsetattr request.
func (Rsetattr) MessageType ¶
func (m Rsetattr) MessageType() MessageType
MessageType returns the message type.
type Rstatfs ¶
type Rstatfs struct { Type uint32 BlockSize uint32 Blocks uint64 BlocksFree uint64 BlocksAvailable uint64 Files uint64 FilesFree uint64 FsID uint64 NameLength uint32 }
Rstatfs response corresponds to the fields returned by the statfs(2) system call.
func (Rstatfs) MessageType ¶
func (m Rstatfs) MessageType() MessageType
MessageType returns the message type.
type Rsymlink ¶
type Rsymlink struct {
Qid
}
Rsymlink message contains a server's reply to a Tsymlink request. The qid for the new symbolic link is returned in the reply.
func (Rsymlink) MessageType ¶
func (m Rsymlink) MessageType() MessageType
MessageType returns the message type.
type Runlinkat ¶
type Runlinkat struct{}
Runlinkat message contains a server's reply to a Tunlinkat message.
func (Runlinkat) MessageType ¶
func (m Runlinkat) MessageType() MessageType
MessageType returns the message type.
type Rversion ¶
type Rversion struct { // MessageSize returns the maximum size (in bytes) of any 9P message // that it will send or accept, and must be equal to or less than // the maximum suggested in the preceding Tversion message. After the // Rversion message is received, both sides of the connection must // honor this limit. MessageSize uint32 // Version identifies the level of the protocol that the server // supports. If a server does not understand the protocol version // sent in a Tversion message, Version will return the string // "unknown". A server may choose to specify a version that is less // than or equal to that supported by the client. Version string }
Rversion reply is sent in response to a Tversion request. It contains the version of the protocol that the server has chosen, and the maximum size of all successive messages.
func (Rversion) MessageType ¶
func (m Rversion) MessageType() MessageType
MessageType returns the message type.
type Rwalk ¶
type Rwalk []Qid
Rwalk message contains a server's reply to a successful Twalk request. If the first path in the corresponding Twalk request cannot be walked, an Rerror message is returned instead.
func AllocRwalk ¶
func AllocRwalk() *Rwalk
AllocRwalk selects an arbitrary item from the Rwalk Pool removes it, and returns it to the caller.
func (*Rwalk) Decode ¶
Decode decodes from the given binary.Buffer. To simplify the implementation, a maximum of sixteen name elements may be packed in a single message.
func (*Rwalk) Encode ¶
Encode encodes to the given binary.Buffer. To simplify the implementation, a maximum of sixteen qid elements may be packed in a single message.
func (Rwalk) MessageType ¶
func (m Rwalk) MessageType() MessageType
MessageType returns the message type.
type Rwrite ¶
type Rwrite struct {
Count uint32
}
Rwrite message returns the bytes requested by a Twrite message.
func (Rwrite) MessageType ¶
func (m Rwrite) MessageType() MessageType
MessageType returns the message type.
type Rxattrcreate ¶
type Rxattrcreate struct{}
Rxattrcreate message contains a server's reply to a Txattrcreate request.
func (*Rxattrcreate) Decode ¶
func (m *Rxattrcreate) Decode(buf *binary.Buffer)
Decode decodes from the given binary.Buffer.
func (Rxattrcreate) Encode ¶
func (m Rxattrcreate) Encode(buf *binary.Buffer)
Encode encodes to the given binary.Buffer.
func (Rxattrcreate) Len ¶
func (m Rxattrcreate) Len() int
Len returns the length of the message in bytes.
func (Rxattrcreate) MessageType ¶
func (m Rxattrcreate) MessageType() MessageType
MessageType returns the message type.
type Rxattrwalk ¶
type Rxattrwalk struct {
Size uint64
}
Rxattrwalk message contains a server's reply to a Txattrwalk request.
func (*Rxattrwalk) Decode ¶
func (m *Rxattrwalk) Decode(buf *binary.Buffer)
Decode decodes from the given binary.Buffer.
func (Rxattrwalk) Encode ¶
func (m Rxattrwalk) Encode(buf *binary.Buffer)
Encode encodes to the given binary.Buffer.
func (Rxattrwalk) Len ¶
func (m Rxattrwalk) Len() int
Len returns the length of the message in bytes.
func (Rxattrwalk) MessageType ¶
func (m Rxattrwalk) MessageType() MessageType
MessageType returns the message type.
type Tclunk ¶
type Tclunk struct {
Fid uint32
}
Tclunk request informs the file server that the current file represented by fid is no longer needed by the client. The actual file is not removed on the server unless the fid had been opened with ORCLOSE.
func (Tclunk) MessageType ¶
func (m Tclunk) MessageType() MessageType
MessageType returns the message type.
type Tflush ¶
type Tflush struct {
OldTag uint16
}
Tflush request is sent to the server to purge the pending response.
func (Tflush) MessageType ¶
func (m Tflush) MessageType() MessageType
MessageType returns the message type.
type Tfsync ¶
type Tfsync struct {
Fid uint32
}
Tfsync flushes any cached data to disk.
func (Tfsync) MessageType ¶
func (m Tfsync) MessageType() MessageType
MessageType returns the message type.
type Tgetattr ¶
type Tgetattr struct { Fid uint32 // RequestMask is a bitmask indicating which fields are requested. RequestMask uint64 }
Tgetattr gets attributes of a file system object referenced by fid.
func (Tgetattr) MessageType ¶
func (m Tgetattr) MessageType() MessageType
MessageType returns the message type.
type Tgetlock ¶
type Tgetlock struct { Fid uint32 Type uint8 Start uint64 Length uint64 ProcID uint32 ClientID string }
Tgetlock tests for the existence of a POSIX record lock and has semantics similar to Linux fcntl(F_GETLK).
func (Tgetlock) MessageType ¶
func (m Tgetlock) MessageType() MessageType
MessageType returns the message type.
type Tlattach ¶
type Tlattach struct { // Fid establishes a fid to be used as the root of the file tree, // should the client's Tlattach request be accepted. Fid uint32 // AuthFid serves to authenticate a user, and must have been // established in a previous Tlauth request. AuthFid uint32 // UserName is the user name of the attaching user. UserName string // Path is the name of the file tree that the client wants to // access. It may be empty. Path string // Uid is the user numerical identifiery of the attaching user. Uid uint32 }
Tlattach message serves as a fresh introduction from a user on the client machine to the server.
func (Tlattach) MessageType ¶
func (m Tlattach) MessageType() MessageType
MessageType returns the message type.
type Tlauth ¶
type Tlauth struct { // AuthFid serves to authenticate a user, and must have been // established in a previous Tlauth request. AuthFid uint32 // UserName is the user name of the attaching user. UserName string // Path is the name of the file tree that the client wants to // access. It may be empty. Path string // Uid is the user numerical identifiery of the attaching user. Uid uint32 }
Tlauth message is used to authenticate users on a connection. If the server does require authentication, it returns aqid defining a file of type QTAUTH that may be read and written to execute an authentication protocol. That protocol's definition is not part of 9P itself.
Once the protocol is complete, the same afid is presented in the attach message for the user, granting entry. The same validated afid may be used for multiple attach messages with the same uname and aname.
func (Tlauth) MessageType ¶
func (m Tlauth) MessageType() MessageType
MessageType returns the message type.
type Tlcreate ¶
Tlcreate creates a regular file name in directory fid and prepares it for I/O. Fid initially represents the parent directory of the new file. After the call it represents the new file. Mode contains Linux creat(2) mode bits. Flags contains Linux open(2) flags bits, e.g. O_RDONLY, O_RDWR, O_WRONLY.
func (Tlcreate) MessageType ¶
func (m Tlcreate) MessageType() MessageType
MessageType returns the message type.
type Tlink ¶
Tlink creates a hard link name in directory dfid. The link target is referenced by fid.
func (Tlink) MessageType ¶
func (m Tlink) MessageType() MessageType
MessageType returns the message type.
type Tlock ¶
type Tlock struct { Fid uint32 Type uint8 Flags uint32 Start uint64 Length uint64 ProcID uint32 ClientID string }
Tlock acquires or releases a POSIX record lock and has semantics similar to Linux fcntl(F_SETLK).
func (Tlock) MessageType ¶
func (m Tlock) MessageType() MessageType
MessageType returns the message type.
type Tlopen ¶
Tlopen prepares fid for file I/O. Flags contains Linux open(2) flags bits, e.g. O_RDONLY, O_RDWR, O_WRONLY.
func (Tlopen) MessageType ¶
func (m Tlopen) MessageType() MessageType
MessageType returns the message type.
type Tmkdir ¶
Tmkdir creates a new directory name in parent directory fid. Mode contains Linux mkdir(2) mode bits. Gid is the effective group ID of the caller.
func (Tmkdir) MessageType ¶
func (m Tmkdir) MessageType() MessageType
MessageType returns the message type.
type Tmknod ¶
type Tmknod struct { DirectoryFid uint32 Name string Perm Mode Major uint32 Minor uint32 Gid uint32 }
Tmknod creates a device node name in directory fid with major and minor numbers. Mode contains Linux mknod(2) mode bits.
func (Tmknod) MessageType ¶
func (m Tmknod) MessageType() MessageType
MessageType returns the message type.
type Tread ¶
Tread request asks for count bytes of data from the file, which must be opened for reading, starting offset bytes after the beginning of the file.
func (Tread) MessageType ¶
func (m Tread) MessageType() MessageType
MessageType returns the message type.
type Treaddir ¶
Treaddir requests that the server return directory entries from the directory represented by fid, previously opened with Tlopen. Offset is zero on the first call.
Directory entries are represented as variable-length records:
qid[13] offset[8] type[1] name[s]
At most count bytes will be returned in data. If count is not zero in the response, more data is available. On subsequent calls, offset is the offset returned in the last directory entry of the previous call.
func (Treaddir) MessageType ¶
func (m Treaddir) MessageType() MessageType
MessageType returns the message type.
type Treadlink ¶
type Treadlink struct {
Fid uint32
}
Treadlink returns the contents of the symbolic link referenced by fid.
func (Treadlink) MessageType ¶
func (m Treadlink) MessageType() MessageType
MessageType returns the message type.
type Tremove ¶
type Tremove struct {
Fid uint32
}
Tremove request asks the file server both to remove a file and to clunk it, even if the remove fails. This request will fail if the client does not have write permission in the parent directory.
func (Tremove) MessageType ¶
func (m Tremove) MessageType() MessageType
MessageType returns the message type.
type Trename ¶
Trename renames a file system object referenced by fid, to name in the directory referenced by directory fid.
func (Trename) MessageType ¶
func (m Trename) MessageType() MessageType
MessageType returns the message type.
type Trenameat ¶
type Trenameat struct { OldDirectoryFid uint32 OldName string NewDirectoryFid uint32 NewName string }
Trenameat changes the name of a file from oldname to newname, possible moving it from old directory represented by fid to new directory represented by new fid.
If the server returns unix.ENOTSUPP, the client should fall back to the rename operation.
func (Trenameat) MessageType ¶
func (m Trenameat) MessageType() MessageType
MessageType returns the message type.
type Tsetattr ¶
type Tsetattr struct { Fid uint32 // Valid is a bitmask selecting which fields to set. Valid uint32 Mode Mode // inode protection mode Uid uint32 // user-id of owner Gid uint32 // group-id of owner Size uint64 // file size as handled by Linux truncate(2) Atime unix.Timespec // time of last access Mtime unix.Timespec // time of last data modification }
Tsetattr sets attributes of a file system object referenced by fid.
func (Tsetattr) MessageType ¶
func (m Tsetattr) MessageType() MessageType
MessageType returns the message type.
type Tstatfs ¶
type Tstatfs struct {
Fid uint32
}
Tstatfs is used to request file system information of the file system containing fid.
func (Tstatfs) MessageType ¶
func (m Tstatfs) MessageType() MessageType
MessageType returns the message type.
type Tsymlink ¶
Tsymlink creates a symbolic link name in directory fid. The link will point to target.
func (Tsymlink) MessageType ¶
func (m Tsymlink) MessageType() MessageType
MessageType returns the message type.
type Tunlinkat ¶
Tunlinkat unlinks name from directory represented by directory fid. If the file is represented by a fid, that fid is not clunked.
If the server returns unix.ENOTSUPP, the client should fall back to the remove operation.
func (Tunlinkat) MessageType ¶
func (m Tunlinkat) MessageType() MessageType
MessageType returns the message type.
type Tversion ¶
type Tversion struct { // MessageSize returns the maximum length, in bytes, that the client // will ever generate or expect to receive in a single 9P message. // This count includes all 9P protocol data, starting from the size // field and extending through the message, but excludes enveloping // transport protocols. MessageSize uint32 // Version identifies the level of the protocol that the client // supports. The string must always begin with the two characters // "9P". Version string }
Tversion request negotiates the protocol version and message size to be used on the connection and initializes the connection for I/O. Tversion must be the first message sent on the 9P connection, and the client cannot issue any further requests until it has received the Rversion reply.
func (Tversion) MessageType ¶
func (m Tversion) MessageType() MessageType
MessageType returns the message type.
type Twalk ¶
type Twalk struct { // Fid must have been established by a previous transaction, such as // an Tattach. Fid uint32 // NewFid contains the proposed fid that the client wishes to // associate with the result of traversing the directory hierarchy. NewFid uint32 // Names contains an ordered list of path name elements that the // client wishes to descend into in succession. // // To simplify the implementation, a maximum of sixteen name elements // may be packed in a single message Names []string }
Twalk message is used to descend a directory hierarchy.
func (*Twalk) Decode ¶
Decode decodes from the given binary.Buffer. To simplify the implementation, a maximum of sixteen name elements may be packed in a single message.
func (Twalk) Encode ¶
Encode encodes to the given binary.Buffer. To simplify the implementation, a maximum of sixteen name elements may be packed in a single message.
func (Twalk) MessageType ¶
func (m Twalk) MessageType() MessageType
MessageType returns the message type.
type Twrite ¶
Twrite message is sent by a client to write data to a file.
func (Twrite) MessageType ¶
func (m Twrite) MessageType() MessageType
MessageType returns the message type.
func (*Twrite) PutPayload ¶
PutPayload sets the decoded payload.
type Txattrcreate ¶
Txattrcreate gets a fid pointing to the xattr name. This fid can later be used to set the xattr value. Flag is derived from set Linux setxattr(2). The manpage says
The flags parameter can be used to refine the semantics of the operation. XATTR_CREATE specifies a pure create, which fails if the named attribute exists already. XATTR_REPLACE specifies a pure replace operation, which fails if the named attribute does not already exist. By default (no flags), the extended attribute will be created if need be, or will simply replace the value if the attribute exists.
The actual setxattr operation happens when the fid is clunked. At that point the written byte count and the attrsize specified in Txattrcreate should be same otherwise an error will be returned.
func (*Txattrcreate) Decode ¶
func (m *Txattrcreate) Decode(buf *binary.Buffer)
Decode decodes from the given binary.Buffer.
func (Txattrcreate) Encode ¶
func (m Txattrcreate) Encode(buf *binary.Buffer)
Encode encodes to the given binary.Buffer.
func (Txattrcreate) Len ¶
func (m Txattrcreate) Len() int
Len returns the length of the message in bytes.
func (Txattrcreate) MessageType ¶
func (m Txattrcreate) MessageType() MessageType
MessageType returns the message type.
type Txattrwalk ¶
Txattrwalk gets a new fid pointing to xattr name. This fid can later be used to read the xattr value. If name is NULL new fid can be used to get the list of extended attributes associated with the file system object.
func (*Txattrwalk) Decode ¶
func (m *Txattrwalk) Decode(buf *binary.Buffer)
Decode decodes from the given binary.Buffer.
func (Txattrwalk) Encode ¶
func (m Txattrwalk) Encode(buf *binary.Buffer)
Encode encodes to the given binary.Buffer.
func (Txattrwalk) Len ¶
func (m Txattrwalk) Len() int
Len returns the length of the message in bytes.
func (Txattrwalk) MessageType ¶
func (m Txattrwalk) MessageType() MessageType
MessageType returns the message type.