wasi

Module wasi_snapshot_preview1

Source

Functions§

args_get
Read command-line argument data. The size of the array should match that returned by args_sizes_get. Each argument is expected to be \0 terminated.
args_sizes_get
Return command-line argument data sizes.
clock_res_get
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.
clock_time_get
Return the time value of a clock. Note: This is similar to clock_gettime in POSIX.
environ_get
Read environment variable data. The sizes of the buffers should match that returned by environ_sizes_get. Key/value pairs are expected to be joined with =s, and terminated with \0s.
environ_sizes_get
Return environment variable data sizes.
fd_advise
Provide file advisory information on a file descriptor. Note: This is similar to posix_fadvise in POSIX.
fd_allocate
Force the allocation of space in a file. Note: This is similar to posix_fallocate in POSIX.
fd_close
Close a file descriptor. Note: This is similar to close in POSIX.
fd_datasync
Synchronize the data of a file to disk. Note: This is similar to fdatasync in POSIX.
fd_fdstat_get
Get the attributes of a file descriptor. Note: This returns similar flags to fsync(fd, F_GETFL) in POSIX, as well as additional fields.
fd_fdstat_set_flags
Adjust the flags associated with a file descriptor. Note: This is similar to fcntl(fd, F_SETFL, flags) in POSIX.
fd_fdstat_set_rights
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
fd_filestat_get
Return the attributes of an open file.
fd_filestat_set_size
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.
fd_filestat_set_times
Adjust the timestamps of an open file or directory. Note: This is similar to futimens in POSIX.
fd_pread
Read from a file descriptor, without using and updating the file descriptor’s offset. Note: This is similar to preadv in POSIX.
fd_prestat_dir_name
Return a description of the given preopened file descriptor.
fd_prestat_get
Return a description of the given preopened file descriptor.
fd_pwrite
Write to a file descriptor, without using and updating the file descriptor’s offset. Note: This is similar to pwritev in POSIX.
fd_read
Read from a file descriptor. Note: This is similar to readv in POSIX.
fd_readdir
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 object, followed by dirent::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.
fd_renumber
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.
fd_seek
Move the offset of a file descriptor. Note: This is similar to lseek in POSIX.
fd_sync
Synchronize the data and metadata of a file to disk. Note: This is similar to fsync in POSIX.
fd_tell
Return the current offset of a file descriptor. Note: This is similar to lseek(fd, 0, SEEK_CUR) in POSIX.
fd_write
Write to a file descriptor. Note: This is similar to writev in POSIX.
path_create_directory
Create a directory. Note: This is similar to mkdirat in POSIX.
path_filestat_get
Return the attributes of a file or directory. Note: This is similar to stat in POSIX.
path_filestat_set_times
Adjust the timestamps of a file or directory. Note: This is similar to utimensat in POSIX.
path_link
Create a hard link. Note: This is similar to linkat in POSIX.
path_open
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.
path_readlink
Read the contents of a symbolic link. Note: This is similar to readlinkat in POSIX.
path_remove_directory
Remove a directory. Return errno::notempty if the directory is not empty. Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR) in POSIX.
path_rename
Rename a file or directory. Note: This is similar to renameat in POSIX.
path_symlink
Create a symbolic link. Note: This is similar to symlinkat in POSIX.
path_unlink_file
Unlink a file. Return errno::isdir if the path refers to a directory. Note: This is similar to unlinkat(fd, path, 0) in POSIX.
poll_oneoff
Concurrently poll for the occurrence of a set of events.
proc_exit
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.
proc_raise
Send a signal to the process of the calling thread. Note: This is similar to raise in POSIX.
random_get
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.
sched_yield
Temporarily yield execution of the calling thread. Note: This is similar to sched_yield in POSIX.
sock_accept
Accept a new incoming connection. Note: This is similar to accept in POSIX.
sock_recv
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.
sock_send
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.
sock_shutdown
Shut down socket send and receive channels. Note: This is similar to shutdown in POSIX.