Types

<a href="#size" name="size"></a> size: u32

Size: 4
Alignment: 4

<a href="#filesize" name="filesize"></a> filesize: u64

Non-negative file size or length of a region within a file.
Size: 8
Alignment: 8

<a href="#timestamp" name="timestamp"></a> timestamp: u64

Timestamp in nanoseconds.
Size: 8
Alignment: 8

<a href="#clockid" name="clockid"></a> clockid: Enum(u32)

Identifiers for clocks.
Size: 4
Alignment: 4

Variants

<a href="#errno" name="errno"></a> errno: Enum(u16)

Error codes returned by functions.
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.
Size: 2
Alignment: 2

Variants

<a href="#rights" name="rights"></a> rights: Flags(u64)

File descriptor rights, determining which actions may be performed.
Size: 8
Alignment: 8

Flags

<a href="#fd" name="fd"></a> fd

A file descriptor handle.
Size: 4
Alignment: 4

Supertypes

<a href="#iovec" name="iovec"></a> iovec: Struct

A region of memory for scatter/gather reads.
Size: 8
Alignment: 4

Struct members

<a href="#dircookie" name="dircookie"></a> dircookie: u64

A reference to the offset of a directory entry.

The value 0 signifies the start of the directory.
Size: 8
Alignment: 8

<a href="#dirnamlen" name="dirnamlen"></a> dirnamlen: u32

The type for the $d_namlen field of $dirent.
Size: 4
Alignment: 4

<a href="#inode" name="inode"></a> inode: u64

File serial number that is unique within its file system.
Size: 8
Alignment: 8

<a href="#filetype" name="filetype"></a> filetype: Enum(u8)

The type of a file descriptor or file.
Size: 1
Alignment: 1

Variants

<a href="#dirent" name="dirent"></a> dirent: Struct

A directory entry.
Size: 24
Alignment: 8

Struct members

<a href="#fdflags" name="fdflags"></a> fdflags: Flags(u16)

File descriptor flags.
Size: 2
Alignment: 2

Flags

<a href="#fdstat" name="fdstat"></a> fdstat: Struct

File descriptor attributes.
Size: 24
Alignment: 8

Struct members

<a href="#lookupflags" name="lookupflags"></a> lookupflags: Flags(u32)

Flags determining the method of how paths are resolved.
Size: 4
Alignment: 4

Flags

<a href="#oflags" name="oflags"></a> oflags: Flags(u16)

Open flags used by path_open.
Size: 2
Alignment: 2

Flags

<a href="#linkcount" name="linkcount"></a> linkcount: u64

Number of hard links to an inode.
Size: 8
Alignment: 8

<a href="#filestat" name="filestat"></a> filestat: Struct

File attributes.
Size: 64
Alignment: 8

Struct members

<a href="#eventrwflags" name="eventrwflags"></a> eventrwflags: Flags(u16)

The state of the file descriptor subscribed to with
eventtype::fd_read or eventtype::fd_write.
Size: 2
Alignment: 2

Flags

<a href="#event_fd_readwrite" name="event_fd_readwrite"></a> event_fd_readwrite: Struct

The contents of an $event when type is eventtype::fd_read or
eventtype::fd_write.
Size: 16
Alignment: 8

Struct members

<a href="#subscription_clock" name="subscription_clock"></a> subscription_clock: Struct

The contents of a subscription when type is eventtype::clock.
Size: 32
Alignment: 8

Struct members

<a href="#subscription" name="subscription"></a> subscription: Struct

Subscription to an event.
Size: 48
Alignment: 8

Struct members

<a href="#riflags" name="riflags"></a> riflags: Flags(u16)

Flags provided to sock_recv.
Size: 2
Alignment: 2

Flags

<a href="#roflags" name="roflags"></a> roflags: Flags(u16)

Flags returned by sock_recv.
Size: 2
Alignment: 2

Flags

<a href="#siflags" name="siflags"></a> siflags: u16

Flags provided to sock_send. As there are currently no flags
defined, it must be set to zero.
Size: 2
Alignment: 2

