wasm_storage_file (wasm_storage v0.1.0)

View Source

A device backed by a file, through the standard file module.

The file is opened in raw mode: calls go straight to the file driver without a server process in between, and only the process that opened the handle may use it. No native code beyond OTP's own is involved.

{ok, H} = wasm_storage:open({wasm_storage_file, "/var/db/data.redb"},
                            #{create => true}).

Options:

  • create: false (the default) opens an existing file; true creates it when missing; exclusive fails with eexist when it exists.
  • access: read_write (the default) or read. A read-only handle refuses writes, resizes and syncs with ebadf.
  • sync: true (the default). false makes sync/2 return ok without syncing and makes info/1 report the device as volatile. It exists for benchmarks that measure everything but the disk; never use it for data you want back.

sync(H, data) calls file:datasync/1, sync(H, full) calls file:sync/1. What those reach on each platform is in the storage contract.

Summary

Functions

The device and inode of the file, so that two paths of one file conflict in wasm_storage_owner. With create the file is created first, so that the identity exists before anyone opens it.

Functions

identity/2

The device and inode of the file, so that two paths of one file conflict in wasm_storage_owner. With create the file is created first, so that the identity exists before anyone opens it.