wasip1

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package wasip1 is a helper to remove package cycles re-using constants.

Index

Constants

View Source
const (
	ArgsGetName      = "args_get"
	ArgsSizesGetName = "args_sizes_get"
)
View Source
const (
	ClockResGetName  = "clock_res_get"
	ClockTimeGetName = "clock_time_get"
)
View Source
const (
	// ClockIDRealtime is the name ID named "realtime" like sys.Walltime
	ClockIDRealtime = iota
	// ClockIDMonotonic is the name ID named "monotonic" like sys.Nanotime
	ClockIDMonotonic
)

https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-clockid-enumu32

View Source
const (
	EnvironGetName      = "environ_get"
	EnvironSizesGetName = "environ_sizes_get"
)
View Source
const (
	FdAdviseName           = "fd_advise"
	FdAllocateName         = "fd_allocate"
	FdCloseName            = "fd_close"
	FdDatasyncName         = "fd_datasync"
	FdFdstatGetName        = "fd_fdstat_get"
	FdFdstatSetFlagsName   = "fd_fdstat_set_flags"
	FdFdstatSetRightsName  = "fd_fdstat_set_rights"
	FdFilestatGetName      = "fd_filestat_get"
	FdFilestatSetSizeName  = "fd_filestat_set_size"
	FdFilestatSetTimesName = "fd_filestat_set_times"
	FdPreadName            = "fd_pread"
	FdPrestatGetName       = "fd_prestat_get"
	FdPrestatDirNameName   = "fd_prestat_dir_name"
	FdPwriteName           = "fd_pwrite"
	FdReadName             = "fd_read"
	FdReaddirName          = "fd_readdir"
	FdRenumberName         = "fd_renumber"
	FdSeekName             = "fd_seek"
	FdSyncName             = "fd_sync"
	FdTellName             = "fd_tell"
	FdWriteName            = "fd_write"

	PathCreateDirectoryName  = "path_create_directory"
	PathFilestatGetName      = "path_filestat_get"
	PathFilestatSetTimesName = "path_filestat_set_times"
	PathLinkName             = "path_link"
	PathOpenName             = "path_open"
	PathReadlinkName         = "path_readlink"
	PathRemoveDirectoryName  = "path_remove_directory"
	PathRenameName           = "path_rename"
	PathSymlinkName          = "path_symlink"
	PathUnlinkFileName       = "path_unlink_file"
)
View Source
const (
	// O_CREAT creates a file if it does not exist.
	O_CREAT uint16 = 1 << iota //nolint
	// O_DIRECTORY fails if not a directory.
	O_DIRECTORY
	// O_EXCL fails if file already exists.
	O_EXCL //nolint
	// O_TRUNC truncates the file to size 0.
	O_TRUNC //nolint
)

oflags are open flags used by path_open See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-oflags-flagsu16

View Source
const (
	FD_APPEND uint16 = 1 << iota //nolint
	FD_DSYNC
	FD_NONBLOCK
	FD_RSYNC
	FD_SYNC
)

file descriptor flags See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#fdflags

View Source
const (
	FILETYPE_UNKNOWN uint8 = iota
	FILETYPE_BLOCK_DEVICE
	FILETYPE_CHARACTER_DEVICE
	FILETYPE_DIRECTORY
	FILETYPE_REGULAR_FILE
	FILETYPE_SOCKET_DGRAM
	FILETYPE_SOCKET_STREAM
	FILETYPE_SYMBOLIC_LINK
)
View Source
const (
	FstflagsAtim uint16 = 1 << iota
	FstflagsAtimNow
	FstflagsMtim
	FstflagsMtimNow
)

https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#fstflags

View Source
const (
	FdAdviceNormal byte = iota
	FdAdviceSequential
	FdAdviceRandom
	FdAdviceWillNeed
	FdAdviceDontNeed
	FdAdviceNoReuse
)

https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-advice-enumu8

View Source
const (
	// EventTypeClock is the timeout event named "name".
	EventTypeClock = iota
	// EventTypeFdRead is the data available event named "fd_read".
	EventTypeFdRead
	// EventTypeFdWrite is the capacity available event named "fd_write".
	EventTypeFdWrite
)

https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-eventtype-enumu8

