cloudabi
cloudabi copied to clipboard
Definitions for the CloudABI data types and system calls
NOTE: This project is unmaintained
CloudABI is no longer being maintained. It was an awesome experiment, but it never got enough traction to be sustainable. If you like the idea behind CloudABI, please consider looking into the WebAssembly System Interface (WASI). WASI's design has been inspired by CloudABI.
The author of CloudABI (Ed Schouten) would like to thank all of the people who contributed to this project. Let's hope CloudABI lives on in spirit and influences the way software is designed in the future!
Nuxi CloudABI
CloudABI is what you get if you take POSIX, add capability-based security, and remove everything that's incompatible with that. The result is a minimal ABI consisting of only 49 syscalls.
CloudABI doesn't have its own kernel, but instead is implemented in existing kernels: FreeBSD has CloudABI support for x86-64 and arm64, and a patch-set for NetBSD and a patch-set for Linux are available as well. This means that CloudABI binaries can be executed on different operating systems, without any modification.
Capability-Based Security
Capability-based security means that processes can only perform actions that have no global impact. Processes cannot open files by their absolute path, cannot open network connections, and cannot observe global system state such as the process table.
The capabilities of a process are fully determined by its set of open file descriptors (fds). For example, files can only be opened if the process already has a file descriptor to a directory the file is in.
Unlike in POSIX, where processes are normally started with file descriptors 0, 1, and 2 reserved for standard input, output, and error, CloudABI does not reserve any file descriptor numbers for specific purposes.
In CloudABI, a process depends on its parent process to launch it with the right set of resources, since the process will not be able to open any new resources. For example, a simple static web server would need to be started with a file descriptor to a TCP listener, and a file descriptor to the directory for which to serve files. The web server will then be unable to do anything other than reading files in that directory, and process incoming network connections.
So, unknown CloudABI binaries can safely be executed without the need for containers, virtual machines, or other sandboxing technologies.
Watch Ed Schouten's Talk at 32C3 for more information about what capability-based security for UNIX means.
Cloudlibc
Cloudlibc is an implementation
of the C standard library, without all CloudABI-incompatible
functions. For example, Cloudlibc does not have printf, but does
have fprintf. It does not have open, but does have openat.
CloudABI-Ports
CloudABI-Ports is a
collection of ports of commonly used libraries and applications to
CloudABI. It contains software such as zlib, libpng, boost,
memcached, and much more. The software is patched to not depend on
any global state, such as files in /etc or /dev, using open(),
etc.
Using CloudABI
Instructions for using CloudABI (including kernel modules/patches, toolchain, and ports) are available for several operating systems:
Specification of the ABI
The entire ABI is specified in a file called
cloudabi.txt,
from which all
headers
and documentation (including the one you're reading now) is generated.
System calls
cloudabi_sys_clock_res_get()cloudabi_sys_clock_time_get()cloudabi_sys_condvar_signal()cloudabi_sys_fd_close()cloudabi_sys_fd_create1()cloudabi_sys_fd_create2()cloudabi_sys_fd_datasync()cloudabi_sys_fd_dup()cloudabi_sys_fd_pread()cloudabi_sys_fd_pwrite()cloudabi_sys_fd_read()cloudabi_sys_fd_replace()cloudabi_sys_fd_seek()cloudabi_sys_fd_stat_get()cloudabi_sys_fd_stat_put()cloudabi_sys_fd_sync()cloudabi_sys_fd_write()cloudabi_sys_file_advise()cloudabi_sys_file_allocate()cloudabi_sys_file_create()cloudabi_sys_file_link()cloudabi_sys_file_open()cloudabi_sys_file_readdir()cloudabi_sys_file_readlink()cloudabi_sys_file_rename()cloudabi_sys_file_stat_fget()cloudabi_sys_file_stat_fput()cloudabi_sys_file_stat_get()cloudabi_sys_file_stat_put()cloudabi_sys_file_symlink()cloudabi_sys_file_unlink()cloudabi_sys_lock_unlock()cloudabi_sys_mem_advise()cloudabi_sys_mem_map()cloudabi_sys_mem_protect()cloudabi_sys_mem_sync()cloudabi_sys_mem_unmap()cloudabi_sys_poll()cloudabi_sys_proc_exec()cloudabi_sys_proc_exit()cloudabi_sys_proc_fork()cloudabi_sys_proc_raise()cloudabi_sys_random_get()cloudabi_sys_sock_recv()cloudabi_sys_sock_send()cloudabi_sys_sock_shutdown()cloudabi_sys_thread_create()cloudabi_sys_thread_exit()cloudabi_sys_thread_yield()
cloudabi_sys_clock_res_get()
Obtains the resolution of a clock.
Inputs:
-
cloudabi_clockid_t clock_idThe clock for which the resolution needs to be returned.
Outputs:
-
cloudabi_timestamp_t resolutionThe resolution of the clock.
cloudabi_sys_clock_time_get()
Obtains the time value of a clock.
Inputs:
-
cloudabi_clockid_t clock_idThe clock for which the time needs to be returned.
-
cloudabi_timestamp_t precisionThe maximum lag (exclusive) that the returned time value may have, compared to its actual value.
Outputs:
-
cloudabi_timestamp_t timeThe time value of the clock.
cloudabi_sys_condvar_signal()
Wakes up threads waiting on a userspace condition variable.
If an invocation of this system call causes all waiting
threads to be woken up, the value of the condition variable
is set to CLOUDABI_CONDVAR_HAS_NO_WAITERS. As long as the condition
variable is set to this value, it is not needed to invoke this
system call.
Inputs:
-
_Atomic(cloudabi_condvar_t) *condvarThe userspace condition variable that has waiting threads.
-
cloudabi_scope_t scopeWhether the condition variable is stored in private or shared memory.
-
cloudabi_nthreads_t nwaitersThe number of threads that need to be woken up. If it exceeds the number of waiting threads, all threads are woken up.
cloudabi_sys_fd_close()
Closes a file descriptor.
Inputs:
-
cloudabi_fd_t fdThe file descriptor that needs to be closed.
cloudabi_sys_fd_create1()
Creates a file descriptor.
Inputs:
-
cloudabi_filetype_t typePossible values:
-
CLOUDABI_FILETYPE_SHARED_MEMORYCreates an anonymous shared memory object.
-
Outputs:
-
cloudabi_fd_t fdThe file descriptor that has been created.
cloudabi_sys_fd_create2()
Creates a pair of file descriptors.
Inputs:
-
cloudabi_filetype_t typePossible values:
-
CLOUDABI_FILETYPE_SOCKET_DGRAMCreates a UNIX datagram socket pair.
-
CLOUDABI_FILETYPE_SOCKET_STREAMCreates a UNIX byte-stream socket pair.
-
Outputs:
-
cloudabi_fd_t fd1The first file descriptor of the pair.
-
cloudabi_fd_t fd2The second file descriptor of the pair.
cloudabi_sys_fd_datasync()
Synchronizes the data of a file to disk.
Inputs:
-
cloudabi_fd_t fdThe file descriptor of the file whose data needs to be synchronized to disk.
cloudabi_sys_fd_dup()
Duplicates a file descriptor.
Inputs:
-
cloudabi_fd_t fromThe file descriptor that needs to be duplicated.
Outputs:
-
cloudabi_fd_t fdThe new file descriptor.
cloudabi_sys_fd_pread()
Reads from a file descriptor, without using and updating the file descriptor's offset.
Inputs:
-
cloudabi_fd_t fdThe file descriptor from which data should be read.
-
const cloudabi_iovec_t *iovsandsize_t iovs_lenList of scatter/gather vectors where data should be stored.
-
cloudabi_filesize_t offsetThe offset within the file at which reading should start.
Outputs:
-
size_t nreadThe number of bytes read.
cloudabi_sys_fd_pwrite()
Writes to a file descriptor, without using and updating the file descriptor's offset.
Inputs:
-
cloudabi_fd_t fdThe file descriptor to which data should be written.
-
const cloudabi_ciovec_t *iovsandsize_t iovs_lenList of scatter/gather vectors where data should be retrieved.
-
cloudabi_filesize_t offsetThe offset within the file at which writing should start.
Outputs:
-
size_t nwrittenThe number of bytes written.
cloudabi_sys_fd_read()
Reads from a file descriptor.
Inputs:
-
cloudabi_fd_t fdThe file descriptor from which data should be read.
-
const cloudabi_iovec_t *iovsandsize_t iovs_lenList of scatter/gather vectors where data should be stored.
Outputs:
-
size_t nreadThe number of bytes read.
cloudabi_sys_fd_replace()
Atomically replaces a file descriptor by a copy of another file descriptor.
Due to the strong focus on thread safety, this environment does not provide a mechanism to duplicate 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 system call provides a way to atomically replace file descriptors, which would disappear if dup2() were to be removed entirely.
Inputs:
-
cloudabi_fd_t fromThe file descriptor that needs to be copied.
-
cloudabi_fd_t toThe file descriptor that needs to be overwritten.
cloudabi_sys_fd_seek()
Moves the offset of the file descriptor.
Inputs:
-
cloudabi_fd_t fdThe file descriptor whose offset has to be moved.
-
cloudabi_filedelta_t offsetThe number of bytes to move.
-
cloudabi_whence_t whenceRelative to which position the move should take place.
Outputs:
-
cloudabi_filesize_t newoffsetThe new offset of the file descriptor, relative to the start of the file.
cloudabi_sys_fd_stat_get()
Gets attributes of a file descriptor.
Inputs:
-
cloudabi_fd_t fdThe file descriptor whose attributes have to be obtained.
-
cloudabi_fdstat_t *bufThe buffer where the file descriptor's attributes are stored.
cloudabi_sys_fd_stat_put()
Adjusts attributes of a file descriptor.
Inputs:
-
cloudabi_fd_t fdThe file descriptor whose attributes have to be adjusted.
-
const cloudabi_fdstat_t *bufThe desired values of the file descriptor attributes that are adjusted.
-
cloudabi_fdsflags_t flagsA bitmask indicating which attributes have to be adjusted.
cloudabi_sys_fd_sync()
Synchronizes the data and metadata of a file to disk.
Inputs:
-
cloudabi_fd_t fdThe file descriptor of the file whose data and metadata needs to be synchronized to disk.
cloudabi_sys_fd_write()
Writes to a file descriptor.
Inputs:
-
cloudabi_fd_t fdThe file descriptor to which data should be written.
-
const cloudabi_ciovec_t *iovsandsize_t iovs_lenList of scatter/gather vectors where data should be retrieved.
Outputs:
-
size_t nwrittenThe number of bytes written.
cloudabi_sys_file_advise()
Provides file advisory information on a file descriptor.
Inputs:
-
cloudabi_fd_t fdThe file descriptor for which to provide file advisory information.
-
cloudabi_filesize_t offsetThe offset within the file to which the advisory applies.
-
cloudabi_filesize_t lenThe length of the region to which the advisory applies.
-
cloudabi_advice_t adviceThe advice.
cloudabi_sys_file_allocate()
Forces the allocation of space in a file.
Inputs:
-
cloudabi_fd_t fdThe file in which the space should be allocated.
-
cloudabi_filesize_t offsetThe offset at which the allocation should start.
-
cloudabi_filesize_t lenThe length of the area that is allocated.
cloudabi_sys_file_create()
Creates a file of a specified type.
Inputs:
-
cloudabi_fd_t fdThe working directory at which the resolution of the file to be created starts.
-
const char *pathandsize_t path_lenThe path at which the file should be created.
-
cloudabi_filetype_t typePossible values:
-
CLOUDABI_FILETYPE_DIRECTORYCreates a directory.
-
cloudabi_sys_file_link()
Creates a hard link.
Inputs:
-
cloudabi_lookup_t fd1The working directory at which the resolution of the source path starts.
-
const char *path1andsize_t path1_lenThe source path of the file that should be hard linked.
-
cloudabi_fd_t fd2The working directory at which the resolution of the destination path starts.
-
const char *path2andsize_t path2_lenThe destination path at which the hard link should be created.
cloudabi_sys_file_open()
Opens a file.
Inputs:
-
cloudabi_lookup_t dirfdThe working directory at which the resolution of the file to be opened starts.
-
const char *pathandsize_t path_lenThe path of the file that should be opened.
-
cloudabi_oflags_t oflagsThe method at which the file should be opened.
-
const cloudabi_fdstat_t *fdscloudabi_fdstat_t::fs_rights_baseandcloudabi_fdstat_t::fs_rights_inheritingspecify the initial rights of the newly created file descriptor. The operating system 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.cloudabi_fdstat_t::fs_flagsspecifies the initial flags of the file descriptor.cloudabi_fdstat_t::fs_filetypeis ignored.
Outputs:
-
cloudabi_fd_t fdThe file descriptor of the file that has been opened.
cloudabi_sys_file_readdir()
Reads 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 cloudabi_dirent_t object, followed by cloudabi_dirent_t::d_namlen bytes
holding the name of the directory entry.
This system call 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.
Inputs:
-
cloudabi_fd_t fdThe directory from which to read the directory entries.
-
void *bufandsize_t buf_lenThe buffer where directory entries are stored.
-
cloudabi_dircookie_t cookieThe location within the directory to start reading.
Outputs:
-
size_t bufusedThe 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.
cloudabi_sys_file_readlink()
Reads the contents of a symbolic link.
Inputs:
-
cloudabi_fd_t fdThe working directory at which the resolution of the path of the symbolic starts.
-
const char *pathandsize_t path_lenThe path of the symbolic link whose contents should be read.
-
char *bufandsize_t buf_lenThe buffer where the contents of the symbolic link should be stored.
Outputs:
-
size_t bufusedThe number of bytes placed in the buffer.
cloudabi_sys_file_rename()
Renames a file.
Inputs:
-
cloudabi_fd_t fd1The working directory at which the resolution of the source path starts.
-
const char *path1andsize_t path1_lenThe source path of the file that should be renamed.
-
cloudabi_fd_t fd2The working directory at which the resolution of the destination path starts.
-
const char *path2andsize_t path2_lenThe destination path to which the file should be renamed.
cloudabi_sys_file_stat_fget()
Gets attributes of a file by file descriptor.
Inputs:
-
cloudabi_fd_t fdThe file descriptor whose attributes have to be obtained.
-
cloudabi_filestat_t *bufThe buffer where the file's attributes are stored.
cloudabi_sys_file_stat_fput()
Adjusts attributes of a file by file descriptor.
Inputs:
-
cloudabi_fd_t fdThe file descriptor whose attributes have to be adjusted.
-
const cloudabi_filestat_t *bufThe desired values of the file attributes that are adjusted.
-
cloudabi_fsflags_t flagsA bitmask indicating which attributes have to be adjusted.
cloudabi_sys_file_stat_get()
Gets attributes of a file by path.
Inputs:
-
cloudabi_lookup_t fdThe working directory at which the resolution of the path whose attributes have to be obtained starts.
-
const char *pathandsize_t path_lenThe path of the file whose attributes have to be obtained.
-
cloudabi_filestat_t *bufThe buffer where the file's attributes are stored.
cloudabi_sys_file_stat_put()
Adjusts attributes of a file by path.
Inputs:
-
cloudabi_lookup_t fdThe working directory at which the resolution of the path whose attributes have to be adjusted starts.
-
const char *pathandsize_t path_lenThe path of the file whose attributes have to be adjusted.
-
const cloudabi_filestat_t *bufThe desired values of the file attributes that are adjusted.
-
cloudabi_fsflags_t flagsA bitmask indicating which attributes have to be adjusted.
cloudabi_sys_file_symlink()
Creates a symbolic link.
Inputs:
-
const char *path1andsize_t path1_lenThe contents of the symbolic link.
-
cloudabi_fd_t fdThe working directory at which the resolution of the destination path starts.
-
const char *path2andsize_t path2_lenThe destination path at which the symbolic link should be created.
cloudabi_sys_file_unlink()
Unlinks a file, or removes a directory.
Inputs:
-
cloudabi_fd_t fdThe working directory at which the resolution of the path starts.
-
const char *pathandsize_t path_lenThe path that needs to be unlinked or removed.
-
cloudabi_ulflags_t flagsPossible values:
-
CLOUDABI_UNLINK_REMOVEDIRIf set, attempt to remove a directory. Otherwise, unlink a file.
-
cloudabi_sys_lock_unlock()
Unlocks a write-locked userspace lock.
If a userspace lock is unlocked while having its
CLOUDABI_LOCK_KERNEL_MANAGED flag set, the lock cannot be unlocked in
userspace directly. This system call needs to be performed
instead, so that any waiting threads can be woken up.
To prevent spurious invocations of this system call, the lock must be locked for writing. This prevents other threads from acquiring additional read locks while the system call is in progress. If the lock is acquired for reading, it must first be upgraded to a write lock.
Inputs:
-
_Atomic(cloudabi_lock_t) *lockThe userspace lock that is locked for writing by the calling thread.
-
cloudabi_scope_t scopeWhether the lock is stored in private or shared memory.
cloudabi_sys_mem_advise()
Provides memory advisory information on a region of memory.
Inputs:
-
void *mappingandsize_t mapping_lenThe pages for which to provide memory advisory information.
-
cloudabi_advice_t adviceThe advice.
cloudabi_sys_mem_map()
Creates a memory mapping, making the contents of a file accessible through memory.
Inputs:
-
void *addrIf
CLOUDABI_MAP_FIXEDis set, specifies to which address the file region is mapped. Otherwise, the mapping is performed at an unused location. -
size_t lenThe length of the memory mapping to be created.
-
cloudabi_mprot_t protInitial memory protection options for the memory mapping.
-
cloudabi_mflags_t flagsMemory mapping flags.
-
cloudabi_fd_t fdIf
CLOUDABI_MAP_ANONis set, this argument must beCLOUDABI_MAP_ANON_FD. Otherwise, this argument specifies the file whose contents need to be mapped. -
cloudabi_filesize_t offIf
CLOUDABI_MAP_ANONis set, this argument must be zero. Otherwise, this argument specifies the offset within the file at which the mapping starts.
Outputs:
-
void *memThe starting address of the memory mapping.
cloudabi_sys_mem_protect()
Change the protection of a memory mapping.
Inputs:
-
void *mappingandsize_t mapping_lenThe pages that need their protection changed.
-
cloudabi_mprot_t protNew protection options.
cloudabi_sys_mem_sync()
Synchronize a region of memory with its physical storage.
Inputs:
-
void *mappingandsize_t mapping_lenThe pages that need to be synchronized.
-
cloudabi_msflags_t flagsThe method of synchronization.
cloudabi_sys_mem_unmap()
Unmaps a region of memory.
Inputs:
-
void *mappingandsize_t mapping_lenThe pages that needs to be unmapped.
cloudabi_sys_poll()
Concurrently polls for the occurrence of a set of events.
Inputs:
-
const cloudabi_subscription_t *inThe events to which to subscribe.
-
cloudabi_event_t *outThe events that have occurred.
-
size_t nsubscriptionsBoth the number of subscriptions and events.
Outputs:
-
size_t neventsThe number of events stored.
cloudabi_sys_proc_exec()
Replaces the process by a new executable.
Process execution in CloudABI differs from POSIX in two ways: handling of arguments and inheritance of file descriptors.
CloudABI does not use string command line arguments. Instead, a buffer with binary data is copied into the address space of the new executable. The kernel does not enforce any specific structure to this data, although CloudABI's C library uses it to store a tree structure that is semantically identical to YAML.
Due to the strong focus on thread safety, file descriptors aren't inherited through close-on-exec flags. An explicit list of file descriptors that need to be retained needs to be provided. After execution, file descriptors are placed in the order in which they are stored in the array. This not only makes the execution process deterministic. It also prevents potential information disclosures about the layout of the original process.
Inputs:
-
cloudabi_fd_t fdA file descriptor of the new executable.
-
const void *dataandsize_t data_lenBinary argument data that is passed on to the new executable.
-
const cloudabi_fd_t *fdsandsize_t fds_lenThe layout of the file descriptor table after execution.
cloudabi_sys_proc_exit()
Terminates the process normally.
Inputs:
-
cloudabi_exitcode_t rvalThe exit code returned by the process. The exit code can be obtained by other processes through
cloudabi_event_t::proc_terminate.exitcode.
Does not return.
cloudabi_sys_proc_fork()
Forks the process of the calling thread.
After forking, a new process shall be created, having only a
copy of the calling thread. The parent process will obtain a
process descriptor. When closed, the child process is
automatically signaled with CLOUDABI_SIGKILL.
Outputs:
-
cloudabi_fd_t fdIn the parent process: the file descriptor number of the process descriptor.
In the child process:
CLOUDABI_PROCESS_CHILD. -
cloudabi_tid_t tidIn the parent process: undefined.
In the child process: the thread ID of the initial thread of the child process.
cloudabi_sys_proc_raise()
Sends a signal to the process of the calling thread.
Inputs:
-
cloudabi_signal_t sigThe signal condition that should be triggered. If the signal causes the process to terminate, its condition can be obtained by other processes through
cloudabi_event_t::proc_terminate.signal.
cloudabi_sys_random_get()
Obtains random data from the kernel random number generator.
As this interface is not guaranteed to be fast, it is advised that the random data obtained through this system call is used as the seed for a userspace pseudo-random number generator.
Inputs:
-
void *bufandsize_t buf_lenThe buffer that needs to be filled with random data.
cloudabi_sys_sock_recv()
Receives a message on a socket.
Inputs:
-
cloudabi_fd_t sockThe socket on which a message should be received.
-
const cloudabi_recv_in_t *inInput parameters.
-
cloudabi_recv_out_t *outOutput parameters.
cloudabi_sys_sock_send()
Sends a message on a socket.
Inputs:
-
cloudabi_fd_t sockThe socket on which a message should be sent.
-
const cloudabi_send_in_t *inInput parameters.
-
cloudabi_send_out_t *outOutput parameters.
cloudabi_sys_sock_shutdown()
Shuts down socket send and receive channels.
Inputs:
-
cloudabi_fd_t sockThe socket that needs its channels shut down.
-
cloudabi_sdflags_t howWhich channels on the socket need to be shut down.
cloudabi_sys_thread_create()
Creates a new thread within the current process.
Inputs:
-
cloudabi_threadattr_t *attrThe desired attributes of the new thread.
Outputs:
-
cloudabi_tid_t tidThe thread ID of the new thread.
cloudabi_sys_thread_exit()
Terminates the calling thread.
This system call can also unlock a single userspace lock after termination, which can be used to implement thread joining.
Inputs:
-
_Atomic(cloudabi_lock_t) *lockUserspace lock that is locked for writing by the calling thread.
-
cloudabi_scope_t scopeWhether the lock is stored in private or shared memory.
Does not return.
cloudabi_sys_thread_yield()
Temporarily yields execution of the calling thread.
Types
cloudabi_advice_t (uint8_t)
File or memory access pattern advisory information.
Used by cloudabi_sys_file_advise() and cloudabi_sys_mem_advise().
Possible values:
-
CLOUDABI_ADVICE_DONTNEEDThe application expects that it will not access the specified data in the near future.
-
CLOUDABI_ADVICE_NOREUSEThe application expects to access the specified data once and then not reuse it thereafter.
-
CLOUDABI_ADVICE_NORMALThe application has no advice to give on its behavior with respect to the specified data.
-
CLOUDABI_ADVICE_RANDOMThe application expects to access the specified data in a random order.
-
CLOUDABI_ADVICE_SEQUENTIALThe application expects to access the specified data sequentially from lower offsets to higher offsets.
-
CLOUDABI_ADVICE_WILLNEEDThe application expects to access the specified data in the near future.
cloudabi_auxtype_t (uint32_t)
Enumeration describing the kind of value stored in cloudabi_auxv_t.
Possible values:
-
CLOUDABI_AT_ARGDATABase address of the binary argument data provided to
cloudabi_sys_proc_exec(). -
CLOUDABI_AT_ARGDATALENLength of the binary argument data provided to
cloudabi_sys_proc_exec(). -
CLOUDABI_AT_BASEBase address at which the executable is placed in memory.
-
CLOUDABI_AT_CANARYBase address of a buffer of random data that may be used for non-cryptographic purposes, for example as a canary for stack smashing protection.
-
CLOUDABI_AT_CANARYLENLength of a buffer of random data that may be used for non-cryptographic purposes, for example as a canary for stack smashing protection.
-
CLOUDABI_AT_NCPUSNumber of CPUs that the system this process is running on has.
-
CLOUDABI_AT_NULLTerminator of the auxiliary vector.
-
CLOUDABI_AT_PAGESZSmallest memory object size for which individual memory protection controls can be configured.
-
CLOUDABI_AT_PHDRAddress of the first ELF program header of the executable.
-
CLOUDABI_AT_PHNUMNumber of ELF program headers of the executable.
-
CLOUDABI_AT_PIDIdentifier of the process.
This environment does not provide any simple numerical process identifiers, for the reason that these are not useful in distributed contexts. Instead, processes are identified by a UUID.
This record should point to sixteen bytes of binary data, containing a version 4 UUID (fully random).
-
CLOUDABI_AT_SYSINFO_EHDRAddress of the ELF header of the vDSO.
The vDSO is a shared library that is mapped in the address space of the process. It provides entry points for every system call supported by the environment, all having a corresponding symbol that is prefixed with
cloudabi_sys_. System calls should be invoked through these entry points.The first advantage of letting processes call into a vDSO to perform system calls instead of raising hardware traps is that it allows for easy emulation of executables on top of existing operating systems. The second advantage is that in cases where an operating system provides native support for CloudABI executables, it may still implement partial userspace implementations of these system calls to improve performance (e.g.,
cloudabi_sys_clock_time_get()). It also provides a more dynamic way of adding, removing or replacing system calls. -
CLOUDABI_AT_TIDThread ID of the initial thread of the process.
cloudabi_auxv_t (struct)
Auxiliary vector entry.
The auxiliary vector is a list of key-value pairs that is
provided to the process on startup. Unlike structures, it is
extensible, as it is possible to add new records later on.
The auxiliary vector is always terminated by an entry having
type CLOUDABI_AT_NULL.
The auxiliary vector is part of the x86-64 ABI, but is used by this environment on all architectures.
Used by cloudabi_processentry_t.
Members:
-
cloudabi_auxtype_t a_typeThe type of the auxiliary vector entry.
-
When
a_typeisCLOUDABI_AT_ARGDATALEN,CLOUDABI_AT_CANARYLEN,CLOUDABI_AT_NCPUS,CLOUDABI_AT_PAGESZ,CLOUDABI_AT_PHNUM, orCLOUDABI_AT_TID:-
size_t a_valA numerical value.
-
-
When
a_typeisCLOUDABI_AT_ARGDATA,CLOUDABI_AT_BASE,CLOUDABI_AT_CANARY,CLOUDABI_AT_PHDR,CLOUDABI_AT_PID, orCLOUDABI_AT_SYSINFO_EHDR:-
void *a_ptrA pointer value.
-
cloudabi_ciovec_t (struct)
A region of memory for scatter/gather writes.
Used by cloudabi_send_in_t, cloudabi_sys_fd_pwrite(), and cloudabi_sys_fd_write().
Members:
-
const void *bufandsize_t buf_lenThe address and length of the buffer to be written.
cloudabi_clockid_t (uint32_t)
Identifiers for clocks.
Used by cloudabi_subscription_t, cloudabi_sys_clock_res_get(), and cloudabi_sys_clock_time_get().
Possible values:
-
CLOUDABI_CLOCK_MONOTONICThe system-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.
-
CLOUDABI_CLOCK_PROCESS_CPUTIME_IDThe CPU-time clock associated with the current process.
-
CLOUDABI_CLOCK_REALTIMEThe system-wide clock measuring real time. Time value zero corresponds with 1970-01-01T00:00:00Z.
-
CLOUDABI_CLOCK_THREAD_CPUTIME_IDThe CPU-time clock associated with the current thread.
cloudabi_condvar_t (uint32_t)
A userspace condition variable.
Used by cloudabi_subscription_t and cloudabi_sys_condvar_signal().
Special values:
-
CLOUDABI_CONDVAR_HAS_NO_WAITERSThe condition variable is in its initial state. There are no threads waiting to be woken up. If the condition variable has any other value, the kernel must be called to wake up any sleeping threads.
cloudabi_device_t (uint64_t)
Identifier for a device containing a file system. Can be used
in combination with cloudabi_inode_t to uniquely identify a file on the
local system.
Used by cloudabi_filestat_t.
cloudabi_dircookie_t (uint64_t)
A reference to the offset of a directory entry.
Used by cloudabi_dirent_t and cloudabi_sys_file_readdir().
Special values:
-
CLOUDABI_DIRCOOKIE_STARTPermanent reference to the first directory entry within a directory.
cloudabi_dirent_t (struct)
A directory entry.
Members:
-
cloudabi_dircookie_t d_nextThe offset of the next directory entry stored in this directory.
-
cloudabi_inode_t d_inoThe serial number of the file referred to by this directory entry.
-
uint32_t d_namlenThe length of the name of the directory entry.
-
cloudabi_filetype_t d_typeThe type of the file referred to by this directory entry.
cloudabi_errno_t (uint16_t)
Error codes returned by system calls.
Not all of these error codes are returned by the system calls provided by this environment, but are either used in userspace exclusively or merely provided for alignment with POSIX.
Used by cloudabi_event_t.
Possible values:
-
CLOUDABI_ESUCCESSNo error occurred. System call completed successfully.
-
CLOUDABI_E2BIGArgument list too long.
-
CLOUDABI_EACCESPermission denied.
-
CLOUDABI_EADDRINUSEAddress in use.
-
CLOUDABI_EADDRNOTAVAILAddress not available.
-
CLOUDABI_EAFNOSUPPORTAddress family not supported.
-
CLOUDABI_EAGAINResource unavailable, or operation would block.
-
CLOUDABI_EALREADYConnection already in progress.
-
CLOUDABI_EBADFBad file descriptor.
-
CLOUDABI_EBADMSGBad message.
-
CLOUDABI_EBUSYDevice or resource busy.
-
CLOUDABI_ECANCELEDOperation canceled.
-
CLOUDABI_ECHILDNo child processes.
-
CLOUDABI_ECONNABORTEDConnection aborted.
-
CLOUDABI_ECONNREFUSEDConnection refused.
-
CLOUDABI_ECONNRESETConnection reset.
-
CLOUDABI_EDEADLKResource deadlock would occur.
-
CLOUDABI_EDESTADDRREQDestination address required.
-
CLOUDABI_EDOMMathematics argument out of domain of function.
-
CLOUDABI_EDQUOTReserved.
-
CLOUDABI_EEXISTFile exists.
-
CLOUDABI_EFAULTBad address.
-
CLOUDABI_EFBIGFile too large.
-
CLOUDABI_EHOSTUNREACHHost is unreachable.
-
CLOUDABI_EIDRMIdentifier removed.
-
CLOUDABI_EILSEQIllegal byte sequence.
-
CLOUDABI_EINPROGRESSOperation in progress.
-
CLOUDABI_EINTRInterrupted function.
-
CLOUDABI_EINVALInvalid argument.
-
CLOUDABI_EIOI/O error.
-
CLOUDABI_EISCONNSocket is connected.
-
CLOUDABI_EISDIRIs a directory.
-
CLOUDABI_ELOOPToo many levels of symbolic links.
-
CLOUDABI_EMFILEFile descriptor value too large.
-
CLOUDABI_EMLINKToo many links.
-
CLOUDABI_EMSGSIZEMessage too large.
-
CLOUDABI_EMULTIHOPReserved.
-
CLOUDABI_ENAMETOOLONGFilename too long.
-
CLOUDABI_ENETDOWNNetwork is down.
-
CLOUDABI_ENETRESETConnection aborted by network.
-
CLOUDABI_ENETUNREACHNetwork unreachable.
-
CLOUDABI_ENFILEToo many files open in system.
-
CLOUDABI_ENOBUFSNo buffer space available.
-
CLOUDABI_ENODEVNo such device.
-
CLOUDABI_ENOENTNo such file or directory.
-
CLOUDABI_ENOEXECExecutable file format error.
-
CLOUDABI_ENOLCKNo locks available.
-
CLOUDABI_ENOLINKReserved.
-
CLOUDABI_ENOMEMNot enough space.
-
CLOUDABI_ENOMSGNo message of the desired type.
-
CLOUDABI_ENOPROTOOPTProtocol not available.
-
CLOUDABI_ENOSPCNo space left on device.
-
CLOUDABI_ENOSYSFunction not supported.
-
CLOUDABI_ENOTCONNThe socket is not connected.
-
CLOUDABI_ENOTDIRNot a directory or a symbolic link to a directory.
-
CLOUDABI_ENOTEMPTYDirectory not empty.
-
CLOUDABI_ENOTRECOVERABLEState not recoverable.
-
CLOUDABI_ENOTSOCKNot a socket.
-
CLOUDABI_ENOTSUPNot supported, or operation not supported on socket.
-
CLOUDABI_ENOTTYInappropriate I/O control operation.
-
CLOUDABI_ENXIONo such device or address.
-
CLOUDABI_EOVERFLOWValue too large to be stored in data type.
-
CLOUDABI_EOWNERDEADPrevious owner died.
-
CLOUDABI_EPERMOperation not permitted.
-
CLOUDABI_EPIPEBroken pipe.
-
CLOUDABI_EPROTOProtocol error.
-
CLOUDABI_EPROTONOSUPPORTProtocol not supported.
-
CLOUDABI_EPROTOTYPEProtocol wrong type for socket.
-
CLOUDABI_ERANGEResult too large.
-
CLOUDABI_EROFSRead-only file system.
-
CLOUDABI_ESPIPEInvalid seek.
-
CLOUDABI_ESRCHNo such process.
-
CLOUDABI_ESTALEReserved.
-
CLOUDABI_ETIMEDOUTConnection timed out.
-
CLOUDABI_ETXTBSYText file busy.
-
CLOUDABI_EXDEVCross-device link.
-
CLOUDABI_ENOTCAPABLEExtension: Capabilities insufficient.
cloudabi_event_t (struct)
An event that occurred.
Used by cloudabi_sys_poll().
Members:
-
cloudabi_userdata_t userdataUser-provided value that got attached to
cloudabi_subscription_t::userdata. -
cloudabi_errno_t errorIf non-zero, an error that occurred while processing the subscription request.
-
cloudabi_eventtype_t typeThe type of the event that occurred.
-
When
typeisCLOUDABI_EVENTTYPE_FD_READorCLOUDABI_EVENTTYPE_FD_WRITE:-
fd_readwrite-
cloudabi_filesize_t nbytesThe number of bytes available for reading or writing.
-
char unused[4]Obsolete.
-
cloudabi_eventrwflags_t flagsThe state of the file descriptor.
-
-
-
When
typeisCLOUDABI_EVENTTYPE_PROC_TERMINATE:-
proc_terminate-
char unused[4]Obsolete.
-
cloudabi_signal_t signalIf zero, the process has exited. Otherwise, the signal condition causing it to terminated.
-
cloudabi_exitcode_t exitcodeIf exited, the exit code of the process.
-
-
cloudabi_eventrwflags_t (uint16_t bitfield)
The state of the file descriptor subscribed to with
CLOUDABI_EVENTTYPE_FD_READ or CLOUDABI_EVENTTYPE_FD_WRITE.
Used by cloudabi_event_t.
Possible values:
-
CLOUDABI_EVENT_FD_READWRITE_HANGUPThe peer of this socket has closed or disconnected.
cloudabi_eventtype_t (uint8_t)
Type of a subscription to an event or its occurrence.
Used by cloudabi_event_t and cloudabi_subscription_t.
Possible values:
-
CLOUDABI_EVENTTYPE_CLOCKThe time value of clock
cloudabi_subscription_t::clock.clock_idhas reached timestampcloudabi_subscription_t::clock.timeout. -
CLOUDABI_EVENTTYPE_CONDVARCondition variable
cloudabi_subscription_t::condvar.condvarhas been woken up andcloudabi_subscription_t::condvar.lockhas been acquired for writing. -
CLOUDABI_EVENTTYPE_FD_READFile descriptor
cloudabi_subscription_t::fd_readwrite.fdhas data available for reading. This event always triggers for regular files. -
CLOUDABI_EVENTTYPE_FD_WRITEFile descriptor
cloudabi_subscription_t::fd_readwrite.fdhas capacity available for writing. This event always triggers for regular files. -
CLOUDABI_EVENTTYPE_LOCK_RDLOCKLock
cloudabi_subscription_t::lock.lockhas been acquired for reading. -
CLOUDABI_EVENTTYPE_LOCK_WRLOCKLock
cloudabi_subscription_t::lock.lockhas been acquired for writing. -
CLOUDABI_EVENTTYPE_PROC_TERMINATEThe process associated with process descriptor
cloudabi_subscription_t::proc_terminate.fdhas terminated.
cloudabi_exitcode_t (uint32_t)
Exit code generated by a process when exiting.
Used by cloudabi_event_t and cloudabi_sys_proc_exit().
cloudabi_fd_t (uint32_t)
A file descriptor number.
Unlike on POSIX-compliant systems, none of the file descriptor numbers are reserved for a purpose (e.g., stdin, stdout, stderr). Operating systems are not required to allocate new file descriptors in ascending order.
Special values:
-
CLOUDABI_PROCESS_CHILDReturned to the child process by
cloudabi_sys_proc_fork(). -
CLOUDABI_MAP_ANON_FDPassed to
cloudabi_sys_mem_map()when creating a mapping to anonymous memory.
cloudabi_fdflags_t (uint16_t bitfield)
File descriptor flags.
Used by cloudabi_fdstat_t.
Possible values:
-
CLOUDABI_FDFLAG_APPENDAppend mode: Data written to the file is always appended to the file's end.
-
CLOUDABI_FDFLAG_DSYNCWrite according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
-
CLOUDABI_FDFLAG_NONBLOCKNon-blocking mode.
-
CLOUDABI_FDFLAG_RSYNCSynchronized read I/O operations.
-
CLOUDABI_FDFLAG_SYNCWrite according to synchronized I/O file integrity completion. In addition to synchronizing the data stored in the file, the system may also synchronously update the file's metadata.
cloudabi_fdsflags_t (uint16_t bitfield)
Which file descriptor attributes to adjust.
Used by cloudabi_sys_fd_stat_put().
Possible values:
-
CLOUDABI_FDSTAT_FLAGSAdjust the file descriptor flags stored in
cloudabi_fdstat_t::fs_flags. -
CLOUDABI_FDSTAT_RIGHTSRestrict the rights of the file descriptor to the rights stored in
cloudabi_fdstat_t::fs_rights_baseandcloudabi_fdstat_t::fs_rights_inheriting.
cloudabi_fdstat_t (struct)
File descriptor attributes.
Used by cloudabi_sys_fd_stat_get(), cloudabi_sys_fd_stat_put(), and cloudabi_sys_file_open().
Members:
-
cloudabi_filetype_t fs_filetypeFile type.
-
cloudabi_fdflags_t fs_flagsFile descriptor flags.
-
cloudabi_rights_t fs_rights_baseRights that apply to this file descriptor.
-
cloudabi_rights_t fs_rights_inheritingMaximum set of rights that can be installed on new file descriptors that are created through this file descriptor, e.g., through
cloudabi_sys_file_open().
cloudabi_filedelta_t (int64_t)
Relative offset within a file.
Used by cloudabi_sys_fd_seek().
cloudabi_filesize_t (uint64_t)
Non-negative file size or length of a region within a file.
Used by cloudabi_event_t, cloudabi_filestat_t, cloudabi_sys_fd_pread(), cloudabi_sys_fd_pwrite(), cloudabi_sys_fd_seek(), cloudabi_sys_file_advise(), cloudabi_sys_file_allocate(), and cloudabi_sys_mem_map().
cloudabi_filestat_t (struct)
File attributes.
Used by cloudabi_sys_file_stat_fget(), cloudabi_sys_file_stat_fput(), cloudabi_sys_file_stat_get(), and cloudabi_sys_file_stat_put().
Members:
-
cloudabi_device_t st_devDevice ID of device containing the file.
-
cloudabi_inode_t st_inoFile serial number.
-
cloudabi_filetype_t st_filetypeFile type.
-
cloudabi_linkcount_t st_nlinkNumber of hard links to the file.
-
cloudabi_filesize_t st_sizeFor regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link.
-
cloudabi_timestamp_t st_atimLast data access timestamp.
-
cloudabi_timestamp_t st_mtimLast data modification timestamp.
-
cloudabi_timestamp_t st_ctimLast file status change timestamp.
cloudabi_filetype_t (uint8_t)
The type of a file descriptor or file.
Used by cloudabi_dirent_t, cloudabi_fdstat_t, cloudabi_filestat_t, cloudabi_sys_fd_create1(), cloudabi_sys_fd_create2(), and cloudabi_sys_file_create().
Possible values:
-
CLOUDABI_FILETYPE_UNKNOWNThe type of the file descriptor or file is unknown or is different from any of the other types specified.
-
CLOUDABI_FILETYPE_BLOCK_DEVICEThe file descriptor or file refers to a block device inode.
-
CLOUDABI_FILETYPE_CHARACTER_DEVICEThe file descriptor or file refers to a character device inode.
-
CLOUDABI_FILETYPE_DIRECTORYThe file descriptor or file refers to a directory inode.
-
CLOUDABI_FILETYPE_PROCESSThe file descriptor refers to a process handle.
-
CLOUDABI_FILETYPE_REGULAR_FILEThe file descriptor or file refers to a regular file inode.
-
CLOUDABI_FILETYPE_SHARED_MEMORYThe file descriptor refers to a shared memory object.
-
CLOUDABI_FILETYPE_SOCKET_DGRAMThe file descriptor or file refers to a datagram socket.
-
CLOUDABI_FILETYPE_SOCKET_STREAMThe file descriptor or file refers to a byte-stream socket.
-
CLOUDABI_FILETYPE_SYMBOLIC_LINKThe file refers to a symbolic link inode.
cloudabi_fsflags_t (uint16_t bitfield)
Which file attributes to adjust.
Used by cloudabi_sys_file_stat_fput() and cloudabi_sys_file_stat_put().
Possible values:
-
CLOUDABI_FILESTAT_ATIMAdjust the last data access timestamp to the value stored in
cloudabi_filestat_t::st_atim. -
CLOUDABI_FILESTAT_ATIM_NOWAdjust the last data access timestamp to the time of clock
CLOUDABI_CLOCK_REALTIME. -
CLOUDABI_FILESTAT_MTIMAdjust the last data modification timestamp to the value stored in
cloudabi_filestat_t::st_mtim. -
CLOUDABI_FILESTAT_MTIM_NOWAdjust the last data modification timestamp to the time of clock
CLOUDABI_CLOCK_REALTIME. -
CLOUDABI_FILESTAT_SIZETruncate or extend the file to the size stored in
cloudabi_filestat_t::st_size.
cloudabi_inode_t (uint64_t)
File serial number that is unique within its file system.
Used by cloudabi_dirent_t and cloudabi_filestat_t.
cloudabi_iovec_t (struct)
A region of memory for scatter/gather reads.
Used by cloudabi_recv_in_t, cloudabi_sys_fd_pread(), and cloudabi_sys_fd_read().
Members:
-
void *bufandsize_t buf_lenThe address and length of the buffer to be filled.
cloudabi_linkcount_t (uint32_t)
Number of hard links to an inode.
Used by cloudabi_filestat_t.
cloudabi_lock_t (uint32_t)
A userspace read-recursive readers-writer lock, similar to a Linux futex or a FreeBSD umtx.
Used by cloudabi_subscription_t, cloudabi_sys_lock_unlock(), and cloudabi_sys_thread_exit().
Special values:
-
CLOUDABI_LOCK_UNLOCKEDValue indicating that the lock is in its initial unlocked state.
-
CLOUDABI_LOCK_WRLOCKEDBitmask indicating that the lock is write-locked. If set, the lower 30 bits of the lock contain the identifier of the thread that owns the write lock. Otherwise, the lower 30 bits of the lock contain the number of acquired read locks.
-
CLOUDABI_LOCK_KERNEL_MANAGEDBitmask indicating that the lock is either read locked or write locked, and that one or more threads have their execution suspended, waiting to acquire the lock. The last owner of the lock must call the kernel to unlock.
When the lock is acquired for reading and this bit is set, it means that one or more threads are attempting to acquire this lock for writing. In that case, other threads should only acquire additional read locks if suspending execution would cause a deadlock. It is preferred to suspend execution, as this prevents starvation of writers.
-
CLOUDABI_LOCK_BOGUSValue indicating that the lock is in an incorrect state. A lock cannot be in its initial unlocked state, while also managed by the kernel.
cloudabi_lookup_t (struct)
Path lookup properties.
Used by cloudabi_sys_file_link(), cloudabi_sys_file_open(), cloudabi_sys_file_stat_get(), and cloudabi_sys_file_stat_put().
Members:
-
cloudabi_fd_t fdThe working directory at which the resolution of the path starts.
-
cloudabi_lookupflags_t flagsFlags determining the method of how the path is resolved.
cloudabi_lookupflags_t (uint32_t bitfield)
Flags determining the method of how paths are resolved.
Used by cloudabi_lookup_t.
Possible values:
-
CLOUDABI_LOOKUP_SYMLINK_FOLLOWAs long as the resolved path corresponds to a symbolic link, it is expanded.
cloudabi_mflags_t (uint8_t bitfield)
Memory mapping flags.
Used by cloudabi_sys_mem_map().
Possible values:
-
CLOUDABI_MAP_ANONInstead of mapping the contents of the file provided, create a mapping to anonymous memory. The file descriptor argument must be set to
CLOUDABI_MAP_ANON_FD, and the offset must be set to zero. -
CLOUDABI_MAP_FIXEDRequire that the mapping is performed at the base address provided.
-
CLOUDABI_MAP_PRIVATEChanges are private.
-
CLOUDABI_MAP_SHAREDChanges are shared.
cloudabi_mprot_t (uint8_t bitfield)
Memory page protection options.
This implementation enforces the W^X property: Pages cannot be
mapped for execution while also mapped for writing.
Used by cloudabi_sys_mem_map() and cloudabi_sys_mem_protect().
Possible values:
-
CLOUDABI_PROT_EXECPage can be executed.
-
CLOUDABI_PROT_WRITEPage can be written.
-
CLOUDABI_PROT_READPage can be read.
cloudabi_msflags_t (uint8_t bitfield)
Methods of synchronizing memory with physical storage.
Used by cloudabi_sys_mem_sync().
Possible values:
-
CLOUDABI_MS_ASYNCPerform asynchronous writes.
-
CLOUDABI_MS_INVALIDATEInvalidate cached data.
-
CLOUDABI_MS_SYNCPerform synchronous writes.
cloudabi_nthreads_t (uint32_t)
Specifies the number of threads sleeping on a condition variable that should be woken up.
Used by cloudabi_sys_condvar_signal().
cloudabi_oflags_t (uint16_t bitfield)
Open flags used by cloudabi_sys_file_open().
Possible values:
-
CLOUDABI_O_CREATCreate file if it does not exist.
-
CLOUDABI_O_DIRECTORYFail if not a directory.
-
CLOUDABI_O_EXCLFail if file already exists.
-
CLOUDABI_O_TRUNCTruncate file to size 0.
cloudabi_processentry_t (function type)
Entry point for a process (_start).
Parameters:
-
const cloudabi_auxv_t *auxvThe auxiliary vector. See
cloudabi_auxv_t.
cloudabi_recv_in_t (struct)
Arguments of cloudabi_sys_sock_recv().
Members:
-
const cloudabi_iovec_t *ri_dataandsize_t ri_data_lenList of scatter/gather vectors where message data should be stored.
-
cloudabi_fd_t *ri_fdsandsize_t ri_fds_lenBuffer where numbers of incoming file descriptors should be stored.
-
cloudabi_riflags_t ri_flagsMessage flags.
cloudabi_recv_out_t (struct)
Results of cloudabi_sys_sock_recv().
Members:
-
size_t ro_datalenNumber of bytes stored in
cloudabi_recv_in_t::ri_data. -
size_t ro_fdslenNumber of file descriptors stored in
cloudabi_recv_in_t::ri_fds. -
char ro_unused[40]Fields that were used by previous implementations.
-
cloudabi_roflags_t ro_flagsMessage flags.
cloudabi_riflags_t (uint16_t bitfield)
Flags provided to cloudabi_sys_sock_recv().
Used by cloudabi_recv_in_t.
Possible values:
-
CLOUDABI_SOCK_RECV_PEEKReturns the message without removing it from the socket's receive queue.
-
CLOUDABI_SOCK_RECV_WAITALLOn byte-stream sockets, block until the full amount of data can be returned.
cloudabi_rights_t (uint64_t bitfield)
File descriptor rights, determining which actions may be performed.
Used by cloudabi_fdstat_t.
Possible values:
-
CLOUDABI_RIGHT_FD_DATASYNCThe right to invoke
cloudabi_sys_fd_datasync().If
CLOUDABI_RIGHT_FILE_OPENis set, includes the right to invokecloudabi_sys_file_open()withCLOUDABI_FDFLAG_DSYNC. -
CLOUDABI_RIGHT_FD_READThe right to invoke
cloudabi_sys_fd_read()andcloudabi_sys_sock_recv().If
CLOUDABI_RIGHT_MEM_MAPis set, includes the right to invokecloudabi_sys_mem_map()with memory protection optionCLOUDABI_PROT_READ.If
CLOUDABI_RIGHT_FD_SEEKis set, includes the right to invokecloudabi_sys_fd_pread(). -
CLOUDABI_RIGHT_FD_SEEKThe right to invoke
cloudabi_sys_fd_seek(). This flag impliesCLOUDABI_RIGHT_FD_TELL. -
CLOUDABI_RIGHT_FD_STAT_PUT_FLAGSThe right to invoke
cloudabi_sys_fd_stat_put()withCLOUDABI_FDSTAT_FLAGS. -
CLOUDABI_RIGHT_FD_SYNCThe right to invoke
cloudabi_sys_fd_sync().If
CLOUDABI_RIGHT_FILE_OPENis set, includes the right to invokecloudabi_sys_file_open()withCLOUDABI_FDFLAG_RSYNCandCLOUDABI_FDFLAG_DSYNC. -
CLOUDABI_RIGHT_FD_TELLThe right to invoke
cloudabi_sys_fd_seek()in such a way that the file offset remains unaltered (i.e.,CLOUDABI_WHENCE_CURwith offset zero). -
CLOUDABI_RIGHT_FD_WRITEThe right to invoke
cloudabi_sys_fd_write()andcloudabi_sys_sock_send().If
CLOUDABI_RIGHT_MEM_MAPis set, includes the right to invokecloudabi_sys_mem_map()with memory protection optionCLOUDABI_PROT_WRITE.If
CLOUDABI_RIGHT_FD_SEEKis set, includes the right to invokecloudabi_sys_fd_pwrite(). -
CLOUDABI_RIGHT_FILE_ADVISEThe right to invoke
cloudabi_sys_file_advise(). -
CLOUDABI_RIGHT_FILE_ALLOCATEThe right to invoke
cloudabi_sys_file_allocate(). -
CLOUDABI_RIGHT_FILE_CREATE_DIRECTORYThe right to invoke
cloudabi_sys_file_create()withCLOUDABI_FILETYPE_DIRECTORY. -
CLOUDABI_RIGHT_FILE_CREATE_FILEIf
CLOUDABI_RIGHT_FILE_OPENis set, the right to invokecloudabi_sys_file_open()withCLOUDABI_O_CREAT. -
CLOUDABI_RIGHT_FILE_LINK_SOURCEThe right to invoke
cloudabi_sys_file_link()with the file descriptor as the source directory. -
CLOUDABI_RIGHT_FILE_LINK_TARGETThe right to invoke
cloudabi_sys_file_link()with the file descriptor as the target directory. -
CLOUDABI_RIGHT_FILE_OPENThe right to invoke
cloudabi_sys_file_open(). -
CLOUDABI_RIGHT_FILE_READDIRThe right to invoke
cloudabi_sys_file_readdir(). -
CLOUDABI_RIGHT_FILE_READLINKThe right to invoke
cloudabi_sys_file_readlink(). -
CLOUDABI_RIGHT_FILE_RENAME_SOURCEThe right to invoke
cloudabi_sys_file_rename()with the file descriptor as the source directory. -
CLOUDABI_RIGHT_FILE_RENAME_TARGETThe right to invoke
cloudabi_sys_file_rename()with the file descriptor as the target directory. -
CLOUDABI_RIGHT_FILE_STAT_FGETThe right to invoke
cloudabi_sys_file_stat_fget(). -
CLOUDABI_RIGHT_FILE_STAT_FPUT_SIZEThe right to invoke
cloudabi_sys_file_stat_fput()withCLOUDABI_FILESTAT_SIZE.If
CLOUDABI_RIGHT_FILE_OPENis set, includes the right to invokecloudabi_sys_file_open()withCLOUDABI_O_TRUNC. -
CLOUDABI_RIGHT_FILE_STAT_FPUT_TIMESThe right to invoke
cloudabi_sys_file_stat_fput()withCLOUDABI_FILESTAT_ATIM,CLOUDABI_FILESTAT_ATIM_NOW,CLOUDABI_FILESTAT_MTIM, andCLOUDABI_FILESTAT_MTIM_NOW. -
CLOUDABI_RIGHT_FILE_STAT_GETThe right to invoke
cloudabi_sys_file_stat_get(). -
CLOUDABI_RIGHT_FILE_STAT_PUT_TIMESThe right to invoke
cloudabi_sys_file_stat_put()withCLOUDABI_FILESTAT_ATIM,CLOUDABI_FILESTAT_ATIM_NOW,CLOUDABI_FILESTAT_MTIM, andCLOUDABI_FILESTAT_MTIM_NOW. -
CLOUDABI_RIGHT_FILE_SYMLINKThe right to invoke
cloudabi_sys_file_symlink(). -
CLOUDABI_RIGHT_FILE_UNLINKThe right to invoke
cloudabi_sys_file_unlink(). -
CLOUDABI_RIGHT_MEM_MAPThe right to invoke
cloudabi_sys_mem_map()withcloudabi_mprot_tset to zero. -
CLOUDABI_RIGHT_MEM_MAP_EXECIf
CLOUDABI_RIGHT_MEM_MAPis set, the right to invokecloudabi_sys_mem_map()withCLOUDABI_PROT_EXEC. -
CLOUDABI_RIGHT_POLL_FD_READWRITEIf
CLOUDABI_RIGHT_FD_READis set, includes the right to invokecloudabi_sys_poll()to subscribe toCLOUDABI_EVENTTYPE_FD_READ.If
CLOUDABI_RIGHT_FD_WRITEis set, includes the right to invokecloudabi_sys_poll()to subscribe toCLOUDABI_EVENTTYPE_FD_WRITE. -
CLOUDABI_RIGHT_POLL_PROC_TERMINATEThe right to invoke
cloudabi_sys_poll()to subscribe toCLOUDABI_EVENTTYPE_PROC_TERMINATE. -
CLOUDABI_RIGHT_PROC_EXECThe right to invoke
cloudabi_sys_proc_exec(). -
CLOUDABI_RIGHT_SOCK_SHUTDOWNThe right to invoke
cloudabi_sys_sock_shutdown().
cloudabi_roflags_t (uint16_t bitfield)
Flags returned by cloudabi_sys_sock_recv().
Used by cloudabi_recv_out_t.
Possible values:
-
CLOUDABI_SOCK_RECV_FDS_TRUNCATEDReturned by
cloudabi_sys_sock_recv(): List of file descriptors has been truncated. -
CLOUDABI_SOCK_RECV_DATA_TRUNCATEDReturned by
cloudabi_sys_sock_recv(): Message data has been truncated.
cloudabi_scope_t (uint8_t)
Indicates whether an object is stored in private or shared memory.
Used by cloudabi_subscription_t, cloudabi_sys_condvar_signal(), cloudabi_sys_lock_unlock(), and cloudabi_sys_thread_exit().
Possible values:
-
CLOUDABI_SCOPE_PRIVATEThe object is stored in private memory.
-
CLOUDABI_SCOPE_SHAREDThe object is stored in shared memory.
cloudabi_sdflags_t (uint8_t bitfield)
Which channels on a socket need to be shut down.
Used by cloudabi_sys_sock_shutdown().
Possible values:
-
CLOUDABI_SHUT_RDDisables further receive operations.
-
CLOUDABI_SHUT_WRDisables further send operations.
cloudabi_send_in_t (struct)
Arguments of cloudabi_sys_sock_send().
Members:
-
const cloudabi_ciovec_t *si_dataandsize_t si_data_lenList of scatter/gather vectors where message data should be retrieved.
-
const cloudabi_fd_t *si_fdsandsize_t si_fds_lenFile descriptors that need to be attached to the message.
-
cloudabi_siflags_t si_flagsMessage flags.
cloudabi_send_out_t (struct)
Results of cloudabi_sys_sock_send().
Members:
-
size_t so_datalenNumber of bytes transmitted.
cloudabi_siflags_t (uint16_t bitfield)
Flags provided to cloudabi_sys_sock_send(). As there are currently no flags
defined, it must be set to zero.
Used by cloudabi_send_in_t.
cloudabi_signal_t (uint8_t)
Signal condition.
Used by cloudabi_event_t and cloudabi_sys_proc_raise().
Possible values:
-
CLOUDABI_SIGABRTProcess abort signal.
Action: Terminates the process.
-
CLOUDABI_SIGALRMAlarm clock.
Action: Terminates the process.
-
CLOUDABI_SIGBUSAccess to an undefined portion of a memory object.
Action: Terminates the process.
-
CLOUDABI_SIGCHLDChild process terminated, stopped, or continued.
Action: Ignored.
-
CLOUDABI_SIGCONTContinue executing, if stopped.
Action: Continues executing, if stopped.
-
CLOUDABI_SIGFPEErroneous arithmetic operation.
Action: Terminates the process.
-
CLOUDABI_SIGHUPHangup.
Action: Terminates the process.
-
CLOUDABI_SIGILLIllegal instruction.
Action: Terminates the process.
-
CLOUDABI_SIGINTTerminate interrupt signal.
Action: Terminates the process.
-
CLOUDABI_SIGKILLKill.
Action: Terminates the process.
-
CLOUDABI_SIGPIPEWrite on a pipe with no one to read it.
Action: Ignored.
-
CLOUDABI_SIGQUITTerminal quit signal.
Action: Terminates the process.
-
CLOUDABI_SIGSEGVInvalid memory reference.
Action: Terminates the process.
-
CLOUDABI_SIGSTOPStop executing.
Action: Stops executing.
-
CLOUDABI_SIGSYSBad system call.
Action: Terminates the process.
-
CLOUDABI_SIGTERMTermination signal.
Action: Terminates the process.
-
CLOUDABI_SIGTRAPTrace/breakpoint trap.
Action: Terminates the process.
-
CLOUDABI_SIGTSTPTerminal stop signal.
Action: Stops executing.
-
CLOUDABI_SIGTTINBackground process attempting read.
Action: Stops executing.
-
CLOUDABI_SIGTTOUBackground process attempting write.
Action: Stops executing.
-
CLOUDABI_SIGURGHigh bandwidth data is available at a socket.
Action: Ignored.
-
CLOUDABI_SIGUSR1User-defined signal 1.
Action: Terminates the process.
-
CLOUDABI_SIGUSR2User-defined signal 2.
Action: Terminates the process.
-
CLOUDABI_SIGVTALRMVirtual timer expired.
Action: Terminates the process.
-
CLOUDABI_SIGXCPUCPU time limit exceeded.
Action: Terminates the process.
-
CLOUDABI_SIGXFSZFile size limit exceeded.
Action: Terminates the process.
cloudabi_subclockflags_t (uint16_t bitfield)
Flags determining how the timestamp provided in
cloudabi_subscription_t::clock.timeout should be interpreted.
Used by cloudabi_subscription_t.
Possible values:
-
CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIMEIf set, treat the timestamp provided in
cloudabi_subscription_t::clock.timeoutas an absolute timestamp of clockcloudabi_subscription_t::clock.clock_id.If clear, treat the timestamp provided in
cloudabi_subscription_t::clock.timeoutrelative to the current time value of clockcloudabi_subscription_t::clock.clock_id.
cloudabi_subrwflags_t (uint16_t bitfield)
Flags influencing the method of polling for read or writing on a file descriptor.
Used by cloudabi_subscription_t.
Possible values:
-
CLOUDABI_SUBSCRIPTION_FD_READWRITE_POLLDeprecated. Must be set by callers and ignored by implementations.
cloudabi_subscription_t (struct)
Subscription to an event.
Used by cloudabi_sys_poll().
Members:
-
cloudabi_userdata_t userdataUser-provided value that is attached to the subscription in the kernel and returned through
cloudabi_event_t::userdata. -
uint16_t unusedUsed by previous implementations. Ignored.
-
cloudabi_eventtype_t typeThe type of the event to which to subscribe.
Currently,
CLOUDABI_EVENTTYPE_CONDVAR,CLOUDABI_EVENTTYPE_LOCK_RDLOCK, andCLOUDABI_EVENTTYPE_LOCK_WRLOCKmust be provided as the first subscription and may only be followed by up to one other subscription, having typeCLOUDABI_EVENTTYPE_CLOCK. -
When
typeisCLOUDABI_EVENTTYPE_CLOCK:-
clock-
cloudabi_userdata_t identifierThe user-defined unique identifier of the clock.
-
cloudabi_clockid_t clock_idThe clock against which the timestamp should be compared.
-
cloudabi_timestamp_t timeoutThe absolute or relative timestamp.
-
cloudabi_timestamp_t precisionThe amount of time that the kernel may wait additionally to coalesce with other events.
-
cloudabi_subclockflags_t flagsFlags specifying whether the timeout is absolute or relative.
-
-
-
When
typeisCLOUDABI_EVENTTYPE_CONDVAR:-
condvar-
_Atomic(cloudabi_condvar_t) *condvarThe condition variable on which to wait to be woken up.
-
_Atomic(cloudabi_lock_t) *lockThe lock that will be released while waiting.
The lock will be reacquired for writing when the condition variable triggers.
-
cloudabi_scope_t condvar_scopeWhether the condition variable is stored in private or shared memory.
-
cloudabi_scope_t lock_scopeWhether the lock is stored in private or shared memory.
-
-
-
When
typeisCLOUDABI_EVENTTYPE_FD_READorCLOUDABI_EVENTTYPE_FD_WRITE:-
fd_readwrite-
cloudabi_fd_t fdThe file descriptor on which to wait for it to become ready for reading or writing.
-
cloudabi_subrwflags_t flagsUnder which conditions to trigger.
-
-
-
When
typeisCLOUDABI_EVENTTYPE_LOCK_RDLOCKorCLOUDABI_EVENTTYPE_LOCK_WRLOCK:-
lock-
_Atomic(cloudabi_lock_t) *lockThe lock that will be acquired for reading or writing.
-
cloudabi_scope_t lock_scopeWhether the lock is stored in private or shared memory.
-
-
-
When
typeisCLOUDABI_EVENTTYPE_PROC_TERMINATE:-
proc_terminate-
cloudabi_fd_t fdThe process descriptor on which to wait for process termination.
-
-
cloudabi_tcb_t (struct)
The Thread Control Block (TCB).
After a thread begins execution (at program startup or when
created through cloudabi_sys_thread_create()), the CPU's registers
controlling Thread-Local Storage (TLS) will already be
initialized. They will point to an area only containing the
TCB.
If the thread needs space for storing thread-specific variables, the thread may allocate a larger area and adjust the CPU's registers to point to that area instead. However, it does need to make sure that the TCB is copied over to the new TLS area.
The purpose of the TCB is that it allows light-weight emulators to store information related to individual threads. For example, it may be used to store a copy of the CPU registers prior emulation, so that TLS for the host system can be restored if needed.
Members:
-
void *parentPointer that may be freely assigned by the system. Its value cannot be interpreted by the application.
cloudabi_threadattr_t (struct)
Attributes for thread creation.
Used by cloudabi_sys_thread_create().
Members:
-
cloudabi_threadentry_t *entry_pointInitial program counter value.
-
void *stackandsize_t stack_lenRegion allocated to serve as stack space.
-
void *argumentArgument to be forwarded to the entry point function.
cloudabi_threadentry_t (function type)
Entry point for additionally created threads.
Used by cloudabi_threadattr_t.
Parameters:
-
cloudabi_tid_t tidThread ID of the current thread.
-
void *auxCopy of the value stored in
cloudabi_threadattr_t::argument.
cloudabi_tid_t (uint32_t)
Unique system-local identifier of a thread. This identifier is only valid during the lifetime of the thread.
Threads must be aware of their thread identifier, as it is written it into locks when acquiring them for writing. It is not advised to use these identifiers for any other purpose.
As the thread identifier is also stored in cloudabi_lock_t when
CLOUDABI_LOCK_WRLOCKED is set, the top two bits of the thread
must always be set to zero.
Used by cloudabi_threadentry_t, cloudabi_sys_proc_fork(), and cloudabi_sys_thread_create().
cloudabi_timestamp_t (uint64_t)
Timestamp in nanoseconds.
Used by cloudabi_filestat_t, cloudabi_subscription_t, cloudabi_sys_clock_res_get(), and cloudabi_sys_clock_time_get().
cloudabi_ulflags_t (uint8_t bitfield)
Specifies whether files are unlinked or directories are removed.
Used by cloudabi_sys_file_unlink().
Possible values:
-
CLOUDABI_UNLINK_REMOVEDIRIf set, removes a directory. Otherwise, unlinks any non-directory file.
cloudabi_userdata_t (uint64_t)
User-provided value that can be attached to objects that is retained when extracted from the kernel.
Used by cloudabi_event_t and cloudabi_subscription_t.
cloudabi_whence_t (uint8_t)
Relative to which position the offset of the file descriptor should be set.
Used by cloudabi_sys_fd_seek().
Possible values:
-
CLOUDABI_WHENCE_CURSeek relative to current position.
-
CLOUDABI_WHENCE_ENDSeek relative to end-of-file.
-
CLOUDABI_WHENCE_SETSeek relative to start-of-file.