Expand description
Layer 1 phase C1, part 2/2: custom wasi:filesystem host impl that gates
open_at (and path-taking siblings) on the FsMatcher.
The host-facing surface:
PolicyFilesystemis aHasDatamarker used in place of the defaultwasmtime_wasi::WasiFilesystemwhen adding thewasi:filesystem/typesandwasi:filesystem/preopensinterfaces to the linker.PolicyFilesystemCtxView<'a>bundles the defaultWasiFilesystemCtx, theResourceTable, the compiledFsMatcher, and a running map offd → absolute host path. It implementspreopens::Host,types::Host,HostDescriptor, andHostDirectoryEntryStream, mostly by delegating to a tempWasiFilesystemCtxViewconstructed from the same fields.- Path-taking methods (
open_at,stat_at,readlink_at,create_directory_at,remove_directory_at,unlink_file_at,rename_at,link_at,symlink_at,metadata_hash_at,set_times_at) resolve the parent fd’s host path, join the guest-supplied relative path, canonicalise, and consult the matcher. Deny →ErrorCode::NotPermitted; allow → delegate and (foropen_at) record the resulting fd’s host path.
fd→path tracking:
- Preopens are recorded at construction (we know their host paths from
derive_preopensbefore callingWasiCtxBuilder::preopened_dir). Their Resource reps aren’t known at that point; we match reps to host paths lazily the first timeget_directories()is called. - New descriptors produced by
open_atare recorded with the canonicalised child path.
Structs§
- FdPath
Map - Tracks the host path associated with each open filesystem descriptor,
plus the configured preopen list (guest path → host path) used to fill
in the map lazily the first time the guest calls
get-directories. - Policy
Filesystem HasDatamarker for our policy-aware filesystem view.- Policy
Filesystem CtxView - Per-call view bundling all state the policy wrapper needs.
- Preopen
- A (guest path → host path) pair handed to wasmtime-wasi’s
preopened_dir. - Resolved
Mount - A resolved mount: concrete guest path + (for binds) an expanded host dir.
Functions§
- create_
mount_ dirs - Create missing
bindhost directories so they can be preopened.rootmounts point at the platform root and create nothing. - derive_
preopens - Build the preopen list from resolved mounts.
- resolve_
mounts - Resolve a component’s declared mounts into concrete topology.