View Source
const (
	ProcExitName  = "proc_exit"
	ProcRaiseName = "proc_raise"
)
View Source
const (
	// RIGHT_FD_DATASYNC is the right to invoke fd_datasync. If RIGHT_PATH_OPEN
	// is set, includes the right to invoke path_open with FD_DSYNC.
	RIGHT_FD_DATASYNC uint32 = 1 << iota //nolint

	// RIGHT_FD_READ is he right to invoke fd_read and sock_recv. If
	// RIGHT_FD_SYNC is set, includes the right to invoke fd_pread.
	RIGHT_FD_READ

	// RIGHT_FD_SEEK is the right to invoke fd_seek. This flag implies
	// RIGHT_FD_TELL.
	RIGHT_FD_SEEK

	// RIGHT_FDSTAT_SET_FLAGS is the right to invoke fd_fdstat_set_flags.
	RIGHT_FDSTAT_SET_FLAGS

	// RIGHT_FD_SYNC The right to invoke fd_sync. If path_open is set, includes
	// the right to invoke path_open with FD_RSYNC and FD_DSYNC.
	RIGHT_FD_SYNC

	// RIGHT_FD_TELL is the right to invoke fd_seek in such a way that the file
	// offset remains unaltered (i.e., whence::cur with offset zero), or to
	// invoke fd_tell.
	RIGHT_FD_TELL

	// RIGHT_FD_WRITE is the right to invoke fd_write and sock_send. If
	// RIGHT_FD_SEEK is set, includes the right to invoke fd_pwrite.
	RIGHT_FD_WRITE

	// RIGHT_FD_ADVISE is the right to invoke fd_advise.
	RIGHT_FD_ADVISE

	// RIGHT_FD_ALLOCATE is the right to invoke fd_allocate.
	RIGHT_FD_ALLOCATE

	// RIGHT_PATH_CREATE_DIRECTORY is the right to invoke
	// path_create_directory.
	RIGHT_PATH_CREATE_DIRECTORY

	// RIGHT_PATH_CREATE_FILE when RIGHT_PATH_OPEN is set, the right to invoke
	// path_open with O_CREAT.
	RIGHT_PATH_CREATE_FILE

	// RIGHT_PATH_LINK_SOURCE is the right to invoke path_link with the file
	// descriptor as the source directory.
	RIGHT_PATH_LINK_SOURCE

	// RIGHT_PATH_LINK_TARGET is the right to invoke path_link with the file
	// descriptor as the target directory.
	RIGHT_PATH_LINK_TARGET

	// RIGHT_PATH_OPEN is the right to invoke path_open.
	RIGHT_PATH_OPEN

	// RIGHT_FD_READDIR is the right to invoke fd_readdir.
	RIGHT_FD_READDIR

	// RIGHT_PATH_READLINK is the right to invoke path_readlink.
	RIGHT_PATH_READLINK

	// RIGHT_PATH_RENAME_SOURCE is the right to invoke path_rename with the
	// file descriptor as the source directory.
	RIGHT_PATH_RENAME_SOURCE

	// RIGHT_PATH_RENAME_TARGET is the right to invoke path_rename with the
	// file descriptor as the target directory.
	RIGHT_PATH_RENAME_TARGET

	// RIGHT_PATH_FILESTAT_GET is the right to invoke path_filestat_get.
	RIGHT_PATH_FILESTAT_GET

	// RIGHT_PATH_FILESTAT_SET_SIZE is the right to change a file's size (there
	// is no path_filestat_set_size). If RIGHT_PATH_OPEN is set, includes the
	// right to invoke path_open with O_TRUNC.
	RIGHT_PATH_FILESTAT_SET_SIZE

	// RIGHT_PATH_FILESTAT_SET_TIMES is the right to invoke
	// path_filestat_set_times.
	RIGHT_PATH_FILESTAT_SET_TIMES

	// RIGHT_FD_FILESTAT_GET is the right to invoke fd_filestat_get.
	RIGHT_FD_FILESTAT_GET

	// RIGHT_FD_FILESTAT_SET_SIZE is the right to invoke fd_filestat_set_size.
	RIGHT_FD_FILESTAT_SET_SIZE

	// RIGHT_FD_FILESTAT_SET_TIMES is the right to invoke
	// fd_filestat_set_times.
	RIGHT_FD_FILESTAT_SET_TIMES

	// RIGHT_PATH_SYMLINK is the right to invoke path_symlink.
	RIGHT_PATH_SYMLINK

	// RIGHT_PATH_REMOVE_DIRECTORY is the right to invoke
	// path_remove_directory.
	RIGHT_PATH_REMOVE_DIRECTORY

	// RIGHT_PATH_UNLINK_FILE is the right to invoke path_unlink_file.
	RIGHT_PATH_UNLINK_FILE

	// RIGHT_POLL_FD_READWRITE when RIGHT_FD_READ is set, includes the right to
	// invoke poll_oneoff to subscribe to eventtype::fd_read. If RIGHT_FD_WRITE
	// is set, includes the right to invoke poll_oneoff to subscribe to
	// eventtype::fd_write.
	RIGHT_POLL_FD_READWRITE

	// RIGHT_SOCK_SHUTDOWN is the right to invoke sock_shutdown.
	RIGHT_SOCK_SHUTDOWN
)