<a href="#sdflags" name="sdflags"></a> sdflags: Flags(u8)

Which channels on a socket to shut down.
Size: 1
Alignment: 1

Flags

<a href="#preopentype" name="preopentype"></a> preopentype: Enum(u8)

Identifiers for preopened capabilities.
Size: 1
Alignment: 1

Variants

<a href="#prestat_dir" name="prestat_dir"></a> prestat_dir: Struct

The contents of a $prestat when type is preopentype::dir.
Size: 4
Alignment: 4

Struct members

Modules

<a href="#wasi_snapshot_preview1" name="wasi_snapshot_preview1"></a> wasi_snapshot_preview1

Imports

Memory

Functions


<a href="#args_get" name="args_get"></a> args_get(argv: Pointer<Pointer<u8>>, argv_buf: Pointer<u8>) -> errno

Read command-line argument data.
The size of the array should match that returned by args_sizes_get

Params
Results

<a href="#args_sizes_get" name="args_sizes_get"></a> args_sizes_get() -> (errno, size, size)

Return command-line argument data sizes.

Params
Results

<a href="#environ_get" name="environ_get"></a> environ_get(environ: Pointer<Pointer<u8>>, environ_buf: Pointer<u8>) -> errno

Read environment variable data.
The sizes of the buffers should match that returned by environ_sizes_get.

Params
Results

<a href="#environ_sizes_get" name="environ_sizes_get"></a> environ_sizes_get() -> (errno, size, size)

Return environment variable data sizes.

Params
Results

<a href="#clock_res_get" name="clock_res_get"></a> clock_res_get(id: clockid) -> (errno, timestamp)

Return the resolution of a clock.
Implementations are required to provide a non-zero value for supported clocks. For unsupported clocks,
return errno::inval.
Note: This is similar to clock_getres in POSIX.

Params
Results

<a href="#clock_time_get" name="clock_time_get"></a> clock_time_get(id: clockid, precision: timestamp) -> (errno, timestamp)

Return the time value of a clock.
Note: This is similar to clock_gettime in POSIX.

Params
Results

<a href="#fd_advise" name="fd_advise"></a> fd_advise(fd: fd, offset: filesize, len: filesize, advice: advice) -> errno

Provide file advisory information on a file descriptor.
Note: This is similar to posix_fadvise in POSIX.

Params
Results

<a href="#fd_allocate" name="fd_allocate"></a> fd_allocate(fd: fd, offset: filesize, len: filesize) -> errno

Force the allocation of space in a file.
Note: This is similar to posix_fallocate in POSIX.

Params
Results

<a href="#fd_close" name="fd_close"></a> fd_close(fd: fd) -> errno

Close a file descriptor.
Note: This is similar to close in POSIX.

Params
Results

<a href="#fd_datasync" name="fd_datasync"></a> fd_datasync(fd: fd) -> errno

Synchronize the data of a file to disk.
Note: This is similar to fdatasync in POSIX.

Params
Results

<a href="#fd_fdstat_get" name="fd_fdstat_get"></a> fd_fdstat_get(fd: fd) -> (errno, fdstat)

Get the attributes of a file descriptor.
Note: This returns similar flags to fsync(fd, F_GETFL) in POSIX, as well as additional fields.

Params
Results

<a href="#fd_fdstat_set_flags" name="fd_fdstat_set_flags"></a> fd_fdstat_set_flags(fd: fd, flags: fdflags) -> errno

Adjust the flags associated with a file descriptor.
Note: This is similar to fcntl(fd, F_SETFL, flags) in POSIX.

Params
Results

<a href="#fd_fdstat_set_rights" name="fd_fdstat_set_rights"></a> fd_fdstat_set_rights(fd: fd, fs_rights_base: rights, fs_rights_inheriting: rights) -> errno

Adjust the rights associated with a file descriptor.
This can only be used to remove rights, and returns errno::notcapable if called in a way that would attempt to add rights

Params
Results

<a href="#fd_filestat_get" name="fd_filestat_get"></a> fd_filestat_get(fd: fd) -> (errno, filestat)

Return the attributes of an open file.

Params
Results

<a href="#fd_filestat_set_size" name="fd_filestat_set_size"></a> fd_filestat_set_size(fd: fd, size: filesize) -> errno

Adjust the size of an open file. If this increases the file's size, the extra bytes are filled with zeros.
Note: This is similar to ftruncate in POSIX.

Params
Results

<a href="#fd_filestat_set_times" name="fd_filestat_set_times"></a> fd_filestat_set_times(fd: fd, atim: timestamp, mtim: timestamp, fst_flags: fstflags) -> errno

Adjust the timestamps of an open file or directory.
Note: This is similar to futimens in POSIX.

Params
Results

<a href="#fd_pread" name="fd_pread"></a> fd_pread(fd: fd, iovs: iovec_array, offset: filesize) -> (errno, size)

Read from a file descriptor, without using and updating the file descriptor's offset.
Note: This is similar to preadv in POSIX.

Params
Results

<a href="#fd_prestat_get" name="fd_prestat_get"></a> fd_prestat_get(fd: fd) -> (errno, prestat)

Return a description of the given preopened file descriptor.

Params
Results

<a href="#fd_prestat_dir_name" name="fd_prestat_dir_name"></a> fd_prestat_dir_name(fd: fd, path: Pointer<u8>, path_len: size) -> errno

Return a description of the given preopened file descriptor.

Params
Results

<a href="#fd_pwrite" name="fd_pwrite"></a> fd_pwrite(fd: fd, iovs: ciovec_array, offset: filesize) -> (errno, size)

Write to a file descriptor, without using and updating the file descriptor's offset.
Note: This is similar to pwritev in POSIX.

Params
Results

<a href="#fd_read" name="fd_read"></a> fd_read(fd: fd, iovs: iovec_array) -> (errno, size)

Read from a file descriptor.
Note: This is similar to readv in POSIX.

Params
Results

Read directory entries from a directory.
When successful, the contents of the output buffer consist of a sequence of
directory entries. Each directory entry consists of a dirent_t object,
followed by dirent_t::d_namlen bytes holding the name of the directory
entry.
This function fills the output buffer as much as possible, potentially
truncating the last directory entry. This allows the caller to grow its
read buffer size in case it's too small to fit a single large directory
entry, or skip the oversized directory entry.

Params
Results

<a href="#fd_renumber" name="fd_renumber"></a> fd_renumber(fd: fd, to: fd) -> errno

Atomically replace a file descriptor by renumbering another file descriptor.
Due to the strong focus on thread safety, this environment does not provide
a mechanism to duplicate or renumber a file descriptor to an arbitrary
number, like dup2(). This would be prone to race conditions, as an actual
file descriptor with the same number could be allocated by a different
thread at the same time.
This function provides a way to atomically renumber file descriptors, which
would disappear if dup2() were to be removed entirely.

Params
Results

<a href="#fd_seek" name="fd_seek"></a> fd_seek(fd: fd, offset: filedelta, whence: whence) -> (errno, filesize)

Move the offset of a file descriptor.
Note: This is similar to lseek in POSIX.

Params
Results

<a href="#fd_sync" name="fd_sync"></a> fd_sync(fd: fd) -> errno

Synchronize the data and metadata of a file to disk.
Note: This is similar to fsync in POSIX.

Params
Results

<a href="#fd_tell" name="fd_tell"></a> fd_tell(fd: fd) -> (errno, filesize)

Return the current offset of a file descriptor.
Note: This is similar to lseek(fd, 0, SEEK_CUR) in POSIX.

Params
Results

<a href="#fd_write" name="fd_write"></a> fd_write(fd: fd, iovs: ciovec_array) -> (errno, size)

Write to a file descriptor.
Note: This is similar to writev in POSIX.

Params
Results

<a href="#path_create_directory" name="path_create_directory"></a> path_create_directory(fd: fd, path: string) -> errno

Create a directory.
Note: This is similar to mkdirat in POSIX.

Params
Results

<a href="#path_filestat_get" name="path_filestat_get"></a> path_filestat_get(fd: fd, flags: lookupflags, path: string) -> (errno, filestat)

Return the attributes of a file or directory.
Note: This is similar to stat in POSIX.

Params
Results

<a href="#path_filestat_set_times" name="path_filestat_set_times"></a> path_filestat_set_times(fd: fd, flags: lookupflags, path: string, atim: timestamp, mtim: timestamp, fst_flags: fstflags) -> errno

Adjust the timestamps of a file or directory.
Note: This is similar to utimensat in POSIX.

Params
Results

Create a hard link.
Note: This is similar to linkat in POSIX.

Params
Results

<a href="#path_open" name="path_open"></a> path_open(fd: fd, dirflags: lookupflags, path: string, oflags: oflags, fs_rights_base: rights, fs_rights_inherting: rights, fdflags: fdflags) -> (errno, fd)

Open a file or directory.
The returned file descriptor is not guaranteed to be the lowest-numbered
file 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 file descriptor is
guaranteed to be less than 2**31.
Note: This is similar to openat in POSIX.

Params
Results

Read the contents of a symbolic link.
Note: This is similar to readlinkat in POSIX.

Params
Results

<a href="#path_remove_directory" name="path_remove_directory"></a> path_remove_directory(fd: fd, path: string) -> errno

Remove a directory.
Return errno::notempty if the directory is not empty.
Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR) in POSIX.

Params
Results

<a href="#path_rename" name="path_rename"></a> path_rename(fd: fd, old_path: string, new_fd: fd, new_path: string) -> errno

Rename a file or directory.
Note: This is similar to renameat in POSIX.

Params
Results

Create a symbolic link.
Note: This is similar to symlinkat in POSIX.

Params
Results

Unlink a file.
Return errno::isdir if the path refers to a directory.
Note: This is similar to unlinkat(fd, path, 0) in POSIX.

Params
Results

<a href="#poll_oneoff" name="poll_oneoff"></a> poll_oneoff(in: ConstPointer<subscription>, out: Pointer<event>, nsubscriptions: size) -> (errno, size)

Concurrently poll for the occurrence of a set of events.

Params
Results

<a href="#proc_exit" name="proc_exit"></a> proc_exit(rval: exitcode)

Terminate the process normally. An exit code of 0 indicates successful
termination of the program. The meanings of other values is dependent on
the environment.

Params
Results

<a href="#proc_raise" name="proc_raise"></a> proc_raise(sig: signal) -> errno

Send a signal to the process of the calling thread.
Note: This is similar to raise in POSIX.

Params
Results

<a href="#sched_yield" name="sched_yield"></a> sched_yield() -> errno

Temporarily yield execution of the calling thread.
Note: This is similar to sched_yield in POSIX.

Params
Results

<a href="#random_get" name="random_get"></a> random_get(buf: Pointer<u8>, buf_len: size) -> errno

Write high-quality random data into a buffer.
This function blocks when the implementation is unable to immediately
provide sufficient high-quality random data.
This function may execute slowly, so when large mounts of random data are
required, it's advisable to use this function to seed a pseudo-random
number generator, rather than to provide the random data directly.

Params
Results

<a href="#sock_recv" name="sock_recv"></a> sock_recv(fd: fd, ri_data: iovec_array, ri_flags: riflags) -> (errno, size, roflags)

Receive a message from a socket.
Note: This is similar to recv in POSIX, though it also supports reading
the data into multiple buffers in the manner of readv.

Params
Results

<a href="#sock_send" name="sock_send"></a> sock_send(fd: fd, si_data: ciovec_array, si_flags: siflags) -> (errno, size)

Send a message on a socket.
Note: This is similar to send in POSIX, though it also supports writing
the data from multiple buffers in the manner of writev.

Params
Results

<a href="#sock_shutdown" name="sock_shutdown"></a> sock_shutdown(fd: fd, how: sdflags) -> errno

Shut down socket send and receive channels.
Note: This is similar to shutdown in POSIX.

Params
Results