Size: 4
Alignment: 4
Non-negative file size or length of a region within a file.
Size: 8
Alignment: 8
Timestamp in nanoseconds.
Size: 8
Alignment: 8
Identifiers for clocks.
Size: 4
Alignment: 4
-
realtime
The clock measuring real time. Time value zero corresponds with 1970-01-01T00:00:00Z. -
monotonic
The 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_id
The CPU-time clock associated with the current process. -
thread_cputime_id
The CPU-time clock associated with the current thread.
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
File descriptor rights, determining which actions may be performed.
Size: 8
Alignment: 8
-
fd_datasync
The right to invokefd_datasync
. Ifpath_open
is set, includes the right to invokepath_open
withfdflags::dsync
. -
fd_read
The right to invokefd_read
andsock_recv
. Ifrights::fd_seek
is set, includes the right to invokefd_pread
. -
fd_seek
The right to invokefd_seek
. This flag impliesrights::fd_tell
. -
fd_fdstat_set_flags
The right to invokefd_fdstat_set_flags
. -
fd_sync
The right to invokefd_sync
. Ifpath_open
is set, includes the right to invokepath_open
withfdflags::rsync
andfdflags::dsync
. -
fd_tell
The right to invokefd_seek
in such a way that the file offset remains unaltered (i.e.,whence::cur
with offset zero), or to invokefd_tell
. -
fd_write
The right to invokefd_write
andsock_send
. Ifrights::fd_seek
is set, includes the right to invokefd_pwrite
. -
fd_advise
The right to invokefd_advise
. -
fd_allocate
The right to invokefd_allocate
. -
path_create_directory
The right to invokepath_create_directory
. -
path_create_file
Ifpath_open
is set, the right to invokepath_open
withoflags::creat
. -
path_link_source
The right to invokepath_link
with the file descriptor as the source directory. -
path_link_target
The right to invokepath_link
with the file descriptor as the target directory. -
path_open
The right to invokepath_open
. -
fd_readdir
The right to invokefd_readdir
. -
path_readlink
The right to invokepath_readlink
. -
path_rename_source
The right to invokepath_rename
with the file descriptor as the source directory. -
path_rename_target
The right to invokepath_rename
with the file descriptor as the target directory. -
path_filestat_get
The right to invokepath_filestat_get
. -
path_filestat_set_size
The right to change a file's size (there is nopath_filestat_set_size
). Ifpath_open
is set, includes the right to invokepath_open
withoflags::trunc
. -
path_filestat_set_times
The right to invokepath_filestat_set_times
. -
fd_filestat_get
The right to invokefd_filestat_get
. -
fd_filestat_set_size
The right to invokefd_filestat_set_size
. -
fd_filestat_set_times
The right to invokefd_filestat_set_times
. -
path_symlink
The right to invokepath_symlink
. -
path_remove_directory
The right to invokepath_remove_directory
. -
path_unlink_file
The right to invokepath_unlink_file
. -
poll_fd_readwrite
Ifrights::fd_read
is set, includes the right to invokepoll_oneoff
to subscribe toeventtype::fd_read
. Ifrights::fd_write
is set, includes the right to invokepoll_oneoff
to subscribe toeventtype::fd_write
. -
sock_shutdown
The right to invokesock_shutdown
.
A file descriptor handle.
Size: 4
Alignment: 4
A region of memory for scatter/gather reads.
Size: 8
Alignment: 4
Offset: 0
-
buf_len
:size
The length of the buffer to be filled.
Offset: 4
A region of memory for scatter/gather writes.
Size: 8
Alignment: 4
Offset: 0
-
buf_len
:size
The length of the buffer to be written.
Offset: 4
Size: 8
Alignment: 4
Size: 8
Alignment: 4
Relative offset within a file.
Size: 8
Alignment: 8
The position relative to which to set the offset of the file descriptor.
Size: 1
Alignment: 1
A reference to the offset of a directory entry.
The value 0 signifies the start of the directory.
Size: 8
Alignment: 8
The type for the dirent::d_namlen
field of dirent
struct.
Size: 4
Alignment: 4
File serial number that is unique within its file system.
Size: 8
Alignment: 8
The type of a file descriptor or file.
Size: 1
Alignment: 1
-
unknown
The type of the file descriptor or file is unknown or is different from any of the other types specified. -
block_device
The file descriptor or file refers to a block device inode. -
character_device
The file descriptor or file refers to a character device inode. -
directory
The file descriptor or file refers to a directory inode. -
regular_file
The file descriptor or file refers to a regular file inode. -
socket_dgram
The file descriptor or file refers to a datagram socket. -
socket_stream
The file descriptor or file refers to a byte-stream socket.
A directory entry.
Size: 24
Alignment: 8
-
d_next
:dircookie
The offset of the next directory entry stored in this directory.
Offset: 0
-
d_ino
:inode
The serial number of the file referred to by this directory entry.
Offset: 8
-
d_namlen
:dirnamlen
The length of the name of the directory entry.
Offset: 16
-
d_type
:filetype
The type of the file referred to by this directory entry.
Offset: 20
File or memory access pattern advisory information.
Size: 1
Alignment: 1
-
normal
The application has no advice to give on its behavior with respect to the specified data. -
sequential
The application expects to access the specified data sequentially from lower offsets to higher offsets. -
random
The application expects to access the specified data in a random order. -
willneed
The application expects to access the specified data in the near future. -
dontneed
The application expects that it will not access the specified data in the near future. -
noreuse
The application expects to access the specified data once and then not reuse it thereafter.
File descriptor flags.
Size: 2
Alignment: 2
-
append
Append mode: Data written to the file is always appended to the file's end. -
dsync
Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized. -
sync
Write 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.
File descriptor attributes.
Size: 24
Alignment: 8
-
fs_filetype
:filetype
File type.
Offset: 0
-
fs_flags
:fdflags
File descriptor flags.
Offset: 2
-
fs_rights_base
:rights
Rights that apply to this file descriptor.
Offset: 8
-
fs_rights_inheriting
:rights
Maximum set of rights that may be installed on new file descriptors that are created through this file descriptor, e.g., throughpath_open
.
Offset: 16
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
Which file time attributes to adjust.
Size: 2
Alignment: 2
-
atim
Adjust the last data access timestamp to the value stored infilestat::atim
. -
atim_now
Adjust the last data access timestamp to the time of clockclockid::realtime
. -
mtim
Adjust the last data modification timestamp to the value stored infilestat::mtim
. -
mtim_now
Adjust the last data modification timestamp to the time of clockclockid::realtime
.
Flags determining the method of how paths are resolved.
Size: 4
Alignment: 4
Open flags used by path_open
.
Size: 2
Alignment: 2
Number of hard links to an inode.
Size: 8
Alignment: 8
File attributes.
Size: 64
Alignment: 8
-
dev
:device
Device ID of device containing the file.
Offset: 0
-
ino
:inode
File serial number.
Offset: 8
-
filetype
:filetype
File type.
Offset: 16
-
nlink
:linkcount
Number of hard links to the file.
Offset: 24
-
size
:filesize
For 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
:timestamp
Last data access timestamp.
Offset: 40
-
mtim
:timestamp
Last data modification timestamp.
Offset: 48
-
ctim
:timestamp
Last file status change timestamp.
Offset: 56
User-provided value that may be attached to objects that is retained when extracted from the implementation.
Size: 8
Alignment: 8
Type of a subscription to an event or its occurrence.
Size: 1
Alignment: 1
-
clock
The time value of clocksubscription_clock::id
has reached timestampsubscription_clock::timeout
. -
fd_read
File descriptorsubscription_fd_readwrite::file_descriptor
has data available for reading. This event always triggers for regular files. -
fd_write
File descriptorsubscription_fd_readwrite::file_descriptor
has capacity available for writing. This event always triggers for regular files.
The state of the file descriptor subscribed to with
eventtype::fd_read
or eventtype::fd_write
.
Size: 2
Alignment: 2
The contents of an event
when type is eventtype::fd_read
or
eventtype::fd_write
.
Size: 16
Alignment: 8
-
nbytes
:filesize
The number of bytes available for reading or writing.
Offset: 0
-
flags
:eventrwflags
The state of the file descriptor.
Offset: 8
An event that occurred.
Size: 32
Alignment: 8
-
userdata
:userdata
User-provided value that got attached tosubscription::userdata
.
Offset: 0
-
error
:errno
If non-zero, an error that occurred while processing the subscription request.
Offset: 8
-
type
:eventtype
The type of event that occured
Offset: 10
-
fd_readwrite
:event_fd_readwrite
The contents of the event, if it is aneventtype::fd_read
oreventtype::fd_write
.eventtype::clock
events ignore this field.
Offset: 16
Flags determining how to interpret the timestamp provided in
subscription_clock::timeout
.
Size: 2
Alignment: 2
-
subscription_clock_abstime
If set, treat the timestamp provided insubscription_clock::timeout
as an absolute timestamp of clocksubscription_clock::id
. If clear, treat the timestamp provided insubscription_clock::timeout
relative to the current time value of clocksubscription_clock::id
.
The contents of a subscription
when type is eventtype::clock
.
Size: 32
Alignment: 8
-
id
:clockid
The clock against which to compare the timestamp.
Offset: 0
-
timeout
:timestamp
The absolute or relative timestamp.
Offset: 8
-
precision
:timestamp
The amount of time that the implementation may wait additionally to coalesce with other events.
Offset: 16
-
flags
:subclockflags
Flags specifying whether the timeout is absolute or relative
Offset: 24
The contents of a subscription
when type is type is
eventtype::fd_read
or eventtype::fd_write
.
Size: 4
Alignment: 4
-
file_descriptor
:fd
The file descriptor on which to wait for it to become ready for reading or writing.
Offset: 0
The contents of a subscription
.
Size: 40
Alignment: 8
- tag_size: 1
- tag_align: 1
- contents_offset: 8
- contents_size: 32
- contents_align: 8
-
clock
:subscription_clock
-
fd_read
:subscription_fd_readwrite
-
fd_write
:subscription_fd_readwrite
Subscription to an event.
Size: 48
Alignment: 8
-
userdata
:userdata
User-provided value that is attached to the subscription in the implementation and returned throughevent::userdata
.
Offset: 0
-
u
:subscription_u
The type of the event to which to subscribe, and its contents
Offset: 8
Exit code generated by a process when exiting.
Size: 4
Alignment: 4
Signal condition.
Size: 1
Alignment: 1
-
none
No signal. Note that POSIX has special semantics forkill(pid, 0)
, so this value is reserved. -
int
Terminate interrupt signal. Action: Terminates the process. -
bus
Access to an undefined portion of a memory object. Action: Terminates the process. -
fpe
Erroneous arithmetic operation. Action: Terminates the process. -
segv
Invalid memory reference. Action: Terminates the process. -
pipe
Write on a pipe with no one to read it. Action: Ignored. -
chld
Child process terminated, stopped, or continued. Action: Ignored. -
cont
Continue executing, if stopped. Action: Continues executing, if stopped. -
ttin
Background process attempting read. Action: Stops executing. -
ttou
Background process attempting write. Action: Stops executing. -
urg
High bandwidth data is available at a socket. Action: Ignored. -
xcpu
CPU time limit exceeded. Action: Terminates the process. -
xfsz
File size limit exceeded. Action: Terminates the process. -
vtalrm
Virtual timer expired. Action: Terminates the process. -
prof
Profiling timer expired. Action: Terminates the process.
Flags provided to sock_recv
.
Size: 2
Alignment: 2
-
recv_peek
Returns the message without removing it from the socket's receive queue. -
recv_waitall
On byte-stream sockets, block until the full amount of data can be returned.
Flags returned by sock_recv
.
Size: 2
Alignment: 2
-
recv_data_truncated
Returned bysock_recv
: Message data has been truncated.
Flags provided to sock_send
. As there are currently no flags
defined, it must be set to zero.
Size: 2
Alignment: 2
Which channels on a socket to shut down.
Size: 1
Alignment: 1
Identifiers for preopened capabilities.
Size: 1
Alignment: 1
The contents of a $prestat when type is preopentype::dir
.
Size: 4
Alignment: 4
-
pr_name_len
:size
The length of the directory name for use withfd_prestat_dir_name
.
Offset: 0
Information about a pre-opened capability.
Size: 8
Alignment: 4
- tag_size: 1
- tag_align: 1
- contents_offset: 4
- contents_size: 4
- contents_align: 4
-
dir
:prestat_dir
Read command-line argument data.
The size of the array should match that returned by args_sizes_get
-
error
:errno
Return command-line argument data sizes.
-
error
:errno
-
argc
:size
The number of arguments. -
argv_buf_size
:size
The size of the argument string data.
Read environment variable data.
The sizes of the buffers should match that returned by environ_sizes_get
.
-
error
:errno
Return environment variable data sizes.
-
error
:errno
-
environc
:size
The number of environment variable arguments. -
environ_buf_size
:size
The size of the environment variable data.
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.
-
id
:clockid
The clock for which to return the resolution.
Return the time value of a clock.
Note: This is similar to clock_gettime
in POSIX.
-
id
:clockid
The clock for which to return the time. -
precision
:timestamp
The maximum lag (exclusive) that the returned time value may have, compared to its actual value.
Provide file advisory information on a file descriptor.
Note: This is similar to posix_fadvise
in POSIX.
-
fd
:fd
-
offset
:filesize
The offset within the file to which the advisory applies. -
len
:filesize
The length of the region to which the advisory applies. -
advice
:advice
The advice.
-
error
:errno
Force the allocation of space in a file.
Note: This is similar to posix_fallocate
in POSIX.
-
fd
:fd
-
offset
:filesize
The offset at which to start the allocation. -
len
:filesize
The length of the area that is allocated.
-
error
:errno
Close a file descriptor.
Note: This is similar to close
in POSIX.
-
fd
:fd
-
error
:errno
Synchronize the data of a file to disk.
Note: This is similar to fdatasync
in POSIX.
-
fd
:fd
-
error
:errno
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
:fd
Adjust the flags associated with a file descriptor.
Note: This is similar to fcntl(fd, F_SETFL, flags)
in POSIX.
-
error
: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
-
fd
:fd
-
fs_rights_base
:rights
The desired rights of the file descriptor. -
fs_rights_inheriting
:rights
-
error
:errno
Return the attributes of an open file.
-
fd
:fd
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.
-
error
:errno
Adjust the timestamps of an open file or directory.
Note: This is similar to futimens
in POSIX.
-
fd
:fd
-
atim
:timestamp
The desired values of the data access timestamp. -
mtim
:timestamp
The desired values of the data modification timestamp. -
fst_flags
:fstflags
A bitmask indicating which timestamps to adjust.
-
error
:errno
Read from a file descriptor, without using and updating the file descriptor's offset.
Note: This is similar to preadv
in POSIX.
-
fd
:fd
-
iovs
:iovec_array
List of scatter/gather vectors in which to store data. -
offset
:filesize
The offset within the file at which to read.
Return a description of the given preopened file descriptor.
-
fd
:fd
Return a description of the given preopened file descriptor.
-
error
:errno
Write to a file descriptor, without using and updating the file descriptor's offset.
Note: This is similar to pwritev
in POSIX.
-
fd
:fd
-
iovs
:ciovec_array
List of scatter/gather vectors from which to retrieve data. -
offset
:filesize
The offset within the file at which to write.
Read from a file descriptor.
Note: This is similar to readv
in POSIX.
-
fd
:fd
-
iovs
:iovec_array
List of scatter/gather vectors to which to store data.
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
:fd
-
buf
:Pointer<u8>
The buffer where directory entries are stored -
buf_len
:size
-
cookie
:dircookie
The location within the directory to start reading
-
error
:errno
-
bufused
:size
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.
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.
-
error
:errno
Move the offset of a file descriptor.
Note: This is similar to lseek
in POSIX.
-
fd
:fd
-
offset
:filedelta
The number of bytes to move. -
whence
:whence
The base from which the offset is relative.
-
error
:errno
-
newoffset
:filesize
The new offset of the file descriptor, relative to the start of the file.
Synchronize the data and metadata of a file to disk.
Note: This is similar to fsync
in POSIX.
-
fd
:fd
-
error
:errno
Return the current offset of a file descriptor.
Note: This is similar to lseek(fd, 0, SEEK_CUR)
in POSIX.
-
fd
:fd
-
error
:errno
-
offset
:filesize
The current offset of the file descriptor, relative to the start of the file.
Write to a file descriptor.
Note: This is similar to writev
in POSIX.
-
fd
:fd
-
iovs
:ciovec_array
List of scatter/gather vectors from which to retrieve data.
Create a directory.
Note: This is similar to mkdirat
in POSIX.
-
fd
:fd
-
error
:errno
Return the attributes of a file or directory.
Note: This is similar to stat
in POSIX.
-
fd
:fd
-
flags
:lookupflags
Flags determining the method of how the path is resolved.
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.
-
fd
:fd
-
flags
:lookupflags
Flags determining the method of how the path is resolved. -
path
:string
The path of the file or directory to operate on. -
atim
:timestamp
The desired values of the data access timestamp. -
mtim
:timestamp
The desired values of the data modification timestamp. -
fst_flags
:fstflags
A bitmask indicating which timestamps to adjust.
-
error
:errno
path_link(old_fd: fd, old_flags: lookupflags, old_path: string, new_fd: fd, new_path: string) -> errno
Create a hard link.
Note: This is similar to linkat
in POSIX.
-
old_fd
:fd
-
old_flags
:lookupflags
Flags determining the method of how the path is resolved. -
new_fd
:fd
The working directory at which the resolution of the new path starts. -
new_path
:string
The destination path at which to create the hard link.
-
error
:errno
path_open(fd: fd, dirflags: lookupflags, path: string, oflags: oflags, fs_rights_base: rights, fs_rights_inheriting: 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.
-
fd
:fd
-
dirflags
:lookupflags
Flags determining the method of how the path is resolved. -
path
:string
The relative path of the file or directory to open, relative to thepath_open::fd
directory. -
oflags
:oflags
The method by which to open the file. -
fs_rights_base
:rights
The 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
Read the contents of a symbolic link.
Note: This is similar to readlinkat
in POSIX.
-
fd
:fd
-
path
:string
The 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
Remove a directory.
Return errno::notempty
if the directory is not empty.
Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR)
in POSIX.
-
fd
:fd
-
error
:errno
Rename a file or directory.
Note: This is similar to renameat
in POSIX.
-
fd
:fd
-
old_path
:string
The source path of the file or directory to rename. -
new_fd
:fd
The working directory at which the resolution of the new path starts. -
new_path
:string
The destination path to which to rename the file or directory.
-
error
:errno
Create a symbolic link.
Note: This is similar to symlinkat
in POSIX.
-
fd
:fd
-
new_path
:string
The destination path at which to create the symbolic link.
-
error
: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.
-
fd
:fd
-
error
:errno
poll_oneoff(in: ConstPointer<subscription>, out: Pointer<event>, nsubscriptions: size) -> (errno, size)
Concurrently poll for the occurrence of a set of events.
-
in
:ConstPointer<subscription>
The events to which to subscribe. -
nsubscriptions
:size
Both the number of subscriptions and events.
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.
-
rval
:exitcode
The exit code returned by the process.
Send a signal to the process of the calling thread.
Note: This is similar to raise
in POSIX.
-
sig
:signal
The signal condition to trigger.
-
error
:errno
Temporarily yield execution of the calling thread.
Note: This is similar to sched_yield
in POSIX.
-
error
: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.
-
buf_len
:size
-
error
: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
.
-
fd
:fd
-
ri_data
:iovec_array
List of scatter/gather vectors to which to store data. -
ri_flags
:riflags
Message flags.
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
.
-
fd
:fd
-
si_data
:ciovec_array
List of scatter/gather vectors to which to retrieve data -
si_flags
:siflags
Message flags.
Shut down socket send and receive channels.
Note: This is similar to shutdown
in POSIX.
-
error
:errno