See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-rights-flagsu64

View Source
const (
	SockAcceptName   = "sock_accept"
	SockRecvName     = "sock_recv"
	SockSendName     = "sock_send"
	SockShutdownName = "sock_shutdown"
)
View Source
const (
	// SD_RD disables further receive operations.
	SD_RD uint8 = 1 << iota //nolint
	// SD_WR disables further send operations.
	SD_WR
)

SD Flags indicate which channels on a socket to shut down. https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-sdflags-flagsu8

View Source
const (
	// RI_RECV_PEEK returns the message without removing it from the socket's receive queue
	RI_RECV_PEEK uint8 = 1 << iota //nolint
	// RI_RECV_WAITALL on byte-stream sockets, block until the full amount of data can be returned.
	RI_RECV_WAITALL
)

RI Flags are flags provided to sock_recv. https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-riflags-flagsu16

View Source
const DirentSize = uint32(24)

DirentSize is the size of the dirent struct, which should be followed by the length of a file name.

View Source
const InternalModuleName = "wasi_snapshot_preview1"

InternalModuleName is not named ModuleName, to avoid a clash on dot imports.

View Source
const (
	// LOOKUP_SYMLINK_FOLLOW expands a path if it resolves into a symbolic
	// link.
	LOOKUP_SYMLINK_FOLLOW uint16 = 1 << iota //nolint
)

See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#lookupflags

View Source
const (
	PollOneoffName = "poll_oneoff"
)
View Source
const (
	// RO_RECV_DATA_TRUNCATED is returned by sock_recv when message data has been truncated.
	RO_RECV_DATA_TRUNCATED uint8 = 1 << iota //nolint
)

RO Flags are flags returned by sock_recv. https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-roflags-flagsu16

View Source
const RandomGetName = "random_get"
View Source
const SchedYieldName = "sched_yield"

Variables

This section is empty.

Functions

func ErrnoName

func ErrnoName(errno uint32) string

ErrnoName returns the POSIX error code name, except ErrnoSuccess, which is not an error. e.g. Errno2big -> "E2BIG"

func FdFlagsString

func FdFlagsString(fdflags int) string

func FiletypeName

func FiletypeName(filetype uint8) string

FiletypeName returns string name of the file type.

func FstflagsString

func FstflagsString(fdflags int) string

func LookupflagsString

func LookupflagsString(lookupflags int) string

func OflagsString

func OflagsString(oflags int) string

func RiFlagsString added in v1.2.0

func RiFlagsString(riflags int) string

func RightsString

func RightsString(rights int) string

func RoFlagsString added in v1.2.0

func RoFlagsString(roflags int) string

func SdFlagsString added in v1.2.0

func SdFlagsString(sdflags int) string

func SiFlagsString added in v1.2.0

func SiFlagsString(siflags int) string

Types

type Errno

type Errno = uint32

Errno is neither uint16 nor an alias for parity with wasm.ValueType.

