- Imports:
- interface
wasi:poll/poll
- interface
wasi:io/streams
- interface
wasi:clocks/wall-clock
- interface
wasi:filesystem/types
- interface
wasi:filesystem/preopens
- interface
A poll API intended to let users wait for I/O events on multiple handles at once.
u32
A "pollable" handle.
This is conceptually represents a stream<_, _>
, or in other words,
a stream that one can wait on, repeatedly, but which does not itself
produce any data. It's temporary scaffolding until component-model's
async features are ready.
And at present, it is a u32
instead of being an actual handle, until
the wit-bindgen implementation of handles and resources is ready.
pollable
lifetimes are not automatically managed. Users must ensure
that they do not outlive the resource they reference.
This represents a resource.
Dispose of the specified pollable
, after which it may no longer
be used.
Poll for completion on a set of pollables.
The "oneoff" in the name refers to the fact that this function must do a linear scan through the entire list of subscriptions, which may be inefficient if the number is large and the same subscriptions are used many times. In the future, this is expected to be obsoleted by the component model async proposal, which will include a scalable waiting facility.
Note that the return type would ideally be list<bool>
, but that would
be more difficult to polyfill given the current state of wit-bindgen
.
See bytecodealliance/preview2-prototyping#11 (comment)
for details. For now, we use zero to mean "not ready" and non-zero to
mean "ready".
WASI I/O is an I/O abstraction API which is currently focused on providing stream types.
In the future, the component model is expected to add built-in stream types; when it does, they are expected to subsume this API.
An error type returned from a stream operation. Currently this doesn't provide any additional information.
u32
An output bytestream. In the future, this will be replaced by handle types.
This conceptually represents a stream<u8, _>
. It's temporary
scaffolding until component-model's async features are ready.
output-stream
s are non-blocking to the extent practical on
underlying platforms. Except where specified otherwise, I/O operations also
always return promptly, after the number of bytes that can be written
promptly, which could even be zero. To wait for the stream to be ready to
accept data, the subscribe-to-output-stream
function to obtain a
pollable
which can be polled for using wasi_poll
.
And at present, it is a u32
instead of being an actual handle, until
the wit-bindgen implementation of handles and resources is ready.
This represents a resource.
u32
An input bytestream. In the future, this will be replaced by handle types.
This conceptually represents a stream<u8, _>
. It's temporary
scaffolding until component-model's async features are ready.
input-stream
s are non-blocking to the extent practical on underlying
platforms. I/O operations always return promptly; if fewer bytes are
promptly available than requested, they return the number of bytes promptly
available, which could even be zero. To wait for data to be available,
use the subscribe-to-input-stream
function to obtain a pollable
which
can be polled for using wasi_poll
.
And at present, it is a u32
instead of being an actual handle, until
the wit-bindgen implementation of handles and resources is ready.
This represents a resource.
Read bytes from a stream.
This function returns a list of bytes containing the data that was
read, along with a bool which, when true, indicates that the end of the
stream was reached. The returned list will contain up to len
bytes; it
may return fewer than requested, but not more.
Once a stream has reached the end, subsequent calls to read or
skip
will always report end-of-stream rather than producing more
data.
If len
is 0, it represents a request to read 0 bytes, which should
always succeed, assuming the stream hasn't reached its end yet, and
return an empty list.
The len here is a u64
, but some callees may not be able to allocate
a buffer as large as that would imply.
FIXME: describe what happens if allocation fails.
this
:input-stream
len
:u64
- result<(list<
u8
>,bool
),stream-error
>
Read bytes from a stream, with blocking.
This is similar to read
, except that it blocks until at least one
byte can be read.
this
:input-stream
len
:u64
- result<(list<
u8
>,bool
),stream-error
>
Skip bytes from a stream.
This is similar to the read
function, but avoids copying the
bytes into the instance.
Once a stream has reached the end, subsequent calls to read or
skip
will always report end-of-stream rather than producing more
data.
This function returns the number of bytes skipped, along with a bool
indicating whether the end of the stream was reached. The returned
value will be at most len
; it may be less.
this
:input-stream
len
:u64
- result<(
u64
,bool
),stream-error
>
Skip bytes from a stream, with blocking.
This is similar to skip
, except that it blocks until at least one
byte can be consumed.
this
:input-stream
len
:u64
- result<(
u64
,bool
),stream-error
>
Create a pollable
which will resolve once either the specified stream
has bytes available to read or the other end of the stream has been
closed.
Dispose of the specified input-stream
, after which it may no longer
be used.
Write bytes to a stream.
This function returns a u64
indicating the number of bytes from
buf
that were written; it may be less than the full list.
this
:output-stream
buf
: list<u8
>
- result<
u64
,stream-error
>
Write bytes to a stream, with blocking.
This is similar to write
, except that it blocks until at least one
byte can be written.
this
:output-stream
buf
: list<u8
>
- result<
u64
,stream-error
>
Write multiple zero bytes to a stream.
This function returns a u64
indicating the number of zero bytes
that were written; it may be less than len
.
this
:output-stream
len
:u64
- result<
u64
,stream-error
>
Write multiple zero bytes to a stream, with blocking.
This is similar to write-zeroes
, except that it blocks until at least
one byte can be written.
this
:output-stream
len
:u64
- result<
u64
,stream-error
>
Read from one stream and write to another.
This function returns the number of bytes transferred; it may be less
than len
.
Unlike other I/O functions, this function blocks until all the data read from the input stream has been written to the output stream.
this
:output-stream
src
:input-stream
len
:u64
- result<(
u64
,bool
),stream-error
>
Read from one stream and write to another, with blocking.
This is similar to splice
, except that it blocks until at least
one byte can be read.
this
:output-stream
src
:input-stream
len
:u64
- result<(
u64
,bool
),stream-error
>
Forward the entire contents of an input stream to an output stream.
This function repeatedly reads from the input stream and writes the data to the output stream, until the end of the input stream is reached, or an error is encountered.
Unlike other I/O functions, this function blocks until the end of the input stream is seen and all the data has been written to the output stream.
This function returns the number of bytes transferred.
- result<
u64
,stream-error
>
Create a pollable
which will resolve once either the specified stream
is ready to accept bytes or the other end of the stream has been closed.
Dispose of the specified output-stream
, after which it may no longer
be used.
WASI Wall Clock is a clock API intended to let users query the current time. The name "wall" makes an analogy to a "clock on the wall", which is not necessarily monotonic as it may be reset.
It is intended to be portable at least between Unix-family platforms and Windows.
A wall clock is a clock which measures the date and time according to some external reference.
External references may be reset, so this clock is not necessarily monotonic, making it unsuitable for measuring elapsed time.
It is intended for reporting the current date and time for humans.
A time and date in seconds plus nanoseconds.
seconds
:u64
nanoseconds
:u32
Read the current value of the clock.
This clock is not monotonic, therefore calling this function repeatedly will not necessarily produce a sequence of non-decreasing values.
The returned timestamps represent the number of seconds since 1970-01-01T00:00:00Z, also known as POSIX's Seconds Since the Epoch, also known as Unix Time.
The nanoseconds field of the output is always less than 1000000000.
Query the resolution of the clock.
The nanoseconds field of the output is always less than 1000000000.
WASI filesystem is a filesystem API primarily intended to let users run WASI programs that access their files on their existing filesystems, without significant overhead.
It is intended to be roughly portable between Unix-family platforms and Windows, though it does not hide many of the major differences.
Paths are passed as interface-type string
s, meaning they must consist of
a sequence of Unicode Scalar Values (USVs). Some filesystems may contain
paths which are not accessible by this API.
The directory separator in WASI is always the forward-slash (/
).
All paths in WASI are relative paths, and are interpreted relative to a
descriptor
referring to a base directory. If a path
argument to any WASI
function starts with /
, or if any step of resolving a path
, including
..
and symbolic link steps, reaches a directory outside of the base
directory, or reaches a symlink to an absolute or rooted path in the
underlying filesystem, the function fails with error-code::not-permitted
.
#### `type output-stream` [`output-stream`](#output_stream)
#### `type datetime` [`datetime`](#datetime)
#### `flags path-flags`
Flags determining the method of how paths are resolved.
symlink-follow
:As long as the resolved path corresponds to a symbolic link, it is expanded.
Open flags used by open-at
.
-
Create file if it does not exist, similar to `O_CREAT` in POSIX.
-
Fail if not a directory, similar to `O_DIRECTORY` in POSIX.
-
Fail if file already exists, similar to `O_EXCL` in POSIX.
-
Truncate file to size 0, similar to `O_TRUNC` in POSIX.
Permissions mode used by open-at
, change-file-permissions-at
, and
similar.
-
True if the resource is considered readable by the containing filesystem.
-
True if the resource is considered writable by the containing filesystem.
-
True if the resource is considered executable by the containing filesystem. This does not apply to directories.
u64
Number of hard links to an inode.
u64
Filesystem object serial number that is unique within its file system.
u64
File size or length of a region within a file.
Error codes returned by functions, similar to errno
in POSIX.
Not all of these error codes are returned by the functions provided by this
API; some are used in higher-level library layers, and others are provided
merely for alignment with POSIX.
-
Permission denied, similar to `EACCES` in POSIX.
-
Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX.
-
Connection already in progress, similar to `EALREADY` in POSIX.
-
Bad descriptor, similar to `EBADF` in POSIX.
-
Device or resource busy, similar to `EBUSY` in POSIX.
-
Resource deadlock would occur, similar to `EDEADLK` in POSIX.
-
Storage quota exceeded, similar to `EDQUOT` in POSIX.
-
File exists, similar to `EEXIST` in POSIX.
-
File too large, similar to `EFBIG` in POSIX.
-
Illegal byte sequence, similar to `EILSEQ` in POSIX.
-
Operation in progress, similar to `EINPROGRESS` in POSIX.
-
Interrupted function, similar to `EINTR` in POSIX.
-
Invalid argument, similar to `EINVAL` in POSIX.
-
I/O error, similar to `EIO` in POSIX.
-
Is a directory, similar to `EISDIR` in POSIX.
-
Too many levels of symbolic links, similar to `ELOOP` in POSIX.
-
Too many links, similar to `EMLINK` in POSIX.
-
Message too large, similar to `EMSGSIZE` in POSIX.
-
Filename too long, similar to `ENAMETOOLONG` in POSIX.
-
No such device, similar to `ENODEV` in POSIX.
-
No such file or directory, similar to `ENOENT` in POSIX.
-
No locks available, similar to `ENOLCK` in POSIX.
-
Not enough space, similar to `ENOMEM` in POSIX.
-
No space left on device, similar to `ENOSPC` in POSIX.
-
Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX.
-
Directory not empty, similar to `ENOTEMPTY` in POSIX.
-
State not recoverable, similar to `ENOTRECOVERABLE` in POSIX.
-
Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX.
-
Inappropriate I/O control operation, similar to `ENOTTY` in POSIX.
-
No such device or address, similar to `ENXIO` in POSIX.
-
Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX.
-
Operation not permitted, similar to `EPERM` in POSIX.
-
Broken pipe, similar to `EPIPE` in POSIX.
-
Read-only file system, similar to `EROFS` in POSIX.
-
Invalid seek, similar to `ESPIPE` in POSIX.
-
Text file busy, similar to `ETXTBSY` in POSIX.
-
Cross-device link, similar to `EXDEV` in POSIX.
u32
A stream of directory entries.
This represents a stream of dir-entry
.
u64
Identifier for a device containing a file system. Can be used in combination with `inode` to uniquely identify a file or directory in the filesystem.
The type of a filesystem object referenced by a descriptor.
Note: This was called filetype
in earlier versions of WASI.
-
The type of the descriptor or file is unknown or is different from any of the other types specified.
-
The descriptor refers to a block device inode.
-
The descriptor refers to a character device inode.
-
The descriptor refers to a directory inode.
-
The descriptor refers to a named pipe.
-
The file refers to a symbolic link inode.
-
The descriptor refers to a regular file inode.
-
The descriptor refers to a socket.
A directory entry.
-
The serial number of the object referred to by this directory entry. May be none if the inode value is not known.
When this is none, libc implementations might do an extra
stat-at
call to retrieve the inode number to fill theird_ino
fields, so implementations which can set this to a non-none value should do so. -
The type of the file referred to by this directory entry.
-
name
:string
The name of the object.
Descriptor flags.
Note: This was called fdflags
in earlier versions of WASI.
-
read
:Read mode: Data can be read.
-
Write mode: Data can be written to.
-
Requests non-blocking operation.
When this flag is enabled, functions may return immediately with an
error-code::would-block
error code in situations where they would otherwise block. However, this non-blocking behavior is not required. Implementations are permitted to ignore this flag and block. This is similar toO_NONBLOCK
in POSIX. -
Request that writes be performed according to synchronized I/O file integrity completion. The data stored in the file and the file's metadata are synchronized. This is similar to `O_SYNC` in POSIX.
The precise semantics of this operation have not yet been defined for WASI. At this time, it should be interpreted as a request, and not a requirement.
-
Request that writes be performed according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized. This is similar to `O_DSYNC` in POSIX.
The precise semantics of this operation have not yet been defined for WASI. At this time, it should be interpreted as a request, and not a requirement.
-
Requests that reads be performed at the same level of integrety requested for writes. This is similar to `O_RSYNC` in POSIX.
The precise semantics of this operation have not yet been defined for WASI. At this time, it should be interpreted as a request, and not a requirement.
-
Mutating directories mode: Directory contents may be mutated.
When this flag is unset on a descriptor, operations using the descriptor which would create, rename, delete, modify the data or metadata of filesystem objects, or obtain another handle which would permit any of those, shall fail with
error-code::read-only
if they would otherwise succeed.This may only be set on directories.
u32
A descriptor is a reference to a filesystem object, which may be a file, directory, named pipe, special file, or other object on which filesystem calls may be made.
This represents a resource.
When setting a timestamp, this gives the value to set it to.
-
Leave the timestamp set to its previous value.
-
Set the timestamp to the current time of the system clock associated with the filesystem.
-
Set the timestamp to the given value.
File attributes.
Note: This was called filestat
in earlier versions of WASI.
-
Device ID of device containing the file.
-
File serial number.
-
File type.
-
Number of hard links to the file.
-
For regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link.
-
data-access-timestamp
:datetime
Last data access timestamp.
-
data-modification-timestamp
:datetime
Last data modification timestamp.
-
status-change-timestamp
:datetime
Last file status change timestamp.
File or memory access pattern advisory information.
-
The application has no advice to give on its behavior with respect to the specified data.
-
The application expects to access the specified data sequentially from lower offsets to higher offsets.
-
The application expects to access the specified data in a random order.
-
The application expects to access the specified data in the near future.
-
The application expects that it will not access the specified data in the near future.
-
The application expects to access the specified data once and then not reuse it thereafter.
Access type used by access-at
.
-
Test for readability, writeability, or executability.
-
Test whether the path exists.
Return a stream for reading from a file, if available.
May fail with an error-code describing why the file cannot be read.
Multiple read, write, and append streams may be active on the same open file and they do not interfere with each other.
Note: This allows using read-stream
, which is similar to read
in POSIX.
- result<
input-stream
,error-code
>
Return a stream for writing to a file, if available.
May fail with an error-code describing why the file cannot be written.
Note: This allows using write-stream
, which is similar to write
in
POSIX.
- result<
output-stream
,error-code
>
Return a stream for appending to a file, if available.
May fail with an error-code describing why the file cannot be appended.
Note: This allows using write-stream
, which is similar to write
with
O_APPEND
in in POSIX.
- result<
output-stream
,error-code
>
Provide file advisory information on a descriptor.
This is similar to posix_fadvise
in POSIX.
- result<_,
error-code
>
Synchronize the data of a file to disk.
This function succeeds with no effect if the file descriptor is not opened for writing.
Note: This is similar to fdatasync
in POSIX.
- result<_,
error-code
>
Get flags associated with a descriptor.
Note: This returns similar flags to fcntl(fd, F_GETFL)
in POSIX.
Note: This returns the value that was the fs_flags
value returned
from fdstat_get
in earlier versions of WASI.
- result<
descriptor-flags
,error-code
>
Get the dynamic type of a descriptor.
Note: This returns the same value as the type
field of the fd-stat
returned by stat
, stat-at
and similar.
Note: This returns similar flags to the st_mode & S_IFMT
value provided
by fstat
in POSIX.
Note: This returns the value that was the fs_filetype
value returned
from fdstat_get
in earlier versions of WASI.
- result<
descriptor-type
,error-code
>
Set status flags associated with a descriptor.
This function may only change the non-blocking
flag.
Note: This is similar to fcntl(fd, F_SETFL, flags)
in POSIX.
Note: This was called fd_fdstat_set_flags
in earlier versions of WASI.
- result<_,
error-code
>
Adjust the size of an open file. If this increases the file's size, the extra bytes are filled with zeros.
Note: This was called fd_filestat_set_size
in earlier versions of WASI.
- result<_,
error-code
>
Adjust the timestamps of an open file or directory.
Note: This is similar to futimens
in POSIX.
Note: This was called fd_filestat_set_times
in earlier versions of WASI.
- result<_,
error-code
>
Read from a descriptor, without using and updating the descriptor's offset.
This function returns a list of bytes containing the data that was
read, along with a bool which, when true, indicates that the end of the
file was reached. The returned list will contain up to length
bytes; it
may return fewer than requested, if the end of the file is reached or
if the I/O operation is interrupted.
In the future, this may change to return a stream<u8, error-code>
.
Note: This is similar to pread
in POSIX.
- result<(list<
u8
>,bool
),error-code
>
Write to a descriptor, without using and updating the descriptor's offset.
It is valid to write past the end of a file; the file is extended to the extent of the write, with bytes between the previous end and the start of the write set to zero.
In the future, this may change to take a stream<u8, error-code>
.
Note: This is similar to pwrite
in POSIX.
this
:descriptor
buffer
: list<u8
>offset
:filesize
- result<
filesize
,error-code
>
Read directory entries from a directory.
On filesystems where directories contain entries referring to themselves
and their parents, often named .
and ..
respectively, these entries
are omitted.
This always returns a new stream which starts at the beginning of the directory. Multiple streams may be active on the same directory, and they do not interfere with each other.
- result<
directory-entry-stream
,error-code
>
Synchronize the data and metadata of a file to disk.
This function succeeds with no effect if the file descriptor is not opened for writing.
Note: This is similar to fsync
in POSIX.
- result<_,
error-code
>
Create a directory.
Note: This is similar to mkdirat
in POSIX.
this
:descriptor
path
:string
- result<_,
error-code
>
Return the attributes of an open file or directory.
Note: This is similar to fstat
in POSIX.
Note: This was called fd_filestat_get
in earlier versions of WASI.
- result<
descriptor-stat
,error-code
>
Return the attributes of a file or directory.
Note: This is similar to fstatat
in POSIX.
Note: This was called path_filestat_get
in earlier versions of WASI.
this
:descriptor
path-flags
:path-flags
path
:string
- result<
descriptor-stat
,error-code
>
Adjust the timestamps of a file or directory.
Note: This is similar to utimensat
in POSIX.
Note: This was called path_filestat_set_times
in earlier versions of
WASI.
this
:descriptor
path-flags
:path-flags
path
:string
data-access-timestamp
:new-timestamp
data-modification-timestamp
:new-timestamp
- result<_,
error-code
>
Create a hard link.
Note: This is similar to linkat
in POSIX.
this
:descriptor
old-path-flags
:path-flags
old-path
:string
new-descriptor
:descriptor
new-path
:string
- result<_,
error-code
>
Open a file or directory.
The returned descriptor is not guaranteed to be the lowest-numbered descriptor not currently open/ it is randomized to prevent applications from depending on making assumptions about indexes, since this is error-prone in multi-threaded contexts. The returned descriptor is guaranteed to be less than 2**31.
If flags
contains descriptor-flags::mutate-directory
, and the base
descriptor doesn't have descriptor-flags::mutate-directory
set,
open-at
fails with error-code::read-only
.
If flags
contains write
or mutate-directory
, or open-flags
contains truncate
or create
, and the base descriptor doesn't have
descriptor-flags::mutate-directory
set, open-at
fails with
error-code::read-only
.
Note: This is similar to openat
in POSIX.
this
:descriptor
path-flags
:path-flags
path
:string
open-flags
:open-flags
flags
:descriptor-flags
modes
:modes
- result<
descriptor
,error-code
>
Read the contents of a symbolic link.
If the contents contain an absolute or rooted path in the underlying
filesystem, this function fails with error-code::not-permitted
.
Note: This is similar to readlinkat
in POSIX.
this
:descriptor
path
:string
- result<
string
,error-code
>
Remove a directory.
Return error-code::not-empty
if the directory is not empty.
Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR)
in POSIX.
this
:descriptor
path
:string
- result<_,
error-code
>
Rename a filesystem object.
Note: This is similar to renameat
in POSIX.
this
:descriptor
old-path
:string
new-descriptor
:descriptor
new-path
:string
- result<_,
error-code
>
Create a symbolic link (also known as a "symlink").
If old-path
starts with /
, the function fails with
error-code::not-permitted
.
Note: This is similar to symlinkat
in POSIX.
this
:descriptor
old-path
:string
new-path
:string
- result<_,
error-code
>
Check accessibility of a filesystem path.
Check whether the given filesystem path names an object which is readable, writable, or executable, or whether it exists.
This does not a guarantee that subsequent accesses will succeed, as filesystem permissions may be modified asynchronously by external entities.
Note: This is similar to faccessat
with the AT_EACCESS
flag in POSIX.
this
:descriptor
path-flags
:path-flags
path
:string
type
:access-type
- result<_,
error-code
>
Unlink a filesystem object that is not a directory.
Return error-code::is-directory
if the path refers to a directory.
Note: This is similar to unlinkat(fd, path, 0)
in POSIX.
this
:descriptor
path
:string
- result<_,
error-code
>
Change the permissions of a filesystem object that is not a directory.
Note that the ultimate meanings of these permissions is filesystem-specific.
Note: This is similar to fchmodat
in POSIX.
this
:descriptor
path-flags
:path-flags
path
:string
modes
:modes
- result<_,
error-code
>
Change the permissions of a directory.
Note that the ultimate meanings of these permissions is filesystem-specific.
Unlike in POSIX, the executable
flag is not reinterpreted as a "search"
flag. read
on a directory implies readability and searchability, and
execute
is not valid for directories.
Note: This is similar to fchmodat
in POSIX.
this
:descriptor
path-flags
:path-flags
path
:string
modes
:modes
- result<_,
error-code
>
Request a shared advisory lock for an open file.
This requests a shared lock; more than one shared lock can be held for a file at the same time.
If the open file has an exclusive lock, this function downgrades the lock to a shared lock. If it has a shared lock, this function has no effect.
This requests an advisory lock, meaning that the file could be accessed by other programs that don't hold the lock.
It is unspecified how shared locks interact with locks acquired by non-WASI programs.
This function blocks until the lock can be acquired.
Not all filesystems support locking; on filesystems which don't support
locking, this function returns error-code::unsupported
.
Note: This is similar to flock(fd, LOCK_SH)
in Unix.
- result<_,
error-code
>
Request an exclusive advisory lock for an open file.
This requests an exclusive lock; no other locks may be held for the file while an exclusive lock is held.
If the open file has a shared lock and there are no exclusive locks held for the file, this function upgrades the lock to an exclusive lock. If the open file already has an exclusive lock, this function has no effect.
This requests an advisory lock, meaning that the file could be accessed by other programs that don't hold the lock.
It is unspecified whether this function succeeds if the file descriptor is not opened for writing. It is unspecified how exclusive locks interact with locks acquired by non-WASI programs.
This function blocks until the lock can be acquired.
Not all filesystems support locking; on filesystems which don't support
locking, this function returns error-code::unsupported
.
Note: This is similar to flock(fd, LOCK_EX)
in Unix.
- result<_,
error-code
>
Request a shared advisory lock for an open file.
This requests a shared lock; more than one shared lock can be held for a file at the same time.
If the open file has an exclusive lock, this function downgrades the lock to a shared lock. If it has a shared lock, this function has no effect.
This requests an advisory lock, meaning that the file could be accessed by other programs that don't hold the lock.
It is unspecified how shared locks interact with locks acquired by non-WASI programs.
This function returns error-code::would-block
if the lock cannot be
acquired.
Not all filesystems support locking; on filesystems which don't support
locking, this function returns error-code::unsupported
.
Note: This is similar to flock(fd, LOCK_SH | LOCK_NB)
in Unix.
- result<_,
error-code
>
Request an exclusive advisory lock for an open file.
This requests an exclusive lock; no other locks may be held for the file while an exclusive lock is held.
If the open file has a shared lock and there are no exclusive locks held for the file, this function upgrades the lock to an exclusive lock. If the open file already has an exclusive lock, this function has no effect.
This requests an advisory lock, meaning that the file could be accessed by other programs that don't hold the lock.
It is unspecified whether this function succeeds if the file descriptor is not opened for writing. It is unspecified how exclusive locks interact with locks acquired by non-WASI programs.
This function returns error-code::would-block
if the lock cannot be
acquired.
Not all filesystems support locking; on filesystems which don't support
locking, this function returns error-code::unsupported
.
Note: This is similar to flock(fd, LOCK_EX | LOCK_NB)
in Unix.
- result<_,
error-code
>
Release a shared or exclusive lock on an open file.
Note: This is similar to flock(fd, LOCK_UN)
in Unix.
- result<_,
error-code
>
Dispose of the specified descriptor
, after which it may no longer
be used.
Read a single directory entry from a directory-entry-stream
.
- result<option<
directory-entry
>,error-code
>
Dispose of the specified directory-entry-stream
, after which it may no longer
be used.
----
Return the set of preopened directories, and their path.
- list<(
descriptor
,string
)>