wasi_p2_filesystem (wasm v0.16.0)
View SourceThe wasi:filesystem slice of the WASI 0.2 host: filesystem/1 builds the
wasi:filesystem/types and wasi:filesystem/preopens imports over preopened
directories, read-only or writable per mount.
Read it when you change what a descriptor can do. Paths go through wasi_fs,
the same calls Preview 1 makes, so the sandbox is not reimplemented here. The
streams a descriptor opens are the output-stream and input-stream resources
wasi_preview2 serves; this module only mints them, and never calls back into
wasi_preview2.
Summary
Functions
The entries of directory descriptor Dir, each #{type, name}.
wasi:filesystem over preopened directories. get-directories hands the guest
a descriptor for preopen (named name, default /), or one per entry of
mounts as {Name, Dir, Writable}. A mount is read-only unless its flag (or
writable, for the single preopen) says otherwise, and write intent on a
read-only one is refused with read-only. Path resolution and the sandbox are not reimplemented here:
open-at passes the guest path straight to wasi_fs:open/3, the same call
Preview 1 makes, so the same escapes are refused.
Functions
-spec dir_entries(non_neg_integer()) -> {ok, [map()]} | {error, binary()}.
The entries of directory descriptor Dir, each #{type, name}.
-spec filesystem(#{preopen => file:filename_all(), name => binary(), writable => boolean(), mounts => [{binary(), file:filename_all(), boolean()}]}) -> #{{binary(), binary()} => fun()}.
wasi:filesystem over preopened directories. get-directories hands the guest
a descriptor for preopen (named name, default /), or one per entry of
mounts as {Name, Dir, Writable}. A mount is read-only unless its flag (or
writable, for the single preopen) says otherwise, and write intent on a
read-only one is refused with read-only. Path resolution and the sandbox are not reimplemented here:
open-at passes the guest path straight to wasi_fs:open/3, the same call
Preview 1 makes, so the same escapes are refused.