const (
	// ErrnoSuccess No error occurred. System call completed successfully.
	ErrnoSuccess Errno = iota
	// Errno2big Argument list too long.
	Errno2big
	// ErrnoAcces Permission denied.
	ErrnoAcces
	// ErrnoAddrinuse Address in use.
	ErrnoAddrinuse
	// ErrnoAddrnotavail Address not available.
	ErrnoAddrnotavail
	// ErrnoAfnosupport Address family not supported.
	ErrnoAfnosupport
	// ErrnoAgain Resource unavailable, or operation would block.
	ErrnoAgain
	// ErrnoAlready Connection already in progress.
	ErrnoAlready
	// ErrnoBadf Bad file descriptor.
	ErrnoBadf
	// ErrnoBadmsg Bad message.
	ErrnoBadmsg
	// ErrnoBusy Device or resource busy.
	ErrnoBusy
	// ErrnoCanceled Operation canceled.
	ErrnoCanceled
	// ErrnoChild No child processes.
	ErrnoChild
	// ErrnoConnaborted Connection aborted.
	ErrnoConnaborted
	// ErrnoConnrefused Connection refused.
	ErrnoConnrefused
	// ErrnoConnreset Connection reset.
	ErrnoConnreset
	// ErrnoDeadlk Resource deadlock would occur.
	ErrnoDeadlk
	// ErrnoDestaddrreq Destination address required.
	ErrnoDestaddrreq
	// ErrnoDom Mathematics argument out of domain of function.
	ErrnoDom
	// ErrnoDquot Reserved.
	ErrnoDquot
	// ErrnoExist File exists.
	ErrnoExist
	// ErrnoFault Bad address.
	ErrnoFault
	// ErrnoFbig File too large.
	ErrnoFbig
	// ErrnoHostunreach Host is unreachable.
	ErrnoHostunreach
	// ErrnoIdrm Identifier removed.
	ErrnoIdrm
	// ErrnoIlseq Illegal byte sequence.
	ErrnoIlseq
	// ErrnoInprogress Operation in progress.
	ErrnoInprogress
	// ErrnoIntr Interrupted function.
	ErrnoIntr
	// ErrnoInval Invalid argument.
	ErrnoInval
	// ErrnoIo I/O error.
	ErrnoIo
	// ErrnoIsconn Socket is connected.
	ErrnoIsconn
	// ErrnoIsdir Is a directory.
	ErrnoIsdir
	// ErrnoLoop Too many levels of symbolic links.
	ErrnoLoop
	// ErrnoMfile File descriptor value too large.
	ErrnoMfile
	// ErrnoMlink Too many links.
	ErrnoMlink
	// ErrnoMsgsize Message too large.
	ErrnoMsgsize
	// ErrnoMultihop Reserved.
	ErrnoMultihop
	// ErrnoNametoolong Filename too long.
	ErrnoNametoolong
	// ErrnoNetdown Network is down.
	ErrnoNetdown
	// ErrnoNetreset Connection aborted by network.
	ErrnoNetreset
	// ErrnoNetunreach Network unreachable.
	ErrnoNetunreach
	// ErrnoNfile Too many files open in system.
	ErrnoNfile
	// ErrnoNobufs No buffer space available.
	ErrnoNobufs
	// ErrnoNodev No such device.
	ErrnoNodev
	// ErrnoNoent No such file or directory.
	ErrnoNoent
	// ErrnoNoexec Executable file format error.
	ErrnoNoexec
	// ErrnoNolck No locks available.
	ErrnoNolck
	// ErrnoNolink Reserved.
	ErrnoNolink
	// ErrnoNomem Not enough space.
	ErrnoNomem
	// ErrnoNomsg No message of the desired type.
	ErrnoNomsg
	// ErrnoNoprotoopt No message of the desired type.
	ErrnoNoprotoopt
	// ErrnoNospc No space left on device.
	ErrnoNospc
	// ErrnoNosys function not supported.
	ErrnoNosys
	// ErrnoNotconn The socket is not connected.
	ErrnoNotconn
	// ErrnoNotdir Not a directory or a symbolic link to a directory.
	ErrnoNotdir
	// ErrnoNotempty Directory not empty.
	ErrnoNotempty
	// ErrnoNotrecoverable State not recoverable.
	ErrnoNotrecoverable
	// ErrnoNotsock Not a socket.
	ErrnoNotsock
	// ErrnoNotsup Not supported, or operation not supported on socket.
	ErrnoNotsup
	// ErrnoNotty Inappropriate I/O control operation.
	ErrnoNotty
	// ErrnoNxio No such device or address.
	ErrnoNxio
	// ErrnoOverflow Value too large to be stored in data type.
	ErrnoOverflow
	// ErrnoOwnerdead Previous owner died.
	ErrnoOwnerdead
	// ErrnoPerm Operation not permitted.
	ErrnoPerm
	// ErrnoPipe Broken pipe.
	ErrnoPipe
	// ErrnoProto Protocol error.
	ErrnoProto
	// ErrnoProtonosupport Protocol error.
	ErrnoProtonosupport
	// ErrnoPrototype Protocol wrong type for socket.
	ErrnoPrototype
	// ErrnoRange Result too large.
	ErrnoRange
	// ErrnoRofs Read-only file system.
	ErrnoRofs
	// ErrnoSpipe Invalid seek.
	ErrnoSpipe
	// ErrnoSrch No such process.
	ErrnoSrch
	// ErrnoStale Reserved.
	ErrnoStale
	// ErrnoTimedout Connection timed out.
	ErrnoTimedout
	// ErrnoTxtbsy Text file busy.
	ErrnoTxtbsy
	// ErrnoXdev Cross-device link.
	ErrnoXdev
)

Note: Below prefers POSIX symbol names over WASI ones, even if the docs are from WASI. See https://linux.die.net/man/3/errno See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#variants-1

func ToErrno

func ToErrno(errno sys.Errno) Errno

ToErrno coerces the error to a WASI Errno.

Note: Coercion isn't centralized in sys.FSContext because ABI use different error codes. For example, wasi-filesystem and GOOS=js don't map to these Errno.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL