A virtual filesystem layer for WASI.
[!TIP] Please use bytecodealliance/WASI-Virt if you are using WASI Preview2 with Component Model
A virtual filesystem layer for WASI.
NOTICE: This project currently supports only WASI applications on the top of wasi-libc
This project provides a language and host-agnostic virtual filesystem layer for WASI.
.wasm binary.A typical installation from the release binaries might look like the following:
…$ brew tap kateinoigakukun/wasi-vfs https://github.com/kateinoigakukun/wasi-vfs.git
$ brew install kateinoigakukun/wasi-vfs/wasi-vfsTo build the project, you need to install the wasi-sdk version 16.0 or later.
…Set $WASI_SDK_PATH environment variable to the path of the wasi-sdk (version 14 or later).
…$ CARGO_TARGET_WASM32_WASIP1_RUNNER=wasmtime cargo test --target wasm32-wasip1$ cargo build --target wasm32-unknown-unknown
$ LIB_WASI_VFS_A=$PWD/target/wasm32-unknown-unknown/debug/libwasi_vfs.a ./tools/run-make-test.shwasi-vfs pack command is a wrapper of wizer, which is a pre-initializer for Wasm applications.
The initialization process scans the mapped directories, then copies them into in-memory virtual filesystem.
Currently, this project only supports WASI applications on the top of wasi-libc because of the following reasons:
This project depends on wasm-ld and wasi-libc's imported symbol behavior.
wasi-libc declares some external symbols to import WASI functions in C like below. When __imported_wasi_snapshot_preview1_fd_read is not defined in any input object files, wasm-ld produces a (import "wasi_snapshot_preview1" "fd_read") entry. This is how wasi-libc calls WASI functions.
int32_t __imported_wasi_snapshot_preview1_fd_read(int32_t arg0, int32_t arg1, int32_t arg2, int32_t arg3) __attribute__((
__import_module__("wasi_snapshot_preview1"),
__import_name__("fd_read")
));This project exploits that external symbols to hook WASI function calls by defining them in libwasi_vfs.a. If those symbols are defined, wasm-ld doesn't produce import entries, and it links symbols normally.
Therefore, this project currently doesn't support Rust application, which calls WASI functions directly without using wasi-libc.
After module-linking and interface-types will be merged, and WASI will adopt shared-nothing architecture, this project will be able to support all WASI applications.
No open issues yet, or sync has not completed.