Types
February 14, 2023 ยท View on GitHub
size: u32
Size: 4
Alignment: 4
filesize: u64
Non-negative file size or length of a region within a file.
Size: 8
Alignment: 8
timestamp: u64
Timestamp in nanoseconds.
Size: 8
Alignment: 8
clockid: Variant
Identifiers for clocks.
Size: 4
Alignment: 4
Variant cases
-
realtimeThe clock measuring real time. Time value zero corresponds with 1970-01-01T00:00:00Z. -
monotonicThe store-wide monotonic clock, which is defined as a clock measuring real time, whose value cannot be adjusted and which cannot have negative clock jumps. The epoch of this clock is undefined. The absolute time value of this clock therefore has no meaning. -
process_cputime_idThe CPU-time clock associated with the current process. -
thread_cputime_idThe CPU-time clock associated with the current thread.
errno: Variant
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
Variant cases
rights: Record
File descriptor rights, determining which actions may be performed.
Size: 8
Alignment: 8
Record members
-
fd_datasync:boolThe right to invokefd_datasync. Ifpath_openis set, includes the right to invokepath_openwithfdflags::dsync.
Bit: 0
-
fd_read:boolThe right to invokefd_readandsock_recv. Ifrights::fd_seekis set, includes the right to invokefd_pread.
Bit: 1
-
fd_seek:boolThe right to invokefd_seek. This flag impliesrights::fd_tell.
Bit: 2
-
fd_fdstat_set_flags:boolThe right to invokefd_fdstat_set_flags.
Bit: 3
-
fd_sync:boolThe right to invokefd_sync. Ifpath_openis set, includes the right to invokepath_openwithfdflags::rsyncandfdflags::dsync.
Bit: 4
-
fd_tell:boolThe right to invokefd_seekin such a way that the file offset remains unaltered (i.e.,whence::curwith offset zero), or to invokefd_tell.
Bit: 5
-
fd_write:boolThe right to invokefd_writeandsock_send. Ifrights::fd_seekis set, includes the right to invokefd_pwrite.
Bit: 6
-
fd_advise:boolThe right to invokefd_advise.
Bit: 7
-
fd_allocate:boolThe right to invokefd_allocate.
Bit: 8
-
path_create_directory:boolThe right to invokepath_create_directory.
Bit: 9
-
path_create_file:boolIfpath_openis set, the right to invokepath_openwithoflags::creat.
Bit: 10
-
path_link_source:boolThe right to invokepath_linkwith the file descriptor as the source directory.
Bit: 11
-
path_link_target:boolThe right to invokepath_linkwith the file descriptor as the target directory.
Bit: 12
-
path_open:boolThe right to invokepath_open.
Bit: 13
-
fd_readdir:boolThe right to invokefd_readdir.
Bit: 14
-
path_readlink:boolThe right to invokepath_readlink.
Bit: 15
-
path_rename_source:boolThe right to invokepath_renamewith the file descriptor as the source directory.
Bit: 16
-
path_rename_target:boolThe right to invokepath_renamewith the file descriptor as the target directory.
Bit: 17
-
path_filestat_get:boolThe right to invokepath_filestat_get.
Bit: 18
-
path_filestat_set_size:boolThe right to change a file's size. Ifpath_openis set, includes the right to invokepath_openwithoflags::trunc. Note: there is no function namedpath_filestat_set_size. This follows POSIX design, which only hasftruncateand does not provideftruncateat. While such function would be desirable from the API design perspective, there are virtually no use cases for it since no code written for POSIX systems would use it. Moreover, implementing it would require multiple syscalls, leading to inferior performance.
Bit: 19
-
path_filestat_set_times:boolThe right to invokepath_filestat_set_times.
Bit: 20
-
fd_filestat_get:boolThe right to invokefd_filestat_get.
Bit: 21
-
fd_filestat_set_size:boolThe right to invokefd_filestat_set_size.
Bit: 22
-
fd_filestat_set_times:boolThe right to invokefd_filestat_set_times.
Bit: 23
-
path_symlink:boolThe right to invokepath_symlink.
Bit: 24
-
path_remove_directory:boolThe right to invokepath_remove_directory.
Bit: 25
-
path_unlink_file:boolThe right to invokepath_unlink_file.
Bit: 26
-
poll_fd_readwrite:boolIfrights::fd_readis set, includes the right to invokepoll_oneoffto subscribe toeventtype::fd_read. Ifrights::fd_writeis set, includes the right to invokepoll_oneoffto subscribe toeventtype::fd_write.
Bit: 27
-
sock_shutdown:boolThe right to invokesock_shutdown.
Bit: 28
-
sock_accept:boolThe right to invokesock_accept.
Bit: 29
fd: Handle
A file descriptor handle.
Size: 4
Alignment: 4
Supertypes
iovec: Record
A region of memory for scatter/gather reads.
Size: 8
Alignment: 4
Record members
Offset: 0
-
buf_len:sizeThe length of the buffer to be filled.
Offset: 4
ciovec: Record
A region of memory for scatter/gather writes.
Size: 8
Alignment: 4
Record members
Offset: 0
-
buf_len:sizeThe length of the buffer to be written.
Offset: 4
iovec_array: List<iovec>
Size: 8
Alignment: 4
ciovec_array: List<ciovec>
Size: 8
Alignment: 4
filedelta: s64
Relative offset within a file.
Size: 8
Alignment: 8
whence: Variant
The position relative to which to set the offset of the file descriptor.
Size: 1
Alignment: 1
Variant cases
dircookie: u64
A reference to the offset of a directory entry.
The value 0 signifies the start of the directory.
Size: 8
Alignment: 8
dirnamlen: u32
The type for the dirent::d_namlen field of dirent struct.
Size: 4
Alignment: 4
inode: u64
File serial number that is unique within its file system.
Size: 8
Alignment: 8
filetype: Variant
The type of a file descriptor or file.
Size: 1
Alignment: 1
Variant cases
-
unknownThe type of the file descriptor or file is unknown or is different from any of the other types specified. -
block_deviceThe file descriptor or file refers to a block device inode. -
character_deviceThe file descriptor or file refers to a character device inode. -
directoryThe file descriptor or file refers to a directory inode. -
regular_fileThe file descriptor or file refers to a regular file inode. -
socket_dgramThe file descriptor or file refers to a datagram socket. -
socket_streamThe file descriptor or file refers to a byte-stream socket.
dirent: Record
A directory entry.
Size: 24
Alignment: 8
Record members
-
d_next:dircookieThe offset of the next directory entry stored in this directory.
Offset: 0
-
d_ino:inodeThe serial number of the file referred to by this directory entry.
Offset: 8
-
d_namlen:dirnamlenThe length of the name of the directory entry.
Offset: 16
-
d_type:filetypeThe type of the file referred to by this directory entry.
Offset: 20
advice: Variant
File or memory access pattern advisory information.
Size: 1
Alignment: 1
Variant cases
-
normalThe application has no advice to give on its behavior with respect to the specified data. -
sequentialThe application expects to access the specified data sequentially from lower offsets to higher offsets. -
randomThe application expects to access the specified data in a random order. -
willneedThe application expects to access the specified data in the near future. -
dontneedThe application expects that it will not access the specified data in the near future. -
noreuseThe application expects to access the specified data once and then not reuse it thereafter.
fdflags: Record
File descriptor flags.
Size: 2
Alignment: 2
Record members
Bit: 0
-
dsync:boolWrite according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
Bit: 1
Bit: 2
Bit: 3
-
sync:boolWrite according to synchronized I/O file integrity completion. In addition to synchronizing the data stored in the file, the implementation may also synchronously update the file's metadata.
Bit: 4
fdstat: Record
File descriptor attributes.
Size: 24
Alignment: 8
Record members
-
fs_filetype:filetypeFile type.
Offset: 0
-
fs_flags:fdflagsFile descriptor flags.
Offset: 2
-
fs_rights_base:rightsRights that apply to this file descriptor.
Offset: 8
-
fs_rights_inheriting:rightsMaximum set of rights that may be installed on new file descriptors that are created through this file descriptor, e.g., throughpath_open.
Offset: 16
device: 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.
Size: 8
Alignment: 8
fstflags: Record
Which file time attributes to adjust.
Size: 2
Alignment: 2
Record members
-
atim:boolAdjust the last data access timestamp to the value stored infilestat::atim.
Bit: 0
-
atim_now:boolAdjust the last data access timestamp to the time of clockclockid::realtime.
Bit: 1
-
mtim:boolAdjust the last data modification timestamp to the value stored infilestat::mtim.
Bit: 2
-
mtim_now:boolAdjust the last data modification timestamp to the time of clockclockid::realtime.
Bit: 3
lookupflags: Record
Flags determining the method of how paths are resolved.
Size: 4
Alignment: 4
Record members
Bit: 0
oflags: Record
Open flags used by path_open.
Size: 2
Alignment: 2
Record members
Bit: 0
Bit: 1
Bit: 2
Bit: 3
linkcount: u64
Number of hard links to an inode.
Size: 8
Alignment: 8
filestat: Record
File attributes.
Size: 64
Alignment: 8
Record members
-
dev:deviceDevice ID of device containing the file.
Offset: 0
-
ino:inodeFile serial number.
Offset: 8
-
filetype:filetypeFile type.
Offset: 16
-
nlink:linkcountNumber of hard links to the file.
Offset: 24
-
size:filesizeFor regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link.
Offset: 32
-
atim:timestampLast data access timestamp.
Offset: 40
-
mtim:timestampLast data modification timestamp.
Offset: 48
-
ctim:timestampLast file status change timestamp.
Offset: 56
userdata: u64
User-provided value that may be attached to objects that is retained when extracted from the implementation.
Size: 8
Alignment: 8
eventtype: Variant
Type of a subscription to an event or its occurrence.
Size: 1
Alignment: 1
Variant cases
-
clockThe time value of clocksubscription_clock::idhas reached timestampsubscription_clock::timeout. -
fd_readFile descriptorsubscription_fd_readwrite::file_descriptorhas data available for reading. This event always triggers for regular files. -
fd_writeFile descriptorsubscription_fd_readwrite::file_descriptorhas capacity available for writing. This event always triggers for regular files.
eventrwflags: Record
The state of the file descriptor subscribed to with
eventtype::fd_read or eventtype::fd_write.
Size: 2
Alignment: 2
Record members
Bit: 0
event_fd_readwrite: Record
The contents of an event when type is eventtype::fd_read or
eventtype::fd_write.
Size: 16
Alignment: 8
Record members
-
nbytes:filesizeThe number of bytes available for reading or writing.
Offset: 0
-
flags:eventrwflagsThe state of the file descriptor.
Offset: 8
event: Record
An event that occurred.
Size: 32
Alignment: 8
Record members
-
userdata:userdataUser-provided value that got attached tosubscription::userdata.
Offset: 0
-
error:errnoIf non-zero, an error that occurred while processing the subscription request.
Offset: 8
-
type:eventtypeThe type of event that occured
Offset: 10
-
fd_readwrite:event_fd_readwriteThe contents of the event, if it is aneventtype::fd_readoreventtype::fd_write.eventtype::clockevents ignore this field.
Offset: 16
subclockflags: Record
Flags determining how to interpret the timestamp provided in
subscription_clock::timeout.
Size: 2
Alignment: 2
Record members
-
subscription_clock_abstime:boolIf set, treat the timestamp provided insubscription_clock::timeoutas an absolute timestamp of clocksubscription_clock::id. If clear, treat the timestamp provided insubscription_clock::timeoutrelative to the current time value of clocksubscription_clock::id.
Bit: 0
subscription_clock: Record
The contents of a subscription when type is eventtype::clock.
Size: 32
Alignment: 8
Record members
-
id:clockidThe clock against which to compare the timestamp.
Offset: 0
-
timeout:timestampThe absolute or relative timestamp.
Offset: 8
-
precision:timestampThe amount of time that the implementation may wait additionally to coalesce with other events.
Offset: 16
-
flags:subclockflagsFlags specifying whether the timeout is absolute or relative
Offset: 24
subscription_fd_readwrite: Record
The contents of a subscription when type is type is
eventtype::fd_read or eventtype::fd_write.
Size: 4
Alignment: 4
Record members
-
file_descriptor:fdThe file descriptor on which to wait for it to become ready for reading or writing.
Offset: 0
subscription_u: Variant
The contents of a subscription.
Size: 40
Alignment: 8
Variant Layout
- size: 40
- align: 8
- tag_size: 1
Variant cases
-
clock:subscription_clock -
fd_read:subscription_fd_readwrite -
fd_write:subscription_fd_readwrite
subscription: Record
Subscription to an event.
Size: 48
Alignment: 8
Record members
-
userdata:userdataUser-provided value that is attached to the subscription in the implementation and returned throughevent::userdata.
Offset: 0
-
u:subscription_uThe type of the event to which to subscribe, and its contents
Offset: 8
exitcode: u32
Exit code generated by a process when exiting.
Size: 4
Alignment: 4
signal: Variant
Signal condition.
Size: 1
Alignment: 1
Variant cases
-
noneNo signal. Note that POSIX has special semantics forkill(pid, 0), so this value is reserved. -
intTerminate interrupt signal. Action: Terminates the process. -
busAccess to an undefined portion of a memory object. Action: Terminates the process. -
fpeErroneous arithmetic operation. Action: Terminates the process. -
segvInvalid memory reference. Action: Terminates the process. -
pipeWrite on a pipe with no one to read it. Action: Ignored. -
chldChild process terminated, stopped, or continued. Action: Ignored. -
contContinue executing, if stopped. Action: Continues executing, if stopped. -
ttinBackground process attempting read. Action: Stops executing. -
ttouBackground process attempting write. Action: Stops executing. -
urgHigh bandwidth data is available at a socket. Action: Ignored. -
xcpuCPU time limit exceeded. Action: Terminates the process. -
xfszFile size limit exceeded. Action: Terminates the process. -
vtalrmVirtual timer expired. Action: Terminates the process. -
profProfiling timer expired. Action: Terminates the process.
riflags: Record
Flags provided to sock_recv.
Size: 2
Alignment: 2
Record members
Bit: 0
Bit: 1
roflags: Record
Flags returned by sock_recv.
Size: 2
Alignment: 2
Record members
-
recv_data_truncated:boolReturned bysock_recv: Message data has been truncated.
Bit: 0
siflags: u16
Flags provided to sock_send. As there are currently no flags
defined, it must be set to zero.
Size: 2
Alignment: 2
sdflags: Record
Which channels on a socket to shut down.
Size: 1
Alignment: 1
Record members
Bit: 0
Bit: 1
preopentype: Variant
Identifiers for preopened capabilities.
Size: 1
Alignment: 1
Variant cases
prestat_dir: Record
The contents of a $prestat when type is preopentype::dir.
Size: 4
Alignment: 4
Record members
-
pr_name_len:sizeThe length of the directory name for use withfd_prestat_dir_name.
Offset: 0
prestat: Variant
Information about a pre-opened capability.
Size: 8
Alignment: 4
Variant Layout
- size: 8
- align: 4
- tag_size: 1
Variant cases
-
dir:prestat_dir
Modules
wasi_snapshot_preview1
Imports
Memory
Functions
args_get(argv: Pointer<Pointer<u8>>, argv_buf: Pointer<u8>) -> Result<(), errno>
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.
Params
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
args_sizes_get() -> Result<(size, size), errno>
Return command-line argument data sizes.
Params
Results
-
error:Result<(size, size), errno>Returns the number of arguments and the size of the argument string data, or an error.
Variant Layout
- size: 12
- align: 4
- tag_size: 4
Variant cases
####### Record members
-
0:size
Offset: 0
-
1:size
Offset: 4
-
err:errno
environ_get(environ: Pointer<Pointer<u8>>, environ_buf: Pointer<u8>) -> Result<(), errno>
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.
Params
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
environ_sizes_get() -> Result<(size, size), errno>
Return environment variable data sizes.
Params
Results
-
error:Result<(size, size), errno>Returns the number of environment variable arguments and the size of the environment variable data.
Variant Layout
- size: 12
- align: 4
- tag_size: 4
Variant cases
####### Record members
-
0:size
Offset: 0
-
1:size
Offset: 4
-
err:errno
clock_res_get(id: clockid) -> Result<timestamp, errno>
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
-
id:clockidThe clock for which to return the resolution.
Results
Variant Layout
- size: 16
- align: 8
- tag_size: 4
Variant cases
clock_time_get(id: clockid, precision: timestamp) -> Result<timestamp, errno>
Return the time value of a clock.
Note: This is similar to clock_gettime in POSIX.
Params
-
id:clockidThe clock for which to return the time. -
precision:timestampThe maximum lag (exclusive) that the returned time value may have, compared to its actual value.
Results
Variant Layout
- size: 16
- align: 8
- tag_size: 4
Variant cases
fd_advise(fd: fd, offset: filesize, len: filesize, advice: advice) -> Result<(), errno>
Provide file advisory information on a file descriptor.
Note: This is similar to posix_fadvise in POSIX.
Params
-
fd:fd -
offset:filesizeThe offset within the file to which the advisory applies. -
len:filesizeThe length of the region to which the advisory applies. -
advice:adviceThe advice.
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
fd_allocate(fd: fd, offset: filesize, len: filesize) -> Result<(), errno>
Force the allocation of space in a file.
Note: This is similar to posix_fallocate in POSIX.
Params
-
fd:fd -
offset:filesizeThe offset at which to start the allocation. -
len:filesizeThe length of the area that is allocated.
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
fd_close(fd: fd) -> Result<(), errno>
Close a file descriptor.
Note: This is similar to close in POSIX.
Params
-
fd:fd
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
fd_datasync(fd: fd) -> Result<(), errno>
Synchronize the data of a file to disk.
Note: This is similar to fdatasync in POSIX.
Params
-
fd:fd
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
fd_fdstat_get(fd: fd) -> Result<fdstat, errno>
Get the attributes of a file descriptor.
Note: This returns similar flags to fcntl(fd, F_GETFL) in POSIX, as well as additional fields.
Params
-
fd:fd
Results
Variant Layout
- size: 32
- align: 8
- tag_size: 4
Variant cases
fd_fdstat_set_flags(fd: fd, flags: fdflags) -> Result<(), errno>
Adjust the flags associated with a file descriptor.
Note: This is similar to fcntl(fd, F_SETFL, flags) in POSIX.
Params
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
fd_fdstat_set_rights(fd: fd, fs_rights_base: rights, fs_rights_inheriting: rights) -> Result<(), 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
-
fd:fd -
fs_rights_base:rightsThe desired rights of the file descriptor. -
fs_rights_inheriting:rights
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
fd_filestat_get(fd: fd) -> Result<filestat, errno>
Return the attributes of an open file.
Params
-
fd:fd
Results
Variant Layout
- size: 72
- align: 8
- tag_size: 4
Variant cases
fd_filestat_set_size(fd: fd, size: filesize) -> Result<(), 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
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
fd_filestat_set_times(fd: fd, atim: timestamp, mtim: timestamp, fst_flags: fstflags) -> Result<(), errno>
Adjust the timestamps of an open file or directory.
Note: This is similar to futimens in POSIX.
Params
-
fd:fd -
atim:timestampThe desired values of the data access timestamp. -
mtim:timestampThe desired values of the data modification timestamp. -
fst_flags:fstflagsA bitmask indicating which timestamps to adjust.
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
fd_pread(fd: fd, iovs: iovec_array, offset: filesize) -> Result<size, errno>
Read from a file descriptor, without using and updating the file descriptor's offset.
Note: This is similar to preadv in Linux (and other Unix-es).
Params
-
fd:fd -
iovs:iovec_arrayList of scatter/gather vectors in which to store data. -
offset:filesizeThe offset within the file at which to read.
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
fd_prestat_get(fd: fd) -> Result<prestat, errno>
Return a description of the given preopened file descriptor.
Params
-
fd:fd
Results
Variant Layout
- size: 12
- align: 4
- tag_size: 4
Variant cases
fd_prestat_dir_name(fd: fd, path: Pointer<u8>, path_len: size) -> Result<(), errno>
Return a description of the given preopened file descriptor.
Params
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
fd_pwrite(fd: fd, iovs: ciovec_array, offset: filesize) -> Result<size, errno>
Write to a file descriptor, without using and updating the file descriptor's offset.
Note: This is similar to pwritev in Linux (and other Unix-es).
Like Linux (and other Unix-es), any calls of pwrite (and other
functions to read or write) for a regular file by other threads in the
WASI process should not be interleaved while pwrite is executed.
Params
-
fd:fd -
iovs:ciovec_arrayList of scatter/gather vectors from which to retrieve data. -
offset:filesizeThe offset within the file at which to write.
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
fd_read(fd: fd, iovs: iovec_array) -> Result<size, errno>
Read from a file descriptor.
Note: This is similar to readv in POSIX.
Params
-
fd:fd -
iovs:iovec_arrayList of scatter/gather vectors to which to store data.
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
fd_readdir(fd: fd, buf: Pointer<u8>, buf_len: size, cookie: dircookie) -> Result<size, errno>
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.
Params
-
fd:fd -
buf:Pointer<u8>The buffer where directory entries are stored -
buf_len:size -
cookie:dircookieThe location within the directory to start reading
Results
-
error:Result<size, errno>The number of bytes stored in the read buffer. If less than the size of the read buffer, the end of the directory has been reached.
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
fd_renumber(fd: fd, to: fd) -> Result<(), 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
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
fd_seek(fd: fd, offset: filedelta, whence: whence) -> Result<filesize, errno>
Move the offset of a file descriptor.
Note: This is similar to lseek in POSIX.
Params
-
fd:fd -
offset:filedeltaThe number of bytes to move. -
whence:whenceThe base from which the offset is relative.
Results
-
error:Result<filesize, errno>The new offset of the file descriptor, relative to the start of the file.
Variant Layout
- size: 16
- align: 8
- tag_size: 4
Variant cases
fd_sync(fd: fd) -> Result<(), errno>
Synchronize the data and metadata of a file to disk.
Note: This is similar to fsync in POSIX.
Params
-
fd:fd
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
fd_tell(fd: fd) -> Result<filesize, errno>
Return the current offset of a file descriptor.
Note: This is similar to lseek(fd, 0, SEEK_CUR) in POSIX.
Params
-
fd:fd
Results
-
error:Result<filesize, errno>The current offset of the file descriptor, relative to the start of the file.
Variant Layout
- size: 16
- align: 8
- tag_size: 4
Variant cases
fd_write(fd: fd, iovs: ciovec_array) -> Result<size, errno>
Write to a file descriptor.
Note: This is similar to writev in POSIX.
Like POSIX, any calls of write (and other functions to read or write)
for a regular file by other threads in the WASI process should not be
interleaved while write is executed.
Params
-
fd:fd -
iovs:ciovec_arrayList of scatter/gather vectors from which to retrieve data.
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
path_create_directory(fd: fd, path: string) -> Result<(), errno>
Create a directory.
Note: This is similar to mkdirat in POSIX.
Params
-
fd:fd
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
path_filestat_get(fd: fd, flags: lookupflags, path: string) -> Result<filestat, errno>
Return the attributes of a file or directory.
Note: This is similar to stat in POSIX.
Params
-
fd:fd -
flags:lookupflagsFlags determining the method of how the path is resolved.
Results
Variant Layout
- size: 72
- align: 8
- tag_size: 4
Variant cases
path_filestat_set_times(fd: fd, flags: lookupflags, path: string, atim: timestamp, mtim: timestamp, fst_flags: fstflags) -> Result<(), errno>
Adjust the timestamps of a file or directory.
Note: This is similar to utimensat in POSIX.
Params
-
fd:fd -
flags:lookupflagsFlags determining the method of how the path is resolved. -
path:stringThe path of the file or directory to operate on. -
atim:timestampThe desired values of the data access timestamp. -
mtim:timestampThe desired values of the data modification timestamp. -
fst_flags:fstflagsA bitmask indicating which timestamps to adjust.
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
path_link(old_fd: fd, old_flags: lookupflags, old_path: string, new_fd: fd, new_path: string) -> Result<(), errno>
Create a hard link.
Note: This is similar to linkat in POSIX.
Params
-
old_fd:fd -
old_flags:lookupflagsFlags determining the method of how the path is resolved. -
new_fd:fdThe working directory at which the resolution of the new path starts. -
new_path:stringThe destination path at which to create the hard link.
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
path_open(fd: fd, dirflags: lookupflags, path: string, oflags: oflags, fs_rights_base: rights, fs_rights_inheriting: rights, fdflags: fdflags) -> Result<fd, errno>
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
-
fd:fd -
dirflags:lookupflagsFlags determining the method of how the path is resolved. -
path:stringThe relative path of the file or directory to open, relative to thepath_open::fddirectory. -
oflags:oflagsThe method by which to open the file. -
fs_rights_base:rightsThe initial rights of the newly created file descriptor. The implementation is allowed to return a file descriptor with fewer rights than specified, if and only if those rights do not apply to the type of file being opened. The base rights are rights that will apply to operations using the file descriptor itself, while the inheriting rights are rights that apply to file descriptors derived from it. -
fs_rights_inheriting:rights -
fdflags:fdflags
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
path_readlink(fd: fd, path: string, buf: Pointer<u8>, buf_len: size) -> Result<size, errno>
Read the contents of a symbolic link.
Note: This is similar to readlinkat in POSIX.
Params
-
fd:fd -
path:stringThe path of the symbolic link from which to read. -
buf:Pointer<u8>The buffer to which to write the contents of the symbolic link. -
buf_len:size
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
path_remove_directory(fd: fd, path: string) -> Result<(), 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
-
fd:fd
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
path_rename(fd: fd, old_path: string, new_fd: fd, new_path: string) -> Result<(), errno>
Rename a file or directory.
Note: This is similar to renameat in POSIX.
Params
-
fd:fd -
old_path:stringThe source path of the file or directory to rename. -
new_fd:fdThe working directory at which the resolution of the new path starts. -
new_path:stringThe destination path to which to rename the file or directory.
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
path_symlink(old_path: string, fd: fd, new_path: string) -> Result<(), errno>
Create a symbolic link.
Note: This is similar to symlinkat in POSIX.
Params
-
fd:fd -
new_path:stringThe destination path at which to create the symbolic link.
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
path_unlink_file(fd: fd, path: string) -> Result<(), errno>
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
-
fd:fd
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
poll_oneoff(in: ConstPointer<subscription>, out: Pointer<event>, nsubscriptions: size) -> Result<size, errno>
Concurrently poll for the occurrence of a set of events.
If nsubscriptions is 0, returns errno::inval.
Params
-
in:ConstPointer<subscription>The events to which to subscribe. -
nsubscriptions:sizeBoth the number of subscriptions and events.
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
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
-
rval:exitcodeThe exit code returned by the process.
Results
proc_raise(sig: signal) -> Result<(), errno>
Send a signal to the process of the calling thread.
Note: This is similar to raise in POSIX.
Params
-
sig:signalThe signal condition to trigger.
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
sched_yield() -> Result<(), errno>
Temporarily yield execution of the calling thread.
Note: This is similar to sched_yield in POSIX.
Params
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
random_get(buf: Pointer<u8>, buf_len: size) -> Result<(), 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
-
buf_len:size
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno
sock_accept(fd: fd, flags: fdflags) -> Result<fd, errno>
Accept a new incoming connection.
Note: This is similar to accept in POSIX.
Params
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
sock_recv(fd: fd, ri_data: iovec_array, ri_flags: riflags) -> Result<(size, roflags), errno>
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
-
fd:fd -
ri_data:iovec_arrayList of scatter/gather vectors to which to store data. -
ri_flags:riflagsMessage flags.
Results
Variant Layout
- size: 12
- align: 4
- tag_size: 4
Variant cases
####### Record members
-
0:size
Offset: 0
-
1:roflags
Offset: 4
-
err:errno
sock_send(fd: fd, si_data: ciovec_array, si_flags: siflags) -> Result<size, errno>
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
-
fd:fd -
si_data:ciovec_arrayList of scatter/gather vectors to which to retrieve data -
si_flags:siflagsMessage flags.
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
sock_shutdown(fd: fd, how: sdflags) -> Result<(), errno>
Shut down socket send and receive channels.
Note: This is similar to shutdown in POSIX.
Params
Results
Variant Layout
- size: 8
- align: 4
- tag_size: 4
Variant cases
-
err:errno