wasm_storage_dir (wasm_storage v0.1.0)
View SourceA namespace in a host directory, through the standard file module.
{ok, Root} = wasm_storage_ns:root({wasm_storage_dir, "/var/db/app"},
#{create => true}).Root options: create (make the directory if missing, default false) and
access (read_write, the default, or read). Devices are
wasm_storage_file handles.
What it guarantees, and what it cannot:
- A path never leaves the root:
wasm_storage_nsrefuses..and absolute paths, and this provider refuses a symbolic link anywhere in the path, final component included, witheloop. - The check and the open are two steps. A process that can change the
directory between them can still swap a link in. Without native code there
is no
openat(O_NOFOLLOW); do not grant a root that untrusted processes can write. rename/3isrename(2): atomic within one filesystem, replacing the target.sync_directory/2returns{error, enotsup}. OTP'sfilemodule refuses to open a directory (eisdir), so a directory cannot be fsynced without native code. A creation, deletion or rename is durable only once the filesystem flushes its metadata on its own. Engines that depend on it must use a commit protocol that does not, see the storage contract.