Working with the WASI Filesystem
Learn how WASI exposes the host filesystem to a sandboxed module through preopened directories and capability-based file access.
Why Files Need Special Handling
A WASM module has no ambient authority — it cannot open any file by default. WASI grants file access only through preopened directories handed to the module at startup.
- No path traversal outside what was granted
- Access is capability-based, not permission-based
Preopened Directories
When a runtime launches a module it can map a host folder to a guest path. The module receives a file descriptor for each mapping.
Example with wasmtime: wasmtime --dir=. app.wasm grants the current directory.
wasmtime run --dir=./data app.wasmAll lessons in this course
- Introduction to WASI & Its Goals
- Building & Running WASI Modules
- WASI Capabilities & Future
- Working with the WASI Filesystem