Documentation ¶
Overview ¶
Package message contains types for 9p messages.
The types defined here can encode/decode themselves to the 9p wire representation.
Index ¶
- Constants
- func OsMode(mode OpenMode) int
- type Content
- type Message
- type OpenMode
- type RAttach
- type RAuth
- type RClunk
- type RCreate
- type RError
- type RFlush
- type ROpen
- type RRead
- type RRemove
- type RStat
- type RVersion
- type RWalk
- type RWrite
- type RWstat
- type TAttach
- type TAuth
- type TClunk
- type TCreate
- type TFlush
- type TOpen
- type TRead
- type TRemove
- type TStat
- type TVersion
- type TWalk
- type TWrite
- type TWstat
Constants ¶
const ( BadAttachErrorString = "unknown specifier in attach" BadOffsetErrorString = "bad offset" BadCountErrorString = "bad count" BotchErrorString = "9P protocol botch" CreateNonDirErrorString = "create in non-directory" DupFidErrorString = "duplicate fid" DupTagErrorString = "duplicate tag" IsDirErrorString = "is a directory" NoCreateErrorString = "create prohibited" NoMemErrorString = "out of memory" NoRemoveErrorString = "remove prohibited" NoStatErrorString = "stat prohibited" NotFoundErrorString = "file not found" NoWriteErrorString = "write prohibited" NoWstatErrorString = "wstat prohibited" PermErrorString = "permission denied" UnknownFidErrorString = "unknown fid" BadDirErrorString = "bad directory in wstat" WalkNoDirErrorString = "walk in non-directory" )
9p defined error strings. See: https://github.com/0intro/plan9/blob/7524062cfa4689019a4ed6fc22500ec209522ef0/sys/src/lib9p/srv.c#L10
const HeaderSize uint64 = 4 + 1 + 2
HeaderSize is the length of the size, type and tag headers in bytes.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Content ¶
type Content interface {
// contains filtered or unexported methods
}
Content is implemented by the message types containing the real information.
type Message ¶
Message is the general message type.
It wraps implementations of interface Content.
func (*Message) Decode ¶
Decode reads a message from a io.Reader.
It returns the count of read bytes and an error.
type OpenMode ¶
type OpenMode uint8
OpenMode is used to signalize the mode a file should be opened with in a TOpenMessage.
const ( // Read opens a file for reading. Read OpenMode = 0 // Write opens a file for writing Write OpenMode = 1 // ReadWrite opens a file for random access. ReadWrite OpenMode = 2 // Exec opens a file for reading but also checks execute permission. Exec OpenMode = 3 // Trunc is to be OR'ed in (except for OpenExec), truncates file before opening. Trunc OpenMode = 16 // CloseExec is to be OR'ed in, closes on execution. CloseExec OpenMode = 32 // Close is to be OR'ed in, remove on closing. Close OpenMode = 64 )
type RAttach ¶
RAttach is the answer to an attach request.
Qid is the servers representation of the file trees root.
See also: http://man.cat-v.org/plan_9/5/attach
type RAuth ¶
RAuth is the response to a TAuth
Aqid is a file of type QidTypeAuth that can be read and written using read and write messages to perform authentication. The authentication protocol is not part of 9p.
See also: http://man.cat-v.org/plan_9/5/attach
type RClunk ¶
type RClunk struct{}
RClunk signals a successful clunk.
After the fid is successfully clunked it can be reused.
See also: http://man.cat-v.org/plan_9/5/clunk
type RCreate ¶
RCreate is the answer for a successful create.
Qid is the new file as seen by the server.
Iounit may be zero. If not, it is the number of bytes guaranteed to succeed to be read or written in one message.
See also: http://man.cat-v.org/plan_9/5/open
type RError ¶
type RError struct {
Ename string
}
RError is the response to failed requests.
It usually contains one of the standard *ErrorString constants.
See also: http://man.cat-v.org/plan_9/5/error
type RFlush ¶
type RFlush struct { }
RFlush is the answer to a TFlush and signals that the flush has finished.
See also: http://man.cat-v.org/plan_9/5/flush
type ROpen ¶
ROpen is the reply to a open request.
Qid is the servers idea of the opened file accessed.
Iounit may be zero. If not, it's the number of bytes which can be read or written in a single call.
See also: http://man.cat-v.org/plan_9/5/open
type RRead ¶
RRead is the reply to a TRead.
The data read is stored in Data, Count being the length of Data in bytes.
For directories, read returns an integral number of directory entries exactly as in RStat, one for each member of the directory. To help with this StatReader can be used.
See also: http://man.cat-v.org/inferno/5/read
type RRemove ¶
type RRemove struct{}
RRemove is the answer for a successful TRemove request.
See also: http://man.cat-v.org/inferno/5/remove
type RStat ¶
RStat contains a machine-independent directory entry, Stat.
See also: http://man.cat-v.org/inferno/5/stat
type RVersion ¶
RVersion is the servers reply to a TVersionMessage.
Msize must be lower or equal of what the client requested.
Version may be set to the clients version string or a string of an earlier protocol version. If the server doesn't understand the requested version, it replies with the version string "unknown".
A version request starts a new session, so any remaining I/O operations are aborted and allocated fids are clunked.
See also: http://man.cat-v.org/inferno/5/version
type RWalk ¶
RWalk is the response to a TWalk.
Wqid contains the qids of the Wnames in a successfull walk. If the walk fails at the first element an error is returned, if it fails at a later point, the qids of the successfully walked elements are returned (len(Wqid) < len(Wname).
See also: http://man.cat-v.org/inferno/5/walk
type RWrite ¶
type RWrite struct {
Count uint32
}
RWrite is the reply to a TWrite.
Count is the number of bytes written. It usually should be the same as requested.
See also: http://man.cat-v.org/inferno/5/read
type RWstat ¶
type RWstat struct{}
RWstat is the reply for a successfull TWstat request.
See also: http://man.cat-v.org/inferno/5/stat
type TAttach ¶
TAttach establishes a new connection.
Fid will be mapped to the root of the file system. Afid specifies a fid gained from a previous TAuth. Uname identifies the user accessing the file system, Aname selecting the file tree to access.
See also: http://man.cat-v.org/plan_9/5/attach
type TAuth ¶
TAuth facilitates authentication.
Afid is a new fid to be used for authentication. Uname and Aname must be the same as for the following TAttach.
Authentication is performed by reading and writing the file referenced by Afid, after receiving RAuth. When complete Afid is used for authentication in TAttach.
The same Afid, Uname and Aname may be used for multiple TAttach messages.
If no authentication is required, RError is returned instead of RAuth.
See also: http://man.cat-v.org/plan_9/5/attach
type TClunk ¶
TClunk requests to forget a fid.
The mapping on the server from fid to actual file should be removed, not touching the actual file unless it was used OpenClose.
Regardless of the result of this call, the fid will not be valid anymore and can be reused.
See also: http://man.cat-v.org/plan_9/5/clunk
type TCreate ¶
TCreate asks the file server to create a new file.
The file is to be created in the directory represented by Fid, with the supplied Name. Write permission is required on the directory. The owner will be implied by the file systems used. The group is the same as the directories. Permissions for a file will be set to
Perm & 0666 | DPerm & 0666
or
Perm & 0777 | DPerm & 0777
if a directory (DPerm being the permissions of the parent directory).
The created file is opened with Mode, and Fid will represent the new file. Mode is not checked to fulfill the permissions of Perm.
Directories are created by setting the DirModeDir bit in Perm.
Names "." and ".." are forbidden.
Fid must not be in use already.
Creating a file with a name already in use, will truncate the existing file.
See also: http://man.cat-v.org/plan_9/5/open
type TFlush ¶
type TFlush struct {
Oldtag uint16
}
TFlush signals the server that it should abort processing a message.
Instances of Server directly handle these message type by running the cancel function of the context for the message which should be aborted. It is here for usage in client implementations.
Unlike the real world, flushing never fails.
See also: http://man.cat-v.org/inferno/5/flush
type TOpen ¶
TOpen is a 9P open request message.
Open requests ask the file server to prepare a fid to be used with read and write requests, checking the permissions before.
Mode determines the type of IO and can be one of the constants OpenRead, OpenWrite, OpenReadWrite, OpenExec, additionally OpenTrunc, OpenCloseExec and OpenClose or'ed into Mode.
See also: http://man.cat-v.org/plan_9/5/open
type TRead ¶
TRead requests data from a file.
The file is identified by Fid, which must be opened before reading. Count bytes are read from the file, starting at Offset bytes after the beginning of the file.
The count Field in the reply indicates the number of bytes returned. This may be less than the requested amount. If the Offset field is greater than or equal to the number of bytes in the file, a Count of zero will be returned.
For directories, the read request message must have Offset equal to zero or the value of Offset in the previous read on the directory, plus the number of bytes returned in the previous read. In other words, seeking other than to the beginning is illegal in a directory.
See also: http://man.cat-v.org/inferno/5/read
type TRemove ¶
TRemove signals the server to remove the file and clunk the Fid.
The Fid is clunked even if the remove fails. The request will fail if the client doesn't have the permission to write the parent directory.
See also: http://man.cat-v.org/inferno/5/remove
type TStat ¶
TStat requests information about file.
The file for which information is requested is identified by Fid.
See also: http://man.cat-v.org/inferno/5/stat
type TVersion ¶
TVersion initializes a new connection.
Msize is the maximum message size the client will ever create, and includes _all_ protocol data (also 9p type, tag and size fields). As the contents of these fields are handled by neinp.Server, the msize has to include the length of the size (4 octets) type (1 octet) and tag (2 octets) fields, even if not visible to neinp.P2000 implementers. The msize returned with RVersion will be read by neinp.Server to setup a io.LimitReader for message reception.
Version identifies the level of the protocol, it must always start with "9P" (though not enforced here).
See also: http://man.cat-v.org/inferno/5/version
type TWalk ¶
TWalk asks to walk down a directory hierarchy.
Fid is an already existing fid, Newfid is a proposed new fid that the client wants to use for the result of the walk. Wname are successive path elements to walk to, and may be of length zero. Fid must be a directory, only if Wname is of length zero. In this case Newfid will represent the same file as Fid.
Fid must be valid and not already opened by a TOpen or TCreate request.
Wname may be "..", which represents the parent directory, "." is not used and forbidden, zero length Wname is used for this.
Wname should have a maximum length of 16 elements (this limit is not enforced here).
See also: http://man.cat-v.org/inferno/5/walk
type TWrite ¶
TWrite requests data to be written to a file.
Write Count bytes of Data at Offset bytes from the beginning of the file. The file which is represented by Fid must be opened for writing before this request, when opened in append mode, the write will be to the end of the file, ignoring Offset. Writes to directories are forbidden.
See also: http://man.cat-v.org/inferno/5/read
type TWstat ¶
TWstat requests to change some of the file status information.
Name can be changed by anyone with write permissions for the parent directory and if the name isn't already in use in the parent directory.
The length of the file can be changed by anyone with write permissions and will reflect in the actual length of the file. The length of directories can't be set to anything than zero.
Servers may refuse length changes.
Mode and mtime may be changed by the owner or group.
All permission and mode bits can be changed, except for the directory bit.
The gid can be changed by the owner if he is member of the new group or by the group leader of both the current and new group.
The other data can't be changed using wstat. It is illegal to change the owner of a file.
Changes are performed atomic, either all changes are applied with the call succeeding, or none.
Modification of properties can be avoided using zero values: Strings of length zero and the maximum value for integers.
If every property is set to such a zero value, it is to be handled as a request to sync the file to stable storage.
See also: http://man.cat-v.org/inferno/5/stat