1# uvwasi
2
3`uvwasi` implements the [WASI][] system call API. Under the hood, `uvwasi`
4leverages [libuv][] where possible for maximum portability.
5
6## Building Locally
7
8To build with [CMake](https://cmake.org/):
9
10```sh
11$ mkdir -p out/cmake ; cd out/cmake   # create build directory
12$ cmake ../.. -DBUILD_TESTING=ON      # generate project with test
13$ cmake --build .                     # build
14$ ctest -C Debug --output-on-failure  # run tests
15```
16
17## Example Usage
18
19```c
20#include <assert.h>
21#include "uv.h"
22#include "uvwasi.h"
23
24int main(void) {
25  uvwasi_t uvwasi;
26  uvwasi_options_t init_options;
27  uvwasi_errno_t err;
28
29  /* Setup the initialization options. */
30  init_options.in = 0;
31  init_options.out = 1;
32  init_options.err = 2;
33  init_options.fd_table_size = 3;
34  init_options.argc = 3;
35  init_options.argv = calloc(3, sizeof(char*));
36  init_options.argv[0] = "--foo=bar";
37  init_options.argv[1] = "-baz";
38  init_options.argv[2] = "100";
39  init_options.envp = NULL;
40  init_options.preopenc = 1;
41  init_options.preopens = calloc(1, sizeof(uvwasi_preopen_t));
42  init_options.preopens[0].mapped_path = "/var";
43  init_options.preopens[0].real_path = ".";
44  init_options.allocator = NULL;
45
46  /* Initialize the sandbox. */
47  err = uvwasi_init(&uvwasi, &init_options);
48  assert(err == UVWASI_ESUCCESS);
49
50  /* TODO(cjihrig): Show an example system call or two. */
51
52  /* Clean up resources. */
53  uvwasi_destroy(&uvwasi);
54  return 0;
55}
56```
57
58## API
59
60The WASI API is versioned. This documentation is based on [snapshot_1][].
61`uvwasi` implements the WASI system call API with the following
62additions/modifications:
63
64- Each system call takes an additional `uvwasi_t*` as its first argument. The
65  `uvwasi_t` is the sandbox under which system calls are issued. Each `uvwasi_t`
66  can have different command line arguments, environment variables, preopened
67  directories, file descriptor mappings, etc. This allows one controlling
68  process to host multiple WASI applications simultaneously.
69- Each system call returns a `uvwasi_errno_t`. This appears to be expected of
70  WASI system calls, but it is not explicitly part of the official API docs.
71  This detail is explicitly documented here.
72- Additional functions and data types are provided for interacting with WASI
73  sandboxes and the `uvwasi` library. These APIs are documented in the
74  Unofficial APIs section below.
75
76### Unofficial APIs
77
78This section contains data types and functions for working with `uvwasi`. They
79are not part of the official WASI API, but are used to embed `uvwasi`.
80
81### <a href="#version_major" name="version_major"></a>`UVWASI_VERSION_MAJOR`
82
83The major release version of the `uvwasi` library. `uvwasi` follows semantic
84versioning. Changes to this value represent breaking changes in the public API.
85
86### <a href="#version_minor" name="version_minor"></a>`UVWASI_VERSION_MINOR`
87
88The minor release version of the `uvwasi` library. `uvwasi` follows semantic
89versioning. Changes to this value represent feature additions in the public API.
90
91### <a href="#version_patch" name="version_patch"></a>`UVWASI_VERSION_PATCH`
92
93The patch release version of the `uvwasi` library. `uvwasi` follows semantic
94versioning. Changes to this value represent bug fixes in the public API.
95
96### <a href="#version_hex" name="version_hex"></a>`UVWASI_VERSION_HEX`
97
98The major, minor, and patch versions of the `uvwasi` library encoded as a single
99integer value.
100
101### <a href="#version_string" name="version_string"></a>`UVWASI_VERSION_STRING`
102
103The major, minor, and patch versions of the `uvwasi` library encoded as a
104version string.
105
106### <a href="#version_wasi" name="version_wasi"></a>`UVWASI_VERSION_WASI`
107
108The version of the WASI API targeted by `uvwasi`.
109
110
111### <a href="#uvwasi_t" name="uvwasi_t"></a>`uvwasi_t`
112
113An individual WASI sandbox instance.
114
115```c
116typedef struct uvwasi_s {
117  struct uvwasi_fd_table_t fds;
118  uvwasi_size_t argc;
119  char** argv;
120  char* argv_buf;
121  uvwasi_size_t argv_buf_size;
122  uvwasi_size_t envc;
123  char** env;
124  char* env_buf;
125  uvwasi_size_t env_buf_size;
126} uvwasi_t;
127```
128
129### <a href="#uvwasi_preopen_t" name="uvwasi_preopen_t"></a>`uvwasi_preopen_t`
130
131A data structure used to map a directory path within a WASI sandbox to a
132directory path on the WASI host platform.
133
134```c
135typedef struct uvwasi_preopen_s {
136  char* mapped_path;
137  char* real_path;
138} uvwasi_preopen_t;
139```
140
141### <a href="#uvwasi_options_t" name="uvwasi_options_t"></a>`uvwasi_options_t`
142
143A data structure used to pass configuration options to `uvwasi_init()`.
144
145```c
146typedef struct uvwasi_options_s {
147  uvwasi_size_t fd_table_size;
148  uvwasi_size_t preopenc;
149  uvwasi_preopen_t* preopens;
150  uvwasi_size_t argc;
151  char** argv;
152  char** envp;
153  uvwasi_fd_t in;
154  uvwasi_fd_t out;
155  uvwasi_fd_t err;
156  const uvwasi_mem_t* allocator;
157} uvwasi_options_t;
158```
159
160### <a href="#uvwasi_init" name="uvwasi_init"></a>`uvwasi_init()`
161
162Initializes a sandbox represented by a `uvwasi_t` using the options represented
163by a `uvwasi_options_t`.
164
165Inputs:
166
167- <a href="#uvwasi_init.uvwasi" name="uvwasi_init.uvwasi"></a><code>[\_\_wasi\_t](#uvwasi_t) <strong>uvwasi</strong></code>
168
169    The sandbox to initialize.
170
171- <a href="#uvwasi_init.options" name="uvwasi_init.options"></a><code>[\_\_wasi\_options\_t](#uvwasi_options_t) <strong>options</strong></code>
172
173    Configuration options used when initializing the sandbox.
174
175Outputs:
176
177- None
178
179Returns:
180
181- <a href="#uvwasi_init.return" name="uvwasi_init.return"></a><code>[\_\_wasi\_errno\_t](#errno) <strong>errno</strong></code>
182
183    A WASI errno.
184
185### <a href="#uvwasi_destroy" name="uvwasi_destroy"></a>`uvwasi_destroy()`
186
187Cleans up resources related to a WASI sandbox. This function notably does not
188return an error code.
189
190Inputs:
191
192- <a href="#uvwasi_destroy.uvwasi" name="uvwasi_destroy.uvwasi"></a><code>[\_\_wasi\_t](#uvwasi_t) <strong>uvwasi</strong></code>
193
194    The sandbox to clean up.
195
196Outputs:
197
198- None
199
200Returns:
201
202- None
203
204### System Calls
205
206This section has been adapted from the official WASI API documentation.
207
208- [`uvwasi_args_get()`](#args_get)
209- [`uvwasi_args_sizes_get()`](#args_sizes_get)
210- [`uvwasi_clock_res_get()`](#clock_res_get)
211- [`uvwasi_clock_time_get()`](#clock_time_get)
212- [`uvwasi_environ_get()`](#environ_get)
213- [`uvwasi_environ_sizes_get()`](#environ_sizes_get)
214- [`uvwasi_fd_advise()`](#fd_advise)
215- [`uvwasi_fd_allocate()`](#fd_allocate)
216- [`uvwasi_fd_close()`](#fd_close)
217- [`uvwasi_fd_datasync()`](#fd_datasync)
218- [`uvwasi_fd_fdstat_get()`](#fd_fdstat_get)
219- [`uvwasi_fd_fdstat_set_flags()`](#fd_fdstat_set_flags)
220- [`uvwasi_fd_fdstat_set_rights()`](#fd_fdstat_set_rights)
221- [`uvwasi_fd_filestat_get()`](#fd_filestat_get)
222- [`uvwasi_fd_filestat_set_size()`](#fd_filestat_set_size)
223- [`uvwasi_fd_filestat_set_times()`](#fd_filestat_set_times)
224- [`uvwasi_fd_pread()`](#fd_pread)
225- [`uvwasi_fd_prestat_get()`](#fd_prestat_get)
226- [`uvwasi_fd_prestat_dir_name()`](#fd_prestat_dir_name)
227- [`uvwasi_fd_pwrite()`](#fd_pwrite)
228- [`uvwasi_fd_read()`](#fd_read)
229- [`uvwasi_fd_readdir()`](#fd_readdir)
230- [`uvwasi_fd_renumber()`](#fd_renumber)
231- [`uvwasi_fd_seek()`](#fd_seek)
232- [`uvwasi_fd_sync()`](#fd_sync)
233- [`uvwasi_fd_tell()`](#fd_tell)
234- [`uvwasi_fd_write()`](#fd_write)
235- [`uvwasi_path_create_directory()`](#path_create_directory)
236- [`uvwasi_path_filestat_get()`](#path_filestat_get)
237- [`uvwasi_path_filestat_set_times()`](#path_filestat_set_times)
238- [`uvwasi_path_link()`](#path_link)
239- [`uvwasi_path_open()`](#path_open)
240- [`uvwasi_path_readlink()`](#path_readlink)
241- [`uvwasi_path_remove_directory()`](#path_remove_directory)
242- [`uvwasi_path_rename()`](#path_rename)
243- [`uvwasi_path_symlink()`](#path_symlink)
244- [`uvwasi_path_unlink_file()`](#path_unlink_file)
245- [`uvwasi_poll_oneoff()`](#poll_oneoff)
246- [`uvwasi_proc_exit()`](#proc_exit)
247- [`uvwasi_proc_raise()`](#proc_raise)
248- [`uvwasi_random_get()`](#random_get)
249- [`uvwasi_sched_yield()`](#sched_yield)
250- [`uvwasi_sock_recv()`](#sock_recv)
251- [`uvwasi_sock_send()`](#sock_send)
252- [`uvwasi_sock_shutdown()`](#sock_shutdown)
253
254### <a href="#args_get" name="args_get"></a>`uvwasi_args_get()`
255
256Read command-line argument data.
257
258The sizes of the buffers should match that returned by [`uvwasi_args_sizes_get()`](#args_sizes_get).
259
260Inputs:
261
262- <a href="#args_get.argv" name="args_get.argv"></a><code>char \*\*<strong>argv</strong></code>
263
264    A pointer to a buffer to write the argument pointers.
265
266- <a href="#args_get.argv_buf" name="args_get.argv_buf"></a><code>char \*<strong>argv\_buf</strong></code>
267
268    A pointer to a buffer to write the argument string data.
269
270### <a href="#args_sizes_get" name="args_sizes_get"></a>`uvwasi_args_sizes_get()`
271
272Return command-line argument data sizes.
273
274Outputs:
275
276- <a href="#args_sizes_get.argc" name="args_sizes_get.argc"></a><code>\_\_wasi\_size\_t \*<strong>argc</strong></code>
277
278    The number of arguments.
279
280- <a href="#args_sizes_get.argv_buf_size" name="args_sizes_get.argv_buf_size"></a><code>\_\_wasi\_size\_t \*<strong>argv\_buf\_size</strong></code>
281
282    The size of the argument string data.
283
284### <a href="#clock_res_get" name="clock_res_get"></a>`uvwasi_clock_res_get()`
285
286Return the resolution of a clock.
287
288Implementations are required to provide a non-zero value for supported clocks.
289For unsupported clocks, return [`UVWASI_EINVAL`](#errno.inval).
290
291Note: This is similar to `clock_getres` in POSIX.
292
293Inputs:
294
295- <a href="#clock_res_get.clock_id" name="clock_res_get.clock_id"></a><code>[\_\_wasi\_clockid\_t](#clockid) <strong>clock\_id</strong></code>
296
297    The clock for which to return the resolution.
298
299Outputs:
300
301- <a href="#clock_res_get.resolution" name="clock_res_get.resolution"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>resolution</strong></code>
302
303    The resolution of the clock.
304
305### <a href="#clock_time_get" name="clock_time_get"></a>`uvwasi_clock_time_get()`
306
307Return the time value of a clock.
308
309Note: This is similar to `clock_gettime` in POSIX.
310
311Inputs:
312
313- <a href="#clock_time_get.clock_id" name="clock_time_get.clock_id"></a><code>[\_\_wasi\_clockid\_t](#clockid) <strong>clock\_id</strong></code>
314
315    The clock for which to return the time.
316
317- <a href="#clock_time_get.precision" name="clock_time_get.precision"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>precision</strong></code>
318
319    The maximum lag (exclusive) that the returned
320    time value may have, compared to its actual
321    value.
322
323Outputs:
324
325- <a href="#clock_time_get.time" name="clock_time_get.time"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>time</strong></code>
326
327    The time value of the clock.
328
329### <a href="#environ_get" name="environ_get"></a>`uvwasi_environ_get()`
330
331Read environment variable data.
332
333The sizes of the buffers should match that returned by [`uvwasi_environ_sizes_get()`](#environ_sizes_get).
334
335Inputs:
336
337- <a href="#environ_get.environ" name="environ_get.environ"></a><code>char \*\*<strong>environ</strong></code>
338
339    A pointer to a buffer to write the environment variable pointers.
340
341- <a href="#environ_get.environ_buf" name="environ_get.environ_buf"></a><code>char \*<strong>environ\_buf</strong></code>
342
343    A pointer to a buffer to write the environment variable string data.
344
345### <a href="#environ_sizes_get" name="environ_sizes_get"></a>`uvwasi_environ_sizes_get()`
346
347Return command-line argument data sizes.
348
349Outputs:
350
351- <a href="#environ_sizes_get.environ_count" name="environ_sizes_get.environ_count"></a><code>\_\_wasi\_size\_t \*<strong>environ\_count</strong></code>
352
353    The number of environment variables.
354
355- <a href="#environ_sizes_get.environ_buf_size" name="environ_sizes_get.environ_buf_size"></a><code>\_\_wasi\_size\_t \*<strong>environ\_buf\_size</strong></code>
356
357    The size of the environment variable string data.
358
359### <a href="#fd_advise" name="fd_advise"></a>`uvwasi_fd_advise()`
360
361Provide file advisory information on a file descriptor.
362
363Note: This is similar to `posix_fadvise` in POSIX.
364
365Inputs:
366
367- <a href="#fd_advise.fd" name="fd_advise.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
368
369    The file descriptor for the file for which to provide file advisory information.
370
371- <a href="#fd_advise.offset" name="fd_advise.offset"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>offset</strong></code>
372
373    The offset within the file to which the advisory applies.
374
375- <a href="#fd_advise.len" name="fd_advise.len"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>len</strong></code>
376
377    The length of the region to which the advisory applies.
378
379- <a href="#fd_advise.advice" name="fd_advise.advice"></a><code>[\_\_wasi\_advice\_t](#advice) <strong>advice</strong></code>
380
381    The advice.
382
383### <a href="#fd_allocate" name="fd_allocate"></a>`uvwasi_fd_allocate()`
384
385Force the allocation of space in a file.
386
387Note: This is similar to `posix_fallocate` in POSIX.
388
389Inputs:
390
391- <a href="#fd_allocate.fd" name="fd_allocate.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
392
393    The file descriptor for the file in which to allocate space.
394
395- <a href="#fd_allocate.offset" name="fd_allocate.offset"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>offset</strong></code>
396
397    The offset at which to start the allocation.
398
399- <a href="#fd_allocate.len" name="fd_allocate.len"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>len</strong></code>
400
401    The length of the area that is allocated.
402
403### <a href="#fd_close" name="fd_close"></a>`uvwasi_fd_close()`
404
405Close a file descriptor.
406
407Note: This is similar to `close` in POSIX.
408
409Inputs:
410
411- <a href="#fd_close.fd" name="fd_close.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
412
413    The file descriptor to close.
414
415### <a href="#fd_datasync" name="fd_datasync"></a>`uvwasi_fd_datasync()`
416
417Synchronize the data of a file to disk.
418
419Note: This is similar to `fdatasync` in POSIX.
420
421Inputs:
422
423- <a href="#fd_datasync.fd" name="fd_datasync.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
424
425    The file descriptor of the file to synchronize to disk.
426
427### <a href="#fd_fdstat_get" name="fd_fdstat_get"></a>`uvwasi_fd_fdstat_get()`
428
429Get the attributes of a file descriptor.
430
431Note: This returns similar flags to `fsync(fd, F_GETFL)` in POSIX, as well
432as additional fields.
433
434Inputs:
435
436- <a href="#fd_fdstat_get.fd" name="fd_fdstat_get.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
437
438    The file descriptor to inspect.
439
440- <a href="#fd_fdstat_get.buf" name="fd_fdstat_get.buf"></a><code>[\_\_wasi\_fdstat\_t](#fdstat) \*<strong>buf</strong></code>
441
442    The buffer where the file descriptor's attributes are stored.
443
444### <a href="#fd_fdstat_set_flags" name="fd_fdstat_set_flags"></a>`uvwasi_fd_fdstat_set_flags()`
445
446Adjust the flags associated with a file descriptor.
447
448Note: This is similar to `fcntl(fd, F_SETFL, flags)` in POSIX.
449
450Inputs:
451
452- <a href="#fd_fdstat_set_flags.fd" name="fd_fdstat_set_flags.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
453
454    The file descriptor to operate on.
455
456- <a href="#fd_fdstat_set_flags.flags" name="fd_fdstat_set_flags.flags"></a><code>[\_\_wasi\_fdflags\_t](#fdflags) <strong>flags</strong></code>
457
458    The desired values of the file descriptor
459    flags.
460
461### <a href="#fd_fdstat_set_rights" name="fd_fdstat_set_rights"></a>`uvwasi_fd_fdstat_set_rights()`
462
463Adjust the rights associated with a file descriptor.
464
465This can only be used to remove rights, and returns
466[`UVWASI_ENOTCAPABLE`](#errno.notcapable) if called in a way that would attempt
467to add rights.
468
469Inputs:
470
471- <a href="#fd_fdstat_set_rights.fd" name="fd_fdstat_set_rights.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
472
473    The file descriptor to operate on.
474
475- <a href="#fd_fdstat_set_rights.fs_rights_base" name="fd_fdstat_set_rights.fs_rights_base"></a><code>[\_\_wasi\_rights\_t](#rights) <strong>fs\_rights\_base</strong></code> and <a href="#fd_fdstat_set_rights.fs_rights_inheriting" name="fd_fdstat_set_rights.fs_rights_inheriting"></a><code>[\_\_wasi\_rights\_t](#rights) <strong>fs\_rights\_inheriting</strong></code>
476
477    The desired rights of the file descriptor.
478
479### <a href="#fd_filestat_get" name="fd_filestat_get"></a>`uvwasi_fd_filestat_get()`
480
481Return the attributes of an open file.
482
483Inputs:
484
485- <a href="#fd_filestat_get.fd" name="fd_filestat_get.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
486
487    The file descriptor to inspect.
488
489- <a href="#fd_filestat_get.buf" name="fd_filestat_get.buf"></a><code>[\_\_wasi\_filestat\_t](#filestat) \*<strong>buf</strong></code>
490
491    The buffer where the file's attributes are
492    stored.
493
494### <a href="#fd_filestat_set_size" name="fd_filestat_set_size"></a>`uvwasi_fd_filestat_set_size()`
495
496Adjust the size of an open file. If this increases the file's size, the extra
497bytes are filled with zeros.
498
499Note: This is similar to `ftruncate` in POSIX.
500
501Inputs:
502
503- <a href="#fd_filestat_set_size.fd" name="fd_filestat_set_size.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
504
505    A file descriptor for the file to adjust.
506
507- <a href="#fd_filestat_set_size.st_size" name="fd_filestat_set_size.st_size"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>st\_size</strong></code>
508
509    The desired file size.
510
511### <a href="#fd_filestat_set_times" name="fd_filestat_set_times"></a>`uvwasi_fd_filestat_set_times()`
512
513Adjust the timestamps of an open file or directory.
514
515Note: This is similar to `futimens` in POSIX.
516
517Inputs:
518
519- <a href="#fd_filestat_set_times.fd" name="fd_filestat_set_times.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
520
521    The file descriptor to operate on.
522
523- <a href="#fd_filestat_set_times.st_atim" name="fd_filestat_set_times.st_atim"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>st\_atim</strong></code>
524
525    The desired values of the data access timestamp.
526
527- <a href="#fd_filestat_set_times.st_mtim" name="fd_filestat_set_times.st_mtim"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>st\_mtim</strong></code>
528
529    The desired values of the data modification timestamp.
530
531- <a href="#fd_filestat_set_times.fst_flags" name="fd_filestat_set_times.fst_flags"></a><code>[\_\_wasi\_fstflags\_t](#fstflags) <strong>fst\_flags</strong></code>
532
533    A bitmask indicating which timestamps to adjust.
534
535### <a href="#fd_pread" name="fd_pread"></a>`uvwasi_fd_pread()`
536
537Read from a file descriptor, without using and updating the
538file descriptor's offset.
539
540Note: This is similar to `preadv` in POSIX.
541
542Inputs:
543
544- <a href="#fd_pread.fd" name="fd_pread.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
545
546    The file descriptor from which to read data.
547
548- <a href="#fd_pread.iovs" name="fd_pread.iovs"></a><code>const [\_\_wasi\_iovec\_t](#iovec) \*<strong>iovs</strong></code> and <a href="#fd_pread.iovs_len" name="fd_pread.iovs_len"></a><code>\_\_wasi\_size\_t <strong>iovs\_len</strong></code>
549
550    List of scatter/gather vectors in which to store data.
551
552- <a href="#fd_pread.offset" name="fd_pread.offset"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>offset</strong></code>
553
554    The offset within the file at which to read.
555
556Outputs:
557
558- <a href="#fd_pread.nread" name="fd_pread.nread"></a><code>\_\_wasi\_size\_t <strong>nread</strong></code>
559
560    The number of bytes read.
561
562### <a href="#fd_prestat_get" name="fd_prestat_get"></a>`uvwasi_fd_prestat_get()`
563
564Return a description of the given preopened file descriptor.
565
566Inputs:
567
568- <a href="#fd_prestat_get.fd" name="fd_prestat_get.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
569
570    The file descriptor about which to retrieve information.
571
572- <a href="#fd_prestat_get.buf" name="fd_prestat_get.buf"></a><code>[\_\_wasi\_prestat\_t](#prestat) \*<strong>buf</strong></code>
573
574    The buffer where the description is stored.
575
576### <a href="#fd_prestat_dir_name" name="fd_prestat_dir_name"></a>`uvwasi_fd_prestat_dir_name()`
577
578Return a description of the given preopened file descriptor.
579
580Inputs:
581
582- <a href="#fd_prestat_dir_name.fd" name="fd_prestat_dir_name.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
583
584    The file descriptor about which to retrieve information.
585
586- <a href="#fd_prestat_dir_name.path" name="fd_prestat_dir_name.path"></a><code>const char \*<strong>path</strong></code> and <a href="#fd_prestat_dir_name.path_len" name="fd_prestat_dir_name.path_len"></a><code>\_\_wasi\_size\_t <strong>path\_len</strong></code>
587
588    A buffer into which to write the preopened directory name.
589
590### <a href="#fd_pwrite" name="fd_pwrite"></a>`uvwasi_fd_pwrite()`
591
592Write to a file descriptor, without using and updating the
593file descriptor's offset.
594
595Note: This is similar to `pwritev` in POSIX.
596
597Inputs:
598
599- <a href="#fd_pwrite.fd" name="fd_pwrite.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
600
601    The file descriptor to which to write data.
602
603- <a href="#fd_pwrite.iovs" name="fd_pwrite.iovs"></a><code>const [\_\_wasi\_ciovec\_t](#ciovec) \*<strong>iovs</strong></code> and <a href="#fd_pwrite.iovs_len" name="fd_pwrite.iovs_len"></a><code>\_\_wasi\_size\_t <strong>iovs\_len</strong></code>
604
605    List of scatter/gather vectors from which to retrieve data.
606
607- <a href="#fd_pwrite.offset" name="fd_pwrite.offset"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>offset</strong></code>
608
609    The offset within the file at which to write.
610
611Outputs:
612
613- <a href="#fd_pwrite.nwritten" name="fd_pwrite.nwritten"></a><code>\_\_wasi\_size\_t <strong>nwritten</strong></code>
614
615    The number of bytes written.
616
617### <a href="#fd_read" name="fd_read"></a>`uvwasi_fd_read()`
618
619Read from a file descriptor.
620
621Note: This is similar to `readv` in POSIX.
622
623Inputs:
624
625- <a href="#fd_read.fd" name="fd_read.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
626
627    The file descriptor from which to read data.
628
629- <a href="#fd_read.iovs" name="fd_read.iovs"></a><code>const [\_\_wasi\_iovec\_t](#iovec) \*<strong>iovs</strong></code> and <a href="#fd_read.iovs_len" name="fd_read.iovs_len"></a><code>\_\_wasi\_size\_t <strong>iovs\_len</strong></code>
630
631    List of scatter/gather vectors to which to store data.
632
633Outputs:
634
635- <a href="#fd_read.nread" name="fd_read.nread"></a><code>\_\_wasi\_size\_t <strong>nread</strong></code>
636
637    The number of bytes read.
638
639### <a href="#fd_readdir" name="fd_readdir"></a>`uvwasi_fd_readdir()`
640
641Read directory entries from a directory.
642
643When successful, the contents of the output buffer consist of
644a sequence of directory entries. Each directory entry consists
645of a [`uvwasi_dirent_t`](#dirent) object, followed by [`uvwasi_dirent_t::d_namlen`](#dirent.d_namlen) bytes
646holding the name of the directory entry.
647
648This function fills the output buffer as much as possible,
649potentially truncating the last directory entry. This allows
650the caller to grow its read buffer size in case it's too small
651to fit a single large directory entry, or skip the oversized
652directory entry.
653
654Inputs:
655
656- <a href="#fd_readdir.fd" name="fd_readdir.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
657
658    The directory from which to read the directory
659    entries.
660
661- <a href="#fd_readdir.buf" name="fd_readdir.buf"></a><code>void \*<strong>buf</strong></code> and <a href="#fd_readdir.buf_len" name="fd_readdir.buf_len"></a><code>\_\_wasi\_size\_t <strong>buf\_len</strong></code>
662
663    The buffer where directory entries are stored.
664
665- <a href="#fd_readdir.cookie" name="fd_readdir.cookie"></a><code>[\_\_wasi\_dircookie\_t](#dircookie) <strong>cookie</strong></code>
666
667    The location within the directory to start
668    reading.
669
670Outputs:
671
672- <a href="#fd_readdir.bufused" name="fd_readdir.bufused"></a><code>\_\_wasi\_size\_t <strong>bufused</strong></code>
673
674    The number of bytes stored in the read buffer.
675    If less than the size of the read buffer, the
676    end of the directory has been reached.
677
678### <a href="#fd_renumber" name="fd_renumber"></a>`uvwasi_fd_renumber()`
679
680Atomically replace a file descriptor by renumbering another
681file descriptor.
682
683Due to the strong focus on thread safety, this environment
684does not provide a mechanism to duplicate or renumber a file
685descriptor to an arbitrary number, like dup2(). This would be
686prone to race conditions, as an actual file descriptor with the
687same number could be allocated by a different thread at the same
688time.
689
690This function provides a way to atomically renumber file
691descriptors, which would disappear if dup2() were to be
692removed entirely.
693
694Inputs:
695
696- <a href="#fd_renumber.from" name="fd_renumber.from"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>from</strong></code>
697
698    The file descriptor to renumber.
699
700- <a href="#fd_renumber.to" name="fd_renumber.to"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>to</strong></code>
701
702    The file descriptor to overwrite.
703
704### <a href="#fd_seek" name="fd_seek"></a>`uvwasi_fd_seek()`
705
706Move the offset of a file descriptor.
707
708Note: This is similar to `lseek` in POSIX.
709
710Inputs:
711
712- <a href="#fd_seek.fd" name="fd_seek.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
713
714    The file descriptor to operate on.
715
716- <a href="#fd_seek.offset" name="fd_seek.offset"></a><code>[\_\_wasi\_filedelta\_t](#filedelta) <strong>offset</strong></code>
717
718    The number of bytes to move.
719
720- <a href="#fd_seek.whence" name="fd_seek.whence"></a><code>[\_\_wasi\_whence\_t](#whence) <strong>whence</strong></code>
721
722    The base from which the offset is relative.
723
724Outputs:
725
726- <a href="#fd_seek.newoffset" name="fd_seek.newoffset"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>newoffset</strong></code>
727
728    The new offset of the file descriptor,
729    relative to the start of the file.
730
731### <a href="#fd_sync" name="fd_sync"></a>`uvwasi_fd_sync()`
732
733Synchronize the data and metadata of a file to disk.
734
735Note: This is similar to `fsync` in POSIX.
736
737Inputs:
738
739- <a href="#fd_sync.fd" name="fd_sync.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
740
741    The file descriptor of the file containing the data
742    and metadata to synchronize to disk.
743
744### <a href="#fd_tell" name="fd_tell"></a>`uvwasi_fd_tell()`
745
746Return the current offset of a file descriptor.
747
748Note: This is similar to `lseek(fd, 0, SEEK_CUR)` in POSIX.
749
750Inputs:
751
752- <a href="#fd_tell.fd" name="fd_tell.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
753
754    The file descriptor to inspect.
755
756Outputs:
757
758- <a href="#fd_tell.offset" name="fd_tell.offset"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>offset</strong></code>
759
760    The current offset of the file descriptor, relative to the start of the file.
761
762### <a href="#fd_write" name="fd_write"></a>`uvwasi_fd_write()`
763
764Write to a file descriptor.
765
766Note: This is similar to `writev` in POSIX.
767
768Inputs:
769
770- <a href="#fd_write.fd" name="fd_write.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
771
772    The file descriptor to which to write data.
773
774- <a href="#fd_write.iovs" name="fd_write.iovs"></a><code>const [\_\_wasi\_ciovec\_t](#ciovec) \*<strong>iovs</strong></code> and <a href="#fd_write.iovs_len" name="fd_write.iovs_len"></a><code>\_\_wasi\_size\_t <strong>iovs\_len</strong></code>
775
776    List of scatter/gather vectors from which to retrieve data.
777
778Outputs:
779
780- <a href="#fd_write.nwritten" name="fd_write.nwritten"></a><code>\_\_wasi\_size\_t <strong>nwritten</strong></code>
781
782    The number of bytes written.
783
784### <a href="#path_create_directory" name="path_create_directory"></a>`uvwasi_path_create_directory()`
785
786Create a directory.
787
788Note: This is similar to `mkdirat` in POSIX.
789
790Inputs:
791
792- <a href="#path_create_directory.fd" name="path_create_directory.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
793
794    The working directory at which the resolution of the path starts.
795
796- <a href="#path_create_directory.path" name="path_create_directory.path"></a><code>const char \*<strong>path</strong></code> and <a href="#path_create_directory.path_len" name="path_create_directory.path_len"></a><code>\_\_wasi\_size\_t <strong>path\_len</strong></code>
797
798    The path at which to create the directory.
799
800### <a href="#path_filestat_get" name="path_filestat_get"></a>`uvwasi_path_filestat_get()`
801
802Return the attributes of a file or directory.
803
804Note: This is similar to `stat` in POSIX.
805
806Inputs:
807
808- <a href="#path_filestat_get.fd" name="path_filestat_get.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
809
810    The working directory at which the resolution of the path starts.
811
812- <a href="#path_filestat_get.flags" name="path_filestat_get.flags"></a><code>[\_\_wasi\_lookupflags\_t](#lookupflags) <strong>flags</strong></code>
813
814    Flags determining the method of how the path is resolved.
815
816- <a href="#path_filestat_get.path" name="path_filestat_get.path"></a><code>const char \*<strong>path</strong></code> and <a href="#path_filestat_get.path_len" name="path_filestat_get.path_len"></a><code>\_\_wasi\_size\_t <strong>path\_len</strong></code>
817
818    The path of the file or directory to inspect.
819
820- <a href="#path_filestat_get.buf" name="path_filestat_get.buf"></a><code>[\_\_wasi\_filestat\_t](#filestat) \*<strong>buf</strong></code>
821
822    The buffer where the file's attributes are
823    stored.
824
825### <a href="#path_filestat_set_times" name="path_filestat_set_times"></a>`uvwasi_path_filestat_set_times()`
826
827Adjust the timestamps of a file or directory.
828
829Note: This is similar to `utimensat` in POSIX.
830
831Inputs:
832
833- <a href="#path_filestat_set_times.fd" name="path_filestat_set_times.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
834
835    The working directory at which the resolution of the path starts.
836
837- <a href="#path_filestat_set_times.flags" name="path_filestat_set_times.flags"></a><code>[\_\_wasi\_lookupflags\_t](#lookupflags) <strong>flags</strong></code>
838
839    Flags determining the method of how the path is resolved.
840
841- <a href="#path_filestat_set_times.path" name="path_filestat_set_times.path"></a><code>const char \*<strong>path</strong></code> and <a href="#path_filestat_set_times.path_len" name="path_filestat_set_times.path_len"></a><code>\_\_wasi\_size\_t <strong>path\_len</strong></code>
842
843    The path of the file or directory to operate on.
844
845- <a href="#path_filestat_set_times.st_atim" name="path_filestat_set_times.st_atim"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>st\_atim</strong></code>
846
847    The desired values of the data access timestamp.
848
849- <a href="#path_filestat_set_times.st_mtim" name="path_filestat_set_times.st_mtim"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>st\_mtim</strong></code>
850
851    The desired values of the data modification timestamp.
852
853- <a href="#path_filestat_set_times.fst_flags" name="path_filestat_set_times.fst_flags"></a><code>[\_\_wasi\_fstflags\_t](#fstflags) <strong>fst\_flags</strong></code>
854
855    A bitmask indicating which timestamps to adjust.
856
857### <a href="#path_link" name="path_link"></a>`uvwasi_path_link()`
858
859Create a hard link.
860
861Note: This is similar to `linkat` in POSIX.
862
863Inputs:
864
865- <a href="#path_link.old_fd" name="path_link.old_fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>old\_fd</strong></code>
866
867    The working directory at which the resolution of the old path starts.
868
869- <a href="#path_link.old_flags" name="path_link.old_flags"></a><code>[\_\_wasi\_lookupflags\_t](#lookupflags) <strong>old\_flags</strong></code>
870
871    Flags determining the method of how the path is resolved.
872
873- <a href="#path_link.old_path" name="path_link.old_path"></a><code>const char \*<strong>old\_path</strong></code> and <a href="#path_link.old_path_len" name="path_link.old_path_len"></a><code>\_\_wasi\_size\_t <strong>old\_path\_len</strong></code>
874
875    The source path from which to link.
876
877- <a href="#path_link.new_fd" name="path_link.new_fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>new\_fd</strong></code>
878
879    The working directory at which the resolution of the new path starts.
880
881- <a href="#path_link.new_path" name="path_link.new_path"></a><code>const char \*<strong>new\_path</strong></code> and <a href="#path_link.new_path_len" name="path_link.new_path_len"></a><code>\_\_wasi\_size\_t <strong>new\_path\_len</strong></code>
882
883    The destination path at which to create the hard link.
884
885### <a href="#path_open" name="path_open"></a>`uvwasi_path_open()`
886
887Open a file or directory.
888
889The returned file descriptor is not guaranteed to be the lowest-numbered
890file descriptor not currently open; it is randomized to prevent
891applications from depending on making assumptions about indexes, since
892this is error-prone in multi-threaded contexts. The returned file
893descriptor is guaranteed to be less than 2<sup>31</sup>.
894
895Note: This is similar to `openat` in POSIX.
896
897Inputs:
898
899- <a href="#path_open.dirfd" name="path_open.dirfd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>dirfd</strong></code>
900
901    The working directory at which the resolution of the path starts.
902
903- <a href="#path_open.dirflags" name="path_open.dirflags"></a><code>[\_\_wasi\_lookupflags\_t](#lookupflags) <strong>dirflags</strong></code>
904
905    Flags determining the method of how the path is resolved.
906
907- <a href="#path_open.path" name="path_open.path"></a><code>const char \*<strong>path</strong></code> and <a href="#path_open.path_len" name="path_open.path_len"></a><code>\_\_wasi\_size\_t <strong>path\_len</strong></code>
908
909    The relative path of the file or directory to open, relative to
910    the [`dirfd`](#path_open.dirfd) directory.
911
912- <a href="#path_open.o_flags" name="path_open.o_flags"></a><code>[\_\_wasi\_oflags\_t](#oflags) <strong>o_flags</strong></code>
913
914    The method by which to open the file.
915
916- <a href="#path_open.fs_rights_base" name="path_open.fs_rights_base"></a><code>[\_\_wasi\_rights\_t](#rights) <strong>fs\_rights\_base</strong></code> and <a href="#path_open.fs_rights_inheriting" name="path_open.fs_rights_inheriting"></a><code>[\_\_wasi\_rights\_t](#rights) <strong>fs\_rights\_inheriting</strong></code>
917
918    The initial rights of the newly created file descriptor. The
919    implementation is allowed to return a file descriptor with fewer
920    rights than specified, if and only if those rights do not apply
921    to the type of file being opened.
922
923    The *base* rights are rights that will apply to operations using
924    the file descriptor itself, while the *inheriting* rights are
925    rights that apply to file descriptors derived from it.
926
927- <a href="#path_open.fs_flags" name="path_open.fs_flags"></a><code>[\_\_wasi\_fdflags\_t](#fdflags) <strong>fs\_flags</strong></code>
928
929    The initial flags of the file descriptor.
930
931Outputs:
932
933- <a href="#path_open.fd" name="path_open.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
934
935    The file descriptor of the file that has been
936    opened.
937
938### <a href="#path_readlink" name="path_readlink"></a>`uvwasi_path_readlink()`
939
940Read the contents of a symbolic link.
941
942Note: This is similar to `readlinkat` in POSIX.
943
944Inputs:
945
946- <a href="#path_readlink.fd" name="path_readlink.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
947
948    The working directory at which the resolution of the path starts.
949
950- <a href="#path_readlink.path" name="path_readlink.path"></a><code>const char \*<strong>path</strong></code> and <a href="#path_readlink.path_len" name="path_readlink.path_len"></a><code>\_\_wasi\_size\_t <strong>path\_len</strong></code>
951
952    The path of the symbolic link from which to read.
953
954- <a href="#path_readlink.buf" name="path_readlink.buf"></a><code>char \*<strong>buf</strong></code> and <a href="#path_readlink.buf_len" name="path_readlink.buf_len"></a><code>\_\_wasi\_size\_t <strong>buf\_len</strong></code>
955
956    The buffer to which to write the contents of the symbolic link.
957
958Outputs:
959
960- <a href="#path_readlink.bufused" name="path_readlink.bufused"></a><code>\_\_wasi\_size\_t <strong>bufused</strong></code>
961
962    The number of bytes placed in the buffer.
963
964### <a href="#path_remove_directory" name="path_remove_directory"></a>`uvwasi_path_remove_directory()`
965
966Remove a directory.
967
968Return [`UVWASI_ENOTEMPTY`](#errno.notempty) if the directory is not empty.
969
970Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX.
971
972Inputs:
973
974- <a href="#path_remove_directory.fd" name="path_remove_directory.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
975
976    The working directory at which the resolution of the path starts.
977
978- <a href="#path_remove_directory.path" name="path_remove_directory.path"></a><code>const char \*<strong>path</strong></code> and <a href="#path_remove_directory.path_len" name="path_remove_directory.path_len"></a><code>\_\_wasi\_size\_t <strong>path\_len</strong></code>
979
980    The path to a directory to remove.
981
982### <a href="#path_rename" name="path_rename"></a>`uvwasi_path_rename()`
983
984Rename a file or directory.
985
986Note: This is similar to `renameat` in POSIX.
987
988Inputs:
989
990- <a href="#path_rename.old_fd" name="path_rename.old_fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>old\_fd</strong></code>
991
992    The working directory at which the resolution of the old path starts.
993
994- <a href="#path_rename.old_path" name="path_rename.old_path"></a><code>const char \*<strong>old\_path</strong></code> and <a href="#path_rename.old_path_len" name="path_rename.old_path_len"></a><code>\_\_wasi\_size\_t <strong>old\_path\_len</strong></code>
995
996    The source path of the file or directory to rename.
997
998- <a href="#path_rename.new_fd" name="path_rename.new_fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>new\_fd</strong></code>
999
1000    The working directory at which the resolution of the new path starts.
1001
1002- <a href="#path_rename.new_path" name="path_rename.new_path"></a><code>const char \*<strong>new\_path</strong></code> and <a href="#path_rename.new_path_len" name="path_rename.new_path_len"></a><code>\_\_wasi\_size\_t <strong>new\_path\_len</strong></code>
1003
1004    The destination path to which to rename the file or directory.
1005
1006### <a href="#path_symlink" name="path_symlink"></a>`uvwasi_path_symlink()`
1007
1008Create a symbolic link.
1009
1010Note: This is similar to `symlinkat` in POSIX.
1011
1012Inputs:
1013
1014- <a href="#path_symlink.old_path" name="path_symlink.old_path"></a><code>const char \*<strong>old\_path</strong></code> and <a href="#path_symlink.old_path_len" name="path_symlink.old_path_len"></a><code>\_\_wasi\_size\_t <strong>old_path\_len</strong></code>
1015
1016    The contents of the symbolic link.
1017
1018- <a href="#path_symlink.fd" name="path_symlink.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
1019
1020    The working directory at which the resolution of the path starts.
1021
1022- <a href="#path_symlink.new_path" name="path_symlink.new_path"></a><code>const char \*<strong>new\_path</strong></code> and <a href="#path_symlink.new_path_len" name="path_symlink.new_path_len"></a><code>\_\_wasi\_size\_t <strong>new\_path\_len</strong></code>
1023
1024    The destination path at which to create the symbolic link.
1025
1026### <a href="#path_unlink_file" name="path_unlink_file"></a>`uvwasi_path_unlink_file()`
1027
1028Unlink a file.
1029
1030Return [`UVWASI_EISDIR`](#errno.isdir) if the path refers to a directory.
1031
1032Note: This is similar to `unlinkat(fd, path, 0)` in POSIX.
1033
1034Inputs:
1035
1036- <a href="#path_unlink_file.fd" name="path_unlink_file.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
1037
1038    The working directory at which the resolution of the path starts.
1039
1040- <a href="#path_unlink_file.path" name="path_unlink_file.path"></a><code>const char \*<strong>path</strong></code> and <a href="#path_unlink_file.path_len" name="path_unlink_file.path_len"></a><code>\_\_wasi\_size\_t <strong>path\_len</strong></code>
1041
1042    The path to a file to unlink.
1043
1044### <a href="#poll_oneoff" name="poll_oneoff"></a>`uvwasi_poll_oneoff()`
1045
1046Concurrently poll for the occurrence of a set of events.
1047
1048Inputs:
1049
1050- <a href="#poll_oneoff.in" name="poll_oneoff.in"></a><code>const [\_\_wasi\_subscription\_t](#subscription) \*<strong>in</strong></code>
1051
1052    The events to which to subscribe.
1053
1054- <a href="#poll_oneoff.out" name="poll_oneoff.out"></a><code>[\_\_wasi\_event\_t](#event) \*<strong>out</strong></code>
1055
1056    The events that have occurred.
1057
1058- <a href="#poll_oneoff.nsubscriptions" name="poll_oneoff.nsubscriptions"></a><code>\_\_wasi\_size\_t <strong>nsubscriptions</strong></code>
1059
1060    Both the number of subscriptions and events.
1061
1062Outputs:
1063
1064- <a href="#poll_oneoff.nevents" name="poll_oneoff.nevents"></a><code>\_\_wasi\_size\_t <strong>nevents</strong></code>
1065
1066    The number of events stored.
1067
1068### <a href="#proc_exit" name="proc_exit"></a>`uvwasi_proc_exit()`
1069
1070Terminate the process normally. An exit code of 0 indicates successful
1071termination of the program. The meanings of other values is dependent on
1072the environment.
1073
1074Note: This is similar to `_Exit` in POSIX.
1075
1076Inputs:
1077
1078- <a href="#proc_exit.rval" name="proc_exit.rval"></a><code>[\_\_wasi\_exitcode\_t](#exitcode) <strong>rval</strong></code>
1079
1080    The exit code returned by the process.
1081
1082Does not return.
1083
1084### <a href="#proc_raise" name="proc_raise"></a>`uvwasi_proc_raise()`
1085
1086Send a signal to the process of the calling thread.
1087
1088Note: This is similar to `raise` in POSIX.
1089
1090Inputs:
1091
1092- <a href="#proc_raise.sig" name="proc_raise.sig"></a><code>[\_\_wasi\_signal\_t](#signal) <strong>sig</strong></code>
1093
1094    The signal condition to trigger.
1095
1096### <a href="#random_get" name="random_get"></a>`uvwasi_random_get()`
1097
1098Write high-quality random data into a buffer.
1099
1100This function blocks when the implementation is unable to immediately
1101provide sufficient high-quality random data.
1102
1103This function may execute slowly, so when large mounts of random
1104data are required, it's advisable to use this function to seed a
1105pseudo-random number generator, rather than to provide the
1106random data directly.
1107
1108Inputs:
1109
1110- <a href="#random_get.buf" name="random_get.buf"></a><code>void \*<strong>buf</strong></code> and <a href="#random_get.buf_len" name="random_get.buf_len"></a><code>\_\_wasi\_size\_t <strong>buf\_len</strong></code>
1111
1112    The buffer to fill with random data.
1113
1114### <a href="#sched_yield" name="sched_yield"></a>`uvwasi_sched_yield()`
1115
1116Temporarily yield execution of the calling thread.
1117
1118Note: This is similar to `sched_yield` in POSIX.
1119
1120### <a href="#sock_recv" name="sock_recv"></a>`uvwasi_sock_recv()`
1121
1122Receive a message from a socket.
1123
1124Note: This is similar to `recv` in POSIX, though it also supports reading
1125the data into multiple buffers in the manner of `readv`.
1126
1127Inputs:
1128
1129- <a href="#sock_recv.sock" name="sock_recv.sock"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>sock</strong></code>
1130
1131    The socket on which to receive data.
1132
1133- <a href="#sock_recv.ri_data" name="sock_recv.ri_data"></a><code>const [\_\_wasi\_iovec\_t](#iovec) \*<strong>ri\_data</strong></code> and <a href="#sock_recv.ri_data_len" name="sock_recv.ri_data_len"></a><code>\_\_wasi\_size\_t <strong>ri\_data\_len</strong></code>
1134
1135    List of scatter/gather vectors to which to store data.
1136
1137- <a href="#sock_recv.ri_flags" name="sock_recv.ri_flags"></a><code>[\_\_wasi\_riflags\_t](#riflags) <strong>ri\_flags</strong></code>
1138
1139    Message flags.
1140
1141Outputs:
1142
1143- <a href="#sock_recv.ro_datalen" name="sock_recv.ro_datalen"></a><code>\_\_wasi\_size\_t <strong>ro\_datalen</strong></code>
1144
1145    Number of bytes stored in [`ri_data`](#sock_recv.ri_data).
1146
1147- <a href="#sock_recv.ro_flags" name="sock_recv.ro_flags"></a><code>[\_\_wasi\_roflags\_t](#roflags) <strong>ro\_flags</strong></code>
1148
1149    Message flags.
1150
1151### <a href="#sock_send" name="sock_send"></a>`uvwasi_sock_send()`
1152
1153Send a message on a socket.
1154
1155Note: This is similar to `send` in POSIX, though it also supports writing
1156the data from multiple buffers in the manner of `writev`.
1157
1158Inputs:
1159
1160- <a href="#sock_send.sock" name="sock_send.sock"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>sock</strong></code>
1161
1162    The socket on which to send data.
1163
1164- <a href="#sock_send.si_data" name="sock_send.si_data"></a><code>const [\_\_wasi\_ciovec\_t](#ciovec) \*<strong>si\_data</strong></code> and <a href="#sock_send.si_data_len" name="sock_send.si_data_len"></a><code>\_\_wasi\_size\_t <strong>si\_data\_len</strong></code>
1165
1166    List of scatter/gather vectors to which to retrieve data
1167
1168- <a href="#sock_send.si_flags" name="sock_send.si_flags"></a><code>[\_\_wasi\_siflags\_t](#siflags) <strong>si\_flags</strong></code>
1169
1170    Message flags.
1171
1172Outputs:
1173
1174- <a href="#sock_send.so_datalen" name="sock_send.so_datalen"></a><code>\_\_wasi\_size\_t <strong>so\_datalen</strong></code>
1175
1176    Number of bytes transmitted.
1177
1178### <a href="#sock_shutdown" name="sock_shutdown"></a>`uvwasi_sock_shutdown()`
1179
1180Shut down socket send and receive channels.
1181
1182Note: This is similar to `shutdown` in POSIX.
1183
1184Inputs:
1185
1186- <a href="#sock_shutdown.sock" name="sock_shutdown.sock"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>sock</strong></code>
1187
1188    The socket on which to shutdown channels.
1189
1190- <a href="#sock_shutdown.how" name="sock_shutdown.how"></a><code>[\_\_wasi\_sdflags\_t](#sdflags) <strong>how</strong></code>
1191
1192    Which channels on the socket to shut down.
1193
1194## Types
1195
1196### <a href="#advice" name="advice"></a>`uvwasi_advice_t` (`uint8_t`)
1197
1198File or memory access pattern advisory information.
1199
1200Used by [`uvwasi_fd_advise()`](#fd_advise).
1201
1202Possible values:
1203
1204- <a href="#advice.dontneed" name="advice.dontneed"></a>**`UVWASI_ADVICE_DONTNEED`**
1205
1206    The application expects that it will not access the
1207    specified data in the near future.
1208
1209- <a href="#advice.noreuse" name="advice.noreuse"></a>**`UVWASI_ADVICE_NOREUSE`**
1210
1211    The application expects to access the specified data
1212    once and then not reuse it thereafter.
1213
1214- <a href="#advice.normal" name="advice.normal"></a>**`UVWASI_ADVICE_NORMAL`**
1215
1216    The application has no advice to give on its behavior
1217    with respect to the specified data.
1218
1219- <a href="#advice.random" name="advice.random"></a>**`UVWASI_ADVICE_RANDOM`**
1220
1221    The application expects to access the specified data
1222    in a random order.
1223
1224- <a href="#advice.sequential" name="advice.sequential"></a>**`UVWASI_ADVICE_SEQUENTIAL`**
1225
1226    The application expects to access the specified data
1227    sequentially from lower offsets to higher offsets.
1228
1229- <a href="#advice.willneed" name="advice.willneed"></a>**`UVWASI_ADVICE_WILLNEED`**
1230
1231    The application expects to access the specified data
1232    in the near future.
1233
1234### <a href="#ciovec" name="ciovec"></a>`uvwasi_ciovec_t` (`struct`)
1235
1236A region of memory for scatter/gather writes.
1237
1238Used by [`uvwasi_fd_pwrite()`](#fd_pwrite), [`uvwasi_fd_write()`](#fd_write), and [`uvwasi_sock_send()`](#sock_send).
1239
1240Members:
1241
1242- <a href="#ciovec.buf" name="ciovec.buf"></a><code>const void \*<strong>buf</strong></code> and <a href="#ciovec.buf_len" name="ciovec.buf_len"></a><code>\_\_wasi\_size\_t <strong>buf\_len</strong></code>
1243
1244    The address and length of the buffer to be written.
1245
1246### <a href="#clockid" name="clockid"></a>`uvwasi_clockid_t` (`uint32_t`)
1247
1248Identifiers for clocks.
1249
1250Used by [`uvwasi_subscription_t`](#subscription), [`uvwasi_clock_res_get()`](#clock_res_get), and [`uvwasi_clock_time_get()`](#clock_time_get).
1251
1252Possible values:
1253
1254- <a href="#clockid.monotonic" name="clockid.monotonic"></a>**`UVWASI_CLOCK_MONOTONIC`**
1255
1256    The store-wide monotonic clock, which is defined as a
1257    clock measuring real time, whose value cannot be
1258    adjusted and which cannot have negative clock jumps.
1259
1260    The epoch of this clock is undefined. The absolute
1261    time value of this clock therefore has no meaning.
1262
1263- <a href="#clockid.process_cputime_id" name="clockid.process_cputime_id"></a>**`UVWASI_CLOCK_PROCESS_CPUTIME_ID`**
1264
1265    The CPU-time clock associated with the current
1266    process.
1267
1268- <a href="#clockid.realtime" name="clockid.realtime"></a>**`UVWASI_CLOCK_REALTIME`**
1269
1270    The clock measuring real time. Time value
1271    zero corresponds with 1970-01-01T00:00:00Z.
1272
1273- <a href="#clockid.thread_cputime_id" name="clockid.thread_cputime_id"></a>**`UVWASI_CLOCK_THREAD_CPUTIME_ID`**
1274
1275    The CPU-time clock associated with the current thread.
1276
1277### <a href="#device" name="device"></a>`uvwasi_device_t` (`uint64_t`)
1278
1279Identifier for a device containing a file system. Can be used
1280in combination with [`uvwasi_inode_t`](#inode) to uniquely identify a file or
1281directory in the filesystem.
1282
1283Used by [`uvwasi_filestat_t`](#filestat).
1284
1285### <a href="#dircookie" name="dircookie"></a>`uvwasi_dircookie_t` (`uint64_t`)
1286
1287A reference to the offset of a directory entry.
1288
1289Used by [`uvwasi_dirent_t`](#dirent) and [`uvwasi_fd_readdir()`](#fd_readdir).
1290
1291Special values:
1292
1293- <a href="#dircookie.start" name="dircookie.start"></a>**`UVWASI_DIRCOOKIE_START`**
1294
1295    Permanent reference to the first directory entry
1296    within a directory.
1297
1298### <a href="#dirent" name="dirent"></a>`uvwasi_dirent_t` (`struct`)
1299
1300A directory entry.
1301
1302Members:
1303
1304- <a href="#dirent.d_next" name="dirent.d_next"></a><code>[\_\_wasi\_dircookie\_t](#dircookie) <strong>d\_next</strong></code>
1305
1306    The offset of the next directory entry stored in this
1307    directory.
1308
1309- <a href="#dirent.d_ino" name="dirent.d_ino"></a><code>[\_\_wasi\_inode\_t](#inode) <strong>d\_ino</strong></code>
1310
1311    The serial number of the file referred to by this
1312    directory entry.
1313
1314- <a href="#dirent.d_namlen" name="dirent.d_namlen"></a><code>uint32\_t <strong>d\_namlen</strong></code>
1315
1316    The length of the name of the directory entry.
1317
1318- <a href="#dirent.d_type" name="dirent.d_type"></a><code>[\_\_wasi\_filetype\_t](#filetype) <strong>d\_type</strong></code>
1319
1320    The type of the file referred to by this directory
1321    entry.
1322
1323### <a href="#errno" name="errno"></a>`uvwasi_errno_t` (`uint16_t`)
1324
1325Error codes returned by functions.
1326
1327Not all of these error codes are returned by the functions
1328provided by this API; some are used in higher-level library layers,
1329and others are provided merely for alignment with POSIX.
1330
1331Used by [`uvwasi_event_t`](#event).
1332
1333Possible values:
1334
1335- <a href="#errno.success" name="errno.success"></a>**`UVWASI_ESUCCESS`**
1336
1337    No error occurred. System call completed successfully.
1338
1339- <a href="#errno.2big" name="errno.2big"></a>**`UVWASI_E2BIG`**
1340
1341    Argument list too long.
1342
1343- <a href="#errno.acces" name="errno.acces"></a>**`UVWASI_EACCES`**
1344
1345    Permission denied.
1346
1347- <a href="#errno.addrinuse" name="errno.addrinuse"></a>**`UVWASI_EADDRINUSE`**
1348
1349    Address in use.
1350
1351- <a href="#errno.addrnotavail" name="errno.addrnotavail"></a>**`UVWASI_EADDRNOTAVAIL`**
1352
1353    Address not available.
1354
1355- <a href="#errno.afnosupport" name="errno.afnosupport"></a>**`UVWASI_EAFNOSUPPORT`**
1356
1357    Address family not supported.
1358
1359- <a href="#errno.again" name="errno.again"></a>**`UVWASI_EAGAIN`**
1360
1361    Resource unavailable, or operation would block.
1362
1363- <a href="#errno.already" name="errno.already"></a>**`UVWASI_EALREADY`**
1364
1365    Connection already in progress.
1366
1367- <a href="#errno.badf" name="errno.badf"></a>**`UVWASI_EBADF`**
1368
1369    Bad file descriptor.
1370
1371- <a href="#errno.badmsg" name="errno.badmsg"></a>**`UVWASI_EBADMSG`**
1372
1373    Bad message.
1374
1375- <a href="#errno.busy" name="errno.busy"></a>**`UVWASI_EBUSY`**
1376
1377    Device or resource busy.
1378
1379- <a href="#errno.canceled" name="errno.canceled"></a>**`UVWASI_ECANCELED`**
1380
1381    Operation canceled.
1382
1383- <a href="#errno.child" name="errno.child"></a>**`UVWASI_ECHILD`**
1384
1385    No child processes.
1386
1387- <a href="#errno.connaborted" name="errno.connaborted"></a>**`UVWASI_ECONNABORTED`**
1388
1389    Connection aborted.
1390
1391- <a href="#errno.connrefused" name="errno.connrefused"></a>**`UVWASI_ECONNREFUSED`**
1392
1393    Connection refused.
1394
1395- <a href="#errno.connreset" name="errno.connreset"></a>**`UVWASI_ECONNRESET`**
1396
1397    Connection reset.
1398
1399- <a href="#errno.deadlk" name="errno.deadlk"></a>**`UVWASI_EDEADLK`**
1400
1401    Resource deadlock would occur.
1402
1403- <a href="#errno.destaddrreq" name="errno.destaddrreq"></a>**`UVWASI_EDESTADDRREQ`**
1404
1405    Destination address required.
1406
1407- <a href="#errno.dom" name="errno.dom"></a>**`UVWASI_EDOM`**
1408
1409    Mathematics argument out of domain of function.
1410
1411- <a href="#errno.dquot" name="errno.dquot"></a>**`UVWASI_EDQUOT`**
1412
1413    Reserved.
1414
1415- <a href="#errno.exist" name="errno.exist"></a>**`UVWASI_EEXIST`**
1416
1417    File exists.
1418
1419- <a href="#errno.fault" name="errno.fault"></a>**`UVWASI_EFAULT`**
1420
1421    Bad address.
1422
1423- <a href="#errno.fbig" name="errno.fbig"></a>**`UVWASI_EFBIG`**
1424
1425    File too large.
1426
1427- <a href="#errno.hostunreach" name="errno.hostunreach"></a>**`UVWASI_EHOSTUNREACH`**
1428
1429    Host is unreachable.
1430
1431- <a href="#errno.idrm" name="errno.idrm"></a>**`UVWASI_EIDRM`**
1432
1433    Identifier removed.
1434
1435- <a href="#errno.ilseq" name="errno.ilseq"></a>**`UVWASI_EILSEQ`**
1436
1437    Illegal byte sequence.
1438
1439- <a href="#errno.inprogress" name="errno.inprogress"></a>**`UVWASI_EINPROGRESS`**
1440
1441    Operation in progress.
1442
1443- <a href="#errno.intr" name="errno.intr"></a>**`UVWASI_EINTR`**
1444
1445    Interrupted function.
1446
1447- <a href="#errno.inval" name="errno.inval"></a>**`UVWASI_EINVAL`**
1448
1449    Invalid argument.
1450
1451- <a href="#errno.io" name="errno.io"></a>**`UVWASI_EIO`**
1452
1453    I/O error.
1454
1455- <a href="#errno.isconn" name="errno.isconn"></a>**`UVWASI_EISCONN`**
1456
1457    Socket is connected.
1458
1459- <a href="#errno.isdir" name="errno.isdir"></a>**`UVWASI_EISDIR`**
1460
1461    Is a directory.
1462
1463- <a href="#errno.loop" name="errno.loop"></a>**`UVWASI_ELOOP`**
1464
1465    Too many levels of symbolic links.
1466
1467- <a href="#errno.mfile" name="errno.mfile"></a>**`UVWASI_EMFILE`**
1468
1469    File descriptor value too large.
1470
1471- <a href="#errno.mlink" name="errno.mlink"></a>**`UVWASI_EMLINK`**
1472
1473    Too many links.
1474
1475- <a href="#errno.msgsize" name="errno.msgsize"></a>**`UVWASI_EMSGSIZE`**
1476
1477    Message too large.
1478
1479- <a href="#errno.multihop" name="errno.multihop"></a>**`UVWASI_EMULTIHOP`**
1480
1481    Reserved.
1482
1483- <a href="#errno.nametoolong" name="errno.nametoolong"></a>**`UVWASI_ENAMETOOLONG`**
1484
1485    Filename too long.
1486
1487- <a href="#errno.netdown" name="errno.netdown"></a>**`UVWASI_ENETDOWN`**
1488
1489    Network is down.
1490
1491- <a href="#errno.netreset" name="errno.netreset"></a>**`UVWASI_ENETRESET`**
1492
1493    Connection aborted by network.
1494
1495- <a href="#errno.netunreach" name="errno.netunreach"></a>**`UVWASI_ENETUNREACH`**
1496
1497    Network unreachable.
1498
1499- <a href="#errno.nfile" name="errno.nfile"></a>**`UVWASI_ENFILE`**
1500
1501    Too many files open in system.
1502
1503- <a href="#errno.nobufs" name="errno.nobufs"></a>**`UVWASI_ENOBUFS`**
1504
1505    No buffer space available.
1506
1507- <a href="#errno.nodev" name="errno.nodev"></a>**`UVWASI_ENODEV`**
1508
1509    No such device.
1510
1511- <a href="#errno.noent" name="errno.noent"></a>**`UVWASI_ENOENT`**
1512
1513    No such file or directory.
1514
1515- <a href="#errno.noexec" name="errno.noexec"></a>**`UVWASI_ENOEXEC`**
1516
1517    Executable file format error.
1518
1519- <a href="#errno.nolck" name="errno.nolck"></a>**`UVWASI_ENOLCK`**
1520
1521    No locks available.
1522
1523- <a href="#errno.nolink" name="errno.nolink"></a>**`UVWASI_ENOLINK`**
1524
1525    Reserved.
1526
1527- <a href="#errno.nomem" name="errno.nomem"></a>**`UVWASI_ENOMEM`**
1528
1529    Not enough space.
1530
1531- <a href="#errno.nomsg" name="errno.nomsg"></a>**`UVWASI_ENOMSG`**
1532
1533    No message of the desired type.
1534
1535- <a href="#errno.noprotoopt" name="errno.noprotoopt"></a>**`UVWASI_ENOPROTOOPT`**
1536
1537    Protocol not available.
1538
1539- <a href="#errno.nospc" name="errno.nospc"></a>**`UVWASI_ENOSPC`**
1540
1541    No space left on device.
1542
1543- <a href="#errno.nosys" name="errno.nosys"></a>**`UVWASI_ENOSYS`**
1544
1545    Function not supported.
1546
1547- <a href="#errno.notconn" name="errno.notconn"></a>**`UVWASI_ENOTCONN`**
1548
1549    The socket is not connected.
1550
1551- <a href="#errno.notdir" name="errno.notdir"></a>**`UVWASI_ENOTDIR`**
1552
1553    Not a directory or a symbolic link to a directory.
1554
1555- <a href="#errno.notempty" name="errno.notempty"></a>**`UVWASI_ENOTEMPTY`**
1556
1557    Directory not empty.
1558
1559- <a href="#errno.notrecoverable" name="errno.notrecoverable"></a>**`UVWASI_ENOTRECOVERABLE`**
1560
1561    State not recoverable.
1562
1563- <a href="#errno.notsock" name="errno.notsock"></a>**`UVWASI_ENOTSOCK`**
1564
1565    Not a socket.
1566
1567- <a href="#errno.notsup" name="errno.notsup"></a>**`UVWASI_ENOTSUP`**
1568
1569    Not supported, or operation not supported on socket.
1570
1571- <a href="#errno.notty" name="errno.notty"></a>**`UVWASI_ENOTTY`**
1572
1573    Inappropriate I/O control operation.
1574
1575- <a href="#errno.nxio" name="errno.nxio"></a>**`UVWASI_ENXIO`**
1576
1577    No such device or address.
1578
1579- <a href="#errno.overflow" name="errno.overflow"></a>**`UVWASI_EOVERFLOW`**
1580
1581    Value too large to be stored in data type.
1582
1583- <a href="#errno.ownerdead" name="errno.ownerdead"></a>**`UVWASI_EOWNERDEAD`**
1584
1585    Previous owner died.
1586
1587- <a href="#errno.perm" name="errno.perm"></a>**`UVWASI_EPERM`**
1588
1589    Operation not permitted.
1590
1591- <a href="#errno.pipe" name="errno.pipe"></a>**`UVWASI_EPIPE`**
1592
1593    Broken pipe.
1594
1595- <a href="#errno.proto" name="errno.proto"></a>**`UVWASI_EPROTO`**
1596
1597    Protocol error.
1598
1599- <a href="#errno.protonosupport" name="errno.protonosupport"></a>**`UVWASI_EPROTONOSUPPORT`**
1600
1601    Protocol not supported.
1602
1603- <a href="#errno.prototype" name="errno.prototype"></a>**`UVWASI_EPROTOTYPE`**
1604
1605    Protocol wrong type for socket.
1606
1607- <a href="#errno.range" name="errno.range"></a>**`UVWASI_ERANGE`**
1608
1609    Result too large.
1610
1611- <a href="#errno.rofs" name="errno.rofs"></a>**`UVWASI_EROFS`**
1612
1613    Read-only file system.
1614
1615- <a href="#errno.spipe" name="errno.spipe"></a>**`UVWASI_ESPIPE`**
1616
1617    Invalid seek.
1618
1619- <a href="#errno.srch" name="errno.srch"></a>**`UVWASI_ESRCH`**
1620
1621    No such process.
1622
1623- <a href="#errno.stale" name="errno.stale"></a>**`UVWASI_ESTALE`**
1624
1625    Reserved.
1626
1627- <a href="#errno.timedout" name="errno.timedout"></a>**`UVWASI_ETIMEDOUT`**
1628
1629    Connection timed out.
1630
1631- <a href="#errno.txtbsy" name="errno.txtbsy"></a>**`UVWASI_ETXTBSY`**
1632
1633    Text file busy.
1634
1635- <a href="#errno.xdev" name="errno.xdev"></a>**`UVWASI_EXDEV`**
1636
1637    Cross-device link.
1638
1639- <a href="#errno.notcapable" name="errno.notcapable"></a>**`UVWASI_ENOTCAPABLE`**
1640
1641    Extension: Capabilities insufficient.
1642
1643### <a href="#event" name="event"></a>`uvwasi_event_t` (`struct`)
1644
1645An event that occurred.
1646
1647Used by [`uvwasi_poll_oneoff()`](#poll_oneoff).
1648
1649Members:
1650
1651- <a href="#event.userdata" name="event.userdata"></a><code>[\_\_wasi\_userdata\_t](#userdata) <strong>userdata</strong></code>
1652
1653    User-provided value that got attached to
1654    [`uvwasi_subscription_t::userdata`](#subscription.userdata).
1655
1656- <a href="#event.error" name="event.error"></a><code>[\_\_wasi\_errno\_t](#errno) <strong>error</strong></code>
1657
1658    If non-zero, an error that occurred while processing
1659    the subscription request.
1660
1661- <a href="#event.type" name="event.type"></a><code>[\_\_wasi\_eventtype\_t](#eventtype) <strong>type</strong></code>
1662
1663    The type of the event that occurred.
1664
1665- When `type` is [`UVWASI_EVENTTYPE_FD_READ`](#eventtype.fd_read) or [`UVWASI_EVENTTYPE_FD_WRITE`](#eventtype.fd_write):
1666
1667    - <a href="#event.u.fd_readwrite" name="event.u.fd_readwrite"></a>**`u.fd_readwrite`**
1668
1669        - <a href="#event.u.fd_readwrite.nbytes" name="event.u.fd_readwrite.nbytes"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>nbytes</strong></code>
1670
1671            The number of bytes available for reading or writing.
1672
1673        - <a href="#event.u.fd_readwrite.flags" name="event.u.fd_readwrite.flags"></a><code>[\_\_wasi\_eventrwflags\_t](#eventrwflags) <strong>flags</strong></code>
1674
1675            The state of the file descriptor.
1676
1677### <a href="#eventrwflags" name="eventrwflags"></a>`uvwasi_eventrwflags_t` (`uint16_t` bitfield)
1678
1679The state of the file descriptor subscribed to with
1680[`UVWASI_EVENTTYPE_FD_READ`](#eventtype.fd_read) or [`UVWASI_EVENTTYPE_FD_WRITE`](#eventtype.fd_write).
1681
1682Used by [`uvwasi_event_t`](#event).
1683
1684Possible values:
1685
1686- <a href="#eventrwflags.hangup" name="eventrwflags.hangup"></a>**`UVWASI_EVENT_FD_READWRITE_HANGUP`**
1687
1688    The peer of this socket has closed or disconnected.
1689
1690### <a href="#eventtype" name="eventtype"></a>`uvwasi_eventtype_t` (`uint8_t`)
1691
1692Type of a subscription to an event or its occurrence.
1693
1694Used by [`uvwasi_event_t`](#event) and [`uvwasi_subscription_t`](#subscription).
1695
1696Possible values:
1697
1698- <a href="#eventtype.u.clock" name="eventtype.u.clock"></a>**`UVWASI_EVENTTYPE_CLOCK`**
1699
1700    The time value of clock [`uvwasi_subscription_t::u.clock.clock_id`](#subscription.u.clock.clock_id)
1701    has reached timestamp [`uvwasi_subscription_t::u.clock.timeout`](#subscription.u.clock.timeout).
1702
1703- <a href="#eventtype.fd_read" name="eventtype.fd_read"></a>**`UVWASI_EVENTTYPE_FD_READ`**
1704
1705    File descriptor [`uvwasi_subscription_t::u.fd_readwrite.fd`](#subscription.u.fd_readwrite.fd) has
1706    data available for reading. This event always triggers
1707    for regular files.
1708
1709- <a href="#eventtype.fd_write" name="eventtype.fd_write"></a>**`UVWASI_EVENTTYPE_FD_WRITE`**
1710
1711    File descriptor [`uvwasi_subscription_t::u.fd_readwrite.fd`](#subscription.u.fd_readwrite.fd) has
1712    capacity available for writing. This event always
1713    triggers for regular files.
1714
1715### <a href="#exitcode" name="exitcode"></a>`uvwasi_exitcode_t` (`uint32_t`)
1716
1717Exit code generated by a process when exiting.
1718
1719Used by [`uvwasi_proc_exit()`](#proc_exit).
1720
1721### <a href="#fd" name="fd"></a>`uvwasi_fd_t` (`uint32_t`)
1722
1723A file descriptor number.
1724
1725Used by many functions in this API.
1726
1727As in POSIX, three file descriptor numbers are provided to instances
1728on startup -- 0, 1, and 2, (a.k.a. `STDIN_FILENO`, `STDOUT_FILENO`,
1729and `STDERR_FILENO`).
1730
1731Other than these, WASI implementations are not required to allocate
1732new file descriptors in ascending order.
1733
1734### <a href="#fdflags" name="fdflags"></a>`uvwasi_fdflags_t` (`uint16_t` bitfield)
1735
1736File descriptor flags.
1737
1738Used by [`uvwasi_fdstat_t`](#fdstat), [`uvwasi_fd_fdstat_set_flags()`](#fd_fdstat_set_flags), and [`uvwasi_path_open()`](#path_open).
1739
1740Possible values:
1741
1742- <a href="#fdflags.append" name="fdflags.append"></a>**`UVWASI_FDFLAG_APPEND`**
1743
1744    Append mode: Data written to the file is always
1745    appended to the file's end.
1746
1747- <a href="#fdflags.dsync" name="fdflags.dsync"></a>**`UVWASI_FDFLAG_DSYNC`**
1748
1749    Write according to synchronized I/O data integrity
1750    completion. Only the data stored in the file is
1751    synchronized.
1752
1753- <a href="#fdflags.nonblock" name="fdflags.nonblock"></a>**`UVWASI_FDFLAG_NONBLOCK`**
1754
1755    Non-blocking mode.
1756
1757- <a href="#fdflags.rsync" name="fdflags.rsync"></a>**`UVWASI_FDFLAG_RSYNC`**
1758
1759    Synchronized read I/O operations.
1760
1761- <a href="#fdflags.sync" name="fdflags.sync"></a>**`UVWASI_FDFLAG_SYNC`**
1762
1763    Write according to synchronized I/O file integrity completion.
1764    In addition to synchronizing the data stored in the file, the
1765    implementation may also synchronously update the file's metadata.
1766
1767### <a href="#fdstat" name="fdstat"></a>`uvwasi_fdstat_t` (`struct`)
1768
1769File descriptor attributes.
1770
1771Used by [`uvwasi_fd_fdstat_get()`](#fd_fdstat_get).
1772
1773Members:
1774
1775- <a href="#fdstat.fs_filetype" name="fdstat.fs_filetype"></a><code>[\_\_wasi\_filetype\_t](#filetype) <strong>fs\_filetype</strong></code>
1776
1777    File type.
1778
1779- <a href="#fdstat.fs_flags" name="fdstat.fs_flags"></a><code>[\_\_wasi\_fdflags\_t](#fdflags) <strong>fs\_flags</strong></code>
1780
1781    File descriptor flags.
1782
1783- <a href="#fdstat.fs_rights_base" name="fdstat.fs_rights_base"></a><code>[\_\_wasi\_rights\_t](#rights) <strong>fs\_rights\_base</strong></code>
1784
1785    Rights that apply to this file descriptor.
1786
1787- <a href="#fdstat.fs_rights_inheriting" name="fdstat.fs_rights_inheriting"></a><code>[\_\_wasi\_rights\_t](#rights) <strong>fs\_rights\_inheriting</strong></code>
1788
1789    Maximum set of rights that may be installed on new
1790    file descriptors that are created through this file
1791    descriptor, e.g., through [`uvwasi_path_open()`](#path_open).
1792
1793### <a href="#filedelta" name="filedelta"></a>`uvwasi_filedelta_t` (`int64_t`)
1794
1795Relative offset within a file.
1796
1797Used by [`uvwasi_fd_seek()`](#fd_seek).
1798
1799### <a href="#filesize" name="filesize"></a>`uvwasi_filesize_t` (`uint64_t`)
1800
1801Non-negative file size or length of a region within a file.
1802
1803Used by [`uvwasi_event_t`](#event), [`uvwasi_filestat_t`](#filestat), [`uvwasi_fd_pread()`](#fd_pread), [`uvwasi_fd_pwrite()`](#fd_pwrite), [`uvwasi_fd_seek()`](#fd_seek), [`uvwasi_path_tell()`](#path_tell), [`uvwasi_fd_advise()`](#fd_advise), [`uvwasi_fd_allocate()`](#fd_allocate), and [`uvwasi_fd_filestat_set_size()`](#fd_filestat_set_size).
1804
1805### <a href="#filestat" name="filestat"></a>`uvwasi_filestat_t` (`struct`)
1806
1807File attributes.
1808
1809Used by [`uvwasi_fd_filestat_get()`](#fd_filestat_get) and [`uvwasi_path_filestat_get()`](#path_filestat_get).
1810
1811Members:
1812
1813- <a href="#filestat.st_dev" name="filestat.st_dev"></a><code>[\_\_wasi\_device\_t](#device) <strong>st\_dev</strong></code>
1814
1815    Device ID of device containing the file.
1816
1817- <a href="#filestat.st_ino" name="filestat.st_ino"></a><code>[\_\_wasi\_inode\_t](#inode) <strong>st\_ino</strong></code>
1818
1819    File serial number.
1820
1821- <a href="#filestat.st_filetype" name="filestat.st_filetype"></a><code>[\_\_wasi\_filetype\_t](#filetype) <strong>st\_filetype</strong></code>
1822
1823    File type.
1824
1825- <a href="#filestat.st_nlink" name="filestat.st_nlink"></a><code>[\_\_wasi\_linkcount\_t](#linkcount) <strong>st\_nlink</strong></code>
1826
1827    Number of hard links to the file.
1828
1829- <a href="#filestat.st_size" name="filestat.st_size"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>st\_size</strong></code>
1830
1831    For regular files, the file size in bytes. For
1832    symbolic links, the length in bytes of the pathname
1833    contained in the symbolic link.
1834
1835- <a href="#filestat.st_atim" name="filestat.st_atim"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>st\_atim</strong></code>
1836
1837    Last data access timestamp.
1838
1839- <a href="#filestat.st_mtim" name="filestat.st_mtim"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>st\_mtim</strong></code>
1840
1841    Last data modification timestamp.
1842
1843- <a href="#filestat.st_ctim" name="filestat.st_ctim"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>st\_ctim</strong></code>
1844
1845    Last file status change timestamp.
1846
1847### <a href="#filetype" name="filetype"></a>`uvwasi_filetype_t` (`uint8_t`)
1848
1849The type of a file descriptor or file.
1850
1851Used by [`uvwasi_dirent_t`](#dirent), [`uvwasi_fdstat_t`](#fdstat), and [`uvwasi_filestat_t`](#filestat).
1852
1853Possible values:
1854
1855- <a href="#filetype.unknown" name="filetype.unknown"></a>**`UVWASI_FILETYPE_UNKNOWN`**
1856
1857    The type of the file descriptor or file is unknown or
1858    is different from any of the other types specified.
1859
1860- <a href="#filetype.block_device" name="filetype.block_device"></a>**`UVWASI_FILETYPE_BLOCK_DEVICE`**
1861
1862    The file descriptor or file refers to a block device
1863    inode.
1864
1865- <a href="#filetype.character_device" name="filetype.character_device"></a>**`UVWASI_FILETYPE_CHARACTER_DEVICE`**
1866
1867    The file descriptor or file refers to a character
1868    device inode.
1869
1870- <a href="#filetype.directory" name="filetype.directory"></a>**`UVWASI_FILETYPE_DIRECTORY`**
1871
1872    The file descriptor or file refers to a directory
1873    inode.
1874
1875- <a href="#filetype.regular_file" name="filetype.regular_file"></a>**`UVWASI_FILETYPE_REGULAR_FILE`**
1876
1877    The file descriptor or file refers to a regular file
1878    inode.
1879
1880- <a href="#filetype.socket_dgram" name="filetype.socket_dgram"></a>**`UVWASI_FILETYPE_SOCKET_DGRAM`**
1881
1882    The file descriptor or file refers to a datagram
1883    socket.
1884
1885- <a href="#filetype.socket_stream" name="filetype.socket_stream"></a>**`UVWASI_FILETYPE_SOCKET_STREAM`**
1886
1887    The file descriptor or file refers to a byte-stream
1888    socket.
1889
1890- <a href="#filetype.symbolic_link" name="filetype.symbolic_link"></a>**`UVWASI_FILETYPE_SYMBOLIC_LINK`**
1891
1892    The file refers to a symbolic link inode.
1893
1894### <a href="#fstflags" name="fstflags"></a>`uvwasi_fstflags_t` (`uint16_t` bitfield)
1895
1896Which file time attributes to adjust.
1897
1898Used by [`uvwasi_fd_filestat_set_times()`](#fd_filestat_set_times) and [`uvwasi_path_filestat_set_times()`](#path_filestat_set_times).
1899
1900Possible values:
1901
1902- <a href="#fstflags.atim" name="fstflags.atim"></a>**`UVWASI_FILESTAT_SET_ATIM`**
1903
1904    Adjust the last data access timestamp to the value
1905    stored in [`uvwasi_filestat_t::st_atim`](#filestat.st_atim).
1906
1907- <a href="#fstflags.atim_now" name="fstflags.atim_now"></a>**`UVWASI_FILESTAT_SET_ATIM_NOW`**
1908
1909    Adjust the last data access timestamp to the time
1910    of clock [`UVWASI_CLOCK_REALTIME`](#clockid.realtime).
1911
1912- <a href="#fstflags.mtim" name="fstflags.mtim"></a>**`UVWASI_FILESTAT_SET_MTIM`**
1913
1914    Adjust the last data modification timestamp to the
1915    value stored in [`uvwasi_filestat_t::st_mtim`](#filestat.st_mtim).
1916
1917- <a href="#fstflags.mtim_now" name="fstflags.mtim_now"></a>**`UVWASI_FILESTAT_SET_MTIM_NOW`**
1918
1919    Adjust the last data modification timestamp to the
1920    time of clock [`UVWASI_CLOCK_REALTIME`](#clockid.realtime).
1921
1922### <a href="#inode" name="inode"></a>`uvwasi_inode_t` (`uint64_t`)
1923
1924File serial number that is unique within its file system.
1925
1926Used by [`uvwasi_dirent_t`](#dirent) and [`uvwasi_filestat_t`](#filestat).
1927
1928### <a href="#iovec" name="iovec"></a>`uvwasi_iovec_t` (`struct`)
1929
1930A region of memory for scatter/gather reads.
1931
1932Used by [`uvwasi_fd_pread()`](#fd_pread), [`uvwasi_fd_read()`](#fd_read), and [`uvwasi_sock_recv()`](#sock_recv).
1933
1934Members:
1935
1936- <a href="#iovec.buf" name="iovec.buf"></a><code>void \*<strong>buf</strong></code> and <a href="#iovec.buf_len" name="iovec.buf_len"></a><code>\_\_wasi\_size\_t <strong>buf\_len</strong></code>
1937
1938    The address and length of the buffer to be filled.
1939
1940### <a href="#linkcount" name="linkcount"></a>`uvwasi_linkcount_t` (`uint64_t`)
1941
1942Number of hard links to an inode.
1943
1944Used by [`uvwasi_filestat_t`](#filestat).
1945
1946### <a href="#lookupflags" name="lookupflags"></a>`uvwasi_lookupflags_t` (`uint32_t` bitfield)
1947
1948Flags determining the method of how paths are resolved.
1949
1950Used by [`uvwasi_path_filestat_get()`](#path_filestat_get), [`uvwasi_path_filestat_set_times()`](#path_filestat_set_times), [`uvwasi_path_link()`](#path_link), and [`uvwasi_path_open()`](#path_open).
1951
1952Possible values:
1953
1954- <a href="#lookupflags.symlink_follow" name="lookupflags.symlink_follow"></a>**`UVWASI_LOOKUP_SYMLINK_FOLLOW`**
1955
1956    As long as the resolved path corresponds to a symbolic
1957    link, it is expanded.
1958
1959### <a href="#oflags" name="oflags"></a>`uvwasi_oflags_t` (`uint16_t` bitfield)
1960
1961Open flags used by [`uvwasi_path_open()`](#path_open).
1962
1963Used by [`uvwasi_path_open()`](#path_open).
1964
1965Possible values:
1966
1967- <a href="#oflags.creat" name="oflags.creat"></a>**`UVWASI_O_CREAT`**
1968
1969    Create file if it does not exist.
1970
1971- <a href="#oflags.directory" name="oflags.directory"></a>**`UVWASI_O_DIRECTORY`**
1972
1973    Fail if not a directory.
1974
1975- <a href="#oflags.excl" name="oflags.excl"></a>**`UVWASI_O_EXCL`**
1976
1977    Fail if file already exists.
1978
1979- <a href="#oflags.trunc" name="oflags.trunc"></a>**`UVWASI_O_TRUNC`**
1980
1981    Truncate file to size 0.
1982
1983### <a href="#riflags" name="riflags"></a>`uvwasi_riflags_t` (`uint16_t` bitfield)
1984
1985Flags provided to [`uvwasi_sock_recv()`](#sock_recv).
1986
1987Used by [`uvwasi_sock_recv()`](#sock_recv).
1988
1989Possible values:
1990
1991- <a href="#riflags.peek" name="riflags.peek"></a>**`UVWASI_SOCK_RECV_PEEK`**
1992
1993    Returns the message without removing it from the
1994    socket's receive queue.
1995
1996- <a href="#riflags.waitall" name="riflags.waitall"></a>**`UVWASI_SOCK_RECV_WAITALL`**
1997
1998    On byte-stream sockets, block until the full amount
1999    of data can be returned.
2000
2001### <a href="#rights" name="rights"></a>`uvwasi_rights_t` (`uint64_t` bitfield)
2002
2003File descriptor rights, determining which actions may be
2004performed.
2005
2006Used by [`uvwasi_fdstat_t`](#fdstat), [`uvwasi_fd_fdstat_set_rights()`](#fd_fdstat_set_rights), and [`uvwasi_path_open()`](#path_open).
2007
2008Possible values:
2009
2010- <a href="#rights.fd_datasync" name="rights.fd_datasync"></a>**`UVWASI_RIGHT_FD_DATASYNC`**
2011
2012    The right to invoke [`uvwasi_fd_datasync()`](#fd_datasync).
2013
2014    If [`UVWASI_RIGHT_PATH_OPEN`](#rights.path_open) is set, includes the right to
2015    invoke [`uvwasi_path_open()`](#path_open) with [`UVWASI_FDFLAG_DSYNC`](#fdflags.dsync).
2016
2017- <a href="#rights.fd_read" name="rights.fd_read"></a>**`UVWASI_RIGHT_FD_READ`**
2018
2019    The right to invoke [`uvwasi_fd_read()`](#fd_read) and [`uvwasi_sock_recv()`](#sock_recv).
2020
2021    If [`UVWASI_RIGHT_FD_SEEK`](#rights.fd_seek) is set, includes the right to invoke
2022    [`uvwasi_fd_pread()`](#fd_pread).
2023
2024- <a href="#rights.fd_seek" name="rights.fd_seek"></a>**`UVWASI_RIGHT_FD_SEEK`**
2025
2026    The right to invoke [`uvwasi_fd_seek()`](#fd_seek). This flag implies
2027    [`UVWASI_RIGHT_FD_TELL`](#rights.fd_tell).
2028
2029- <a href="#rights.fd_fdstat_set_flags" name="rights.fd_fdstat_set_flags"></a>**`UVWASI_RIGHT_FD_FDSTAT_SET_FLAGS`**
2030
2031    The right to invoke [`uvwasi_fd_fdstat_set_flags()`](#fd_fdstat_set_flags).
2032
2033- <a href="#rights.fd_sync" name="rights.fd_sync"></a>**`UVWASI_RIGHT_FD_SYNC`**
2034
2035    The right to invoke [`uvwasi_fd_sync()`](#fd_sync).
2036
2037    If [`UVWASI_RIGHT_PATH_OPEN`](#rights.path_open) is set, includes the right to
2038    invoke [`uvwasi_path_open()`](#path_open) with [`UVWASI_FDFLAG_RSYNC`](#fdflags.rsync) and
2039    [`UVWASI_FDFLAG_DSYNC`](#fdflags.dsync).
2040
2041- <a href="#rights.fd_tell" name="rights.fd_tell"></a>**`UVWASI_RIGHT_FD_TELL`**
2042
2043    The right to invoke [`uvwasi_fd_seek()`](#fd_seek) in such a way that the
2044    file offset remains unaltered (i.e., [`UVWASI_WHENCE_CUR`](#whence.cur) with
2045    offset zero), or to invoke [`uvwasi_fd_tell()`](#fd_tell).
2046
2047- <a href="#rights.fd_write" name="rights.fd_write"></a>**`UVWASI_RIGHT_FD_WRITE`**
2048
2049    The right to invoke [`uvwasi_fd_write()`](#fd_write) and [`uvwasi_sock_send()`](#sock_send).
2050
2051    If [`UVWASI_RIGHT_FD_SEEK`](#rights.fd_seek) is set, includes the right to
2052    invoke [`uvwasi_fd_pwrite()`](#fd_pwrite).
2053
2054- <a href="#rights.fd_advise" name="rights.fd_advise"></a>**`UVWASI_RIGHT_FD_ADVISE`**
2055
2056    The right to invoke [`uvwasi_fd_advise()`](#fd_advise).
2057
2058- <a href="#rights.fd_allocate" name="rights.fd_allocate"></a>**`UVWASI_RIGHT_FD_ALLOCATE`**
2059
2060    The right to invoke [`uvwasi_fd_allocate()`](#fd_allocate).
2061
2062- <a href="#rights.path_create_directory" name="rights.path_create_directory"></a>**`UVWASI_RIGHT_PATH_CREATE_DIRECTORY`**
2063
2064    The right to invoke [`uvwasi_path_create_directory()`](#path_create_directory).
2065
2066- <a href="#rights.path_create_file" name="rights.path_create_file"></a>**`UVWASI_RIGHT_PATH_CREATE_FILE`**
2067
2068    If [`UVWASI_RIGHT_PATH_OPEN`](#rights.path_open) is set, the right to invoke
2069    [`uvwasi_path_open()`](#path_open) with [`UVWASI_O_CREAT`](#oflags.creat).
2070
2071- <a href="#rights.path_link_source" name="rights.path_link_source"></a>**`UVWASI_RIGHT_PATH_LINK_SOURCE`**
2072
2073    The right to invoke [`uvwasi_path_link()`](#path_link) with the file
2074    descriptor as the source directory.
2075
2076- <a href="#rights.path_link_target" name="rights.path_link_target"></a>**`UVWASI_RIGHT_PATH_LINK_TARGET`**
2077
2078    The right to invoke [`uvwasi_path_link()`](#path_link) with the file
2079    descriptor as the target directory.
2080
2081- <a href="#rights.path_open" name="rights.path_open"></a>**`UVWASI_RIGHT_PATH_OPEN`**
2082
2083    The right to invoke [`uvwasi_path_open()`](#path_open).
2084
2085- <a href="#rights.fd_readdir" name="rights.fd_readdir"></a>**`UVWASI_RIGHT_FD_READDIR`**
2086
2087    The right to invoke [`uvwasi_fd_readdir()`](#fd_readdir).
2088
2089- <a href="#rights.path_readlink" name="rights.path_readlink"></a>**`UVWASI_RIGHT_PATH_READLINK`**
2090
2091    The right to invoke [`uvwasi_path_readlink()`](#path_readlink).
2092
2093- <a href="#rights.path_rename_source" name="rights.path_rename_source"></a>**`UVWASI_RIGHT_PATH_RENAME_SOURCE`**
2094
2095    The right to invoke [`uvwasi_path_rename()`](#path_rename) with the file
2096    descriptor as the source directory.
2097
2098- <a href="#rights.path_rename_target" name="rights.path_rename_target"></a>**`UVWASI_RIGHT_PATH_RENAME_TARGET`**
2099
2100    The right to invoke [`uvwasi_path_rename()`](#path_rename) with the file
2101    descriptor as the target directory.
2102
2103- <a href="#rights.path_filestat_get" name="rights.path_filestat_get"></a>**`UVWASI_RIGHT_PATH_FILESTAT_GET`**
2104
2105    The right to invoke [`uvwasi_path_filestat_get()`](#path_filestat_get).
2106
2107- <a href="#rights.path_filestat_set_size" name="rights.path_filestat_set_size"></a>**`UVWASI_RIGHT_PATH_FILESTAT_SET_SIZE`**
2108
2109    The right to change a file's size (there is no `uvwasi_path_filestat_set_size()`).
2110
2111    If [`UVWASI_RIGHT_PATH_OPEN`](#rights.path_open) is set, includes the right to
2112    invoke [`uvwasi_path_open()`](#path_open) with [`UVWASI_O_TRUNC`](#oflags.trunc).
2113
2114- <a href="#rights.path_filestat_set_times" name="rights.path_filestat_set_times"></a>**`UVWASI_RIGHT_PATH_FILESTAT_SET_TIMES`**
2115
2116    The right to invoke [`uvwasi_path_filestat_set_times()`](#path_filestat_set_times).
2117
2118- <a href="#rights.fd_filestat_get" name="rights.fd_filestat_get"></a>**`UVWASI_RIGHT_FD_FILESTAT_GET`**
2119
2120    The right to invoke [`uvwasi_fd_filestat_get()`](#fd_filestat_get).
2121
2122- <a href="#rights.fd_filestat_set_size" name="rights.fd_filestat_set_size"></a>**`UVWASI_RIGHT_FD_FILESTAT_SET_SIZE`**
2123
2124    The right to invoke [`uvwasi_fd_filestat_set_size()`](#fd_filestat_set_size).
2125
2126- <a href="#rights.fd_filestat_set_times" name="rights.fd_filestat_set_times"></a>**`UVWASI_RIGHT_FD_FILESTAT_SET_TIMES`**
2127
2128    The right to invoke [`uvwasi_fd_filestat_set_times()`](#fd_filestat_set_times).
2129
2130- <a href="#rights.path_symlink" name="rights.path_symlink"></a>**`UVWASI_RIGHT_PATH_SYMLINK`**
2131
2132    The right to invoke [`uvwasi_path_symlink()`](#path_symlink).
2133
2134- <a href="#rights.path_unlink_file" name="rights.path_unlink_file"></a>**`UVWASI_RIGHT_PATH_UNLINK_FILE`**
2135
2136    The right to invoke [`uvwasi_path_unlink_file()`](#path_unlink_file).
2137
2138- <a href="#rights.path_remove_directory" name="rights.path_remove_directory"></a>**`UVWASI_RIGHT_PATH_REMOVE_DIRECTORY`**
2139
2140    The right to invoke [`uvwasi_path_remove_directory()`](#path_remove_directory).
2141
2142- <a href="#rights.poll_fd_readwrite" name="rights.poll_fd_readwrite"></a>**`UVWASI_RIGHT_POLL_FD_READWRITE`**
2143
2144    If [`UVWASI_RIGHT_FD_READ`](#rights.fd_read) is set, includes the right to
2145    invoke [`uvwasi_poll_oneoff()`](#poll_oneoff) to subscribe to [`UVWASI_EVENTTYPE_FD_READ`](#eventtype.fd_read).
2146
2147    If [`UVWASI_RIGHT_FD_WRITE`](#rights.fd_write) is set, includes the right to
2148    invoke [`uvwasi_poll_oneoff()`](#poll_oneoff) to subscribe to [`UVWASI_EVENTTYPE_FD_WRITE`](#eventtype.fd_write).
2149
2150- <a href="#rights.sock_shutdown" name="rights.sock_shutdown"></a>**`UVWASI_RIGHT_SOCK_SHUTDOWN`**
2151
2152    The right to invoke [`uvwasi_sock_shutdown()`](#sock_shutdown).
2153
2154### <a href="#roflags" name="roflags"></a>`uvwasi_roflags_t` (`uint16_t` bitfield)
2155
2156Flags returned by [`uvwasi_sock_recv()`](#sock_recv).
2157
2158Used by [`uvwasi_sock_recv()`](#sock_recv).
2159
2160Possible values:
2161
2162- <a href="#roflags.data_truncated" name="roflags.data_truncated"></a>**`UVWASI_SOCK_RECV_DATA_TRUNCATED`**
2163
2164    Returned by [`uvwasi_sock_recv()`](#sock_recv): Message data has been
2165    truncated.
2166
2167### <a href="#sdflags" name="sdflags"></a>`uvwasi_sdflags_t` (`uint8_t` bitfield)
2168
2169Which channels on a socket to shut down.
2170
2171Used by [`uvwasi_sock_shutdown()`](#sock_shutdown).
2172
2173Possible values:
2174
2175- <a href="#sdflags.rd" name="sdflags.rd"></a>**`UVWASI_SHUT_RD`**
2176
2177    Disables further receive operations.
2178
2179- <a href="#sdflags.wr" name="sdflags.wr"></a>**`UVWASI_SHUT_WR`**
2180
2181    Disables further send operations.
2182
2183### <a href="#siflags" name="siflags"></a>`uvwasi_siflags_t` (`uint16_t` bitfield)
2184
2185Flags provided to [`uvwasi_sock_send()`](#sock_send). As there are currently no flags
2186defined, it must be set to zero.
2187
2188Used by [`uvwasi_sock_send()`](#sock_send).
2189
2190### <a href="#signal" name="signal"></a>`uvwasi_signal_t` (`uint8_t`)
2191
2192Signal condition.
2193
2194Used by [`uvwasi_proc_raise()`](#proc_raise).
2195
2196Possible values:
2197
2198- <a href="#signal.abrt" name="signal.abrt"></a>**`UVWASI_SIGABRT`**
2199
2200    Process abort signal.
2201
2202    Action: Terminates the process.
2203
2204- <a href="#signal.alrm" name="signal.alrm"></a>**`UVWASI_SIGALRM`**
2205
2206    Alarm clock.
2207
2208    Action: Terminates the process.
2209
2210- <a href="#signal.bus" name="signal.bus"></a>**`UVWASI_SIGBUS`**
2211
2212    Access to an undefined portion of a memory object.
2213
2214    Action: Terminates the process.
2215
2216- <a href="#signal.chld" name="signal.chld"></a>**`UVWASI_SIGCHLD`**
2217
2218    Child process terminated, stopped, or continued.
2219
2220    Action: Ignored.
2221
2222- <a href="#signal.cont" name="signal.cont"></a>**`UVWASI_SIGCONT`**
2223
2224    Continue executing, if stopped.
2225
2226    Action: Continues executing, if stopped.
2227
2228- <a href="#signal.fpe" name="signal.fpe"></a>**`UVWASI_SIGFPE`**
2229
2230    Erroneous arithmetic operation.
2231
2232    Action: Terminates the process.
2233
2234- <a href="#signal.hup" name="signal.hup"></a>**`UVWASI_SIGHUP`**
2235
2236    Hangup.
2237
2238    Action: Terminates the process.
2239
2240- <a href="#signal.ill" name="signal.ill"></a>**`UVWASI_SIGILL`**
2241
2242    Illegal instruction.
2243
2244    Action: Terminates the process.
2245
2246- <a href="#signal.int" name="signal.int"></a>**`UVWASI_SIGINT`**
2247
2248    Terminate interrupt signal.
2249
2250    Action: Terminates the process.
2251
2252- <a href="#signal.kill" name="signal.kill"></a>**`UVWASI_SIGKILL`**
2253
2254    Kill.
2255
2256    Action: Terminates the process.
2257
2258- <a href="#signal.pipe" name="signal.pipe"></a>**`UVWASI_SIGPIPE`**
2259
2260    Write on a pipe with no one to read it.
2261
2262    Action: Ignored.
2263
2264- <a href="#signal.quit" name="signal.quit"></a>**`UVWASI_SIGQUIT`**
2265
2266    Terminal quit signal.
2267
2268    Action: Terminates the process.
2269
2270- <a href="#signal.segv" name="signal.segv"></a>**`UVWASI_SIGSEGV`**
2271
2272    Invalid memory reference.
2273
2274    Action: Terminates the process.
2275
2276- <a href="#signal.stop" name="signal.stop"></a>**`UVWASI_SIGSTOP`**
2277
2278    Stop executing.
2279
2280    Action: Stops executing.
2281
2282- <a href="#signal.sys" name="signal.sys"></a>**`UVWASI_SIGSYS`**
2283
2284    Bad system call.
2285
2286    Action: Terminates the process.
2287
2288- <a href="#signal.term" name="signal.term"></a>**`UVWASI_SIGTERM`**
2289
2290    Termination signal.
2291
2292    Action: Terminates the process.
2293
2294- <a href="#signal.trap" name="signal.trap"></a>**`UVWASI_SIGTRAP`**
2295
2296    Trace/breakpoint trap.
2297
2298    Action: Terminates the process.
2299
2300- <a href="#signal.tstp" name="signal.tstp"></a>**`UVWASI_SIGTSTP`**
2301
2302    Terminal stop signal.
2303
2304    Action: Stops executing.
2305
2306- <a href="#signal.ttin" name="signal.ttin"></a>**`UVWASI_SIGTTIN`**
2307
2308    Background process attempting read.
2309
2310    Action: Stops executing.
2311
2312- <a href="#signal.ttou" name="signal.ttou"></a>**`UVWASI_SIGTTOU`**
2313
2314    Background process attempting write.
2315
2316    Action: Stops executing.
2317
2318- <a href="#signal.urg" name="signal.urg"></a>**`UVWASI_SIGURG`**
2319
2320    High bandwidth data is available at a socket.
2321
2322    Action: Ignored.
2323
2324- <a href="#signal.usr1" name="signal.usr1"></a>**`UVWASI_SIGUSR1`**
2325
2326    User-defined signal 1.
2327
2328    Action: Terminates the process.
2329
2330- <a href="#signal.usr2" name="signal.usr2"></a>**`UVWASI_SIGUSR2`**
2331
2332    User-defined signal 2.
2333
2334    Action: Terminates the process.
2335
2336- <a href="#signal.vtalrm" name="signal.vtalrm"></a>**`UVWASI_SIGVTALRM`**
2337
2338    Virtual timer expired.
2339
2340    Action: Terminates the process.
2341
2342- <a href="#signal.xcpu" name="signal.xcpu"></a>**`UVWASI_SIGXCPU`**
2343
2344    CPU time limit exceeded.
2345
2346    Action: Terminates the process.
2347
2348- <a href="#signal.xfsz" name="signal.xfsz"></a>**`UVWASI_SIGXFSZ`**
2349
2350    File size limit exceeded.
2351
2352    Action: Terminates the process.
2353
2354### <a href="#subclockflags" name="subclockflags"></a>`uvwasi_subclockflags_t` (`uint16_t` bitfield)
2355
2356Flags determining how to interpret the timestamp provided in
2357[`uvwasi_subscription_t::u.clock.timeout`](#subscription.u.clock.timeout).
2358
2359Used by [`uvwasi_subscription_t`](#subscription).
2360
2361Possible values:
2362
2363- <a href="#subclockflags.abstime" name="subclockflags.abstime"></a>**`UVWASI_SUBSCRIPTION_CLOCK_ABSTIME`**
2364
2365    If set, treat the timestamp provided in
2366    [`uvwasi_subscription_t::u.clock.timeout`](#subscription.u.clock.timeout) as an absolute timestamp
2367    of clock [`uvwasi_subscription_t::u.clock.clock_id`](#subscription.u.clock.clock_id).
2368
2369    If clear, treat the timestamp provided in
2370    [`uvwasi_subscription_t::u.clock.timeout`](#subscription.u.clock.timeout) relative to the current
2371    time value of clock [`uvwasi_subscription_t::u.clock.clock_id`](#subscription.u.clock.clock_id).
2372
2373### <a href="#subscription" name="subscription"></a>`uvwasi_subscription_t` (`struct`)
2374
2375Subscription to an event.
2376
2377Used by [`uvwasi_poll_oneoff()`](#poll_oneoff).
2378
2379Members:
2380
2381- <a href="#subscription.userdata" name="subscription.userdata"></a><code>[\_\_wasi\_userdata\_t](#userdata) <strong>userdata</strong></code>
2382
2383    User-provided value that is attached to the subscription in the
2384    implementation and returned through
2385    [`uvwasi_event_t::userdata`](#event.userdata).
2386
2387- <a href="#subscription.type" name="subscription.type"></a><code>[\_\_wasi\_eventtype\_t](#eventtype) <strong>type</strong></code>
2388
2389    The type of the event to which to subscribe.
2390
2391- When `type` is [`UVWASI_EVENTTYPE_CLOCK`](#eventtype.u.clock):
2392
2393    - <a href="#subscription.u.clock" name="subscription.u.clock"></a>**`u.clock`**
2394
2395        - <a href="#subscription.u.clock.clock_id" name="subscription.u.clock.clock_id"></a><code>[\_\_wasi\_clockid\_t](#clockid) <strong>clock\_id</strong></code>
2396
2397            The clock against which to compare the timestamp.
2398
2399        - <a href="#subscription.u.clock.timeout" name="subscription.u.clock.timeout"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>timeout</strong></code>
2400
2401            The absolute or relative timestamp.
2402
2403        - <a href="#subscription.u.clock.precision" name="subscription.u.clock.precision"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>precision</strong></code>
2404
2405            The amount of time that the implementation may wait additionally
2406            to coalesce with other events.
2407
2408        - <a href="#subscription.u.clock.flags" name="subscription.u.clock.flags"></a><code>[\_\_wasi\_subclockflags\_t](#subclockflags) <strong>flags</strong></code>
2409
2410            Flags specifying whether the timeout is absolute or relative.
2411
2412- When `type` is [`UVWASI_EVENTTYPE_FD_READ`](#eventtype.fd_read) or [`UVWASI_EVENTTYPE_FD_WRITE`](#eventtype.fd_write):
2413
2414    - <a href="#subscription.u.fd_readwrite" name="subscription.u.fd_readwrite"></a>**`u.fd_readwrite`**
2415
2416        - <a href="#subscription.u.fd_readwrite.fd" name="subscription.u.fd_readwrite.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code>
2417
2418            The file descriptor on which to wait for it to become ready
2419            for reading or writing.
2420
2421### <a href="#timestamp" name="timestamp"></a>`uvwasi_timestamp_t` (`uint64_t`)
2422
2423Timestamp in nanoseconds.
2424
2425Used by [`uvwasi_filestat_t`](#filestat), [`uvwasi_subscription_t`](#subscription), [`uvwasi_clock_res_get()`](#clock_res_get), [`uvwasi_clock_time_get()`](#clock_time_get), [`uvwasi_fd_filestat_set_times()`](#fd_filestat_set_times), and [`uvwasi_path_filestat_set_times()`](#path_filestat_set_times).
2426
2427### <a href="#userdata" name="userdata"></a>`uvwasi_userdata_t` (`uint64_t`)
2428
2429User-provided value that may be attached to objects that is
2430retained when extracted from the implementation.
2431
2432Used by [`uvwasi_event_t`](#event) and [`uvwasi_subscription_t`](#subscription).
2433
2434### <a href="#whence" name="whence"></a>`uvwasi_whence_t` (`uint8_t`)
2435
2436The position relative to which to set the offset of the file descriptor.
2437
2438Used by [`uvwasi_fd_seek()`](#fd_seek).
2439
2440Possible values:
2441
2442- <a href="#whence.cur" name="whence.cur"></a>**`UVWASI_WHENCE_CUR`**
2443
2444    Seek relative to current position.
2445
2446- <a href="#whence.end" name="whence.end"></a>**`UVWASI_WHENCE_END`**
2447
2448    Seek relative to end-of-file.
2449
2450- <a href="#whence.set" name="whence.set"></a>**`UVWASI_WHENCE_SET`**
2451
2452    Seek relative to start-of-file.
2453
2454[WASI]: https://github.com/WebAssembly/WASI
2455[libuv]: https://github.com/libuv/libuv
2456[snapshot_1]: https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md
2457