Documentation ¶
Overview ¶
Package p9 is a 9P2000.L implementation.
Index ¶
- Constants
- Variables
- func CanOpen(mode FileMode) bool
- func ExtractErrno(err error) unix.Errno
- func ExtractLinuxerrErrno(err error) error
- func HighestVersionString() string
- func StatToAttr(s *syscall.Stat_t, req AttrMask) (Attr, AttrMask)
- func TryExtractErrno(err error) (unix.Errno, bool)
- func VersionSupportsAnonymous(v uint32) bool
- func VersionSupportsConnect(v uint32) bool
- func VersionSupportsMultiUser(v uint32) bool
- func VersionSupportsOpenTruncateFlag(v uint32) bool
- func VersionSupportsTflushf(v uint32) bool
- type AllocateMode
- type Attacher
- type AttacherOptions
- type Attr
- type AttrMask
- type Client
- type DefaultWalkGetAttr
- type Dirent
- type DisallowClientCalls
- type DisallowServerCalls
- type ErrBadResponse
- type ErrInvalidMsgType
- type ErrMessageTooLarge
- type ErrSocket
- type FID
- type FSStat
- type File
- type FileMode
- func (m FileMode) FileType() FileMode
- func (m FileMode) IsBlockDevice() bool
- func (m FileMode) IsCharacterDevice() bool
- func (m FileMode) IsDir() bool
- func (m FileMode) IsExecutable() bool
- func (m FileMode) IsNamedPipe() bool
- func (m FileMode) IsReadable() bool
- func (m FileMode) IsRegular() bool
- func (m FileMode) IsSocket() bool
- func (m FileMode) IsSymlink() bool
- func (m FileMode) IsWritable() bool
- func (m FileMode) OSMode() os.FileMode
- func (m FileMode) Permissions() FileMode
- func (m FileMode) QIDType() QIDType
- func (m FileMode) Writable() FileMode
- type FullStat
- type GID
- type MsgType
- type NoServerOptions
- type OpenFlags
- type QID
- type QIDGenerator
- type QIDType
- type Rallocate
- type Rattach
- type Rauth
- type Rbind
- type Rchannel
- type Rclunk
- type ReadWriterFile
- type Rflush
- type Rflushf
- type Rfsync
- type Rgetattr
- type Rgetxattr
- type Rlconnect
- type Rlcreate
- type Rlerror
- type Rlink
- type Rlistxattr
- type Rlopen
- type Rmkdir
- type Rmknod
- type Rmultigetattr
- type Rread
- type Rreaddir
- type Rreadlink
- type Rremove
- type Rremovexattr
- type Rrename
- type Rrenameat
- type Rsetattr
- type Rsetattrclunk
- type Rsetxattr
- type Rstatfs
- type Rsymlink
- type Rucreate
- type Rumkdir
- type Rumknod
- type Runlinkat
- type Rusymlink
- type Rversion
- type Rwalk
- type Rwalkgetattr
- type Rwrite
- type Rxattrcreate
- type Rxattrwalk
- type Server
- type SetAttr
- type SetAttrMask
- type SocketType
- type Tag
- type Tallocate
- type Tattach
- type Tauth
- type Tbind
- type Tchannel
- type Tclunk
- type Tflush
- type Tflushf
- type Tfsync
- type Tgetattr
- type Tgetxattr
- type Tlconnect
- type Tlcreate
- type Tlink
- type Tlistxattr
- type Tlopen
- type Tmkdir
- type Tmknod
- type Tmultigetattr
- type Tread
- type Treaddir
- type Treadlink
- type Tremove
- type Tremovexattr
- type Trename
- type Trenameat
- type Tsetattr
- type Tsetattrclunk
- type Tsetxattr
- type Tstatfs
- type Tsymlink
- type Tucreate
- type Tumkdir
- type Tumknod
- type Tunlinkat
- type Tusymlink
- type Tversion
- type Twalk
- type Twalkgetattr
- type Twrite
- type Txattrcreate
- type Txattrwalk
- type UID
Constants ¶
const ( // NoTag is a sentinel used to indicate no valid tag. NoTag Tag = math.MaxUint16 // NoFID is a sentinel used to indicate no valid FID. NoFID FID = math.MaxUint32 // NoUID is a sentinel used to indicate no valid UID. NoUID UID = math.MaxUint32 // NoGID is a sentinel used to indicate no valid GID. NoGID GID = math.MaxUint32 )
const ( // DefaultMessageSize is a sensible default. DefaultMessageSize uint32 = 64 << 10 )
const DirentSizeStatic = 24
DirentSizeStatic is the number of bytes required to encode a p9.Dirent with an empty name. In other words, it is the static part of its size.
Variables ¶
var ErrBadVersionString = errors.New("bad version string")
ErrBadVersionString indicates that the version string is malformed or unsupported.
var ErrNoValidMessage = errors.New("buffer contained no valid message")
ErrNoValidMessage indicates no valid message could be decoded.
var ErrOutOfFIDs = errors.New("out of FIDs -- messages lost?")
ErrOutOfFIDs indicates no more FIDs are available.
var ErrOutOfTags = errors.New("out of tags -- messages lost?")
ErrOutOfTags indicates no tags are available.
var ErrUnexpectedTag = errors.New("unexpected tag in response")
ErrUnexpectedTag indicates a response with an unexpected tag was received.
var ErrVersionsExhausted = errors.New("exhausted all versions to negotiate")
ErrVersionsExhausted indicates that all versions to negotiate have been exhausted.
Functions ¶
func CanOpen ¶
CanOpen returns whether this file open can be opened, read and written to.
This includes everything except symlinks and sockets.
func ExtractErrno ¶
ExtractErrno extracts a unix.Errno from an error, best effort.
func ExtractLinuxerrErrno ¶
ExtractLinuxerrErrno extracts a *errors.Error from a error, best effort. TODO(b/34162363): Merge this with ExtractErrno.
func HighestVersionString ¶
func HighestVersionString() string
HighestVersionString returns the highest possible version string that a client may request or a server may support.
func StatToAttr ¶
StatToAttr converts a Linux syscall stat structure to an Attr.
func TryExtractErrno ¶
TryExtractErrno extracts a unix.Errno from an error, and reports whether it was successful. If unsuccessful, the returned errno is EIO.
func VersionSupportsAnonymous ¶
VersionSupportsAnonymous returns true if version v supports Tlconnect with the AnonymousSocket mode. This predicate must be checked by clients before attempting to use the AnonymousSocket Tlconnect mode.
func VersionSupportsConnect ¶
VersionSupportsConnect returns true if version v supports the Tlconnect message. This predicate must be checked by clients before attempting to make a Tlconnect request. If Tlconnect messages are not supported, Tlopen should be used.
func VersionSupportsMultiUser ¶
VersionSupportsMultiUser returns true if version v supports multi-user fake directory permissions and ID values.
func VersionSupportsOpenTruncateFlag ¶
VersionSupportsOpenTruncateFlag returns true if version v supports passing the OpenTruncate flag to Tlopen.
func VersionSupportsTflushf ¶
VersionSupportsTflushf returns true if version v supports the Tflushf message. This predicate must be checked by clients before attempting to make a Tflushf request. If this predicate returns false, then clients may safely no-op.
Types ¶
type AllocateMode ¶
type AllocateMode struct { KeepSize bool PunchHole bool NoHideStale bool CollapseRange bool ZeroRange bool InsertRange bool }
AllocateMode are possible modes to p9.File.Allocate().
func ToAllocateMode ¶
func ToAllocateMode(mode uint64) AllocateMode
ToAllocateMode returns an AllocateMode from a fallocate(2) mode.
func (*AllocateMode) ToLinux ¶
func (a *AllocateMode) ToLinux() uint32
ToLinux converts to a value compatible with fallocate(2)'s mode.
type Attacher ¶
type Attacher interface { // Attach returns a new File. // // The client-side attach will be translated to a series of walks from // the file returned by this Attach call. Attach() (File, error) // ServerOptions returns configuration options for this attach point. // // This is never caller in the client-side. ServerOptions() AttacherOptions }
Attacher is provided by the server.
type AttacherOptions ¶
type AttacherOptions struct { // SetAttrOnDeleted is set to true if it's safe to call File.SetAttr for // deleted files. SetAttrOnDeleted bool // AllocateOnDeleted is set to true if it's safe to call File.Allocate for // deleted files. AllocateOnDeleted bool // MultiGetAttrSupported is set to true if it's safe to call // File.MultiGetAttr with read concurrency guarantee only on start directory. MultiGetAttrSupported bool }
AttacherOptions contains Attacher configuration.
type Attr ¶
type Attr struct { Mode FileMode UID UID GID GID NLink uint64 RDev uint64 Size uint64 BlockSize uint64 Blocks uint64 ATimeSeconds uint64 ATimeNanoSeconds uint64 MTimeSeconds uint64 MTimeNanoSeconds uint64 CTimeSeconds uint64 CTimeNanoSeconds uint64 BTimeSeconds uint64 BTimeNanoSeconds uint64 Gen uint64 DataVersion uint64 }
Attr is a set of attributes for getattr.
func (*Attr) Apply ¶
func (a *Attr) Apply(mask SetAttrMask, attr SetAttr)
Apply applies this to the given Attr.
type AttrMask ¶
type AttrMask struct { Mode bool NLink bool UID bool GID bool RDev bool ATime bool MTime bool CTime bool INo bool Size bool Blocks bool BTime bool Gen bool DataVersion bool }
AttrMask is a mask of attributes for getattr.
func AttrMaskAll ¶
func AttrMaskAll() AttrMask
AttrMaskAll returns an AttrMask with all fields masked.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is at least a 9P2000.L client.
func NewClient ¶
NewClient creates a new client. It performs a Tversion exchange with the server to assert that messageSize is ok to use.
If NewClient succeeds, ownership of socket is transferred to the new Client.
type DefaultWalkGetAttr ¶
type DefaultWalkGetAttr struct{}
DefaultWalkGetAttr implements File.WalkGetAttr to return ENOSYS for server-side Files.
func (*DefaultWalkGetAttr) WalkGetAttr ¶
WalkGetAttr implements File.WalkGetAttr.
type Dirent ¶
type Dirent struct { // QID is the entry QID. QID QID // Offset is the offset in the directory. // // This will be communicated back the original caller. Offset uint64 // Type is the 9P type. Type QIDType // Name is the name of the entry (i.e. basename). Name string }
Dirent is used for readdir.
type DisallowClientCalls ¶
type DisallowClientCalls struct{}
DisallowClientCalls panics if a client-only function is called.
func (*DisallowClientCalls) SetAttrClose ¶
func (*DisallowClientCalls) SetAttrClose(SetAttrMask, SetAttr) error
SetAttrClose implements File.SetAttrClose.
type DisallowServerCalls ¶
type DisallowServerCalls struct{}
DisallowServerCalls panics if a server-only function is called.
func (*DisallowServerCalls) Renamed ¶
func (*DisallowServerCalls) Renamed(File, string)
Renamed implements File.Renamed.
func (*DisallowServerCalls) ServerOptions ¶
func (*DisallowServerCalls) ServerOptions() AttacherOptions
ServerOptions implements Attacher.
type ErrBadResponse ¶
ErrBadResponse indicates the response didn't match the request.
func (*ErrBadResponse) Error ¶
func (e *ErrBadResponse) Error() string
Error returns a highly descriptive error.
type ErrInvalidMsgType ¶
type ErrInvalidMsgType struct {
MsgType
}
ErrInvalidMsgType is returned when an unsupported message type is found.
func (*ErrInvalidMsgType) Error ¶
func (e *ErrInvalidMsgType) Error() string
Error returns a useful string.
type ErrMessageTooLarge ¶
type ErrMessageTooLarge struct {
// contains filtered or unexported fields
}
ErrMessageTooLarge indicates the size was larger than reasonable.
func (*ErrMessageTooLarge) Error ¶
func (e *ErrMessageTooLarge) Error() string
Error returns a sensible error.
type ErrSocket ¶
type ErrSocket struct {
// contains filtered or unexported fields
}
ErrSocket is returned in cases of a socket issue.
This may be treated differently than other errors.
type FSStat ¶
type FSStat struct { // Type is the filesystem type. Type uint32 // BlockSize is the blocksize. BlockSize uint32 // Blocks is the number of blocks. Blocks uint64 // BlocksFree is the number of free blocks. BlocksFree uint64 // BlocksAvailable is the number of blocks *available*. BlocksAvailable uint64 // Files is the number of files available. Files uint64 // FilesFree is the number of free file nodes. FilesFree uint64 // FSID is the filesystem ID. FSID uint64 // NameLength is the maximum name length. NameLength uint32 }
FSStat is used by statfs.
type File ¶
type File interface { // Walk walks to the path components given in names. // // Walk returns QIDs in the same order that the names were passed in. // // An empty list of arguments should return a copy of the current file. // // On the server, Walk has a read concurrency guarantee. Walk(names []string) ([]QID, File, error) // WalkGetAttr walks to the next file and returns its maximal set of // attributes. // // Server-side p9.Files may return unix.ENOSYS to indicate that Walk // and GetAttr should be used separately to satisfy this request. // // On the server, WalkGetAttr has a read concurrency guarantee. WalkGetAttr([]string) ([]QID, File, AttrMask, Attr, error) // MultiGetAttr batches up multiple calls to GetAttr(). names is a list of // path components similar to Walk(). If the first component name is empty, // the current file is stat'd and included in the results. If the walk reaches // a file that doesn't exist or not a directory, MultiGetAttr returns the // partial result with no error. // // On the server, MultiGetAttr has a read concurrency guarantee. MultiGetAttr(names []string) ([]FullStat, error) // StatFS returns information about the file system associated with // this file. // // On the server, StatFS has no concurrency guarantee. StatFS() (FSStat, error) // GetAttr returns attributes of this node. // // On the server, GetAttr has a read concurrency guarantee. GetAttr(req AttrMask) (QID, AttrMask, Attr, error) // SetAttr sets attributes on this node. // // On the server, SetAttr has a write concurrency guarantee. SetAttr(valid SetAttrMask, attr SetAttr) error // GetXattr returns extended attributes of this node. // // Size indicates the size of the buffer that has been allocated to hold the // attribute value. If the value is larger than size, implementations may // return ERANGE to indicate that the buffer is too small, but they are also // free to ignore the hint entirely (i.e. the value returned may be larger // than size). All size checking is done independently at the syscall layer. // // On the server, GetXattr has a read concurrency guarantee. GetXattr(name string, size uint64) (string, error) // SetXattr sets extended attributes on this node. // // On the server, SetXattr has a write concurrency guarantee. SetXattr(name, value string, flags uint32) error // ListXattr lists the names of the extended attributes on this node. // // Size indicates the size of the buffer that has been allocated to hold the // attribute list. If the list would be larger than size, implementations may // return ERANGE to indicate that the buffer is too small, but they are also // free to ignore the hint entirely (i.e. the value returned may be larger // than size). All size checking is done independently at the syscall layer. // // On the server, ListXattr has a read concurrency guarantee. ListXattr(size uint64) (map[string]struct{}, error) // RemoveXattr removes extended attributes on this node. // // On the server, RemoveXattr has a write concurrency guarantee. RemoveXattr(name string) error // Allocate allows the caller to directly manipulate the allocated disk space // for the file. See fallocate(2) for more details. Allocate(mode AllocateMode, offset, length uint64) error // Close is called when all references are dropped on the server side, // and Close should be called by the client to drop all references. // // For server-side implementations of Close, the error is ignored. // // Close must be called even when Open has not been called. // // On the server, Close has no concurrency guarantee. Close() error // SetAttrClose is the equivalent of calling SetAttr() followed by Close(). // This can be used to set file times before closing the file in a single // operation. // // On the server, SetAttr has a write concurrency guarantee. // On the server, Close has no concurrency guarantee. SetAttrClose(valid SetAttrMask, attr SetAttr) error // Open must be called prior to using Read, Write or Readdir. Once Open // is called, some operations, such as Walk, will no longer work. // // On the client, Open should be called only once. The fd return is // optional, and may be nil. // // On the server, Open has a read concurrency guarantee. If an *fd.FD // is provided, ownership now belongs to the caller. Open is guaranteed // to be called only once. // // N.B. The server must resolve any lazy paths when open is called. // After this point, read and write may be called on files with no // deletion check, so resolving in the data path is not viable. Open(flags OpenFlags) (*fd.FD, QID, uint32, error) // Read reads from this file. Open must be called first. // // This may return io.EOF in addition to unix.Errno values. // // On the server, ReadAt has a read concurrency guarantee. See Open for // additional requirements regarding lazy path resolution. ReadAt(p []byte, offset uint64) (int, error) // Write writes to this file. Open must be called first. // // This may return io.EOF in addition to unix.Errno values. // // On the server, WriteAt has a read concurrency guarantee. See Open // for additional requirements regarding lazy path resolution. WriteAt(p []byte, offset uint64) (int, error) // FSync syncs this node. Open must be called first. // // On the server, FSync has a read concurrency guarantee. FSync() error // Create creates a new regular file and opens it according to the // flags given. This file is already Open. // // N.B. On the client, the returned file is a reference to the current // file, which now represents the created file. This is not the case on // the server. These semantics are very subtle and can easily lead to // bugs, but are a consequence of the 9P create operation. // // See p9.File.Open for a description of *fd.FD. // // On the server, Create has a write concurrency guarantee. Create(name string, flags OpenFlags, permissions FileMode, uid UID, gid GID) (*fd.FD, File, QID, uint32, error) // Mkdir creates a subdirectory. // // On the server, Mkdir has a write concurrency guarantee. Mkdir(name string, permissions FileMode, uid UID, gid GID) (QID, error) // Symlink makes a new symbolic link. // // On the server, Symlink has a write concurrency guarantee. Symlink(oldName string, newName string, uid UID, gid GID) (QID, error) // Link makes a new hard link. // // On the server, Link has a write concurrency guarantee. Link(target File, newName string) error // Mknod makes a new device node. // // On the server, Mknod has a write concurrency guarantee. Mknod(name string, mode FileMode, major uint32, minor uint32, uid UID, gid GID) (QID, error) // Rename renames the file. // // Rename will never be called on the server, and RenameAt will always // be used instead. Rename(newDir File, newName string) error // RenameAt renames a given file to a new name in a potentially new // directory. // // oldName must be a name relative to this file, which must be a // directory. newName is a name relative to newDir. // // On the server, RenameAt has a global concurrency guarantee. RenameAt(oldName string, newDir File, newName string) error // UnlinkAt the given named file. // // name must be a file relative to this directory. // // Flags are implementation-specific (e.g. O_DIRECTORY), but are // generally Linux unlinkat(2) flags. // // On the server, UnlinkAt has a write concurrency guarantee. UnlinkAt(name string, flags uint32) error // Readdir reads directory entries. // // This may return io.EOF in addition to unix.Errno values. count is the // number of bytes to read. // // direntOffset is the directory offset at which the read should happen. // direntOffset can be set to 0 to start reading the directory from start. // direntOffset is used more like a cookie. The unit of direntOffset is // unspecified. Gofers can choose their own unit. The client must set it // to one of the values returned in Dirent.Offset, preferably the last offset // returned, which should cause the readdir to continue from where it was // left off. // // On the server, Readdir has a read concurrency guarantee. Readdir(direntOffset uint64, count uint32) ([]Dirent, error) // Readlink reads the link target. // // On the server, Readlink has a read concurrency guarantee. Readlink() (string, error) // Flush is called prior to Close. // // Whereas Close drops all references to the file, Flush cleans up the // file state. Behavior is implementation-specific. // // Flush is not related to flush(9p). Flush is an extension to 9P2000.L, // see version.go. // // On the server, Flush has a read concurrency guarantee. Flush() error // Bind binds to a host unix domain socket. If successful, it creates a // socket file on the host filesystem and returns a File for the newly // created socket file. The File implementation must save the bound socket // FD so that subsequent Listen and Accept operations on the File can be // served. // // Bind is an extension to 9P2000.L, see version.go. // // On the server, Bind has a write concurrency guarantee. Bind(sockType uint32, sockName string, uid UID, gid GID) (File, QID, AttrMask, Attr, error) // Connect establishes a new host-socket backed connection with a // socket. A File does not need to be opened before it can be connected // and it can be connected to multiple times resulting in a unique // *fd.FD each time. In addition, the lifetime of the *fd.FD is // independent from the lifetime of the p9.File and must be managed by // the caller. // // The returned FD must be non-blocking. // // Flags indicates the requested type of socket. // // On the server, Connect has a read concurrency guarantee. Connect(socketType SocketType) (*fd.FD, error) // Renamed is called when this node is renamed. // // This may not fail. The file will hold a reference to its parent // within the p9 package, and is therefore safe to use for the lifetime // of this File (until Close is called). // // This method should not be called by clients, who should use the // relevant Rename methods. (Although the method will be a no-op.) // // On the server, Renamed has a global concurrency guarantee. Renamed(newDir File, newName string) }
File is a set of operations corresponding to a single node.
Note that on the server side, the server logic places constraints on concurrent operations to make things easier. This may reduce the need for complex, error-prone locking and logic in the backend. These are documented for each method.
There are three different types of guarantees provided:
none: There is no concurrency guarantee. The method may be invoked concurrently with any other method on any other file.
read: The method is guaranteed to be exclusive of any write or global operation that is mutating the state of the directory tree starting at this node. For example, this means creating new files, symlinks, directories or renaming a directory entry (or renaming in to this target), but the method may be called concurrently with other read methods.
write: The method is guaranteed to be exclusive of any read, write or global operation that is mutating the state of the directory tree starting at this node, as described in read above. There may however, be other write operations executing concurrently on other components in the directory tree.
global: The method is guaranteed to be exclusive of any read, write or global operation.
type FileMode ¶
type FileMode uint32
FileMode are flags corresponding to file modes.
These correspond to bits sent over the wire. These also correspond to mode_t bits.
const ( // FileModeMask is a mask of all the file mode bits of FileMode. FileModeMask FileMode = 0170000 // ModeSocket is an (unused) mode bit for a socket. ModeSocket FileMode = 0140000 // ModeSymlink is a mode bit for a symlink. ModeSymlink FileMode = 0120000 // ModeRegular is a mode bit for regular files. ModeRegular FileMode = 0100000 // ModeBlockDevice is a mode bit for block devices. ModeBlockDevice FileMode = 060000 // ModeDirectory is a mode bit for directories. ModeDirectory FileMode = 040000 // ModeCharacterDevice is a mode bit for a character device. ModeCharacterDevice FileMode = 020000 // ModeNamedPipe is a mode bit for a named pipe. ModeNamedPipe FileMode = 010000 // Read is a mode bit indicating read permission. Read FileMode = 04 // Write is a mode bit indicating write permission. Write FileMode = 02 // Exec is a mode bit indicating exec permission. Exec FileMode = 01 // AllPermissions is a mask with rwx bits set for user, group and others. AllPermissions FileMode = 0777 // Sticky is a mode bit indicating sticky directories. Sticky FileMode = 01000 // SetGID is the set group ID bit. SetGID FileMode = 02000 // SetUID is the set user ID bit. SetUID FileMode = 04000 )
func ModeFromOS ¶
ModeFromOS returns a FileMode from an os.FileMode.
func (FileMode) IsBlockDevice ¶
IsBlockDevice returns true if m represents a character device.
func (FileMode) IsCharacterDevice ¶
IsCharacterDevice returns true if m represents a character device.
func (FileMode) IsExecutable ¶
IsExecutable returns true if m represents a file that can be executed.
func (FileMode) IsNamedPipe ¶
IsNamedPipe returns true if m represents a named pipe.
func (FileMode) IsReadable ¶
IsReadable returns true if m represents a file that can be read.
func (FileMode) IsWritable ¶
IsWritable returns true if m represents a file that can be written to.
func (FileMode) Permissions ¶
Permissions returns just the permission bits of the mode.
type MsgType ¶
type MsgType uint8
MsgType is a type identifier.
const ( MsgTlerror MsgType = 6 MsgRlerror MsgType = 7 MsgTstatfs MsgType = 8 MsgRstatfs MsgType = 9 MsgTlopen MsgType = 12 MsgRlopen MsgType = 13 MsgTlcreate MsgType = 14 MsgRlcreate MsgType = 15 MsgTsymlink MsgType = 16 MsgRsymlink MsgType = 17 MsgTmknod MsgType = 18 MsgRmknod MsgType = 19 MsgTrename MsgType = 20 MsgRrename MsgType = 21 MsgTreadlink MsgType = 22 MsgRreadlink MsgType = 23 MsgTgetattr MsgType = 24 MsgRgetattr MsgType = 25 MsgTsetattr MsgType = 26 MsgRsetattr MsgType = 27 MsgTlistxattr MsgType = 28 MsgRlistxattr MsgType = 29 MsgTxattrwalk MsgType = 30 MsgRxattrwalk MsgType = 31 MsgTxattrcreate MsgType = 32 MsgRxattrcreate MsgType = 33 MsgTgetxattr MsgType = 34 MsgRgetxattr MsgType = 35 MsgTsetxattr MsgType = 36 MsgRsetxattr MsgType = 37 MsgTremovexattr MsgType = 38 MsgRremovexattr MsgType = 39 MsgTreaddir MsgType = 40 MsgRreaddir MsgType = 41 MsgTfsync MsgType = 50 MsgRfsync MsgType = 51 MsgTlink MsgType = 70 MsgRlink MsgType = 71 MsgTmkdir MsgType = 72 MsgRmkdir MsgType = 73 MsgTrenameat MsgType = 74 MsgRrenameat MsgType = 75 MsgTunlinkat MsgType = 76 MsgRunlinkat MsgType = 77 MsgTversion MsgType = 100 MsgRversion MsgType = 101 MsgTauth MsgType = 102 MsgRauth MsgType = 103 MsgTattach MsgType = 104 MsgRattach MsgType = 105 MsgTflush MsgType = 108 MsgRflush MsgType = 109 MsgTwalk MsgType = 110 MsgRwalk MsgType = 111 MsgTread MsgType = 116 MsgRread MsgType = 117 MsgTwrite MsgType = 118 MsgRwrite MsgType = 119 MsgTclunk MsgType = 120 MsgRclunk MsgType = 121 MsgTremove MsgType = 122 MsgRremove MsgType = 123 MsgTflushf MsgType = 124 MsgRflushf MsgType = 125 MsgTwalkgetattr MsgType = 126 MsgRwalkgetattr MsgType = 127 MsgTucreate MsgType = 128 MsgRucreate MsgType = 129 MsgTumkdir MsgType = 130 MsgRumkdir MsgType = 131 MsgTumknod MsgType = 132 MsgRumknod MsgType = 133 MsgTusymlink MsgType = 134 MsgRusymlink MsgType = 135 MsgTlconnect MsgType = 136 MsgRlconnect MsgType = 137 MsgTallocate MsgType = 138 MsgRallocate MsgType = 139 MsgTsetattrclunk MsgType = 140 MsgRsetattrclunk MsgType = 141 MsgTmultigetattr MsgType = 142 MsgRmultigetattr MsgType = 143 MsgTbind MsgType = 144 MsgRbind MsgType = 145 MsgTchannel MsgType = 250 MsgRchannel MsgType = 251 )
MsgType declarations.
type NoServerOptions ¶
type NoServerOptions struct{}
NoServerOptions partially implements Attacher with empty AttacherOptions.
func (*NoServerOptions) ServerOptions ¶
func (*NoServerOptions) ServerOptions() AttacherOptions
ServerOptions implements Attacher.
type OpenFlags ¶
type OpenFlags uint32
OpenFlags is the mode passed to Open and Create operations.
These correspond to bits sent over the wire.
const ( // ReadOnly is a Tlopen and Tlcreate flag indicating read-only mode. ReadOnly OpenFlags = 0 // WriteOnly is a Tlopen and Tlcreate flag indicating write-only mode. WriteOnly OpenFlags = 1 // ReadWrite is a Tlopen flag indicates read-write mode. ReadWrite OpenFlags = 2 // OpenFlagsModeMask is a mask of valid OpenFlags mode bits. OpenFlagsModeMask OpenFlags = 3 // OpenTruncate is a Tlopen flag indicating that the opened file should be // truncated. OpenTruncate OpenFlags = 01000 )
type QID ¶
type QID struct { // Type is the highest order byte of the file mode. Type QIDType // Version is an arbitrary server version number. Version uint32 // Path is a unique server identifier for this path (e.g. inode). Path uint64 }
QID is a unique file identifier.
This may be embedded in other requests and responses.
type QIDGenerator ¶
type QIDGenerator struct {
// contains filtered or unexported fields
}
QIDGenerator is a simple generator for QIDs that atomically increments Path values.
func (*QIDGenerator) Get ¶
func (q *QIDGenerator) Get(t QIDType) QID
Get returns a new 9P unique ID with a unique Path given a QID type.
While the 9P spec allows Version to be incremented every time the file is modified, we currently do not use the Version member for anything. Hence, it is set to 0.
type QIDType ¶
type QIDType uint8
QIDType represents the file type for QIDs.
QIDType corresponds to the high 8 bits of a Plan 9 file mode.
const ( // TypeDir represents a directory type. TypeDir QIDType = 0x80 // TypeAppendOnly represents an append only file. TypeAppendOnly QIDType = 0x40 // TypeExclusive represents an exclusive-use file. TypeExclusive QIDType = 0x20 // TypeMount represents a mounted channel. TypeMount QIDType = 0x10 // TypeAuth represents an authentication file. TypeAuth QIDType = 0x08 // TypeTemporary represents a temporary file. TypeTemporary QIDType = 0x04 // TypeSymlink represents a symlink. TypeSymlink QIDType = 0x02 // TypeLink represents a hard link. TypeLink QIDType = 0x01 // TypeRegular represents a regular file. TypeRegular QIDType = 0x00 )
type Rauth ¶
type Rauth struct {
QID
}
Rauth is an authentication response.
encode and decode are inherited directly from QID.
type Rbind ¶
type Rbind struct { // QID is the resulting QID of the created socket file. QID QID // Valid indicates which fields are valid. Valid AttrMask // Attr is the set of attributes of the created socket file. Attr Attr }
Rbind is a bind response.
type Rchannel ¶
Rchannel is the channel response.
func (*Rchannel) FilePayload ¶
FilePayload returns the file payload.
func (*Rchannel) SetFilePayload ¶
SetFilePayload sets the received file.
type ReadWriterFile ¶
ReadWriterFile wraps a File and implements io.ReadWriter, io.ReaderAt, and io.WriterAt.
func (*ReadWriterFile) Read ¶
func (r *ReadWriterFile) Read(p []byte) (int, error)
Read implements part of the io.ReadWriter interface.
func (*ReadWriterFile) ReadAt ¶
func (r *ReadWriterFile) ReadAt(p []byte, offset int64) (int, error)
ReadAt implements the io.ReaderAt interface.
func (*ReadWriterFile) Write ¶
func (r *ReadWriterFile) Write(p []byte) (int, error)
Write implements part of the io.ReadWriter interface.
Note that this may return a short write with a nil error. This violates the contract of io.Writer, but is more consistent with gVisor's pattern of returning errors that correspond to Linux errnos. Since short writes without error are common in Linux, returning a nil error is appropriate.
type Rgetattr ¶
type Rgetattr struct { // Valid indicates which fields are valid. Valid AttrMask // QID is the QID for this file. QID // Attr is the set of attributes. Attr Attr }
Rgetattr is a getattr response.
type Rgetxattr ¶
type Rgetxattr struct { // Value is the extended attribute value. Value string }
Rgetxattr is a getxattr response.
type Rlconnect ¶
type Rlconnect struct {
// contains filtered or unexported fields
}
Rlconnect is a connect response.
func (*Rlconnect) FilePayload ¶
FilePayload returns the file payload.
func (*Rlconnect) SetFilePayload ¶
SetFilePayload sets the received file.
type Rlcreate ¶
type Rlcreate struct {
Rlopen
}
Rlcreate is a create response.
The encode, decode, etc. methods are inherited from Rlopen.
func (*Rlcreate) FilePayload ¶
FilePayload returns the file payload.
func (*Rlcreate) SetFilePayload ¶
SetFilePayload sets the received file.
type Rlerror ¶
type Rlerror struct {
Error uint32
}
Rlerror is an error response.
Note that this replaces the error code used in 9p.
type Rlistxattr ¶
type Rlistxattr struct { // Xattrs is a list of extended attribute names. Xattrs []string }
Rlistxattr is a listxattr response.
type Rlopen ¶
type Rlopen struct { // QID is the file's QID. QID QID // IoUnit is the recommended I/O unit. IoUnit uint32 // contains filtered or unexported fields }
Rlopen is a open response.
func (*Rlopen) FilePayload ¶
FilePayload returns the file payload.
func (*Rlopen) SetFilePayload ¶
SetFilePayload sets the received file.
type Rmkdir ¶
type Rmkdir struct { // QID is the resulting QID. QID QID }
Rmkdir is a mkdir response.
type Rmknod ¶
type Rmknod struct { // QID is the resulting QID. QID QID }
Rmknod is a mknod response.
type Rmultigetattr ¶
type Rmultigetattr struct { // Stats are the set of FullStat returned for each of the names in the // request. Stats []FullStat }
Rmultigetattr is a multi-getattr response.
func (*Rmultigetattr) String ¶
func (r *Rmultigetattr) String() string
String implements fmt.Stringer.
type Rread ¶
type Rread struct { // Data is the resulting data. Data []byte }
Rread is the response for a Tread.
func (*Rread) SetPayload ¶
SetPayload implements payloader.SetPayload.
type Rreaddir ¶
type Rreaddir struct { // Count is the byte limit. // // This should always be set from the Treaddir request. Count uint32 // Entries are the resulting entries. // // This may be constructed in decode. Entries []Dirent // contains filtered or unexported fields }
Rreaddir is a readdir response.
func (*Rreaddir) SetPayload ¶
SetPayload implements payloader.SetPayload.
type Rreadlink ¶
type Rreadlink struct { // Target is the symlink target. Target string }
Rreadlink is a readlink response.
type Rremovexattr ¶
type Rremovexattr struct { }
Rremovexattr is a removexattr response.
func (*Rremovexattr) String ¶
func (r *Rremovexattr) String() string
String implements fmt.Stringer.
type Rsetattrclunk ¶
type Rsetattrclunk struct { }
Rsetattrclunk is a setattr+close response.
func (*Rsetattrclunk) String ¶
func (r *Rsetattrclunk) String() string
String implements fmt.Stringer.
type Rstatfs ¶
type Rstatfs struct { // FSStat is the stat result. FSStat FSStat }
Rstatfs is the response for a Tstatfs.
type Rsymlink ¶
type Rsymlink struct { // QID is the new symlink's QID. QID QID }
Rsymlink is a symlink response.
type Rucreate ¶
type Rucreate struct {
Rlcreate
}
Rucreate is a file creation response.
func (*Rucreate) FilePayload ¶
FilePayload returns the file payload.
func (*Rucreate) SetFilePayload ¶
SetFilePayload sets the received file.
type Rversion ¶
type Rversion struct { // MSize is the negotiated size. MSize uint32 // Version is the negotiated version. Version string }
Rversion is a version response.
type Rwalk ¶
type Rwalk struct { // QIDs are the set of QIDs returned. QIDs []QID }
Rwalk is a walk response.
type Rwalkgetattr ¶
type Rwalkgetattr struct { // Valid indicates which fields are valid in the Attr below. Valid AttrMask // Attr is the set of attributes for the last QID (the file walked to). Attr Attr // QIDs are the set of QIDs returned. QIDs []QID }
Rwalkgetattr is a walk response.
func (*Rwalkgetattr) String ¶
func (r *Rwalkgetattr) String() string
String implements fmt.Stringer.
type Rwrite ¶
type Rwrite struct { // Count indicates the number of bytes successfully written. Count uint32 }
Rwrite is the response for a Twrite.
type Rxattrcreate ¶
type Rxattrcreate struct { }
Rxattrcreate is a xattrcreate response.
func (*Rxattrcreate) String ¶
func (r *Rxattrcreate) String() string
String implements fmt.Stringer.
type Rxattrwalk ¶
type Rxattrwalk struct { // Size is the size of the extended attribute. Size uint64 }
Rxattrwalk is a xattrwalk response.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a 9p2000.L server.
type SetAttr ¶
type SetAttr struct { Permissions FileMode UID UID GID GID Size uint64 ATimeSeconds uint64 ATimeNanoSeconds uint64 MTimeSeconds uint64 MTimeNanoSeconds uint64 }
SetAttr specifies a set of attributes for a setattr.
type SetAttrMask ¶
type SetAttrMask struct { Permissions bool UID bool GID bool Size bool ATime bool MTime bool CTime bool ATimeNotSystemTime bool MTimeNotSystemTime bool }
SetAttrMask specifies a valid mask for setattr.
func (SetAttrMask) Empty ¶
func (s SetAttrMask) Empty() bool
Empty returns true if no fields are masked.
func (SetAttrMask) IsSubsetOf ¶
func (s SetAttrMask) IsSubsetOf(m SetAttrMask) bool
IsSubsetOf returns whether s is a subset of m.
type SocketType ¶
type SocketType uint32
SocketType is the socket type passed in Connect and Bind operations.
These correspond to bits sent over the wire.
const ( // StreamSocket indicates SOCK_STREAM mode. StreamSocket SocketType = 0 // DgramSocket indicates SOCK_DGRAM mode. DgramSocket SocketType = 1 // SeqpacketSocket indicates SOCK_SEQPACKET mode. SeqpacketSocket SocketType = 2 // AnonymousSocket is only valid for Connect calls, and indicates that // the caller will accept any socket type. AnonymousSocket SocketType = 3 )
func SocketTypeFromLinux ¶
func SocketTypeFromLinux(st linux.SockType) (SocketType, bool)
SocketTypeFromLinux maps a Linux socket type to a SocketType.
type Tallocate ¶
type Tallocate struct { FID FID Mode AllocateMode Offset uint64 Length uint64 }
Tallocate is an allocate request. This is an extension to 9P protocol, not present in the 9P2000.L standard.
type Tattach ¶
type Tattach struct { // FID is the FID to be attached. FID FID // Auth is the embedded authentication request. // // See client.Attach for information regarding authentication. Auth Tauth }
Tattach is an attach request.
type Tauth ¶
type Tauth struct { // AuthenticationFID is the FID to attach the authentication result. AuthenticationFID FID // UserName is the user to attach. UserName string // AttachName is the attach name. AttachName string // UserID is the numeric identifier for UserName. UID UID }
Tauth is an authentication request.
type Tbind ¶
type Tbind struct { // Directory is the directory inside which the bound socket file should be // created. Directory FID // SockType is the type of socket to be used. This is passed as an argument // to socket(2). SockType uint32 // SockName is the name of the socket file to be created. SockName string // UID is the owning user. UID UID // GID is the owning group. GID GID // NewFID is the resulting FID for the socket file. NewFID FID }
Tbind is a bind request.
type Tchannel ¶
type Tchannel struct { // ID is the channel ID. ID uint32 // Control is 0 if the Rchannel response should provide the flipcall // component of the channel, and 1 if the Rchannel response should // provide the fdchannel component of the channel. Control uint32 }
Tchannel creates a new channel.
type Tclunk ¶
type Tclunk struct { // FID is the FID to be closed. FID FID }
Tclunk is a close request.
type Tflush ¶
type Tflush struct { // OldTag is the tag to wait on. OldTag Tag }
Tflush is a flush request.
type Tflushf ¶
type Tflushf struct { // FID is the FID to be flushed. FID FID }
Tflushf is a flush file request, not to be confused with Tflush.
type Tgetattr ¶
type Tgetattr struct { // FID is the FID to get attributes for. FID FID // AttrMask is the set of attributes to get. AttrMask AttrMask }
Tgetattr is a getattr request.
type Tgetxattr ¶
type Tgetxattr struct { // FID refers to the file for which to get xattrs. FID FID // Name is the xattr to get. Name string // Size is the buffer size for the xattr to get. Size uint64 }
Tgetxattr is a getxattr request.
type Tlconnect ¶
type Tlconnect struct { // FID is the FID to be connected. FID FID // SocketType is the socket type to be connected to. SocketType SocketType }
Tlconnect is a connect request.
type Tlcreate ¶
type Tlcreate struct { // FID is the parent FID. // // This becomes the new file. FID FID // Name is the file name to create. Name string // Mode is the open mode (O_RDWR, etc.). // // Note that flags like O_TRUNC are ignored, as is O_EXCL. All // create operations are exclusive. OpenFlags OpenFlags // Permissions is the set of permission bits. Permissions FileMode // GID is the group ID to use for creating the file. GID GID }
Tlcreate is a create request.
type Tlink ¶
type Tlink struct { // Directory is the directory to contain the link. Directory FID // FID is the target. Target FID // Name is the new source name. Name string }
Tlink is a link request.
type Tlistxattr ¶
type Tlistxattr struct { // FID refers to the file on which to list xattrs. FID FID // Size is the buffer size for the xattr list. Size uint64 }
Tlistxattr is a listxattr request.
type Tlopen ¶
type Tlopen struct { // FID is the FID to be opened. FID FID // Flags are the open flags. Flags OpenFlags }
Tlopen is an open request.
type Tmkdir ¶
type Tmkdir struct { // Directory is the parent directory. Directory FID // Name is the new directory name. Name string // Permissions is the set of permission bits. Permissions FileMode // GID is the owning group. GID GID }
Tmkdir is a mkdir request.
type Tmknod ¶
type Tmknod struct { // Directory is the parent directory. Directory FID // Name is the device name. Name string // Mode is the device mode and permissions. Mode FileMode // Major is the device major number. Major uint32 // Minor is the device minor number. Minor uint32 // GID is the device GID. GID GID }
Tmknod is a mknod request.
type Tmultigetattr ¶
type Tmultigetattr struct { // FID is the FID to be walked. FID FID // Names are the set of names to be walked. Names []string }
Tmultigetattr is a multi-getattr request.
func (*Tmultigetattr) String ¶
func (t *Tmultigetattr) String() string
String implements fmt.Stringer.
type Tread ¶
type Tread struct { // FID is the FID to read. FID FID // Offset indicates the file offset. Offset uint64 // Count indicates the number of bytes to read. Count uint32 }
Tread is a read request.
type Treaddir ¶
type Treaddir struct { // Directory is the directory FID to read. Directory FID // DirentOffset is the dirent offset to read at. DirentOffset uint64 // Count is the number of bytes to read. Count uint32 }
Treaddir is a readdir request.
type Treadlink ¶
type Treadlink struct { // FID is the symlink. FID FID }
Treadlink is a readlink request.
type Tremove ¶
type Tremove struct { // FID is the FID to be removed. FID FID }
Tremove is a remove request.
This will eventually be replaced by Tunlinkat.
type Tremovexattr ¶
type Tremovexattr struct { // FID refers to the file on which to set xattrs. FID FID // Name is the attribute name. Name string }
Tremovexattr is a removexattr request.
func (*Tremovexattr) String ¶
func (t *Tremovexattr) String() string
String implements fmt.Stringer.
type Trename ¶
type Trename struct { // FID is the FID to rename. FID FID // Directory is the target directory. Directory FID // Name is the new file name. Name string }
Trename is a rename request.
Note that this generally isn't used anymore, and ideally all rename calls should Trenameat below.
type Trenameat ¶
type Trenameat struct { // OldDirectory is the source directory. OldDirectory FID // OldName is the source file name. OldName string // NewDirectory is the target directory. NewDirectory FID // NewName is the new file name. NewName string }
Trenameat is a rename request.
type Tsetattr ¶
type Tsetattr struct { // FID is the FID to change. FID FID // Valid is the set of bits which will be used. Valid SetAttrMask // SetAttr is the set request. SetAttr SetAttr }
Tsetattr is a setattr request.
type Tsetattrclunk ¶
type Tsetattrclunk struct { // FID is the FID to change. FID FID // Valid is the set of bits which will be used. Valid SetAttrMask // SetAttr is the set request. SetAttr SetAttr }
Tsetattrclunk is a setattr+close request.
func (*Tsetattrclunk) String ¶
func (t *Tsetattrclunk) String() string
String implements fmt.Stringer.
type Tsetxattr ¶
type Tsetxattr struct { // FID refers to the file on which to set xattrs. FID FID // Name is the attribute name. Name string // Value is the attribute value. Value string // Linux setxattr(2) flags. Flags uint32 }
Tsetxattr sets extended attributes.
type Tsymlink ¶
type Tsymlink struct { // Directory is the directory FID. Directory FID // Name is the new in the directory. Name string // Target is the symlink target. Target string // GID is the owning group. GID GID }
Tsymlink is a symlink request.
type Tucreate ¶
type Tucreate struct { Tlcreate // UID is the UID to use as the effective UID in creation messages. UID UID }
Tucreate is a Tlcreate message that includes a UID.
type Tumkdir ¶
type Tumkdir struct { Tmkdir // UID is the UID to use as the effective UID in creation messages. UID UID }
Tumkdir is a Tmkdir message that includes a UID.
type Tumknod ¶
type Tumknod struct { Tmknod // UID is the UID to use as the effective UID in creation messages. UID UID }
Tumknod is a Tmknod message that includes a UID.
type Tunlinkat ¶
type Tunlinkat struct { // Directory is the originating directory. Directory FID // Name is the name of the entry to unlink. Name string // Flags are extra flags (e.g. O_DIRECTORY). These are not interpreted by p9. Flags uint32 }
Tunlinkat is an unlink request.
type Tusymlink ¶
type Tusymlink struct { Tsymlink // UID is the UID to use as the effective UID in creation messages. UID UID }
Tusymlink is a Tsymlink message that includes a UID.
type Tversion ¶
type Tversion struct { // MSize is the message size to use. MSize uint32 // Version is the version string. // // For this implementation, this must be 9P2000.L. Version string }
Tversion is a version request.
type Twalk ¶
type Twalk struct { // FID is the FID to be walked. FID FID // NewFID is the resulting FID. NewFID FID // Names are the set of names to be walked. Names []string }
Twalk is a walk request.
type Twalkgetattr ¶
type Twalkgetattr struct { // FID is the FID to be walked. FID FID // NewFID is the resulting FID. NewFID FID // Names are the set of names to be walked. Names []string }
Twalkgetattr is a walk request.
func (*Twalkgetattr) String ¶
func (t *Twalkgetattr) String() string
String implements fmt.Stringer.
type Twrite ¶
type Twrite struct { // FID is the FID to read. FID FID // Offset indicates the file offset. Offset uint64 // Data is the data to be written. Data []byte }
Twrite is a write request.
func (*Twrite) SetPayload ¶
SetPayload implements payloader.SetPayload.
type Txattrcreate ¶
type Txattrcreate struct { // FID is input/output parameter, it identifies the file on which // extended attributes will be set but after successful Rxattrcreate // it is used to write the extended attribute value. FID FID // Name is the attribute name. Name string // Size of the attribute value. When the FID is clunked it has to match // the number of bytes written to the FID. AttrSize uint64 // Linux setxattr(2) flags. Flags uint32 }
Txattrcreate prepare to set extended attributes.
func (*Txattrcreate) String ¶
func (t *Txattrcreate) String() string
String implements fmt.Stringer.
type Txattrwalk ¶
type Txattrwalk struct { // FID is the FID to check for attributes. FID FID // NewFID is the new FID associated with the attributes. NewFID FID // Name is the attribute name. Name string }
Txattrwalk walks extended attributes.