Host modules¶
WasmVM ships with a built-in sysenv host that exposes a small POSIX-style
interface to wasm modules. It is split into two sub-modules — sys_fs for
filesystem operations and sys_proc for process / environment access — both
registered automatically by wasmvm unless --no-system is supplied.
WasmVM targets the 64-bit memory model (wasm64), so every function below is
registered with i64 pointer and length parameters. Other scalar arguments
(fd, flags, mode, whence, clk_id …) remain i32.
Pointer / length convention¶
For functions that take buffers, parameter pairs named ptr and len are
i64 and refer to a contiguous range in memory 0 of the calling module.
Negative i32 return values are POSIX-style errors: the magnitude equals the
host’s errno after the failed syscall.
sys_fs¶
Filesystem operations.
Function |
Signature |
Description |
|---|---|---|
|
|
Open a path; returns a wasm fd ( |
|
|
Close a wasm fd. |
|
|
Read up to |
|
|
Write up to |
|
|
Seek; returns the new offset or a negative error. |
|
|
Stat a path into |
|
|
Stat by file descriptor. |
|
|
Remove a file. |
|
|
Rename or move a path. |
|
|
Create a directory. |
|
|
Remove an empty directory. |
|
|
Write the current working directory into |
|
|
Open a directory iterator; returns a directory fd. |
|
|
Read the next entry into |
|
|
Close a directory iterator. |
sys_proc¶
Process and environment access.
Function |
Signature |
Description |
|---|---|---|
|
|
Terminate the wasm program with the given exit code. |
|
|
Number of command-line arguments. Argument 0 is the main module
path; subsequent arguments come from |
|
|
Length in bytes of argument |
|
|
Copy argument |
|
|
Look up an environment variable and copy it into |
|
|
Read a monotonic / realtime clock into a |
Disabling the host¶
Pass --no-system (-ns) to wasmvm to disable automatic
instantiation of sys_fs and sys_proc. This is useful when running
modules that should not be granted filesystem or process access.