You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Walrus currently registers 37 WASI functions in FOR_EACH_WASI_FUNC (src/wasi/WASI.h), while the WASI preview1 (wasi_snapshot_preview1) specification defines 46 host functions. This issue tracks the remaining 9 unimplemented functions so that Walrus can reach full preview1 coverage.
Since Walrus delegates WASI to uvwasi(https://github.com/nodejs/uvwasi) and uvwasi already exposes an API for every preview1 function, most of these can be implemented as thin wrappers following the existing patterns in src/wasi/WASI.cpp (memory-pointer validation via get_memory_pointer(), TemporaryData<> for iovec marshalling, and WasiErrNo result values).
Wrap uvwasi_fd_fdstat_set_rights(). Note: the rights system only exists in preview1 (removed in later WASI revisions), but it is still part of the snapshot_1 ABI that toolchains such as wasi-sdk target.
Note: uvwasi may return UVWASI_ENOTSUP for sock_recv/sock_send depending on the pinned submodule version. If so, we should still register the functions and propagate the errno, so that modules importing them can at least instantiate (matching the behavior of other runtimes).
Suggested implementation steps (per function)
Add an entry to FOR_EACH_WASI_FUNC in src/wasi/WASI.h with the correct signature string.
Implement the wrapper in src/wasi/WASI.cpp, following the existing conventions:
Validate all guest pointers with get_memory_pointer() and return WasiErrNo::inval on failure.
Use TemporaryData<uvwasi_ciovec_t, 8> for scatter/gather buffers (see fd_write / fd_pread).
Add a test under test/wasi/ (.wast), following existing tests such as fd_seek.wast or path_readlink.wast.
Verify with tools/run-tests.py wasi and run tools/check_tidy.py before submitting the PR.
Related: missing test coverage for already-implemented functions
While auditing test/wasi/, we also noticed some implemented functions have no dedicated test yet. These could be tracked here or split into a separate issue:
fd_pread
fd_readdir
fd_fdstat_set_flags
poll_oneoff
path_rename / path_unlink_file / path_create_directory / path_remove_directory (partially covered by filesystem_functions.wast — dedicated edge-case tests would help)
Notes
We (a group of undergraduate contributors) would like to work on this incrementally, one function per PR, starting with fd_pwrite. Please let us know if this plan works for the maintainers, or if any of these functions are intentionally omitted (e.g., for embedded targets).
[WASI] Implement missing WASI preview1 functions
Summary
Walrus currently registers 37 WASI functions in
FOR_EACH_WASI_FUNC(src/wasi/WASI.h), while the WASI preview1 (wasi_snapshot_preview1) specification defines 46 host functions. This issue tracks the remaining 9 unimplemented functions so that Walrus can reach full preview1 coverage.Since Walrus delegates WASI to uvwasi(https://github.com/nodejs/uvwasi) and uvwasi already exposes an API for every preview1 function, most of these can be implemented as thin wrappers following the existing patterns in
src/wasi/WASI.cpp(memory-pointer validation viaget_memory_pointer(),TemporaryData<>for iovec marshalling, andWasiErrNoresult values).Reference: WASI preview1 documentation
Missing functions
fd operations
fd_allocate—I32I64I64_RI32(fd, offset, len) → errnouvwasi_fd_allocate(). Structure is nearly identical to the existingfd_adviseimplementation.fd_pwrite—I32I32I32I64I32_RI32(fd, iovs, iovs_len, offset, nwritten) → errnouvwasi_fd_pwrite(). Mirror image of the already-implementedfd_pread(useuvwasi_ciovec_tinstead ofuvwasi_iovec_t, same asfd_write).fd_filestat_set_size—I32I64_RI32(fd, size) → errnouvwasi_fd_filestat_set_size().fd_fdstat_set_rights—I32I64I64_RI32(fd, fs_rights_base, fs_rights_inheriting) → errnouvwasi_fd_fdstat_set_rights(). Note: the rights system only exists in preview1 (removed in later WASI revisions), but it is still part of the snapshot_1 ABI that toolchains such as wasi-sdk target.path operations
path_link—I32I32I32I32I32I32I32_RI32(old_fd, old_flags, old_path, old_path_len, new_fd, new_path, new_path_len) → errnouvwasi_path_link(). Two-path pattern similar to the existingpath_rename.path_symlink—I32I32I32I32I32_RI32(old_path, old_path_len, fd, new_path, new_path_len) → errnouvwasi_path_symlink(). Counterpart of the existingpath_readlink.sock operations
sock_accept—I32I32I32_RI32(fd, flags, ro_fd) → errnouvwasi_sock_accept()(available since uvwasi v0.0.12).sock_recv—I32I32I32I32I32I32_RI32(fd, ri_data, ri_data_len, ri_flags, ro_datalen, ro_flags) → errnosock_send—I32I32I32I32I32_RI32(fd, si_data, si_data_len, si_flags, so_datalen) → errnoUVWASI_ENOTSUPforsock_recv/sock_senddepending on the pinned submodule version. If so, we should still register the functions and propagate the errno, so that modules importing them can at least instantiate (matching the behavior of other runtimes).Suggested implementation steps (per function)
FOR_EACH_WASI_FUNCinsrc/wasi/WASI.hwith the correct signature string.src/wasi/WASI.cpp, following the existing conventions:get_memory_pointer()and returnWasiErrNo::invalon failure.TemporaryData<uvwasi_ciovec_t, 8>for scatter/gather buffers (seefd_write/fd_pread).test/wasi/(.wast), following existing tests such asfd_seek.wastorpath_readlink.wast.tools/run-tests.py wasiand runtools/check_tidy.pybefore submitting the PR.Related: missing test coverage for already-implemented functions
While auditing
test/wasi/, we also noticed some implemented functions have no dedicated test yet. These could be tracked here or split into a separate issue:fd_preadfd_readdirfd_fdstat_set_flagspoll_oneoffpath_rename/path_unlink_file/path_create_directory/path_remove_directory(partially covered byfilesystem_functions.wast— dedicated edge-case tests would help)Notes
fd_pwrite. Please let us know if this plan works for the maintainers, or if any of these functions are intentionally omitted (e.g., for embedded targets).