Documentation
¶
Overview ¶
Package wasi is a WASI preview 1 (wasi_snapshot_preview1) host written against a byte-addressed guest memory and the engine's rootfs.FS.
It implements every function Go's wasip1 port imports (runtime, syscall, internal/syscall/unix), with the layouts and errno values of the snapshot-01 specification (docs/REFERENCES.md). It knows nothing of a WebAssembly runtime: a host calls Proc.Call with the raw arguments and a Memory, so the same code serves the native executor (as a wazero host module) and the browser executor (from a worker, over shared memory).
Index ¶
Constants ¶
const ( ESUCCESS = 0 E2BIG = 1 EACCES = 2 EAGAIN = 6 EBADF = 8 EEXIST = 20 EFAULT = 21 EINVAL = 28 EIO = 29 EISDIR = 31 ELOOP = 32 ENAMETOOLONG = 37 ENOENT = 44 ENOSPC = 51 ENOSYS = 52 ENOTDIR = 54 ENOTEMPTY = 55 ENOTSUP = 58 EPERM = 63 EROFS = 69 ESPIPE = 70 ENOTCAPABLE = 76 )
Errno values of wasi_snapshot_preview1 (enum order of the spec).
const ( I32 = 'i' I64 = 'I' )
Param types of a function's core-wasm signature.
const MaxFDs = 1024
MaxFDs bounds the descriptors a process may hold.
Variables ¶
var FuncIndex = func() map[string]int { m := make(map[string]int, len(Funcs)) for i, f := range Funcs { m[f.Name] = i } return m }()
FuncIndex maps a name to its index in Funcs.
var Funcs = []Func{ {"args_get", "ii", false}, {"args_sizes_get", "ii", false}, {"environ_get", "ii", false}, {"environ_sizes_get", "ii", false}, {"clock_res_get", "ii", false}, {"clock_time_get", "iIi", false}, {"fd_advise", "iIIi", false}, {"fd_allocate", "iII", false}, {"fd_close", "i", false}, {"fd_datasync", "i", false}, {"fd_fdstat_get", "ii", false}, {"fd_fdstat_set_flags", "ii", false}, {"fd_fdstat_set_rights", "iII", false}, {"fd_filestat_get", "ii", false}, {"fd_filestat_set_size", "iI", false}, {"fd_filestat_set_times", "iIIi", false}, {"fd_pread", "iiiIi", false}, {"fd_prestat_get", "ii", false}, {"fd_prestat_dir_name", "iii", false}, {"fd_pwrite", "iiiIi", false}, {"fd_read", "iiii", false}, {"fd_readdir", "iiiIi", false}, {"fd_renumber", "ii", false}, {"fd_seek", "iIii", false}, {"fd_sync", "i", false}, {"fd_tell", "ii", false}, {"fd_write", "iiii", false}, {"path_create_directory", "iii", false}, {"path_filestat_get", "iiiii", false}, {"path_filestat_set_times", "iiiiIIi", false}, {"path_link", "iiiiiii", false}, {"path_open", "iiiiiIIii", false}, {"path_readlink", "iiiiii", false}, {"path_remove_directory", "iii", false}, {"path_rename", "iiiiii", false}, {"path_symlink", "iiiii", false}, {"path_unlink_file", "iii", false}, {"poll_oneoff", "iiii", false}, {"proc_exit", "i", true}, {"proc_raise", "i", false}, {"sched_yield", "", false}, {"random_get", "ii", false}, {"sock_accept", "iii", false}, {"sock_recv", "iiiiii", false}, {"sock_send", "iiiii", false}, {"sock_shutdown", "ii", false}, }
Funcs lists the imports, in a fixed order a host may index by.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Args, Env []string
FS *rootfs.FS
Stdin io.Reader
Stdout, Stderr io.Writer
// Now is the realtime clock (default time.Now).
Now func() time.Time
// Rand is the randomness source (default crypto/rand).
Rand io.Reader
}
Config is a process's world.
type Func ¶
type Func struct {
Name string
Params string // one of I32/I64 per parameter
// NoResult is set for proc_exit; every other function returns an errno.
NoResult bool
}
Func describes one import.
type Memory ¶
Memory is the guest's linear memory. Read returns a slice valid until the next call on the Memory; both return false out of bounds.