0Pricing
WebAssembly (WASM) for High Performance Apps · Lesson

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.wasm

All lessons in this course

  1. Introduction to WASI & Its Goals
  2. Building & Running WASI Modules
  3. WASI Capabilities & Future
  4. Working with the WASI Filesystem
← Back to WebAssembly (WASM) for High Performance Apps