Documentation ¶
Index ¶
- Constants
- func FS(ctx context.Context, sys System, root FD) fs.FS
- func SizesGet(values []string) (count, size int)
- type AddressInfo
- type AddressInfoFlags
- type Advice
- type BytesValue
- type ClockID
- type Device
- type Dir
- type DirCookie
- type DirEntry
- type DirNameLength
- type Errno
- type Event
- type EventFDReadWrite
- type EventFDReadWriteFlags
- type EventType
- type ExitCode
- type FD
- type FDFlags
- type FDStat
- type FSTFlags
- type File
- type FileDelta
- type FileSize
- type FileStat
- type FileTable
- func (t *FileTable[T]) Close(ctx context.Context) error
- func (t *FileTable[T]) FDAdvise(ctx context.Context, fd FD, offset FileSize, length FileSize, advice Advice) Errno
- func (t *FileTable[T]) FDAllocate(ctx context.Context, fd FD, offset FileSize, length FileSize) Errno
- func (t *FileTable[T]) FDClose(ctx context.Context, fd FD) Errno
- func (t *FileTable[T]) FDDataSync(ctx context.Context, fd FD) Errno
- func (t *FileTable[T]) FDFileStatGet(ctx context.Context, fd FD) (FileStat, Errno)
- func (t *FileTable[T]) FDFileStatSetSize(ctx context.Context, fd FD, size FileSize) Errno
- func (t *FileTable[T]) FDFileStatSetTimes(ctx context.Context, fd FD, accessTime, modifyTime Timestamp, flags FSTFlags) Errno
- func (t *FileTable[T]) FDPreStatDirName(ctx context.Context, fd FD) (string, Errno)
- func (t *FileTable[T]) FDPreStatGet(ctx context.Context, fd FD) (PreStat, Errno)
- func (t *FileTable[T]) FDPread(ctx context.Context, fd FD, iovecs []IOVec, offset FileSize) (Size, Errno)
- func (t *FileTable[T]) FDPwrite(ctx context.Context, fd FD, iovecs []IOVec, offset FileSize) (Size, Errno)
- func (t *FileTable[T]) FDRead(ctx context.Context, fd FD, iovecs []IOVec) (Size, Errno)
- func (t *FileTable[T]) FDReadDir(ctx context.Context, fd FD, entries []DirEntry, cookie DirCookie, ...) (int, Errno)
- func (t *FileTable[T]) FDRenumber(ctx context.Context, from, to FD) Errno
- func (t *FileTable[T]) FDSeek(ctx context.Context, fd FD, delta FileDelta, whence Whence) (FileSize, Errno)
- func (t *FileTable[T]) FDStatGet(ctx context.Context, fd FD) (FDStat, Errno)
- func (t *FileTable[T]) FDStatSetFlags(ctx context.Context, fd FD, flags FDFlags) Errno
- func (t *FileTable[T]) FDStatSetRights(ctx context.Context, fd FD, rightsBase, rightsInheriting Rights) Errno
- func (t *FileTable[T]) FDSync(ctx context.Context, fd FD) Errno
- func (t *FileTable[T]) FDTell(ctx context.Context, fd FD) (FileSize, Errno)
- func (t *FileTable[T]) FDWrite(ctx context.Context, fd FD, iovecs []IOVec) (Size, Errno)
- func (t *FileTable[T]) LookupFD(fd FD, rights Rights) (file T, stat FDStat, errno Errno)
- func (t *FileTable[T]) LookupSocketFD(fd FD, rights Rights) (file T, stat FDStat, errno Errno)
- func (t *FileTable[T]) NumOpenDirs() int
- func (t *FileTable[T]) NumOpenFiles() int
- func (t *FileTable[T]) NumPreopens() int
- func (t *FileTable[T]) PathCreateDirectory(ctx context.Context, fd FD, path string) Errno
- func (t *FileTable[T]) PathFileStatGet(ctx context.Context, fd FD, lookupFlags LookupFlags, path string) (FileStat, Errno)
- func (t *FileTable[T]) PathFileStatSetTimes(ctx context.Context, fd FD, lookupFlags LookupFlags, path string, ...) Errno
- func (t *FileTable[T]) PathLink(ctx context.Context, fd FD, flags LookupFlags, oldPath string, newFD FD, ...) Errno
- func (t *FileTable[T]) PathOpen(ctx context.Context, fd FD, lookupFlags LookupFlags, path string, ...) (FD, Errno)
- func (t *FileTable[T]) PathReadLink(ctx context.Context, fd FD, path string, buffer []byte) (int, Errno)
- func (t *FileTable[T]) PathRemoveDirectory(ctx context.Context, fd FD, path string) Errno
- func (t *FileTable[T]) PathRename(ctx context.Context, fd FD, oldPath string, newFD FD, newPath string) Errno
- func (t *FileTable[T]) PathSymlink(ctx context.Context, oldPath string, fd FD, newPath string) Errno
- func (t *FileTable[T]) PathUnlinkFile(ctx context.Context, fd FD, path string) Errno
- func (t *FileTable[T]) Preopen(file T, path string, stat FDStat) FD
- func (t *FileTable[T]) PreopenFD(fd FD)
- func (t *FileTable[T]) Register(file T, stat FDStat) FD
- type FileType
- type INode
- type IOVec
- type Inet4Address
- type Inet6Address
- type IntValue
- type LinkCount
- type LookupFlags
- type OpenFlags
- type Port
- type PreOpenType
- type PreStat
- type PreStatDir
- type Protocol
- type ProtocolFamily
- type RIFlags
- type ROFlags
- type Rights
- type SDFlags
- type SIFlags
- type Signal
- type Size
- type SocketAddress
- type SocketOption
- type SocketOptionLevel
- type SocketOptionValue
- type SocketType
- type SocketsNotSupported
- func (SocketsNotSupported) SockAccept(ctx context.Context, fd FD, flags FDFlags) (FD, SocketAddress, SocketAddress, Errno)
- func (SocketsNotSupported) SockAddressInfo(ctx context.Context, name, service string, hints AddressInfo, ...) (int, Errno)
- func (SocketsNotSupported) SockBind(ctx context.Context, fd FD, addr SocketAddress) (SocketAddress, Errno)
- func (SocketsNotSupported) SockConnect(ctx context.Context, fd FD, addr SocketAddress) (SocketAddress, Errno)
- func (SocketsNotSupported) SockGetOpt(ctx context.Context, fd FD, level SocketOptionLevel, option SocketOption) (SocketOptionValue, Errno)
- func (SocketsNotSupported) SockListen(ctx context.Context, fd FD, backlog int) Errno
- func (SocketsNotSupported) SockLocalAddress(ctx context.Context, fd FD) (SocketAddress, Errno)
- func (SocketsNotSupported) SockOpen(ctx context.Context, family ProtocolFamily, socketType SocketType, ...) (FD, Errno)
- func (SocketsNotSupported) SockRecv(ctx context.Context, fd FD, iovecs []IOVec, flags RIFlags) (Size, ROFlags, Errno)
- func (SocketsNotSupported) SockRecvFrom(ctx context.Context, fd FD, iovecs []IOVec, flags RIFlags) (Size, ROFlags, SocketAddress, Errno)
- func (SocketsNotSupported) SockRemoteAddress(ctx context.Context, fd FD) (SocketAddress, Errno)
- func (SocketsNotSupported) SockSend(ctx context.Context, fd FD, iovecs []IOVec, flags SIFlags) (Size, Errno)
- func (SocketsNotSupported) SockSendTo(ctx context.Context, fd FD, iovecs []IOVec, flags SIFlags, addr SocketAddress) (Size, Errno)
- func (SocketsNotSupported) SockSetOpt(ctx context.Context, fd FD, level SocketOptionLevel, option SocketOption, ...) Errno
- func (SocketsNotSupported) SockShutdown(ctx context.Context, fd FD, flags SDFlags) Errno
- type Subscription
- func (s Subscription) FormatObject(w io.Writer, m api.Memory, b []byte)
- func (s *Subscription) GetClock() SubscriptionClock
- func (s *Subscription) GetFDReadWrite() SubscriptionFDReadWrite
- func (s Subscription) LoadObject(_ api.Memory, b []byte) Subscription
- func (s Subscription) ObjectSize() int
- func (s *Subscription) SetClock(c SubscriptionClock)
- func (s *Subscription) SetFDReadWrite(fdrw SubscriptionFDReadWrite)
- func (s Subscription) StoreObject(_ api.Memory, b []byte)
- type SubscriptionClock
- type SubscriptionClockFlags
- type SubscriptionFDReadWrite
- type System
- type TimeValue
- type Timestamp
- type TracerOption
- type UnixAddress
- type UserData
- type Whence
Constants ¶
const SizeOfDirent = 24
SizeOfDirent is the size in bytes of directory entries when serialized to the output buffer of fd_readdir.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AddressInfo ¶ added in v0.4.0
type AddressInfo struct { Flags AddressInfoFlags Family ProtocolFamily SocketType SocketType Protocol Protocol Address SocketAddress CanonicalName string }
AddressInfo is information about an address.
type AddressInfoFlags ¶ added in v0.4.0
type AddressInfoFlags uint16
AddressInfoFlags are AddressInfo flags.
const ( Passive AddressInfoFlags = 1 << iota CanonicalName NumericHost NumericService V4Mapped QueryAll AddressConfigured )
func (AddressInfoFlags) Has ¶ added in v0.4.0
func (flags AddressInfoFlags) Has(f AddressInfoFlags) bool
Has is true if the flag is set. If multiple flags are specified, Has returns true if all flags are set.
func (AddressInfoFlags) HasAny ¶ added in v0.4.0
func (flags AddressInfoFlags) HasAny(f AddressInfoFlags) bool
HasAny is true if any of the specified flags are set.
func (AddressInfoFlags) String ¶ added in v0.4.0
func (flags AddressInfoFlags) String() (s string)
type Advice ¶
type Advice uint8
Advice is file or memory access pattern advisory information.
const ( // Normal indicates that the application has no advice to give on its // behavior with respect to the specified data. Normal Advice = iota // Sequential indicates that the application expects to access the // specified data sequentially from lower offsets to higher offsets. Sequential // Random indicates that the application expects to access the specified // data in a random order. Random // WillNeed indicates that the application expects to access the specified // data in the near future. WillNeed // DontNeed indicates that the application expects that it will not access // the specified data in the near future. DontNeed // NoReuse indicates that the application expects to access the specified // data once and then not reuse it thereafter. NoReuse )
type BytesValue ¶ added in v0.6.19
type BytesValue []byte
BytesValue is used to represent an arbitrary socket option value.
func (BytesValue) String ¶ added in v0.6.19
func (s BytesValue) String() string
type ClockID ¶
type ClockID uint32
ClockID is an identifier for clocks.
const ( // Realtime is the clock measuring real time. Time value zero corresponds // with 1970-01-01T00:00:00Z. Realtime ClockID = iota // Monotonic is the store-wide monotonic clock, which is defined as a clock // measuring real time, whose value cannot be adjusted and which cannot // have negative clock jumps. The epoch of this clock is undefined. The // absolute time value of this clock therefore has no meaning. Monotonic // ProcessCPUTimeID is the CPU-time clock associated with the current // process. ProcessCPUTimeID // ThreadCPUTimeID is the CPU-time clock associated with the current // thread. ThreadCPUTimeID )
type Device ¶
type Device uint64
Device is an identifier for a device containing a file system.
It can be used in combination with INode to uniquely identify a file or directory in the filesystem.
type Dir ¶ added in v0.3.4
type Dir interface { FDReadDir(ctx context.Context, entries []DirEntry, cookie DirCookie, bufferSizeBytes int) (int, Errno) FDCloseDir(ctx context.Context) Errno }
Dir instances are returned by File.FDOpenDir and used to iterate over
type DirCookie ¶
type DirCookie uint64
DirCookie is a reference to the offset of a directory entry.
The value 0 signifies the start of the directory.
type DirEntry ¶
type DirEntry struct { // Next is the offset of the next directory entry stored in this directory. Next DirCookie // INode is the serial number of the file referred to by this directory // entry. INode INode // Type is the type of the file referred to by this directory entry. Type FileType // Name of the directory entry. When the directory entry is retrieved by a // call to FDReadDir, the name may point to an internal buffer and therefore // remains valid only until the next call to FDReadDir. Name []byte }
DirEntry is a directory entry.
type DirNameLength ¶
type DirNameLength uint32
DirNameLength is the type for the DirEntry.NameLength field.
type Errno ¶
type Errno uint16
Errno are the error codes returned by functions.
Not all of these error codes are returned by the functions provided by this API; some are used in higher-level library layers, and others are provided merely for alignment with POSIX.
const ( // ESUCCESS indicates that no error occurred (system call completed // successfully). ESUCCESS Errno = iota // E2BIG means an argument list is too long. E2BIG // EACCES means permission is denied. EACCES // EADDRINUSE means an address is already in use. EADDRINUSE // EADDRNOTAVAIL means an address is not available. EADDRNOTAVAIL // EAFNOSUPPORT means an address family is not supported by a protocol family. EAFNOSUPPORT // EAGAIN means the caller should try again. EAGAIN // EALREADY means a socket already connected EALREADY // EBADF means bad file number. EBADF // EBADMSG indicates that the caller is trying to read an unreadable message. EBADMSG // EBUSY means a device or resource busy. EBUSY // ECANCELED means an operation was canceled. ECANCELED // ECHILD means no child processes. ECHILD // ECONNABORTED means a connection was aborted. ECONNABORTED // ECONNREFUSED means connection was refused. ECONNREFUSED // ECONNRESET means a connection was reset by peer. ECONNRESET // EDEADLK indicates a deadlock condition. EDEADLK // EDESTADDRREQ means a destination address is required. EDESTADDRREQ // EDOM means a math argument is out of domain of func. EDOM // EDQUOT means a quota was exceeded. EDQUOT // EEXIST means a file exists. EEXIST // EFAULT means bad address. EFAULT // EFBIG indicates a file is too large. EFBIG // EHOSTUNREACH means a host is unreachable. EHOSTUNREACH // EIDRM means identifier removed. EIDRM // EILSEQ indicates an illegal byte sequence EILSEQ // EINPROGRESS means a connection is already in progress. EINPROGRESS // EINTR means a system call was interrupted. EINTR // EINVAL means an argument was invalid. EINVAL // EIO means an I/O error occurred. EIO // EISCONN means a socket is already connected. EISCONN // EISDIR means a file is a directory. EISDIR // ELOOP indicates that there are too many symbolic links. ELOOP // EMFILE indicates that there are too many open files EMFILE // EMLINK indicates that there are too many links EMLINK // EMSGSIZE means a message is too long. EMSGSIZE // EMULTIHOP means a multihop was attempted. EMULTIHOP // ENAMETOOLONG means a file name is too long. ENAMETOOLONG // ENETDOWN means a network interface is not configured. ENETDOWN // ENETRESET means a network was dropped connection on reset. ENETRESET // ENETUNREACH means a network is unreachable. ENETUNREACH // ENFILE means a file table overflow occurred. ENFILE // ENOBUFS means that no buffer space is available. ENOBUFS // ENODEV means no such device. ENODEV // ENOENT means no such file or directory. ENOENT // ENOEXEC means an exec format error. ENOEXEC // ENOLCK means that there are no record locks available ENOLCK // ENOLINK means the link has been severed. ENOLINK // ENOMEM means out of memory. ENOMEM // ENOMSG means that there is no message of desired type. ENOMSG // ENOPROTOOPT means a protocol is not available. ENOPROTOOPT // ENOSPC means that there is no space left on a device. ENOSPC // ENOSYS means not implemented. ENOSYS // ENOTCONN means a socket is not connected. ENOTCONN // ENOTDIR means a file is not a directory ENOTDIR // ENOTEMPTY means a directory is not empty. ENOTEMPTY // ENOTRECOVERABLE means state is not recoverable. ENOTRECOVERABLE // ENOTSOCK means a socket operation was attempted on a non-socket. ENOTSOCK // ENOTSUP means not supported. ENOTSUP // ENOTTY means not a typewriter. ENOTTY // ENXIO means no such device or address. ENXIO // EOVERFLOW means the value is too large for defined data type. EOVERFLOW // EOWNERDEAD means an owner died. EOWNERDEAD // EPERM means an operation is not permitted. EPERM // EPIPE means broken pipe. EPIPE // EPROTO means a protocol error ocurred. EPROTO // EPROTONOSUPPORT means a protocol is not supported. EPROTONOSUPPORT // EPROTOTYPE means that a protocol is the wrong type for socket. EPROTOTYPE // ERANGE means a math result is not representable. ERANGE // EROFS means a file system is read-only. EROFS // ESPIPE means a seek is illegal. ESPIPE // ESRCH means no such process. ESRCH // ESTALE means a file handle is stale. ESTALE // ETIMEDOUT means a connection timed out. ETIMEDOUT // ETXTBSY means text file busy. ETXTBSY // EXDEV means cross-device link. EXDEV // ENOTCAPABLE means capabilities are insufficient. ENOTCAPABLE )
func MakeErrno ¶ added in v0.6.2
MakeErrno converts a Go error to a WASI errno value in a way that is portable across platforms.
func (Errno) Syscall ¶ added in v0.6.16
Syscall convers the error to a native error number of the host platform.
The method does the inverse of passing the syscall.Errno value to wasi.MakeErrno tho some error numbers may differ on the host platform, therefore there is no guarantee that the wasi.Errno value obtained by a call to wasi.MakeErrno will yield the same syscall.Errno returned by this method.
type Event ¶
type Event struct { // UserData is the user-provided value that got attached to // Subscription.UserData. UserData UserData // Errno is an error that occurred while processing the subscription // request. Errno Errno // EventType is the type of event that occurred. EventType EventType // FDReadWrite is the contents of the event, if it is a FDReadEvent or // FDWriteEvent. ClockEvent events ignore this field. FDReadWrite EventFDReadWrite }
Event is an event that occurred.
func (Event) ObjectSize ¶
type EventFDReadWrite ¶
type EventFDReadWrite struct { // NBytes is the number of bytes available for reading or writing. NBytes FileSize // Flags is the state of the file descriptor. Flags EventFDReadWriteFlags }
EventFDReadWrite is the contents of an event when event type is FDReadEvent or FDWriteEvent.
type EventFDReadWriteFlags ¶
type EventFDReadWriteFlags uint16
EventFDReadWriteFlags is the state of the file descriptor subscribed to with FDReadEvent or FDWriteEvent.
const ( // Hangup is a flag that indicates that the peer of this socket // has closed or disconnected. Hangup EventFDReadWriteFlags = 1 << iota )
func (EventFDReadWriteFlags) Has ¶
func (flags EventFDReadWriteFlags) Has(f EventFDReadWriteFlags) bool
Has is true if the flag is set.
func (EventFDReadWriteFlags) String ¶
func (flags EventFDReadWriteFlags) String() string
type EventType ¶
type EventType uint8
EventType is a type of a subscription to an event, or its occurrence.
const ( // ClockEvent is an event type that indicates that the time value of clock // SubscriptionClock.ID has reached timestamp SubscriptionClock.Timeout. ClockEvent EventType = iota // FDReadEvent is an event type that indicates that the file descriptor // SubscriptionFDReadWrite.FD has data available for reading. FDReadEvent // FDWriteEvent is an event type that indicates that the file descriptor // SubscriptionFDReadWrite.FD has data available for writing. FDWriteEvent )
type FDFlags ¶
type FDFlags uint16
FDFlags are file descriptor flags.
const ( // Append indicates append mode; data written to the file is always // appended to the file's end. Append FDFlags = 1 << iota // DSync means write according to synchronized I/O data integrity // completion. // // Only the data stored in the file is synchronized. DSync // NonBlock indicates non-blocking mode. NonBlock // RSync indicates synchronized read I/O operations. RSync // Sync means write according to synchronized I/O data integrity // completion. // // In addition to synchronizing the data stored in the file, the // implementation may also synchronously update the file's metadata. Sync )
type FDStat ¶
type FDStat struct { // FileType is the file type. FileType FileType // Flags are the file descriptor flags. Flags FDFlags // RightsBase are rights that apply to this file descriptor. RightsBase Rights // RightsInheriting are the maximum set of rights that may be installed on // new file descriptors that are created through this file descriptor, // e.g. through PathOpen. RightsInheriting Rights }
FDStat is file descriptor attributes.
func (FDStat) ObjectSize ¶
type FSTFlags ¶
type FSTFlags uint16
FSTFlags indicate which file time attributes to adjust.
const ( // AccessTime means adjust the last data access timestamp to the value // stored in FileStat.AccessTime. AccessTime FSTFlags = 1 << iota // AccessTimeNow means adjust the last data access timestamp to the time // of clock Realtime. AccessTimeNow // ModifyTime means adjust the last data modification timestamp to the value // stored in FileStat.ModifyTime. ModifyTime // ModifyTimeNow means adjust the last data modification timestamp to the time // of clock Realtime. ModifyTimeNow )
type File ¶ added in v0.3.4
type File[T any] interface { FDAdvise(ctx context.Context, offset, length FileSize, advice Advice) Errno FDAllocate(ctx context.Context, offset, length FileSize) Errno FDClose(ctx context.Context) Errno FDDataSync(ctx context.Context) Errno FDStatSetFlags(ctx context.Context, flags FDFlags) Errno FDFileStatGet(ctx context.Context) (FileStat, Errno) FDFileStatSetSize(ctx context.Context, size FileSize) Errno FDFileStatSetTimes(ctx context.Context, accessTime, modifyTime Timestamp, flags FSTFlags) Errno FDPread(ctx context.Context, iovecs []IOVec, offset FileSize) (Size, Errno) FDPwrite(ctx context.Context, iovecs []IOVec, offset FileSize) (Size, Errno) FDRead(ctx context.Context, iovecs []IOVec) (Size, Errno) FDWrite(ctx context.Context, iovecs []IOVec) (Size, Errno) FDSync(ctx context.Context) Errno FDSeek(ctx context.Context, delta FileDelta, whence Whence) (FileSize, Errno) FDOpenDir(ctx context.Context) (Dir, Errno) PathCreateDirectory(ctx context.Context, path string) Errno PathFileStatGet(ctx context.Context, flags LookupFlags, path string) (FileStat, Errno) PathFileStatSetTimes(ctx context.Context, lookupFlags LookupFlags, path string, accessTime, modifyTime Timestamp, flags FSTFlags) Errno PathLink(ctx context.Context, flags LookupFlags, oldPath string, newFile T, newPath string) Errno PathOpen(ctx context.Context, lookupFlags LookupFlags, path string, openFlags OpenFlags, rightsBase, rightsInheriting Rights, fdFlags FDFlags) (T, Errno) PathReadLink(ctx context.Context, path string, buffer []byte) (int, Errno) PathRemoveDirectory(ctx context.Context, path string) Errno PathRename(ctx context.Context, oldPath string, newFile T, newPath string) Errno PathSymlink(ctx context.Context, oldPath string, newPath string) Errno PathUnlinkFile(ctx context.Context, path string) Errno }
File is an interface used as constraint in the FileType generic type parameter.
File implement the WASI functions which operate on a file descriptor number.
type FileSize ¶
type FileSize uint64
FileSize is a non-negative file size or length of a region within a file.
type FileStat ¶
type FileStat struct { // Device is the ID of the device containing the file. Device Device // INode is the file serial number. INode INode // FileType is the file type. FileType FileType // NLink is the number of hard links to the file. NLink LinkCount // Size is the size. For regular files, it's the file size in bytes. For // symbolic links, the length in bytes of the pathname contained in the // symbolic link. Size FileSize // AccessTime is the last data access timestamp. AccessTime Timestamp // ModifyTime is the last data modification timestamp. ModifyTime Timestamp // ChangeTime is the last file status change timestamp. ChangeTime Timestamp }
FileStat are file attributes.
func (FileStat) ObjectSize ¶
type FileTable ¶ added in v0.3.4
type FileTable[T File[T]] struct { // Limit the number of files that may be opened on the table. // // Zero means no limit. MaxOpenFiles int // Limit the number of directories that may be opened. // // Zero means no limit. MaxOpenDirs int // contains filtered or unexported fields }
FileTable is a building block used to construct implementations of the System interface.
The file table maintains the set of open files and associates them with file descriptor numbers.
The type paritally implements the System interface, it is common to embed a FileTable field in a struct in order to inherit its methods. The generic type allows for specialization of the behavior of files, for example:
// System embeds a wasi.FileTable to implements most of the wasi.System // interface methods. type System struct { wasi.FileTable[File] ... } // File implements the wasi.File interface to specialize the behavior of // WASI functions. type File struct { ... }
func (*FileTable[T]) FDAllocate ¶ added in v0.3.4
func (*FileTable[T]) FDDataSync ¶ added in v0.3.4
func (*FileTable[T]) FDFileStatGet ¶ added in v0.3.4
func (*FileTable[T]) FDFileStatSetSize ¶ added in v0.3.4
func (*FileTable[T]) FDFileStatSetTimes ¶ added in v0.3.4
func (*FileTable[T]) FDPreStatDirName ¶ added in v0.3.4
func (*FileTable[T]) FDPreStatGet ¶ added in v0.3.4
func (*FileTable[T]) FDRenumber ¶ added in v0.3.4
func (*FileTable[T]) FDStatSetFlags ¶ added in v0.3.4
func (*FileTable[T]) FDStatSetRights ¶ added in v0.3.4
func (*FileTable[T]) LookupSocketFD ¶ added in v0.3.4
func (*FileTable[T]) NumOpenDirs ¶ added in v0.7.3
func (*FileTable[T]) NumOpenFiles ¶ added in v0.7.3
func (*FileTable[T]) NumPreopens ¶ added in v0.7.3
func (*FileTable[T]) PathCreateDirectory ¶ added in v0.3.4
func (*FileTable[T]) PathFileStatGet ¶ added in v0.3.4
func (*FileTable[T]) PathFileStatSetTimes ¶ added in v0.3.4
func (*FileTable[T]) PathReadLink ¶ added in v0.3.4
func (*FileTable[T]) PathRemoveDirectory ¶ added in v0.3.4
func (*FileTable[T]) PathRename ¶ added in v0.3.4
func (*FileTable[T]) PathSymlink ¶ added in v0.3.4
func (*FileTable[T]) PathUnlinkFile ¶ added in v0.3.4
type FileType ¶
type FileType uint8
FileType is the type of a file descriptor or file.
const ( // UnknownType indicates that the type of the file descriptor or file is // unknown or is different from any of the other types specified. UnknownType FileType = iota // BlockDeviceType is indicates that the file descriptor or file refers to // a block device inode. BlockDeviceType // CharacterDeviceType indicates that the file descriptor or file refers to // a character device inode. CharacterDeviceType // DirectoryType indicates that the file descriptor or file refers to a // directory inode. DirectoryType // RegularFileType indicates that the file descriptor or file refers to a // regular file inode. RegularFileType // SocketDGramType indicates that the file descriptor or file refers to a // datagram socket. SocketDGramType // SocketStreamType indicates that the file descriptor or file refers to a // byte-stream socket. SocketStreamType // SymbolicLinkType indicates that the file refers to a symbolic link // inode. SymbolicLinkType )
type IOVec ¶
type IOVec []byte
IOVec is a slice of bytes.
func (IOVec) FormatObject ¶
func (IOVec) ObjectSize ¶
type Inet4Address ¶
func (*Inet4Address) Family ¶ added in v0.6.5
func (a *Inet4Address) Family() ProtocolFamily
func (*Inet4Address) MarshalJSON ¶ added in v0.3.1
func (a *Inet4Address) MarshalJSON() ([]byte, error)
func (*Inet4Address) MarshalYAML ¶ added in v0.3.1
func (a *Inet4Address) MarshalYAML() (any, error)
func (*Inet4Address) Network ¶
func (a *Inet4Address) Network() string
func (*Inet4Address) String ¶
func (a *Inet4Address) String() string
type Inet6Address ¶
func (*Inet6Address) Family ¶ added in v0.6.5
func (a *Inet6Address) Family() ProtocolFamily
func (*Inet6Address) MarshalJSON ¶ added in v0.3.1
func (a *Inet6Address) MarshalJSON() ([]byte, error)
func (*Inet6Address) MarshalYAML ¶ added in v0.3.1
func (a *Inet6Address) MarshalYAML() (any, error)
func (*Inet6Address) Network ¶
func (a *Inet6Address) Network() string
func (*Inet6Address) String ¶
func (a *Inet6Address) String() string
type LookupFlags ¶
type LookupFlags uint32
LookupFlags determine the method of how paths are resolved.
const ( // SymlinkFollow means that as long as the resolved path corresponds to a // symbolic link, it is expanded. SymlinkFollow LookupFlags = 1 << iota )
func (LookupFlags) Has ¶
func (flags LookupFlags) Has(f LookupFlags) bool
Has is true if the flag is set.
func (LookupFlags) String ¶
func (flags LookupFlags) String() string
type OpenFlags ¶
type OpenFlags uint16
OpenFlags are flags used by PathOpen.
const ( // OpenCreate means create a file if it does not exist. OpenCreate OpenFlags = 1 << iota // OpenDirectory means fail if the path is not a directory. OpenDirectory // OpenExclusive means fail if the file already exists. OpenExclusive // OpenTruncate means truncate file to size 0. OpenTruncate )
type PreOpenType ¶
type PreOpenType uint8
PreOpenType are identifiers for pre-opened capabilities.
const ( // PreOpenDir is a pre-opened directory. PreOpenDir PreOpenType = iota )
func (PreOpenType) String ¶
func (p PreOpenType) String() string
type PreStat ¶
type PreStat struct { // Type is the type of pre-open. Type PreOpenType // PreStatDir is directory information when type is PreOpenDir. PreStatDir PreStatDir }
PreStat is information about a pre-opened capability.
func (PreStat) ObjectSize ¶
type PreStatDir ¶
type PreStatDir struct { // NameLength is the length of the directory name for use with // FDPreStatDirName. NameLength Size }
PreStatDir is the contents of a PreStat when type is PreOpenDir.
type ProtocolFamily ¶
type ProtocolFamily int32
ProtocolFamily is a socket protocol family.
const ( UnspecifiedFamily ProtocolFamily = iota InetFamily Inet6Family UnixFamily )
func (ProtocolFamily) String ¶
func (pf ProtocolFamily) String() string
type Rights ¶
type Rights uint64
Rights are file descriptor rights, determining which actions may be performed.
const ( // FDDataSyncRight is the right to invoke FDDataSync. // // If PathOpenRight is set, it includes the right to invoke PathOpen with // the DSync flag. FDDataSyncRight Rights = 1 << iota // FDReadRight is the right to invoke FDRead and SockRecv. // // If FDSeekRight is set, it includes the right to invoke FDPread. FDReadRight // FDSeekRight is the right to invoke FDSeek. This flag implies FDTellRight. FDSeekRight // FDStatSetFlagsRight is the right to invoke FDStatSetFlags. FDStatSetFlagsRight // FDSyncRight is the right to invoke FDSync. // // If PathOpenRight is set, it includes the right to invoke PathOpen with // flags RSync and DSync. FDSyncRight // FDTellRight is the right to invoke FDTell, and the right to invoke // FDSeek in such a way that the file offset remains unaltered (i.e. // WhenceCurrent with offset zero). FDTellRight // FDWriteRight is the right to invoke FDWrite and SockSend. // // If FDSeekRight is set, it includes the right to invoke FDPwrite. FDWriteRight // FDAdviseRight is the right to invoke FDAdvise. FDAdviseRight // FDAllocateRight is the right to invoke FDAllocate. FDAllocateRight // PathCreateDirectoryRight is the right to invoke PathCreateDirectory. PathCreateDirectoryRight // PathCreateFileRight is (along with PathOpenRight) the right to invoke // PathOpen with the OpenCreate flag. PathCreateFileRight // PathLinkSourceRight is the right to invoke PathLink with the file // descriptor as the source directory. PathLinkSourceRight // PathLinkTargetRight is the right to invoke PathLink with the file // descriptor as the target directory. PathLinkTargetRight // PathOpenRight is the right to invoke PathOpen. PathOpenRight // FDReadDirRight is the right to invoke FDReadDir. FDReadDirRight // PathReadLinkRight is the right to invoke PathReadLink. PathReadLinkRight // PathRenameSourceRight is the right to invoke PathRename with the file // descriptor as the source directory. PathRenameSourceRight // PathRenameTargetRight is the right to invoke PathRename with the file // descriptor as the target directory. PathRenameTargetRight // PathFileStatGetRight is the right to invoke PathFileStatGet. PathFileStatGetRight // PathFileStatSetSizeRight is the right to change a file's size. // // If PathOpenRight is set, it includes the right to invoke PathOpen with // the OpenTruncate flag. // // Note: there is no function named PathFileStatSetSize. This follows POSIX // design, which only has ftruncate and does not provide ftruncateat. While // such function would be desirable from the API design perspective, there // are virtually no use cases for it since no code written for POSIX // systems would use it. Moreover, implementing it would require multiple // syscalls, leading to inferior performance. PathFileStatSetSizeRight // PathFileStatSetTimesRight is the right to invoke PathFileStatSetTimes. PathFileStatSetTimesRight // FDFileStatGetRight is the right to invoke FDFileStatGet. FDFileStatGetRight // FDFileStatSetSizeRight is the right to invoke FDFileStatSetSize. FDFileStatSetSizeRight // FDFileStatSetTimesRight is the right to invoke FDFileStatSetTimes. FDFileStatSetTimesRight // PathSymlinkRight is the right to invoke PathSymlink. PathSymlinkRight // PathRemoveDirectoryRight is the right to invoke PathRemoveDirectory. PathRemoveDirectoryRight // PathUnlinkFileRight is the right to invoke PathUnlinkFile. PathUnlinkFileRight // PollFDReadWriteRight is the right to invoke PollOneOff. // // If FDReadWrite is set, it includes the right to invoke PollOneOff with a // FDReadEvent subscription. If FDWriteWrite is set, it includes the right // to invoke PollOneOff with a FDWriteEvent subscription. PollFDReadWriteRight // SockShutdownRight is the right to invoke SockShutdown SockShutdownRight // SockAccessRight is the right to invoke SockAccept SockAcceptRight // AllRights is the set of all available rights AllRights Rights = (1 << 30) - 1 // ReadRights are rights related to reads. ReadRights Rights = FDReadRight | FDReadDirRight // WriteRights are rights related to writes. WriteRights Rights = FDWriteRight | FDAllocateRight | PathFileStatSetSizeRight | FDDataSyncRight // FileRights are rights related to files. FileRights Rights = syncRights | seekRights | fileStatRights | FDReadRight | FDStatSetFlagsRight | FDWriteRight | FDAdviseRight | FDAllocateRight | PollFDReadWriteRight // DirectoryRights are rights related to directories. // See https://github.com/WebAssembly/wasi-testsuite/blob/1b1d4a5/tests/rust/src/bin/directory_seek.rs DirectoryRights Rights = pathRights | syncRights | fileStatRights | FDStatSetFlagsRight | FDReadDirRight // TTYRights are rights related to terminals. // See https://github.com/WebAssembly/wasi-libc/blob/a6f871343/libc-bottom-half/sources/isatty.c TTYRights = FileRights &^ seekRights // SockListenRights are rights for listener sockets. SockListenRights = SockAcceptRight | PollFDReadWriteRight | FDFileStatGetRight | FDStatSetFlagsRight // SockConnectionRights are rights for connection sockets. SockConnectionRights = FDReadRight | FDWriteRight | PollFDReadWriteRight | SockShutdownRight | FDFileStatGetRight | FDStatSetFlagsRight )
func (Rights) Has ¶
Has is true if the flag is set. If multiple flags are specified, Has returns true if all flags are set.
type SDFlags ¶
type SDFlags uint16
SDFlags are flags provided to SockShutdown which indicate which channels on a socket to shut down.
type SIFlags ¶
type SIFlags uint16
SIFlags are flags provided to SockSend.
As there are currently no flags defined, it must be set to zero.
type Signal ¶
type Signal uint8
Signal is a signal condition.
const ( // SIGNONE means no signal. Note that POSIX has special semantics for // kill(pid, 0), so this value is reserved. SIGNONE Signal = iota // SIGHUP means hangup. Action: Terminates the process. SIGHUP // SIGINT is the terminate interrupt signal. Action: Terminates the // process. SIGINT // SIGQUIT is the terminal quit signal. Action: Terminates the process. SIGQUIT // SIGILL means illegal instruction. Action: Terminates the process. SIGILL // SIGTRAP is the trace/breakpoint trap. Action: Terminates the process. SIGTRAP // SIGABRT is the process abort signal. Action: Terminates the process. SIGABRT // SIGBUS indicates access to an undefined portion of a memory object. // Action: Terminates the process. SIGBUS // SIGFPE indicates an erroneous arithmetic operation. Action: Terminates // the process. SIGFPE // SIGKILL means kill. Action: Terminates the process. SIGKILL // SIGUSR1 is the user-defined signal 1. Action: Terminates the process. SIGUSR1 // SIGSEGV indicates an invalid memory reference. Action: Terminates the // process. SIGSEGV // SIGUSR2 is the user-defined signal 1. Action: Terminates the process. SIGUSR2 // SIGPIPE indicates a write on a pipe with no one to read it. // Action: Ignored. SIGPIPE // SIGALRM indicates an alarm clock. Action: Terminates the process. SIGALRM // SIGTERM is the termination signal. Action: Terminates the process. SIGTERM // SIGCHLD indicates that a child process terminated, stopped, or // continued. Action: Ignored. SIGCHLD // SIGCONT indicates that execution should continue, if stopped. // Action: Continues executing, if stopped. SIGCONT // SIGSTOP means stop executing. Action: Stops executing. SIGSTOP // SIGTSTP is the terminal stop signal. Action: Stops executing. SIGTSTP // SIGTTIN indicates that a background process is attempting read. // Action: Stops executing. SIGTTIN // SIGTTOU indicates that a background process is attempting write. // Action: Stops executing. SIGTTOU // SIGURG indicates that high bandwidth data is available at a socket. // Action: Ignored. SIGURG // SIGXCPU means CPU time limit exceeded. Action: Terminates the process. SIGXCPU // SIGXFSZ means file size limit exceeded. Action: Terminates the process. SIGXFSZ // SIGVTALRM means virtual timer expired. Action: Terminates the process. SIGVTALRM // SIGPROF means profiling timer expired. Action: Terminates the process. SIGPROF // SIGWINCH means window changed. Action: Ignored. SIGWINCH // SIGPOLL means I/O is possible. Action: Terminates the process. SIGPOLL // SIGPWR indicates power failure. Action: Terminates the process. SIGPWR // SIGSYS indicates a bad system call. Action: Terminates the process. SIGSYS )
type SocketAddress ¶
type SocketAddress interface { Network() string String() string Family() ProtocolFamily // contains filtered or unexported methods }
SocketAddress is a socket address.
type SocketOption ¶
type SocketOption int64
SocketOption is a socket option that can be queried or set.
const ( ReuseAddress SocketOption = (SocketOption(SocketLevel) << 32) | iota QuerySocketType QuerySocketError DontRoute Broadcast SendBufferSize RecvBufferSize KeepAlive OOBInline Linger RecvLowWatermark RecvTimeout SendTimeout QueryAcceptConnections BindToDevice )
SOL_SOCKET level options.
const (
TcpNoDelay SocketOption = (SocketOption(TcpLevel) << 32) | (15)
)
IPPROTO_TCP level options
func MakeSocketOption ¶ added in v0.6.19
func MakeSocketOption(level SocketOptionLevel, option int32) SocketOption
func (SocketOption) Level ¶ added in v0.6.19
func (s SocketOption) Level() SocketOptionLevel
func (SocketOption) String ¶
func (so SocketOption) String() string
type SocketOptionLevel ¶
type SocketOptionLevel int32
SocketOptionLevel controls the level that a socket option is applied at or queried from.
const ( SocketLevel SocketOptionLevel = 0 // SOL_SOCKET TcpLevel SocketOptionLevel = 6 // IPPROTO_TCP )
func (SocketOptionLevel) String ¶
func (sl SocketOptionLevel) String() string
type SocketOptionValue ¶ added in v0.5.0
type SocketOptionValue interface { String() string // contains filtered or unexported methods }
SocketOptionValue is a socket option value.
type SocketType ¶
type SocketType int32
SocketType is a type of socket.
const ( AnySocket SocketType = iota DatagramSocket StreamSocket )
func (SocketType) String ¶
func (st SocketType) String() string
type SocketsNotSupported ¶ added in v0.6.0
type SocketsNotSupported struct{}
SocketsNotSupported is a helper type intended to be embeded in implementations of the Sytem interface that do not support sockets.
The type defines all socket-related methods to return ENOSYS, allowing the type to implement the interface but indicating to callers that the functionality is not supported.
func (SocketsNotSupported) SockAccept ¶ added in v0.6.0
func (SocketsNotSupported) SockAccept(ctx context.Context, fd FD, flags FDFlags) (FD, SocketAddress, SocketAddress, Errno)
func (SocketsNotSupported) SockAddressInfo ¶ added in v0.6.0
func (SocketsNotSupported) SockAddressInfo(ctx context.Context, name, service string, hints AddressInfo, results []AddressInfo) (int, Errno)
func (SocketsNotSupported) SockBind ¶ added in v0.6.0
func (SocketsNotSupported) SockBind(ctx context.Context, fd FD, addr SocketAddress) (SocketAddress, Errno)
func (SocketsNotSupported) SockConnect ¶ added in v0.6.0
func (SocketsNotSupported) SockConnect(ctx context.Context, fd FD, addr SocketAddress) (SocketAddress, Errno)
func (SocketsNotSupported) SockGetOpt ¶ added in v0.6.0
func (SocketsNotSupported) SockGetOpt(ctx context.Context, fd FD, level SocketOptionLevel, option SocketOption) (SocketOptionValue, Errno)
func (SocketsNotSupported) SockListen ¶ added in v0.6.0
func (SocketsNotSupported) SockLocalAddress ¶ added in v0.6.0
func (SocketsNotSupported) SockLocalAddress(ctx context.Context, fd FD) (SocketAddress, Errno)
func (SocketsNotSupported) SockOpen ¶ added in v0.6.0
func (SocketsNotSupported) SockOpen(ctx context.Context, family ProtocolFamily, socketType SocketType, protocol Protocol, rightsBase, rightsInheriting Rights) (FD, Errno)
func (SocketsNotSupported) SockRecvFrom ¶ added in v0.6.0
func (SocketsNotSupported) SockRecvFrom(ctx context.Context, fd FD, iovecs []IOVec, flags RIFlags) (Size, ROFlags, SocketAddress, Errno)
func (SocketsNotSupported) SockRemoteAddress ¶ added in v0.6.0
func (SocketsNotSupported) SockRemoteAddress(ctx context.Context, fd FD) (SocketAddress, Errno)
func (SocketsNotSupported) SockSendTo ¶ added in v0.6.0
func (SocketsNotSupported) SockSendTo(ctx context.Context, fd FD, iovecs []IOVec, flags SIFlags, addr SocketAddress) (Size, Errno)
func (SocketsNotSupported) SockSetOpt ¶ added in v0.6.0
func (SocketsNotSupported) SockSetOpt(ctx context.Context, fd FD, level SocketOptionLevel, option SocketOption, value SocketOptionValue) Errno
func (SocketsNotSupported) SockShutdown ¶ added in v0.6.0
type Subscription ¶
type Subscription struct { // UserData is a user-provided value that is attached to the subscription // in the implementation and returned through Event.UserData. UserData UserData // EventType is the type of the event to subscribe to. EventType EventType // contains filtered or unexported fields }
Subscription is a subscription to an event.
func MakeSubscriptionClock ¶
func MakeSubscriptionClock(userData UserData, c SubscriptionClock) Subscription
MakeSubscriptionClock makes a Subscription for ClockEvent events.
func MakeSubscriptionFDReadWrite ¶
func MakeSubscriptionFDReadWrite(userData UserData, eventType EventType, fdrw SubscriptionFDReadWrite) Subscription
MakeSubscriptionFDReadWrite makes a Subscription for FDReadEvent or FDWriteEvent events.
func (Subscription) FormatObject ¶
func (*Subscription) GetClock ¶
func (s *Subscription) GetClock() SubscriptionClock
GetClock gets the embedded SubscriptionClock.
func (*Subscription) GetFDReadWrite ¶
func (s *Subscription) GetFDReadWrite() SubscriptionFDReadWrite
GetFDReadWrite gets the embedded SubscriptionFDReadWrite.
func (Subscription) LoadObject ¶
func (s Subscription) LoadObject(_ api.Memory, b []byte) Subscription
func (Subscription) ObjectSize ¶
func (s Subscription) ObjectSize() int
func (*Subscription) SetClock ¶
func (s *Subscription) SetClock(c SubscriptionClock)
SetClock sets the subscription variant to a SubscriptionClock.
func (*Subscription) SetFDReadWrite ¶
func (s *Subscription) SetFDReadWrite(fdrw SubscriptionFDReadWrite)
SetFDReadWrite sets the subscription variant to a SubscriptionFDReadWrite.
func (Subscription) StoreObject ¶
func (s Subscription) StoreObject(_ api.Memory, b []byte)
type SubscriptionClock ¶
type SubscriptionClock struct { // ID is the clock against which to compare the timestamp. ID ClockID // Timeout is the absolute or relative timestamp. Timeout Timestamp // Precision is the amount of time that the implementation may wait // additionally to coalesce with other events. Precision Timestamp // Flags specify whether the timeout is absolute or relative. Flags SubscriptionClockFlags }
SubscriptionClock is the contents of a subscription when event type is ClockEvent.
func (SubscriptionClock) Format ¶
func (c SubscriptionClock) Format(w io.Writer)
type SubscriptionClockFlags ¶
type SubscriptionClockFlags uint16
SubscriptionClockFlags are flags determining how to interpret the timestamp provided in SubscriptionClock.Timeout.
const ( // Abstime is a flag indicating that the timestamp provided in // SubscriptionClock.Timeout is an absolute timestamp of clock // SubscriptionClock.ID. If unset, treat the timestamp provided in // SubscriptionClock.Timeout as relative to the current time value of clock // SubscriptionClock.ID. Abstime SubscriptionClockFlags = 1 << iota )
func (SubscriptionClockFlags) Has ¶
func (flags SubscriptionClockFlags) Has(f SubscriptionClockFlags) bool
Has is true if the flag is set.
func (SubscriptionClockFlags) String ¶
func (flags SubscriptionClockFlags) String() string
type SubscriptionFDReadWrite ¶
type SubscriptionFDReadWrite struct { // FD is the file descriptor to wait on. FD FD }
SubscriptionFDReadWrite is the contents of a subscription when event type is FDReadEvent or FDWriteEvent.
func (SubscriptionFDReadWrite) Format ¶
func (c SubscriptionFDReadWrite) Format(w io.Writer)
type System ¶
type System interface { // ArgsSizesGet reads command-line argument data sizes. // // The implementation should return the number of args, and the number of // bytes required to hold the strings (including terminating null bytes). ArgsSizesGet(ctx context.Context) (argCount int, stringBytes int, errno Errno) // ArgsGet reads command-line argument data. ArgsGet(ctx context.Context) ([]string, Errno) // EnvironSizesGet reads environment variable data sizes. // // The implementation should return the number of env variables, and the // number of bytes required to hold the strings (including terminating // null bytes). EnvironSizesGet(ctx context.Context) (argCount int, stringBytes int, errno Errno) // EnvironGet reads environment variable data. // // Key/value pairs are expected to be joined with an '=' char. EnvironGet(ctx context.Context) ([]string, Errno) // ClockResGet returns the resolution of a clock. // // The function accepts the clock ID for which to return the resolution. // // Implementations are required to provide a non-zero value for supported // clocks. For unsupported clocks, EINVAL is returned. // // Note: This is similar to clock_getres in POSIX. ClockResGet(ctx context.Context, id ClockID) (Timestamp, Errno) // ClockTimeGet returns the time value of a clock. // // The function accepts the clock ID for which to return the time. It // also accepts a precision which represents the maximum lag (exclusive) // that the returned time value may have, compared to its actual value. // // Note: This is similar to clock_gettime in POSIX. ClockTimeGet(ctx context.Context, id ClockID, precision Timestamp) (Timestamp, Errno) // FDAdvise provides file advisory information on a file descriptor // // Note: This is similar to posix_fadvise in POSIX. FDAdvise(ctx context.Context, fd FD, offset FileSize, length FileSize, advice Advice) Errno // FDAllocate forces the allocation of space in a file. // // Note: This is similar to posix_fallocate in POSIX. FDAllocate(ctx context.Context, fd FD, offset FileSize, length FileSize) Errno // FDClose closes a file descriptor. // // Note: This is similar to close in POSIX. FDClose(ctx context.Context, fd FD) Errno // FDDataSync synchronizes the data of a file to disk. // // Note: This is similar to fdatasync in POSIX. FDDataSync(ctx context.Context, fd FD) Errno // FDStatGet gets the attributes of a file descriptor. // // Note: This returns similar flags to fcntl(fd, F_GETFL) in POSIX, as // well as additional fields. FDStatGet(ctx context.Context, fd FD) (FDStat, Errno) // FDStatSetFlags adjusts the flags associated with a file descriptor. // // Note: This is similar to fcntl(fd, F_SETFL, flags) in POSIX. FDStatSetFlags(ctx context.Context, fd FD, flags FDFlags) Errno // FDStatSetRights adjusts the rights associated with a file descriptor. // // This can only be used to remove rights, and returns ENOTCAPABLE if // called in a way that would attempt to add rights. FDStatSetRights(ctx context.Context, fd FD, rightsBase, rightsInheriting Rights) Errno // FDFileStatGet returns the attributes of an open file. FDFileStatGet(ctx context.Context, fd FD) (FileStat, Errno) // FDFileStatSetSize adjusts the size of an open file. // // If this increases the file's size, the extra bytes are filled with // zeros. // // Note: This is similar to ftruncate in POSIX. FDFileStatSetSize(ctx context.Context, fd FD, size FileSize) Errno // FDFileStatSetTimes adjusts the timestamps of an open file or directory. // // Note: This is similar to futimens in POSIX. FDFileStatSetTimes(ctx context.Context, fd FD, accessTime, modifyTime Timestamp, flags FSTFlags) Errno // FDPread reads from a file descriptor, without using and updating the // file descriptor's offset. // // On success, it returns the number of bytes read. On failure, it returns // an Errno. // // Note: This is similar to preadv in Linux (and other Unix-es). FDPread(ctx context.Context, fd FD, iovecs []IOVec, offset FileSize) (Size, Errno) // FDPreStatGet returns a description of the given pre-opened file // descriptor. FDPreStatGet(ctx context.Context, fd FD) (PreStat, Errno) // FDPreStatDirName returns a description of the given pre-opened file // descriptor. FDPreStatDirName(ctx context.Context, fd FD) (string, Errno) // FDPwrite writes from a file descriptor, without using and updating the // file descriptor's offset. // // On success, it returns the number of bytes read. On failure, it returns // an Errno. // // Note: This is similar to pwritev in Linux (and other Unix-es). // // Like Linux (and other Unix-es), any calls of pwrite (and other functions // to read or write) for a regular file by other threads in the WASI // process should not be interleaved while pwrite is executed. FDPwrite(ctx context.Context, fd FD, iovecs []IOVec, offset FileSize) (Size, Errno) // FDRead reads from a file descriptor. // // On success, it returns the number of bytes read. On failure, it returns // an Errno. // // Note: This is similar to readv in POSIX. FDRead(ctx context.Context, fd FD, iovecs []IOVec) (Size, Errno) // FDReadDir reads directory entries from a directory. // // The implementation must write entries to the provided entries buffer, // and return the number of entries written. // // The implementation must ensure that the entries fit into a buffer // with the specified size (bufferSizeBytes). It's ok if the final entry // only partially fits into such a buffer. FDReadDir(ctx context.Context, fd FD, entries []DirEntry, cookie DirCookie, bufferSizeBytes int) (int, Errno) // FDRenumber atomically replaces a file descriptor by renumbering another // file descriptor. Due to the strong focus on thread safety, this // environment does not provide a mechanism to duplicate or renumber a file // descriptor to an arbitrary number, like dup2(). This would be prone to // race conditions, as an actual file descriptor with the same number could // be allocated by a different thread at the same time. This function // provides a way to atomically renumber file descriptors, which would // disappear if dup2() were to be removed entirely. FDRenumber(ctx context.Context, from, to FD) Errno // FDSeek moves the offset of a file descriptor. // // On success, this returns the new offset of the file descriptor, relative // to the start of the file. On failure, it returns an Errno. // // Note: This is similar to lseek in POSIX. FDSeek(ctx context.Context, fd FD, offset FileDelta, whence Whence) (FileSize, Errno) // FDSync synchronizes the data and metadata of a file to disk. // // Note: This is similar to fsync in POSIX. FDSync(ctx context.Context, fd FD) Errno // FDTell returns the current offset of a file descriptor. // // Note: This is similar to lseek(fd, 0, SEEK_CUR) in POSIX. FDTell(ctx context.Context, fd FD) (FileSize, Errno) // FDWrite write to a file descriptor. // // Note: This is similar to writev in POSIX. // // Like POSIX, any calls of write (and other functions to read or write) // for a regular file by other threads in the WASI process should not be // interleaved while write is executed. FDWrite(ctx context.Context, fd FD, iovecs []IOVec) (Size, Errno) // PathCreateDirectory create a directory. // // Note: This is similar to mkdirat in POSIX. PathCreateDirectory(ctx context.Context, fd FD, path string) Errno // PathFileStatGet returns the attributes of a file or directory. // // Note: This is similar to stat in POSIX. PathFileStatGet(ctx context.Context, fd FD, lookupFlags LookupFlags, path string) (FileStat, Errno) // PathFileStatSetTimes adjusts the timestamps of a file or directory. // // Note: This is similar to utimensat in POSIX. PathFileStatSetTimes(ctx context.Context, fd FD, lookupFlags LookupFlags, path string, accessTime, modifyTime Timestamp, flags FSTFlags) Errno // PathLink creates a hard link. // // Note: This is similar to linkat in POSIX. PathLink(ctx context.Context, oldFD FD, oldFlags LookupFlags, oldPath string, newFD FD, newPath string) Errno // PathOpen opens a file or directory. // // The returned file descriptor is not guaranteed to be the lowest-numbered // file descriptor not currently open; it is randomized to prevent // applications from depending on making assumptions about indexes, since // this is error-prone in multi-threaded contexts. The returned file // descriptor is guaranteed to be less than 2**31. // // Note: This is similar to openat in POSIX. PathOpen(ctx context.Context, fd FD, dirFlags LookupFlags, path string, openFlags OpenFlags, rightsBase, rightsInheriting Rights, fdFlags FDFlags) (FD, Errno) // PathReadLink reads the contents of a symbolic link. // // The implementation must read the path into the specified buffer and // returns the number of bytes written. If the buffer is not large enough // to hold the contents of the symbolic link, the implementation must // return ERANGE. // // Note: This is similar to readlinkat in POSIX. PathReadLink(ctx context.Context, fd FD, path string, buffer []byte) (int, Errno) // PathRemoveDirectory removes a directory. // // If the directory is not empty, ENOTEMPTY is returned. // // Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR) in POSIX. PathRemoveDirectory(ctx context.Context, fd FD, path string) Errno // PathRename renames a file or directory. // // Note: This is similar to renameat in POSIX. PathRename(ctx context.Context, fd FD, oldPath string, newFD FD, newPath string) Errno // PathSymlink creates a symbolic link. // // Note: This is similar to symlinkat in POSIX. PathSymlink(ctx context.Context, oldPath string, fd FD, newPath string) Errno // PathUnlinkFile unlinks a file. // // If the path refers to a directory, EISDIR is returned. // // Note: This is similar to unlinkat(fd, path, 0) in POSIX. PathUnlinkFile(ctx context.Context, fd FD, path string) Errno // PollOneOff concurrently polls for the occurrence of a set of events. // // If len(subscriptions) == 0, EINVAL is returned. // // The function writes events to the provided []Event buffer, expecting // len(events)>=len(subscriptions). PollOneOff(ctx context.Context, subscriptions []Subscription, events []Event) (int, Errno) // ProcExit terminates the process normally. // // An exit code of 0 indicates successful termination of the program. // The meanings of other values is dependent on the environment. ProcExit(ctx context.Context, exitCode ExitCode) Errno // ProcRaise sends a signal to the process of the calling thread. // // Note: This is similar to raise in POSIX. ProcRaise(ctx context.Context, signal Signal) Errno // SchedYield temporarily yields execution of the calling thread. // // Note: This is similar to sched_yield in POSIX. SchedYield(ctx context.Context) Errno // RandomGet write high-quality random data into a buffer. // // This function blocks when the implementation is unable to immediately // provide sufficient high-quality random data. This function may execute // slowly, so when large mounts of random data are required, it's // advisable to use this function to seed a pseudo-random number generator, // rather than to provide the random data directly. RandomGet(ctx context.Context, b []byte) Errno // SockOpen opens a socket. // // Note: This is similar to socket in POSIX. SockOpen(ctx context.Context, family ProtocolFamily, socketType SocketType, protocol Protocol, rightsBase, rightsInheriting Rights) (FD, Errno) // SockBind binds a socket to an address. // // The method returns the address that the socket has been bound to, which // may differ from the one passed as argument. For example, in cases where // the caller used an address with port 0, and the system is responsible for // selecting a free port to bind the socket to. // // The implementation must not retain the socket address. // // Note: This is similar to bind in POSIX. SockBind(ctx context.Context, fd FD, addr SocketAddress) (SocketAddress, Errno) // SockConnect connects a socket to an address, returning the local socket // address that the connection was made from. // // The implementation must not retain the socket address. // // Note: This is similar to connect in POSIX. SockConnect(ctx context.Context, fd FD, addr SocketAddress) (SocketAddress, Errno) // SockListen allows the socket to accept connections with SockAccept. // // Note: This is similar to listen in POSIX. SockListen(ctx context.Context, fd FD, backlog int) Errno // SockAccept accepts a new incoming connection. // // The method returns a pair of socket addresses where the first one is the // local server address that accepted the connection, and the second is the // peer address that the connection was established from. // // Although the method returns the address of the connecting entity, WASI // preview 1 does not currently support passing the address to the calling // WebAssembly module via the "sock_accept" host function call. This // address is only used by implementations and wrappers of the System // interface, and is discarded before returning control to the WebAssembly // module. // // Note: This is similar to accept in POSIX. SockAccept(ctx context.Context, fd FD, flags FDFlags) (newfd FD, peer, addr SocketAddress, err Errno) // SockRecv receives a message from a socket. // // On success, this returns the number of bytes read along with // output flags. On failure, this returns an Errno. // // Note: This is similar to recv in POSIX, though it also supports reading // the data into multiple buffers in the manner of readv. SockRecv(ctx context.Context, fd FD, iovecs []IOVec, flags RIFlags) (Size, ROFlags, Errno) // SockSend sends a message on a socket. // // On success, this returns the number of bytes written. On failure, this // returns an Errno. // // Note: This is similar to send in POSIX, though it also supports // writing the data from multiple buffers in the manner of writev. SockSend(ctx context.Context, fd FD, iovecs []IOVec, flags SIFlags) (Size, Errno) // SockSendTo sends a message on a socket. // // It's similar to SockSend, but accepts an additional SocketAddress. // // Note: This is similar to sendto in POSIX, though it also supports // writing the data from multiple buffers in the manner of writev. SockSendTo(ctx context.Context, fd FD, iovecs []IOVec, flags SIFlags, addr SocketAddress) (Size, Errno) // SockRecvFrom receives a message from a socket. // // It's similar to SockRecv, but returns an additional SocketAddress. // // Note: This is similar to recvfrom in POSIX, though it also supports reading // the data into multiple buffers in the manner of readv. SockRecvFrom(ctx context.Context, fd FD, iovecs []IOVec, flags RIFlags) (Size, ROFlags, SocketAddress, Errno) // SockGetOpt gets a socket option. // // Note: This is similar to getsockopt in POSIX. SockGetOpt(ctx context.Context, fd FD, option SocketOption) (SocketOptionValue, Errno) // SockSetOpt sets a socket option. // // Note: This is similar to setsockopt in POSIX. SockSetOpt(ctx context.Context, fd FD, option SocketOption, value SocketOptionValue) Errno // SockLocalAddress gets the local address of the socket. // // The returned address is only valid until the next call on this // interface. Assume that any method may invalidate the address. // // Note: This is similar to getsockname in POSIX. SockLocalAddress(ctx context.Context, fd FD) (SocketAddress, Errno) // SockRemoteAddress gets the address of the peer when the socket is a // connection. // // The returned address is only valid until the next call on this // interface. Assume that any method may invalidate the address. // // Note: This is similar to getpeername in POSIX. SockRemoteAddress(ctx context.Context, fd FD) (SocketAddress, Errno) // SockAddressInfo get a list of IP addresses and port numbers for a // host name and service. // // The function populates the AddressInfo.Address fields of the provided // results slice, and returns a count indicating how many results were // written. // // The returned addresses are only valid until the next call on this // interface. Assume that any method may invalidate the addresses. // // Note: This is similar to getaddrinfo in POSIX. SockAddressInfo(ctx context.Context, name, service string, hints AddressInfo, results []AddressInfo) (int, Errno) // SockShutdown shuts down a socket's send and/or receive channels. // // Note: This is similar to shutdown in POSIX. SockShutdown(ctx context.Context, fd FD, flags SDFlags) Errno // Close closes the System. Close(ctx context.Context) error }
System is the WebAssembly System Interface (WASI).
type TimeValue ¶ added in v0.6.11
type TimeValue Timestamp
TimeValue is used to represent socket options with a duration value.
type TracerOption ¶ added in v0.8.0
type TracerOption func(*tracer)
TracerOption configures a tracer.
func WithTracerStringSize ¶ added in v0.8.0
func WithTracerStringSize(stringSize int) TracerOption
WithTracerStringSize sets the number of bytes to print when printing strings.
To disable truncation of strings, use stringSize < 0.
The default string size is 32.
type UnixAddress ¶
type UnixAddress struct {
Name string
}
func (*UnixAddress) Family ¶ added in v0.6.5
func (a *UnixAddress) Family() ProtocolFamily
func (*UnixAddress) MarshalJSON ¶ added in v0.3.1
func (a *UnixAddress) MarshalJSON() ([]byte, error)
func (*UnixAddress) MarshalYAML ¶ added in v0.3.1
func (a *UnixAddress) MarshalYAML() (any, error)
func (*UnixAddress) Network ¶
func (a *UnixAddress) Network() string
func (*UnixAddress) String ¶
func (a *UnixAddress) String() string
type UserData ¶
type UserData uint64
UserData is a user-provided value that may be attached to objects that is retained when extracted from the implementation.