wasmtime 0.3.0

Command-line interface for Wasmtime
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
<!--
This document is derived from the file docs/cloudabi.md at revision
af51ede669dbca0875d20893dae7f760b052b238 of the CloudABI repository
hosted here: https://github.com/NuxiNL/cloudabi

The upstream file bears the following notice, though note that the
file is no longer generated, and contains significant edits:

Copyright (c) 2016-2017 Nuxi (https://nuxi.nl/) and contributors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

This file is automatically generated. Do not edit.

Source: https://github.com/NuxiNL/cloudabi
-->

# WASI Core API

This is the API-level documentation for WASI Core. The function names
are prefixed with "\_\_wasi\_" to reflect how they are spelled in
flat-namespace contexts, however at the wasm module level, they are
unprefixed, because they're inside a module namespace (currently
"wasi\_unstable").

Functions that start with `__wasi_fd_` operate on file descriptors,
while functions that start with `__wasi_path_` operate on filesystem
paths, which are relative to directory file descriptors.

Much inspiration and content here is derived from [CloudABI] and [POSIX],
though there are also several differences from CloudABI and POSIX. For
example, WASI Core has no concept of processes in the traditional Unix
sense. While wasm linear memories have some of the aspects of processes,
and it's possible to *emulate* the full semantics of processes on top of
them, this can sometimes be unnatural and inefficient. The goal for
WASI Core is to be a WebAssembly-native API that exposes APIs that fit
well into the underlying WebAssembly platform, rather than to directly
emulate other platforms.

This is also a work in progress, and the API here is still evolving.

[CloudABI]: https://github.com/NuxiNL/cloudabi
[POSIX]: http://pubs.opengroup.org/onlinepubs/9699919799/

## System calls

- [`__wasi_args_get()`]#args_get
- [`__wasi_args_sizes_get()`]#args_sizes_get
- [`__wasi_clock_res_get()`]#clock_res_get
- [`__wasi_clock_time_get()`]#clock_time_get
- [`__wasi_environ_get()`]#environ_get
- [`__wasi_environ_sizes_get()`]#environ_sizes_get
- [`__wasi_fd_advise()`]#fd_advise
- [`__wasi_fd_allocate()`]#fd_allocate
- [`__wasi_fd_close()`]#fd_close
- [`__wasi_fd_datasync()`]#fd_datasync
- [`__wasi_fd_fdstat_get()`]#fd_fdstat_get
- [`__wasi_fd_fdstat_set_flags()`]#fd_fdstat_set_flags
- [`__wasi_fd_fdstat_set_rights()`]#fd_fdstat_set_rights
- [`__wasi_fd_filestat_get()`]#fd_filestat_get
- [`__wasi_fd_filestat_set_size()`]#fd_filestat_set_size
- [`__wasi_fd_filestat_set_times()`]#fd_filestat_set_times
- [`__wasi_fd_pread()`]#fd_pread
- [`__wasi_fd_prestat_dir_name()`]#fd_prestat_dir_name
- [`__wasi_fd_prestat_get()`]#fd_prestat_get
- [`__wasi_fd_pwrite()`]#fd_pwrite
- [`__wasi_fd_read()`]#fd_read
- [`__wasi_fd_readdir()`]#fd_readdir
- [`__wasi_fd_renumber()`]#fd_renumber
- [`__wasi_fd_seek()`]#fd_seek
- [`__wasi_fd_sync()`]#fd_sync
- [`__wasi_fd_tell()`]#fd_tell
- [`__wasi_fd_write()`]#fd_write
- [`__wasi_path_create_directory()`]#path_create_directory
- [`__wasi_path_filestat_get()`]#path_filestat_get
- [`__wasi_path_filestat_set_times()`]#path_filestat_set_times
- [`__wasi_path_link()`]#path_link
- [`__wasi_path_open()`]#path_open
- [`__wasi_path_readlink()`]#path_readlink
- [`__wasi_path_remove_directory()`]#path_remove_directory
- [`__wasi_path_rename()`]#path_rename
- [`__wasi_path_symlink()`]#path_symlink
- [`__wasi_path_unlink_file()`]#path_unlink_file
- [`__wasi_poll_oneoff()`]#poll_oneoff
- [`__wasi_proc_exit()`]#proc_exit
- [`__wasi_proc_raise()`]#proc_raise
- [`__wasi_random_get()`]#random_get
- [`__wasi_sched_yield()`]#sched_yield
- [`__wasi_sock_recv()`]#sock_recv
- [`__wasi_sock_send()`]#sock_send
- [`__wasi_sock_shutdown()`]#sock_shutdown

### <a href="#args_get" name="args_get"></a>`__wasi_args_get()`

Read command-line argument data.

The sizes of the buffers should match that returned by [`__wasi_args_sizes_get()`](#args_sizes_get).

Inputs:

- <a href="#args_get.argv" name="args_get.argv"></a><code>char \*\*<strong>argv</strong></code>

    A pointer to a buffer to write the argument pointers.

- <a href="#args_get.argv_buf" name="args_get.argv_buf"></a><code>char \*<strong>argv\_buf</strong></code>

    A pointer to a buffer to write the argument string data.

### <a href="#args_sizes_get" name="args_sizes_get"></a>`__wasi_args_sizes_get()`

Return command-line argument data sizes.

Outputs:

- <a href="#args_sizes_get.argc" name="args_sizes_get.argc"></a><code>size\_t <strong>argc</strong></code>

    The number of arguments.

- <a href="#args_sizes_get.argv_buf_size" name="args_sizes_get.argv_buf_size"></a><code>size\_t <strong>argv\_buf\_size</strong></code>

    The size of the argument string data.

### <a href="#clock_res_get" name="clock_res_get"></a>`__wasi_clock_res_get()`

Return the resolution of a clock.

Implementations are required to provide a non-zero value for supported clocks.
For unsupported clocks, return [`__WASI_EINVAL`](#errno.inval).

Note: This is similar to `clock_getres` in POSIX.

Inputs:

- <a href="#clock_res_get.clock_id" name="clock_res_get.clock_id"></a><code>[\_\_wasi\_clockid\_t]#clockid <strong>clock\_id</strong></code>

    The clock for which to return the resolution.

Outputs:

- <a href="#clock_res_get.resolution" name="clock_res_get.resolution"></a><code>[\_\_wasi\_timestamp\_t]#timestamp <strong>resolution</strong></code>

    The resolution of the clock.

### <a href="#clock_time_get" name="clock_time_get"></a>`__wasi_clock_time_get()`

Return the time value of a clock.

Note: This is similar to `clock_gettime` in POSIX.

Inputs:

- <a href="#clock_time_get.clock_id" name="clock_time_get.clock_id"></a><code>[\_\_wasi\_clockid\_t]#clockid <strong>clock\_id</strong></code>

    The clock for which to return the time.

- <a href="#clock_time_get.precision" name="clock_time_get.precision"></a><code>[\_\_wasi\_timestamp\_t]#timestamp <strong>precision</strong></code>

    The maximum lag (exclusive) that the returned
    time value may have, compared to its actual
    value.

Outputs:

- <a href="#clock_time_get.time" name="clock_time_get.time"></a><code>[\_\_wasi\_timestamp\_t]#timestamp <strong>time</strong></code>

    The time value of the clock.

### <a href="#environ_get" name="environ_get"></a>`__wasi_environ_get()`

Read environment variable data.

The sizes of the buffers should match that returned by [`__wasi_environ_sizes_get()`](#environ_sizes_get).

Inputs:

- <a href="#environ_get.environ" name="environ_get.environ"></a><code>char \*\*<strong>environ</strong></code>

    A pointer to a buffer to write the environment variable pointers.

- <a href="#environ_get.environ_buf" name="environ_get.environ_buf"></a><code>char \*<strong>environ\_buf</strong></code>

    A pointer to a buffer to write the environment variable string data.

### <a href="#environ_sizes_get" name="environ_sizes_get"></a>`__wasi_environ_sizes_get()`

Return environment variable data sizes.

Outputs:

- <a href="#environ_sizes_get.environ_count" name="environ_sizes_get.environ_count"></a><code>size\_t <strong>environ\_count</strong></code>

    The number of environment variables.

- <a href="#environ_sizes_get.environ_buf_size" name="environ_sizes_get.environ_buf_size"></a><code>size\_t <strong>environ\_buf\_size</strong></code>

    The size of the environment variable string data.

### <a href="#fd_advise" name="fd_advise"></a>`__wasi_fd_advise()`

Provide file advisory information on a file descriptor.

Note: This is similar to `posix_fadvise` in POSIX.

Inputs:

- <a href="#fd_advise.fd" name="fd_advise.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The file descriptor for the file for which to provide file advisory information.

- <a href="#fd_advise.offset" name="fd_advise.offset"></a><code>[\_\_wasi\_filesize\_t]#filesize <strong>offset</strong></code>

    The offset within the file to which the advisory applies.

- <a href="#fd_advise.len" name="fd_advise.len"></a><code>[\_\_wasi\_filesize\_t]#filesize <strong>len</strong></code>

    The length of the region to which the advisory applies.

- <a href="#fd_advise.advice" name="fd_advise.advice"></a><code>[\_\_wasi\_advice\_t]#advice <strong>advice</strong></code>

    The advice.

### <a href="#fd_allocate" name="fd_allocate"></a>`__wasi_fd_allocate()`

Force the allocation of space in a file.

Note: This is similar to `posix_fallocate` in POSIX.

Inputs:

- <a href="#fd_allocate.fd" name="fd_allocate.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The file descriptor for the file in which to allocate space.

- <a href="#fd_allocate.offset" name="fd_allocate.offset"></a><code>[\_\_wasi\_filesize\_t]#filesize <strong>offset</strong></code>

    The offset at which to start the allocation.

- <a href="#fd_allocate.len" name="fd_allocate.len"></a><code>[\_\_wasi\_filesize\_t]#filesize <strong>len</strong></code>

    The length of the area that is allocated.

### <a href="#fd_close" name="fd_close"></a>`__wasi_fd_close()`

Close a file descriptor.

Note: This is similar to `close` in POSIX.

Inputs:

- <a href="#fd_close.fd" name="fd_close.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The file descriptor to close.

### <a href="#fd_datasync" name="fd_datasync"></a>`__wasi_fd_datasync()`

Synchronize the data of a file to disk.

Note: This is similar to `fdatasync` in POSIX.

Inputs:

- <a href="#fd_datasync.fd" name="fd_datasync.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The file descriptor of the file to synchronize to disk.

### <a href="#fd_fdstat_get" name="fd_fdstat_get"></a>`__wasi_fd_fdstat_get()`

Get the attributes of a file descriptor.

Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX, as well
as additional fields.

Inputs:

- <a href="#fd_fdstat_get.fd" name="fd_fdstat_get.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The file descriptor to inspect.

- <a href="#fd_fdstat_get.buf" name="fd_fdstat_get.buf"></a><code>[\_\_wasi\_fdstat\_t]#fdstat \*<strong>buf</strong></code>

    The buffer where the file descriptor's attributes are stored.

### <a href="#fd_fdstat_set_flags" name="fd_fdstat_set_flags"></a>`__wasi_fd_fdstat_set_flags()`

Adjust the flags associated with a file descriptor.

Note: This is similar to `fcntl(fd, F_SETFL, flags)` in POSIX.

Inputs:

- <a href="#fd_fdstat_set_flags.fd" name="fd_fdstat_set_flags.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The file descriptor to operate on.

- <a href="#fd_fdstat_set_flags.flags" name="fd_fdstat_set_flags.flags"></a><code>[\_\_wasi\_fdflags\_t]#fdflags <strong>flags</strong></code>

    The desired values of the file descriptor flags.

### <a href="#fd_fdstat_set_rights" name="fd_fdstat_set_rights"></a>`__wasi_fd_fdstat_set_rights()`

Adjust the rights associated with a file descriptor.

This can only be used to remove rights, and returns
[`__WASI_ENOTCAPABLE`](#errno.notcapable) if called in a way that would attempt
to add rights.

Inputs:

- <a href="#fd_fdstat_set_rights.fd" name="fd_fdstat_set_rights.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The file descriptor to operate on.

- <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>

    The desired base rights of the file descriptor.

- <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>

    The desired inheriting rights of the file descriptor.

### <a href="#fd_filestat_get" name="fd_filestat_get"></a>`__wasi_fd_filestat_get()`

Return the attributes of an open file.

Inputs:

- <a href="#fd_filestat_get.fd" name="fd_filestat_get.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The file descriptor to inspect.

- <a href="#fd_filestat_get.buf" name="fd_filestat_get.buf"></a><code>[\_\_wasi\_filestat\_t]#filestat \*<strong>buf</strong></code>

    The buffer where the file's attributes are
    stored.

### <a href="#fd_filestat_set_size" name="fd_filestat_set_size"></a>`__wasi_fd_filestat_set_size()`

Adjust the size of an open file. If this increases the file's size, the extra
bytes are filled with zeros.

Note: This is similar to `ftruncate` in POSIX.

Inputs:

- <a href="#fd_filestat_set_size.fd" name="fd_filestat_set_size.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    A file descriptor for the file to adjust.

- <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>

    The desired file size.

### <a href="#fd_filestat_set_times" name="fd_filestat_set_times"></a>`__wasi_fd_filestat_set_times()`

Adjust the timestamps of an open file or directory.

Note: This is similar to `futimens` in POSIX.

Inputs:

- <a href="#fd_filestat_set_times.fd" name="fd_filestat_set_times.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The file descriptor to operate on.

- <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>

    The desired values of the data access timestamp.

- <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>

    The desired values of the data modification timestamp.

- <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>

    A bitmask indicating which timestamps to adjust.

### <a href="#fd_pread" name="fd_pread"></a>`__wasi_fd_pread()`

Read from a file descriptor, without using and updating the
file descriptor's offset.

Note: This is similar to `preadv` in POSIX.

Inputs:

- <a href="#fd_pread.fd" name="fd_pread.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The file descriptor from which to read data.

- <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>size\_t <strong>iovs\_len</strong></code>

    List of scatter/gather vectors in which to store data.

- <a href="#fd_pread.offset" name="fd_pread.offset"></a><code>[\_\_wasi\_filesize\_t]#filesize <strong>offset</strong></code>

    The offset within the file at which to read.

Outputs:

- <a href="#fd_pread.nread" name="fd_pread.nread"></a><code>size\_t <strong>nread</strong></code>

    The number of bytes read.

### <a href="#fd_prestat_dir_name" name="fd_prestat_dir_name"></a>`__wasi_fd_prestat_dir_name()`

Return a description of the given preopened file descriptor.

Inputs:

- <a href="#fd_prestat_dir_name.fd" name="fd_prestat_dir_name.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The file descriptor about which to retrieve information.

- <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>size\_t <strong>path\_len</strong></code>

    A buffer into which to write the preopened directory name.

### <a href="#fd_prestat_get" name="fd_prestat_get"></a>`__wasi_fd_prestat_get()`

Return a description of the given preopened file descriptor.

Inputs:

- <a href="#fd_prestat_get.fd" name="fd_prestat_get.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The file descriptor about which to retrieve information.

- <a href="#fd_prestat_get.buf" name="fd_prestat_get.buf"></a><code>[\_\_wasi\_prestat\_t]#prestat \*<strong>buf</strong></code>

    The buffer where the description is stored.

### <a href="#fd_pwrite" name="fd_pwrite"></a>`__wasi_fd_pwrite()`

Write to a file descriptor, without using and updating the
file descriptor's offset.

Note: This is similar to `pwritev` in POSIX.

Inputs:

- <a href="#fd_pwrite.fd" name="fd_pwrite.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The file descriptor to which to write data.

- <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>size\_t <strong>iovs\_len</strong></code>

    List of scatter/gather vectors from which to retrieve data.

- <a href="#fd_pwrite.offset" name="fd_pwrite.offset"></a><code>[\_\_wasi\_filesize\_t]#filesize <strong>offset</strong></code>

    The offset within the file at which to write.

Outputs:

- <a href="#fd_pwrite.nwritten" name="fd_pwrite.nwritten"></a><code>size\_t <strong>nwritten</strong></code>

    The number of bytes written.

### <a href="#fd_read" name="fd_read"></a>`__wasi_fd_read()`

Read from a file descriptor.

Note: This is similar to `readv` in POSIX.

Inputs:

- <a href="#fd_read.fd" name="fd_read.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The file descriptor from which to read data.

- <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>size\_t <strong>iovs\_len</strong></code>

    List of scatter/gather vectors to which to store data.

Outputs:

- <a href="#fd_read.nread" name="fd_read.nread"></a><code>size\_t <strong>nread</strong></code>

    The number of bytes read.

### <a href="#fd_readdir" name="fd_readdir"></a>`__wasi_fd_readdir()`

Read directory entries from a directory.

When successful, the contents of the output buffer consist of
a sequence of directory entries. Each directory entry consists
of a [`__wasi_dirent_t`](#dirent) object, followed by [`__wasi_dirent_t::d_namlen`](#dirent.d_namlen) bytes
holding the name of the directory entry.

This function fills the output buffer as much as possible,
potentially truncating the last directory entry. This allows
the caller to grow its read buffer size in case it's too small
to fit a single large directory entry, or skip the oversized
directory entry.

Inputs:

- <a href="#fd_readdir.fd" name="fd_readdir.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The directory from which to read the directory
    entries.

- <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>size\_t <strong>buf\_len</strong></code>

    The buffer where directory entries are stored.

- <a href="#fd_readdir.cookie" name="fd_readdir.cookie"></a><code>[\_\_wasi\_dircookie\_t]#dircookie <strong>cookie</strong></code>

    The location within the directory to start
    reading.

Outputs:

- <a href="#fd_readdir.bufused" name="fd_readdir.bufused"></a><code>size\_t <strong>bufused</strong></code>

    The number of bytes stored in the read buffer.
    If less than the size of the read buffer, the
    end of the directory has been reached.

### <a href="#fd_renumber" name="fd_renumber"></a>`__wasi_fd_renumber()`

Atomically replace a file descriptor by renumbering another
file descriptor.

Due to the strong focus on thread safety, this environment
does not provide a mechanism to duplicate or renumber a file
descriptor to an arbitrary number, like dup2(). This would be
prone to race conditions, as an actual file descriptor with the
same number could be allocated by a different thread at the same
time.

This function provides a way to atomically renumber file
descriptors, which would disappear if dup2() were to be
removed entirely.

Inputs:

- <a href="#fd_renumber.from" name="fd_renumber.from"></a><code>[\_\_wasi\_fd\_t]#fd <strong>from</strong></code>

    The file descriptor to renumber.

- <a href="#fd_renumber.to" name="fd_renumber.to"></a><code>[\_\_wasi\_fd\_t]#fd <strong>to</strong></code>

    The file descriptor to overwrite.

### <a href="#fd_seek" name="fd_seek"></a>`__wasi_fd_seek()`

Move the offset of a file descriptor.

Note: This is similar to `lseek` in POSIX.

Inputs:

- <a href="#fd_seek.fd" name="fd_seek.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The file descriptor to operate on.

- <a href="#fd_seek.offset" name="fd_seek.offset"></a><code>[\_\_wasi\_filedelta\_t]#filedelta <strong>offset</strong></code>

    The number of bytes to move.

- <a href="#fd_seek.whence" name="fd_seek.whence"></a><code>[\_\_wasi\_whence\_t]#whence <strong>whence</strong></code>

    The base from which the offset is relative.

Outputs:

- <a href="#fd_seek.newoffset" name="fd_seek.newoffset"></a><code>[\_\_wasi\_filesize\_t]#filesize <strong>newoffset</strong></code>

    The new offset of the file descriptor,
    relative to the start of the file.

### <a href="#fd_sync" name="fd_sync"></a>`__wasi_fd_sync()`

Synchronize the data and metadata of a file to disk.

Note: This is similar to `fsync` in POSIX.

Inputs:

- <a href="#fd_sync.fd" name="fd_sync.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The file descriptor of the file containing the data
    and metadata to synchronize to disk.

### <a href="#fd_tell" name="fd_tell"></a>`__wasi_fd_tell()`

Return the current offset of a file descriptor.

Note: This is similar to `lseek(fd, 0, SEEK_CUR)` in POSIX.

Inputs:

- <a href="#fd_tell.fd" name="fd_tell.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The file descriptor to inspect.

Outputs:

- <a href="#fd_tell.offset" name="fd_tell.offset"></a><code>[\_\_wasi\_filesize\_t]#filesize <strong>offset</strong></code>

    The current offset of the file descriptor, relative to the start of the file.

### <a href="#fd_write" name="fd_write"></a>`__wasi_fd_write()`

Write to a file descriptor.

Note: This is similar to `writev` in POSIX.

Inputs:

- <a href="#fd_write.fd" name="fd_write.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The file descriptor to which to write data.

- <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>size\_t <strong>iovs\_len</strong></code>

    List of scatter/gather vectors from which to retrieve data.

Outputs:

- <a href="#fd_write.nwritten" name="fd_write.nwritten"></a><code>size\_t <strong>nwritten</strong></code>

    The number of bytes written.

### <a href="#path_create_directory" name="path_create_directory"></a>`__wasi_path_create_directory()`

Create a directory.

Note: This is similar to `mkdirat` in POSIX.

Inputs:

- <a href="#path_create_directory.fd" name="path_create_directory.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The working directory at which the resolution of the path starts.

- <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>size\_t <strong>path\_len</strong></code>

    The path at which to create the directory.

### <a href="#path_filestat_get" name="path_filestat_get"></a>`__wasi_path_filestat_get()`

Return the attributes of a file or directory.

Note: This is similar to `stat` in POSIX.

Inputs:

- <a href="#path_filestat_get.fd" name="path_filestat_get.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The working directory at which the resolution of the path starts.

- <a href="#path_filestat_get.flags" name="path_filestat_get.flags"></a><code>[\_\_wasi\_lookupflags\_t]#lookupflags <strong>flags</strong></code>

    Flags determining the method of how the path is resolved.

- <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>size\_t <strong>path\_len</strong></code>

    The path of the file or directory to inspect.

- <a href="#path_filestat_get.buf" name="path_filestat_get.buf"></a><code>[\_\_wasi\_filestat\_t]#filestat \*<strong>buf</strong></code>

    The buffer where the file's attributes are stored.

### <a href="#path_filestat_set_times" name="path_filestat_set_times"></a>`__wasi_path_filestat_set_times()`

Adjust the timestamps of a file or directory.

Note: This is similar to `utimensat` in POSIX.

Inputs:

- <a href="#path_filestat_set_times.fd" name="path_filestat_set_times.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The working directory at which the resolution of the path starts.

- <a href="#path_filestat_set_times.flags" name="path_filestat_set_times.flags"></a><code>[\_\_wasi\_lookupflags\_t]#lookupflags <strong>flags</strong></code>

    Flags determining the method of how the path is resolved.

- <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>size\_t <strong>path\_len</strong></code>

    The path of the file or directory to operate on.

- <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>

    The desired values of the data access timestamp.

- <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>

    The desired values of the data modification timestamp.

- <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>

    A bitmask indicating which timestamps to adjust.

### <a href="#path_link" name="path_link"></a>`__wasi_path_link()`

Create a hard link.

Note: This is similar to `linkat` in POSIX.

Inputs:

- <a href="#path_link.old_fd" name="path_link.old_fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>old\_fd</strong></code>

    The working directory at which the resolution of the old path starts.

- <a href="#path_link.old_flags" name="path_link.old_flags"></a><code>[\_\_wasi\_lookupflags\_t]#lookupflags <strong>old\_flags</strong></code>

    Flags determining the method of how the path is resolved.

- <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>size\_t <strong>old\_path\_len</strong></code>

    The source path from which to link.

- <a href="#path_link.new_fd" name="path_link.new_fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>new\_fd</strong></code>

    The working directory at which the resolution of the new path starts.

- <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>size\_t <strong>new\_path\_len</strong></code>

    The destination path at which to create the hard link.

### <a href="#path_open" name="path_open"></a>`__wasi_path_open()`

Open a file or directory.

The returned file descriptor is not guaranteed to be the lowest-numbered
file descriptor not currently open; it is randomized to prevent
applications from depending on making assumptions about indexes, since
this is error-prone in multi-threaded contexts. The returned file
descriptor is guaranteed to be less than 2<sup>31</sup>.

Note: This is similar to `openat` in POSIX.

Inputs:

- <a href="#path_open.dirfd" name="path_open.dirfd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>dirfd</strong></code>

    The working directory at which the resolution of the path starts.

- <a href="#path_open.dirflags" name="path_open.dirflags"></a><code>[\_\_wasi\_lookupflags\_t]#lookupflags <strong>dirflags</strong></code>

    Flags determining the method of how the path is resolved.

- <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>size\_t <strong>path\_len</strong></code>

    The relative path of the file or directory to open, relative to
    the [`dirfd`]#path_open.dirfd directory.

- <a href="#path_open.o_flags" name="path_open.o_flags"></a><code>[\_\_wasi\_oflags\_t]#oflags <strong>o_flags</strong></code>

    The method by which to open the file.

- <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>

    The initial base rights of the newly created file descriptor. The
    implementation is allowed to return a file descriptor with fewer
    rights than specified, if and only if those rights do not apply
    to the type of file being opened.

    The *base* rights are rights that will apply to operations using
    the file descriptor itself.

- <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>

    The initial inheriting rights of the newly created file descriptor. The
    implementation is allowed to return a file descriptor with fewer
    rights than specified, if and only if those rights do not apply
    to the type of file being opened.

    The *inheriting* rights are rights that will apply to file descriptors derived
    from the file descriptor itself.

- <a href="#path_open.fs_flags" name="path_open.fs_flags"></a><code>[\_\_wasi\_fdflags\_t]#fdflags <strong>fs\_flags</strong></code>

    The initial flags of the file descriptor.

Outputs:

- <a href="#path_open.fd" name="path_open.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The file descriptor of the file that has been
    opened.

### <a href="#path_readlink" name="path_readlink"></a>`__wasi_path_readlink()`

Read the contents of a symbolic link.

Note: This is similar to `readlinkat` in POSIX.

Inputs:

- <a href="#path_readlink.fd" name="path_readlink.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The working directory at which the resolution of the path starts.

- <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>size\_t <strong>path\_len</strong></code>

    The path of the symbolic link from which to read.

- <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>size\_t <strong>buf\_len</strong></code>

    The buffer to which to write the contents of the symbolic link.

Outputs:

- <a href="#path_readlink.bufused" name="path_readlink.bufused"></a><code>size\_t <strong>bufused</strong></code>

    The number of bytes placed in the buffer.

### <a href="#path_remove_directory" name="path_remove_directory"></a>`__wasi_path_remove_directory()`

Remove a directory.

Return [`__WASI_ENOTEMPTY`](#errno.notempty) if the directory is not empty.

Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX.

Inputs:

- <a href="#path_remove_directory.fd" name="path_remove_directory.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The working directory at which the resolution of the path starts.

- <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>size\_t <strong>path\_len</strong></code>

    The path to a directory to remove.

### <a href="#path_rename" name="path_rename"></a>`__wasi_path_rename()`

Rename a file or directory.

Note: This is similar to `renameat` in POSIX.

Inputs:

- <a href="#path_rename.old_fd" name="path_rename.old_fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>old\_fd</strong></code>

    The working directory at which the resolution of the old path starts.

- <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>size\_t <strong>old\_path\_len</strong></code>

    The source path of the file or directory to rename.

- <a href="#path_rename.new_fd" name="path_rename.new_fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>new\_fd</strong></code>

    The working directory at which the resolution of the new path starts.

- <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>size\_t <strong>new\_path\_len</strong></code>

    The destination path to which to rename the file or directory.

### <a href="#path_symlink" name="path_symlink"></a>`__wasi_path_symlink()`

Create a symbolic link.

Note: This is similar to `symlinkat` in POSIX.

Inputs:

- <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>size\_t <strong>old_path\_len</strong></code>

    The contents of the symbolic link.

- <a href="#path_symlink.fd" name="path_symlink.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The working directory at which the resolution of the path starts.

- <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>size\_t <strong>new\_path\_len</strong></code>

    The destination path at which to create the symbolic link.

### <a href="#path_unlink_file" name="path_unlink_file"></a>`__wasi_path_unlink_file()`

Unlink a file.

Return [`__WASI_EISDIR`](#errno.isdir) if the path refers to a directory.

Note: This is similar to `unlinkat(fd, path, 0)` in POSIX.

Inputs:

- <a href="#path_unlink_file.fd" name="path_unlink_file.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

    The working directory at which the resolution of the path starts.

- <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>size\_t <strong>path\_len</strong></code>

    The path to a file to unlink.

### <a href="#poll_oneoff" name="poll_oneoff"></a>`__wasi_poll_oneoff()`

Concurrently poll for the occurrence of a set of events.

Inputs:

- <a href="#poll_oneoff.in" name="poll_oneoff.in"></a><code>const [\_\_wasi\_subscription\_t]#subscription \*<strong>in</strong></code>

    The events to which to subscribe.

- <a href="#poll_oneoff.out" name="poll_oneoff.out"></a><code>[\_\_wasi\_event\_t]#event \*<strong>out</strong></code>

    The events that have occurred.

- <a href="#poll_oneoff.nsubscriptions" name="poll_oneoff.nsubscriptions"></a><code>size\_t <strong>nsubscriptions</strong></code>

    Both the number of subscriptions and events.

Outputs:

- <a href="#poll_oneoff.nevents" name="poll_oneoff.nevents"></a><code>size\_t <strong>nevents</strong></code>

    The number of events stored.

### <a href="#proc_exit" name="proc_exit"></a>`__wasi_proc_exit()`

Terminate the process normally. An exit code of 0 indicates successful
termination of the program. The meanings of other values is dependent on
the environment.

Note: This is similar to `_Exit` in POSIX.

Inputs:

- <a href="#proc_exit.rval" name="proc_exit.rval"></a><code>[\_\_wasi\_exitcode\_t]#exitcode <strong>rval</strong></code>

    The exit code returned by the process.

Does not return.

### <a href="#proc_raise" name="proc_raise"></a>`__wasi_proc_raise()`

Send a signal to the process of the calling thread.

Note: This is similar to `raise` in POSIX.

Inputs:

- <a href="#proc_raise.sig" name="proc_raise.sig"></a><code>[\_\_wasi\_signal\_t]#signal <strong>sig</strong></code>

    The signal condition to trigger.

### <a href="#random_get" name="random_get"></a>`__wasi_random_get()`

Write high-quality random data into a buffer.

This function blocks when the implementation is unable to immediately
provide sufficient high-quality random data.

This function may execute slowly, so when large mounts of random
data are required, it's advisable to use this function to seed a
pseudo-random number generator, rather than to provide the
random data directly.

Inputs:

- <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>size\_t <strong>buf\_len</strong></code>

    The buffer to fill with random data.

### <a href="#sched_yield" name="sched_yield"></a>`__wasi_sched_yield()`

Temporarily yield execution of the calling thread.

Note: This is similar to `sched_yield` in POSIX.

### <a href="#sock_recv" name="sock_recv"></a>`__wasi_sock_recv()`

Receive a message from a socket.

Note: This is similar to `recv` in POSIX, though it also supports reading
the data into multiple buffers in the manner of `readv`.

Inputs:

- <a href="#sock_recv.sock" name="sock_recv.sock"></a><code>[\_\_wasi\_fd\_t]#fd <strong>sock</strong></code>

    The socket on which to receive data.

- <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>size\_t <strong>ri\_data\_len</strong></code>

    List of scatter/gather vectors to which to store data.

- <a href="#sock_recv.ri_flags" name="sock_recv.ri_flags"></a><code>[\_\_wasi\_riflags\_t]#riflags <strong>ri\_flags</strong></code>

    Message flags.

Outputs:

- <a href="#sock_recv.ro_datalen" name="sock_recv.ro_datalen"></a><code>size\_t <strong>ro\_datalen</strong></code>

    Number of bytes stored in [`ri_data`]#sock_recv.ri_data.

- <a href="#sock_recv.ro_flags" name="sock_recv.ro_flags"></a><code>[\_\_wasi\_roflags\_t]#roflags <strong>ro\_flags</strong></code>

    Message flags.

### <a href="#sock_send" name="sock_send"></a>`__wasi_sock_send()`

Send a message on a socket.

Note: This is similar to `send` in POSIX, though it also supports writing
the data from multiple buffers in the manner of `writev`.

Inputs:

- <a href="#sock_send.sock" name="sock_send.sock"></a><code>[\_\_wasi\_fd\_t]#fd <strong>sock</strong></code>

    The socket on which to send data.

- <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>size\_t <strong>si\_data\_len</strong></code>

    List of scatter/gather vectors to which to retrieve data.

- <a href="#sock_send.si_flags" name="sock_send.si_flags"></a><code>[\_\_wasi\_siflags\_t]#siflags <strong>si\_flags</strong></code>

    Message flags.

Outputs:

- <a href="#sock_send.so_datalen" name="sock_send.so_datalen"></a><code>size\_t <strong>so\_datalen</strong></code>

    Number of bytes transmitted.

### <a href="#sock_shutdown" name="sock_shutdown"></a>`__wasi_sock_shutdown()`

Shut down socket send and receive channels.

Note: This is similar to `shutdown` in POSIX.

Inputs:

- <a href="#sock_shutdown.sock" name="sock_shutdown.sock"></a><code>[\_\_wasi\_fd\_t]#fd <strong>sock</strong></code>

    The socket on which to shutdown channels.

- <a href="#sock_shutdown.how" name="sock_shutdown.how"></a><code>[\_\_wasi\_sdflags\_t]#sdflags <strong>how</strong></code>

    Which channels on the socket to shut down.

## Types

### <a href="#advice" name="advice"></a>`__wasi_advice_t` (`uint8_t`)

File or memory access pattern advisory information.

Used by [`__wasi_fd_advise()`](#fd_advise).

Possible values:

- <a href="#advice.dontneed" name="advice.dontneed"></a>**`__WASI_ADVICE_DONTNEED`**

    The application expects that it will not access the
    specified data in the near future.

- <a href="#advice.noreuse" name="advice.noreuse"></a>**`__WASI_ADVICE_NOREUSE`**

    The application expects to access the specified data
    once and then not reuse it thereafter.

- <a href="#advice.normal" name="advice.normal"></a>**`__WASI_ADVICE_NORMAL`**

    The application has no advice to give on its behavior
    with respect to the specified data.

- <a href="#advice.random" name="advice.random"></a>**`__WASI_ADVICE_RANDOM`**

    The application expects to access the specified data
    in a random order.

- <a href="#advice.sequential" name="advice.sequential"></a>**`__WASI_ADVICE_SEQUENTIAL`**

    The application expects to access the specified data
    sequentially from lower offsets to higher offsets.

- <a href="#advice.willneed" name="advice.willneed"></a>**`__WASI_ADVICE_WILLNEED`**

    The application expects to access the specified data
    in the near future.

### <a href="#ciovec" name="ciovec"></a>`__wasi_ciovec_t` (`struct`)

A region of memory for scatter/gather writes.

Used by [`__wasi_fd_pwrite()`](#fd_pwrite), [`__wasi_fd_write()`](#fd_write), and [`__wasi_sock_send()`](#sock_send).

Members:

- <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>size\_t <strong>buf\_len</strong></code>

    The address and length of the buffer to be written.

### <a href="#clockid" name="clockid"></a>`__wasi_clockid_t` (`uint32_t`)

Identifiers for clocks.

Used by [`__wasi_subscription_t`](#subscription), [`__wasi_clock_res_get()`](#clock_res_get), and [`__wasi_clock_time_get()`](#clock_time_get).

Possible values:

- <a href="#clockid.monotonic" name="clockid.monotonic"></a>**`__WASI_CLOCK_MONOTONIC`**

    The store-wide monotonic clock, which is defined as a
    clock measuring real time, whose value cannot be
    adjusted and which cannot have negative clock jumps.

    The epoch of this clock is undefined. The absolute
    time value of this clock therefore has no meaning.

- <a href="#clockid.process_cputime_id" name="clockid.process_cputime_id"></a>**`__WASI_CLOCK_PROCESS_CPUTIME_ID`**

    The CPU-time clock associated with the current
    process.

- <a href="#clockid.realtime" name="clockid.realtime"></a>**`__WASI_CLOCK_REALTIME`**

    The clock measuring real time. Time value
    zero corresponds with 1970-01-01T00:00:00Z.

- <a href="#clockid.thread_cputime_id" name="clockid.thread_cputime_id"></a>**`__WASI_CLOCK_THREAD_CPUTIME_ID`**

    The CPU-time clock associated with the current thread.

### <a href="#device" name="device"></a>`__wasi_device_t` (`uint64_t`)

Identifier for a device containing a file system. Can be used
in combination with [`__wasi_inode_t`](#inode) to uniquely identify a file or
directory in the filesystem.

Used by [`__wasi_filestat_t`](#filestat).

### <a href="#dircookie" name="dircookie"></a>`__wasi_dircookie_t` (`uint64_t`)

A reference to the offset of a directory entry.

Used by [`__wasi_dirent_t`](#dirent) and [`__wasi_fd_readdir()`](#fd_readdir).

Special values:

- <a href="#dircookie.start" name="dircookie.start"></a>**`__WASI_DIRCOOKIE_START`**

    Permanent reference to the first directory entry
    within a directory.

### <a href="#dirent" name="dirent"></a>`__wasi_dirent_t` (`struct`)

A directory entry.

Members:

- <a href="#dirent.d_next" name="dirent.d_next"></a><code>[\_\_wasi\_dircookie\_t]#dircookie <strong>d\_next</strong></code>

    The offset of the next directory entry stored in this
    directory.

- <a href="#dirent.d_ino" name="dirent.d_ino"></a><code>[\_\_wasi\_inode\_t]#inode <strong>d\_ino</strong></code>

    The serial number of the file referred to by this
    directory entry.

- <a href="#dirent.d_namlen" name="dirent.d_namlen"></a><code>uint32\_t <strong>d\_namlen</strong></code>

    The length of the name of the directory entry.

- <a href="#dirent.d_type" name="dirent.d_type"></a><code>[\_\_wasi\_filetype\_t]#filetype <strong>d\_type</strong></code>

    The type of the file referred to by this directory
    entry.

### <a href="#errno" name="errno"></a>`__wasi_errno_t` (`uint16_t`)

Error codes returned by functions.

Not all of these error codes are returned by the functions
provided by this API; some are used in higher-level library layers,
and others are provided merely for alignment with POSIX.

Used by [`__wasi_event_t`](#event).

Possible values:

- <a href="#errno.success" name="errno.success"></a>**`__WASI_ESUCCESS`**

    No error occurred. System call completed successfully.

- <a href="#errno.2big" name="errno.2big"></a>**`__WASI_E2BIG`**

    Argument list too long.

- <a href="#errno.acces" name="errno.acces"></a>**`__WASI_EACCES`**

    Permission denied.

- <a href="#errno.addrinuse" name="errno.addrinuse"></a>**`__WASI_EADDRINUSE`**

    Address in use.

- <a href="#errno.addrnotavail" name="errno.addrnotavail"></a>**`__WASI_EADDRNOTAVAIL`**

    Address not available.

- <a href="#errno.afnosupport" name="errno.afnosupport"></a>**`__WASI_EAFNOSUPPORT`**

    Address family not supported.

- <a href="#errno.again" name="errno.again"></a>**`__WASI_EAGAIN`**

    Resource unavailable, or operation would block.

- <a href="#errno.already" name="errno.already"></a>**`__WASI_EALREADY`**

    Connection already in progress.

- <a href="#errno.badf" name="errno.badf"></a>**`__WASI_EBADF`**

    Bad file descriptor.

- <a href="#errno.badmsg" name="errno.badmsg"></a>**`__WASI_EBADMSG`**

    Bad message.

- <a href="#errno.busy" name="errno.busy"></a>**`__WASI_EBUSY`**

    Device or resource busy.

- <a href="#errno.canceled" name="errno.canceled"></a>**`__WASI_ECANCELED`**

    Operation canceled.

- <a href="#errno.child" name="errno.child"></a>**`__WASI_ECHILD`**

    No child processes.

- <a href="#errno.connaborted" name="errno.connaborted"></a>**`__WASI_ECONNABORTED`**

    Connection aborted.

- <a href="#errno.connrefused" name="errno.connrefused"></a>**`__WASI_ECONNREFUSED`**

    Connection refused.

- <a href="#errno.connreset" name="errno.connreset"></a>**`__WASI_ECONNRESET`**

    Connection reset.

- <a href="#errno.deadlk" name="errno.deadlk"></a>**`__WASI_EDEADLK`**

    Resource deadlock would occur.

- <a href="#errno.destaddrreq" name="errno.destaddrreq"></a>**`__WASI_EDESTADDRREQ`**

    Destination address required.

- <a href="#errno.dom" name="errno.dom"></a>**`__WASI_EDOM`**

    Mathematics argument out of domain of function.

- <a href="#errno.dquot" name="errno.dquot"></a>**`__WASI_EDQUOT`**

    Reserved.

- <a href="#errno.exist" name="errno.exist"></a>**`__WASI_EEXIST`**

    File exists.

- <a href="#errno.fault" name="errno.fault"></a>**`__WASI_EFAULT`**

    Bad address.

- <a href="#errno.fbig" name="errno.fbig"></a>**`__WASI_EFBIG`**

    File too large.

- <a href="#errno.hostunreach" name="errno.hostunreach"></a>**`__WASI_EHOSTUNREACH`**

    Host is unreachable.

- <a href="#errno.idrm" name="errno.idrm"></a>**`__WASI_EIDRM`**

    Identifier removed.

- <a href="#errno.ilseq" name="errno.ilseq"></a>**`__WASI_EILSEQ`**

    Illegal byte sequence.

- <a href="#errno.inprogress" name="errno.inprogress"></a>**`__WASI_EINPROGRESS`**

    Operation in progress.

- <a href="#errno.intr" name="errno.intr"></a>**`__WASI_EINTR`**

    Interrupted function.

- <a href="#errno.inval" name="errno.inval"></a>**`__WASI_EINVAL`**

    Invalid argument.

- <a href="#errno.io" name="errno.io"></a>**`__WASI_EIO`**

    I/O error.

- <a href="#errno.isconn" name="errno.isconn"></a>**`__WASI_EISCONN`**

    Socket is connected.

- <a href="#errno.isdir" name="errno.isdir"></a>**`__WASI_EISDIR`**

    Is a directory.

- <a href="#errno.loop" name="errno.loop"></a>**`__WASI_ELOOP`**

    Too many levels of symbolic links.

- <a href="#errno.mfile" name="errno.mfile"></a>**`__WASI_EMFILE`**

    File descriptor value too large.

- <a href="#errno.mlink" name="errno.mlink"></a>**`__WASI_EMLINK`**

    Too many links.

- <a href="#errno.msgsize" name="errno.msgsize"></a>**`__WASI_EMSGSIZE`**

    Message too large.

- <a href="#errno.multihop" name="errno.multihop"></a>**`__WASI_EMULTIHOP`**

    Reserved.

- <a href="#errno.nametoolong" name="errno.nametoolong"></a>**`__WASI_ENAMETOOLONG`**

    Filename too long.

- <a href="#errno.netdown" name="errno.netdown"></a>**`__WASI_ENETDOWN`**

    Network is down.

- <a href="#errno.netreset" name="errno.netreset"></a>**`__WASI_ENETRESET`**

    Connection aborted by network.

- <a href="#errno.netunreach" name="errno.netunreach"></a>**`__WASI_ENETUNREACH`**

    Network unreachable.

- <a href="#errno.nfile" name="errno.nfile"></a>**`__WASI_ENFILE`**

    Too many files open in system.

- <a href="#errno.nobufs" name="errno.nobufs"></a>**`__WASI_ENOBUFS`**

    No buffer space available.

- <a href="#errno.nodev" name="errno.nodev"></a>**`__WASI_ENODEV`**

    No such device.

- <a href="#errno.noent" name="errno.noent"></a>**`__WASI_ENOENT`**

    No such file or directory.

- <a href="#errno.noexec" name="errno.noexec"></a>**`__WASI_ENOEXEC`**

    Executable file format error.

- <a href="#errno.nolck" name="errno.nolck"></a>**`__WASI_ENOLCK`**

    No locks available.

- <a href="#errno.nolink" name="errno.nolink"></a>**`__WASI_ENOLINK`**

    Reserved.

- <a href="#errno.nomem" name="errno.nomem"></a>**`__WASI_ENOMEM`**

    Not enough space.

- <a href="#errno.nomsg" name="errno.nomsg"></a>**`__WASI_ENOMSG`**

    No message of the desired type.

- <a href="#errno.noprotoopt" name="errno.noprotoopt"></a>**`__WASI_ENOPROTOOPT`**

    Protocol not available.

- <a href="#errno.nospc" name="errno.nospc"></a>**`__WASI_ENOSPC`**

    No space left on device.

- <a href="#errno.nosys" name="errno.nosys"></a>**`__WASI_ENOSYS`**

    Function not supported.

- <a href="#errno.notconn" name="errno.notconn"></a>**`__WASI_ENOTCONN`**

    The socket is not connected.

- <a href="#errno.notdir" name="errno.notdir"></a>**`__WASI_ENOTDIR`**

    Not a directory or a symbolic link to a directory.

- <a href="#errno.notempty" name="errno.notempty"></a>**`__WASI_ENOTEMPTY`**

    Directory not empty.

- <a href="#errno.notrecoverable" name="errno.notrecoverable"></a>**`__WASI_ENOTRECOVERABLE`**

    State not recoverable.

- <a href="#errno.notsock" name="errno.notsock"></a>**`__WASI_ENOTSOCK`**

    Not a socket.

- <a href="#errno.notsup" name="errno.notsup"></a>**`__WASI_ENOTSUP`**

    Not supported, or operation not supported on socket.

- <a href="#errno.notty" name="errno.notty"></a>**`__WASI_ENOTTY`**

    Inappropriate I/O control operation.

- <a href="#errno.nxio" name="errno.nxio"></a>**`__WASI_ENXIO`**

    No such device or address.

- <a href="#errno.overflow" name="errno.overflow"></a>**`__WASI_EOVERFLOW`**

    Value too large to be stored in data type.

- <a href="#errno.ownerdead" name="errno.ownerdead"></a>**`__WASI_EOWNERDEAD`**

    Previous owner died.

- <a href="#errno.perm" name="errno.perm"></a>**`__WASI_EPERM`**

    Operation not permitted.

- <a href="#errno.pipe" name="errno.pipe"></a>**`__WASI_EPIPE`**

    Broken pipe.

- <a href="#errno.proto" name="errno.proto"></a>**`__WASI_EPROTO`**

    Protocol error.

- <a href="#errno.protonosupport" name="errno.protonosupport"></a>**`__WASI_EPROTONOSUPPORT`**

    Protocol not supported.

- <a href="#errno.prototype" name="errno.prototype"></a>**`__WASI_EPROTOTYPE`**

    Protocol wrong type for socket.

- <a href="#errno.range" name="errno.range"></a>**`__WASI_ERANGE`**

    Result too large.

- <a href="#errno.rofs" name="errno.rofs"></a>**`__WASI_EROFS`**

    Read-only file system.

- <a href="#errno.spipe" name="errno.spipe"></a>**`__WASI_ESPIPE`**

    Invalid seek.

- <a href="#errno.srch" name="errno.srch"></a>**`__WASI_ESRCH`**

    No such process.

- <a href="#errno.stale" name="errno.stale"></a>**`__WASI_ESTALE`**

    Reserved.

- <a href="#errno.timedout" name="errno.timedout"></a>**`__WASI_ETIMEDOUT`**

    Connection timed out.

- <a href="#errno.txtbsy" name="errno.txtbsy"></a>**`__WASI_ETXTBSY`**

    Text file busy.

- <a href="#errno.xdev" name="errno.xdev"></a>**`__WASI_EXDEV`**

    Cross-device link.

- <a href="#errno.notcapable" name="errno.notcapable"></a>**`__WASI_ENOTCAPABLE`**

    Extension: Capabilities insufficient.

### <a href="#event" name="event"></a>`__wasi_event_t` (`struct`)

An event that occurred.

Used by [`__wasi_poll_oneoff()`](#poll_oneoff).

Members:

- <a href="#event.userdata" name="event.userdata"></a><code>[\_\_wasi\_userdata\_t]#userdata <strong>userdata</strong></code>

    User-provided value that got attached to
    [`__wasi_subscription_t::userdata`]#subscription.userdata.

- <a href="#event.error" name="event.error"></a><code>[\_\_wasi\_errno\_t]#errno <strong>error</strong></code>

    If non-zero, an error that occurred while processing
    the subscription request.

- <a href="#event.type" name="event.type"></a><code>[\_\_wasi\_eventtype\_t]#eventtype <strong>type</strong></code>

    The type of the event that occurred.

- When `type` is [`__WASI_EVENTTYPE_FD_READ`]#eventtype.fd_read or [`__WASI_EVENTTYPE_FD_WRITE`]#eventtype.fd_write:

    - <a href="#event.u.fd_readwrite" name="event.u.fd_readwrite"></a>**`u.fd_readwrite`**

        - <a href="#event.u.fd_readwrite.nbytes" name="event.u.fd_readwrite.nbytes"></a><code>[\_\_wasi\_filesize\_t]#filesize <strong>nbytes</strong></code>

            The number of bytes available for reading or writing.

        - <a href="#event.u.fd_readwrite.flags" name="event.u.fd_readwrite.flags"></a><code>[\_\_wasi\_eventrwflags\_t]#eventrwflags <strong>flags</strong></code>

            The state of the file descriptor.

### <a href="#eventrwflags" name="eventrwflags"></a>`__wasi_eventrwflags_t` (`uint16_t` bitfield)

The state of the file descriptor subscribed to with
[`__WASI_EVENTTYPE_FD_READ`](#eventtype.fd_read) or [`__WASI_EVENTTYPE_FD_WRITE`](#eventtype.fd_write).

Used by [`__wasi_event_t`](#event).

Possible values:

- <a href="#eventrwflags.hangup" name="eventrwflags.hangup"></a>**`__WASI_EVENT_FD_READWRITE_HANGUP`**

    The peer of this socket has closed or disconnected.

### <a href="#eventtype" name="eventtype"></a>`__wasi_eventtype_t` (`uint8_t`)

Type of a subscription to an event or its occurrence.

Used by [`__wasi_event_t`](#event) and [`__wasi_subscription_t`](#subscription).

Possible values:

- <a href="#eventtype.u.clock" name="eventtype.u.clock"></a>**`__WASI_EVENTTYPE_CLOCK`**

    The time value of clock [`__wasi_subscription_t::u.clock.clock_id`]#subscription.u.clock.clock_id
    has reached timestamp [`__wasi_subscription_t::u.clock.timeout`]#subscription.u.clock.timeout.

- <a href="#eventtype.fd_read" name="eventtype.fd_read"></a>**`__WASI_EVENTTYPE_FD_READ`**

    File descriptor [`__wasi_subscription_t::u.fd_readwrite.fd`]#subscription.u.fd_readwrite.fd has
    data available for reading. This event always triggers
    for regular files.

- <a href="#eventtype.fd_write" name="eventtype.fd_write"></a>**`__WASI_EVENTTYPE_FD_WRITE`**

    File descriptor [`__wasi_subscription_t::u.fd_readwrite.fd`]#subscription.u.fd_readwrite.fd has
    capacity available for writing. This event always
    triggers for regular files.

### <a href="#exitcode" name="exitcode"></a>`__wasi_exitcode_t` (`uint32_t`)

Exit code generated by a process when exiting.

Used by [`__wasi_proc_exit()`](#proc_exit).

### <a href="#fd" name="fd"></a>`__wasi_fd_t` (`uint32_t`)

A file descriptor number.

Used by many functions in this API.

As in POSIX, three file descriptor numbers are provided to instances
on startup -- 0, 1, and 2, (a.k.a. `STDIN_FILENO`, `STDOUT_FILENO`,
and `STDERR_FILENO`). Starting at 3 follow a possibly-entry sequence
of preopened file descriptors provided by the host environment or the argument passed to the wasmtime command;
information about these may be obtained through
[`__wasi_fd_prestat_get()`](#fd_prestat_get).

i.e., if we have called `wasmtime --dir=. <some command inside>`  we can specify `3` that will refer to the `--dir` value.

Other than these, WASI implementations are not required to allocate
new file descriptors in ascending order.

### <a href="#fdflags" name="fdflags"></a>`__wasi_fdflags_t` (`uint16_t` bitfield)

File descriptor flags.

Used by [`__wasi_fdstat_t`](#fdstat), [`__wasi_fd_fdstat_set_flags()`](#fd_fdstat_set_flags), and [`__wasi_path_open()`](#path_open).

Possible values:

- <a href="#fdflags.append" name="fdflags.append"></a>**`__WASI_FDFLAG_APPEND`**

    Append mode: Data written to the file is always
    appended to the file's end.

- <a href="#fdflags.dsync" name="fdflags.dsync"></a>**`__WASI_FDFLAG_DSYNC`**

    Write according to synchronized I/O data integrity
    completion. Only the data stored in the file is
    synchronized.

- <a href="#fdflags.nonblock" name="fdflags.nonblock"></a>**`__WASI_FDFLAG_NONBLOCK`**

    Non-blocking mode.

- <a href="#fdflags.rsync" name="fdflags.rsync"></a>**`__WASI_FDFLAG_RSYNC`**

    Synchronized read I/O operations.

- <a href="#fdflags.sync" name="fdflags.sync"></a>**`__WASI_FDFLAG_SYNC`**

    Write according to synchronized I/O file integrity completion.
    In addition to synchronizing the data stored in the file, the
    implementation may also synchronously update the file's metadata.

### <a href="#fdstat" name="fdstat"></a>`__wasi_fdstat_t` (`struct`)

File descriptor attributes.

Used by [`__wasi_fd_fdstat_get()`](#fd_fdstat_get).

Members:

- <a href="#fdstat.fs_filetype" name="fdstat.fs_filetype"></a><code>[\_\_wasi\_filetype\_t]#filetype <strong>fs\_filetype</strong></code>

    File type.

- <a href="#fdstat.fs_flags" name="fdstat.fs_flags"></a><code>[\_\_wasi\_fdflags\_t]#fdflags <strong>fs\_flags</strong></code>

    File descriptor flags.

- <a href="#fdstat.fs_rights_base" name="fdstat.fs_rights_base"></a><code>[\_\_wasi\_rights\_t]#rights <strong>fs\_rights\_base</strong></code>

    Rights that apply to this file descriptor.

- <a href="#fdstat.fs_rights_inheriting" name="fdstat.fs_rights_inheriting"></a><code>[\_\_wasi\_rights\_t]#rights <strong>fs\_rights\_inheriting</strong></code>

    Maximum set of rights that may be installed on new
    file descriptors that are created through this file
    descriptor, e.g., through [`__wasi_path_open()`]#path_open.

### <a href="#filedelta" name="filedelta"></a>`__wasi_filedelta_t` (`int64_t`)

Relative offset within a file.

Used by [`__wasi_fd_seek()`](#fd_seek).

### <a href="#filesize" name="filesize"></a>`__wasi_filesize_t` (`uint64_t`)

Non-negative file size or length of a region within a file.

Used by [`__wasi_event_t`](#event), [`__wasi_filestat_t`](#filestat), [`__wasi_fd_advise()`](#fd_advise), [`__wasi_fd_allocate()`](#fd_allocate), [`__wasi_fd_filestat_set_size()`](#fd_filestat_set_size), [`__wasi_fd_pread()`](#fd_pread), [`__wasi_fd_pwrite()`](#fd_pwrite), [`__wasi_fd_seek()`](#fd_seek), and [`__wasi_fd_tell()`](#fd_tell).

### <a href="#filestat" name="filestat"></a>`__wasi_filestat_t` (`struct`)

File attributes.

Used by [`__wasi_fd_filestat_get()`](#fd_filestat_get) and [`__wasi_path_filestat_get()`](#path_filestat_get).

Members:

- <a href="#filestat.st_dev" name="filestat.st_dev"></a><code>[\_\_wasi\_device\_t]#device <strong>st\_dev</strong></code>

    Device ID of device containing the file.

- <a href="#filestat.st_ino" name="filestat.st_ino"></a><code>[\_\_wasi\_inode\_t]#inode <strong>st\_ino</strong></code>

    File serial number.

- <a href="#filestat.st_filetype" name="filestat.st_filetype"></a><code>[\_\_wasi\_filetype\_t]#filetype <strong>st\_filetype</strong></code>

    File type.

- <a href="#filestat.st_nlink" name="filestat.st_nlink"></a><code>[\_\_wasi\_linkcount\_t]#linkcount <strong>st\_nlink</strong></code>

    Number of hard links to the file.

- <a href="#filestat.st_size" name="filestat.st_size"></a><code>[\_\_wasi\_filesize\_t]#filesize <strong>st\_size</strong></code>

    For regular files, the file size in bytes. For
    symbolic links, the length in bytes of the pathname
    contained in the symbolic link.

- <a href="#filestat.st_atim" name="filestat.st_atim"></a><code>[\_\_wasi\_timestamp\_t]#timestamp <strong>st\_atim</strong></code>

    Last data access timestamp.

- <a href="#filestat.st_mtim" name="filestat.st_mtim"></a><code>[\_\_wasi\_timestamp\_t]#timestamp <strong>st\_mtim</strong></code>

    Last data modification timestamp.

- <a href="#filestat.st_ctim" name="filestat.st_ctim"></a><code>[\_\_wasi\_timestamp\_t]#timestamp <strong>st\_ctim</strong></code>

    Last file status change timestamp.

### <a href="#filetype" name="filetype"></a>`__wasi_filetype_t` (`uint8_t`)

The type of a file descriptor or file.

Used by [`__wasi_dirent_t`](#dirent), [`__wasi_fdstat_t`](#fdstat), and [`__wasi_filestat_t`](#filestat).

Possible values:

- <a href="#filetype.unknown" name="filetype.unknown"></a>**`__WASI_FILETYPE_UNKNOWN`**

    The type of the file descriptor or file is unknown or
    is different from any of the other types specified.

- <a href="#filetype.block_device" name="filetype.block_device"></a>**`__WASI_FILETYPE_BLOCK_DEVICE`**

    The file descriptor or file refers to a block device
    inode.

- <a href="#filetype.character_device" name="filetype.character_device"></a>**`__WASI_FILETYPE_CHARACTER_DEVICE`**

    The file descriptor or file refers to a character
    device inode.

- <a href="#filetype.directory" name="filetype.directory"></a>**`__WASI_FILETYPE_DIRECTORY`**

    The file descriptor or file refers to a directory
    inode.

- <a href="#filetype.regular_file" name="filetype.regular_file"></a>**`__WASI_FILETYPE_REGULAR_FILE`**

    The file descriptor or file refers to a regular file
    inode.

- <a href="#filetype.socket_dgram" name="filetype.socket_dgram"></a>**`__WASI_FILETYPE_SOCKET_DGRAM`**

    The file descriptor or file refers to a datagram
    socket.

- <a href="#filetype.socket_stream" name="filetype.socket_stream"></a>**`__WASI_FILETYPE_SOCKET_STREAM`**

    The file descriptor or file refers to a byte-stream
    socket.

- <a href="#filetype.symbolic_link" name="filetype.symbolic_link"></a>**`__WASI_FILETYPE_SYMBOLIC_LINK`**

    The file refers to a symbolic link inode.

### <a href="#fstflags" name="fstflags"></a>`__wasi_fstflags_t` (`uint16_t` bitfield)

Which file time attributes to adjust.

Used by [`__wasi_fd_filestat_set_times()`](#fd_filestat_set_times) and [`__wasi_path_filestat_set_times()`](#path_filestat_set_times).

Possible values:

- <a href="#fstflags.atim" name="fstflags.atim"></a>**`__WASI_FILESTAT_SET_ATIM`**

    Adjust the last data access timestamp to the value
    stored in [`__wasi_filestat_t::st_atim`]#filestat.st_atim.

- <a href="#fstflags.atim_now" name="fstflags.atim_now"></a>**`__WASI_FILESTAT_SET_ATIM_NOW`**

    Adjust the last data access timestamp to the time
    of clock [`__WASI_CLOCK_REALTIME`]#clockid.realtime.

- <a href="#fstflags.mtim" name="fstflags.mtim"></a>**`__WASI_FILESTAT_SET_MTIM`**

    Adjust the last data modification timestamp to the
    value stored in [`__wasi_filestat_t::st_mtim`]#filestat.st_mtim.

- <a href="#fstflags.mtim_now" name="fstflags.mtim_now"></a>**`__WASI_FILESTAT_SET_MTIM_NOW`**

    Adjust the last data modification timestamp to the
    time of clock [`__WASI_CLOCK_REALTIME`]#clockid.realtime.

### <a href="#inode" name="inode"></a>`__wasi_inode_t` (`uint64_t`)

File serial number that is unique within its file system.

Used by [`__wasi_dirent_t`](#dirent) and [`__wasi_filestat_t`](#filestat).

### <a href="#iovec" name="iovec"></a>`__wasi_iovec_t` (`struct`)

A region of memory for scatter/gather reads.

Used by [`__wasi_fd_pread()`](#fd_pread), [`__wasi_fd_read()`](#fd_read), and [`__wasi_sock_recv()`](#sock_recv).

Members:

- <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>size\_t <strong>buf\_len</strong></code>

    The address and length of the buffer to be filled.

### <a href="#linkcount" name="linkcount"></a>`__wasi_linkcount_t` (`uint32_t`)

Number of hard links to an inode.

Used by [`__wasi_filestat_t`](#filestat).

### <a href="#lookupflags" name="lookupflags"></a>`__wasi_lookupflags_t` (`uint32_t` bitfield)

Flags determining the method of how paths are resolved.

Used by [`__wasi_path_filestat_get()`](#path_filestat_get), [`__wasi_path_filestat_set_times()`](#path_filestat_set_times), [`__wasi_path_link()`](#path_link), and [`__wasi_path_open()`](#path_open).

Possible values:

- <a href="#lookupflags.symlink_follow" name="lookupflags.symlink_follow"></a>**`__WASI_LOOKUP_SYMLINK_FOLLOW`**

    As long as the resolved path corresponds to a symbolic
    link, it is expanded.

### <a href="#oflags" name="oflags"></a>`__wasi_oflags_t` (`uint16_t` bitfield)

Open flags used by [`__wasi_path_open()`](#path_open).

Used by [`__wasi_path_open()`](#path_open).

Possible values:

- <a href="#oflags.creat" name="oflags.creat"></a>**`__WASI_O_CREAT`**

    Create file if it does not exist.

- <a href="#oflags.directory" name="oflags.directory"></a>**`__WASI_O_DIRECTORY`**

    Fail if not a directory.

- <a href="#oflags.excl" name="oflags.excl"></a>**`__WASI_O_EXCL`**

    Fail if file already exists.

- <a href="#oflags.trunc" name="oflags.trunc"></a>**`__WASI_O_TRUNC`**

    Truncate file to size 0.

### <a href="#preopentype" name="preopentype"></a>`__wasi_preopentype_t` (`uint8_t`)

Preopened resource type.

Used by [`__wasi_prestat_t`](#prestat).

Possible values:

- <a href="#preopentype.dir" name="preopentype.dir"></a>**`__WASI_PREOPENTYPE_DIR`**

    Preopened directory.

### <a href="#prestat" name="prestat"></a>`__wasi_prestat_t` (`struct`)

Information about a preopened resource.

Used by [`__wasi_fd_prestat_get()`](#fd_prestat_get).

Members:

- <a href="#prestat.pr_type" name="prestat.pr_type"></a><code>[\_\_wasi\_preopentype\_t]#preopentype <strong>pr\_type</strong></code>

    The type of the preopened resource.

- When `pr_type` is [`__WASI_PREOPENTYPE_DIR`]#preopentype.dir:

    - <a href="#prestat.pr_name_len" name="prestat.pr_name_len"></a><code>size\_t <strong>u.pr\_name\_len</strong></code>

        The length of the preopened directory name.

### <a href="#riflags" name="riflags"></a>`__wasi_riflags_t` (`uint16_t` bitfield)

Flags provided to [`__wasi_sock_recv()`](#sock_recv).

Used by [`__wasi_sock_recv()`](#sock_recv).

Possible values:

- <a href="#riflags.peek" name="riflags.peek"></a>**`__WASI_SOCK_RECV_PEEK`**

    Returns the message without removing it from the
    socket's receive queue.

- <a href="#riflags.waitall" name="riflags.waitall"></a>**`__WASI_SOCK_RECV_WAITALL`**

    On byte-stream sockets, block until the full amount
    of data can be returned.

### <a href="#rights" name="rights"></a>`__wasi_rights_t` (`uint64_t` bitfield)

File descriptor rights, determining which actions may be
performed.

Used by [`__wasi_fdstat_t`](#fdstat), [`__wasi_fd_fdstat_set_rights()`](#fd_fdstat_set_rights), and [`__wasi_path_open()`](#path_open).

Possible values:

- <a href="#rights.fd_datasync" name="rights.fd_datasync"></a>**`__WASI_RIGHT_FD_DATASYNC`**

    The right to invoke [`__wasi_fd_datasync()`]#fd_datasync.

    If [`__WASI_RIGHT_PATH_OPEN`]#rights.path_open is set, includes the right to
    invoke [`__wasi_path_open()`]#path_open with [`__WASI_FDFLAG_DSYNC`]#fdflags.dsync.

- <a href="#rights.fd_read" name="rights.fd_read"></a>**`__WASI_RIGHT_FD_READ`**

    The right to invoke [`__wasi_fd_read()`]#fd_read and [`__wasi_sock_recv()`]#sock_recv.

    If [`__WASI_RIGHT_FD_SEEK`]#rights.fd_seek is set, includes the right to invoke
    [`__wasi_fd_pread()`]#fd_pread.

- <a href="#rights.fd_seek" name="rights.fd_seek"></a>**`__WASI_RIGHT_FD_SEEK`**

    The right to invoke [`__wasi_fd_seek()`]#fd_seek. This flag implies
    [`__WASI_RIGHT_FD_TELL`]#rights.fd_tell.

- <a href="#rights.fd_fdstat_set_flags" name="rights.fd_fdstat_set_flags"></a>**`__WASI_RIGHT_FD_FDSTAT_SET_FLAGS`**

    The right to invoke [`__wasi_fd_fdstat_set_flags()`]#fd_fdstat_set_flags.

- <a href="#rights.fd_sync" name="rights.fd_sync"></a>**`__WASI_RIGHT_FD_SYNC`**

    The right to invoke [`__wasi_fd_sync()`]#fd_sync.

    If [`__WASI_RIGHT_PATH_OPEN`]#rights.path_open is set, includes the right to
    invoke [`__wasi_path_open()`]#path_open with [`__WASI_FDFLAG_RSYNC`]#fdflags.rsync and
    [`__WASI_FDFLAG_DSYNC`]#fdflags.dsync.

- <a href="#rights.fd_tell" name="rights.fd_tell"></a>**`__WASI_RIGHT_FD_TELL`**

    The right to invoke [`__wasi_fd_seek()`]#fd_seek in such a way that the
    file offset remains unaltered (i.e., [`__WASI_WHENCE_CUR`]#whence.cur with
    offset zero), or to invoke [`__wasi_fd_tell()`]#fd_tell.

- <a href="#rights.fd_write" name="rights.fd_write"></a>**`__WASI_RIGHT_FD_WRITE`**

    The right to invoke [`__wasi_fd_write()`]#fd_write and [`__wasi_sock_send()`]#sock_send.

    If [`__WASI_RIGHT_FD_SEEK`]#rights.fd_seek is set, includes the right to
    invoke [`__wasi_fd_pwrite()`]#fd_pwrite.

- <a href="#rights.fd_advise" name="rights.fd_advise"></a>**`__WASI_RIGHT_FD_ADVISE`**

    The right to invoke [`__wasi_fd_advise()`]#fd_advise.

- <a href="#rights.fd_allocate" name="rights.fd_allocate"></a>**`__WASI_RIGHT_FD_ALLOCATE`**

    The right to invoke [`__wasi_fd_allocate()`]#fd_allocate.

- <a href="#rights.path_create_directory" name="rights.path_create_directory"></a>**`__WASI_RIGHT_PATH_CREATE_DIRECTORY`**

    The right to invoke [`__wasi_path_create_directory()`]#path_create_directory.

- <a href="#rights.path_create_file" name="rights.path_create_file"></a>**`__WASI_RIGHT_PATH_CREATE_FILE`**

    If [`__WASI_RIGHT_PATH_OPEN`]#rights.path_open is set, the right to invoke
    [`__wasi_path_open()`]#path_open with [`__WASI_O_CREAT`]#oflags.creat.

- <a href="#rights.path_link_source" name="rights.path_link_source"></a>**`__WASI_RIGHT_PATH_LINK_SOURCE`**

    The right to invoke [`__wasi_path_link()`]#path_link with the file
    descriptor as the source directory.

- <a href="#rights.path_link_target" name="rights.path_link_target"></a>**`__WASI_RIGHT_PATH_LINK_TARGET`**

    The right to invoke [`__wasi_path_link()`]#path_link with the file
    descriptor as the target directory.

- <a href="#rights.path_open" name="rights.path_open"></a>**`__WASI_RIGHT_PATH_OPEN`**

    The right to invoke [`__wasi_path_open()`]#path_open.

- <a href="#rights.fd_readdir" name="rights.fd_readdir"></a>**`__WASI_RIGHT_FD_READDIR`**

    The right to invoke [`__wasi_fd_readdir()`]#fd_readdir.

- <a href="#rights.path_readlink" name="rights.path_readlink"></a>**`__WASI_RIGHT_PATH_READLINK`**

    The right to invoke [`__wasi_path_readlink()`]#path_readlink.

- <a href="#rights.path_rename_source" name="rights.path_rename_source"></a>**`__WASI_RIGHT_PATH_RENAME_SOURCE`**

    The right to invoke [`__wasi_path_rename()`]#path_rename with the file
    descriptor as the source directory.

- <a href="#rights.path_rename_target" name="rights.path_rename_target"></a>**`__WASI_RIGHT_PATH_RENAME_TARGET`**

    The right to invoke [`__wasi_path_rename()`]#path_rename with the file
    descriptor as the target directory.

- <a href="#rights.path_filestat_get" name="rights.path_filestat_get"></a>**`__WASI_RIGHT_PATH_FILESTAT_GET`**

    The right to invoke [`__wasi_path_filestat_get()`]#path_filestat_get.

- <a href="#rights.path_filestat_set_size" name="rights.path_filestat_set_size"></a>**`__WASI_RIGHT_PATH_FILESTAT_SET_SIZE`**

    The right to change a file's size (there is no `__wasi_path_filestat_set_size()`).

    If [`__WASI_RIGHT_PATH_OPEN`]#rights.path_open is set, includes the right to
    invoke [`__wasi_path_open()`]#path_open with [`__WASI_O_TRUNC`]#oflags.trunc.

- <a href="#rights.path_filestat_set_times" name="rights.path_filestat_set_times"></a>**`__WASI_RIGHT_PATH_FILESTAT_SET_TIMES`**

    The right to invoke [`__wasi_path_filestat_set_times()`]#path_filestat_set_times.

- <a href="#rights.fd_filestat_get" name="rights.fd_filestat_get"></a>**`__WASI_RIGHT_FD_FILESTAT_GET`**

    The right to invoke [`__wasi_fd_filestat_get()`]#fd_filestat_get.

- <a href="#rights.fd_filestat_set_size" name="rights.fd_filestat_set_size"></a>**`__WASI_RIGHT_FD_FILESTAT_SET_SIZE`**

    The right to invoke [`__wasi_fd_filestat_set_size()`]#fd_filestat_set_size.

- <a href="#rights.fd_filestat_set_times" name="rights.fd_filestat_set_times"></a>**`__WASI_RIGHT_FD_FILESTAT_SET_TIMES`**

    The right to invoke [`__wasi_fd_filestat_set_times()`]#fd_filestat_set_times.

- <a href="#rights.path_symlink" name="rights.path_symlink"></a>**`__WASI_RIGHT_PATH_SYMLINK`**

    The right to invoke [`__wasi_path_symlink()`]#path_symlink.

- <a href="#rights.path_unlink_file" name="rights.path_unlink_file"></a>**`__WASI_RIGHT_PATH_UNLINK_FILE`**

    The right to invoke [`__wasi_path_unlink_file()`]#path_unlink_file.

- <a href="#rights.path_remove_directory" name="rights.path_remove_directory"></a>**`__WASI_RIGHT_PATH_REMOVE_DIRECTORY`**

    The right to invoke [`__wasi_path_remove_directory()`]#path_remove_directory.

- <a href="#rights.poll_fd_readwrite" name="rights.poll_fd_readwrite"></a>**`__WASI_RIGHT_POLL_FD_READWRITE`**

    If [`__WASI_RIGHT_FD_READ`]#rights.fd_read is set, includes the right to
    invoke [`__wasi_poll_oneoff()`]#poll_oneoff to subscribe to [`__WASI_EVENTTYPE_FD_READ`]#eventtype.fd_read.

    If [`__WASI_RIGHT_FD_WRITE`]#rights.fd_write is set, includes the right to
    invoke [`__wasi_poll_oneoff()`]#poll_oneoff to subscribe to [`__WASI_EVENTTYPE_FD_WRITE`]#eventtype.fd_write.

- <a href="#rights.sock_shutdown" name="rights.sock_shutdown"></a>**`__WASI_RIGHT_SOCK_SHUTDOWN`**

    The right to invoke [`__wasi_sock_shutdown()`]#sock_shutdown.

### <a href="#roflags" name="roflags"></a>`__wasi_roflags_t` (`uint16_t` bitfield)

Flags returned by [`__wasi_sock_recv()`](#sock_recv).

Used by [`__wasi_sock_recv()`](#sock_recv).

Possible values:

- <a href="#roflags.data_truncated" name="roflags.data_truncated"></a>**`__WASI_SOCK_RECV_DATA_TRUNCATED`**

    Returned by [`__wasi_sock_recv()`]#sock_recv: Message data has been
    truncated.

### <a href="#sdflags" name="sdflags"></a>`__wasi_sdflags_t` (`uint8_t` bitfield)

Which channels on a socket to shut down.

Used by [`__wasi_sock_shutdown()`](#sock_shutdown).

Possible values:

- <a href="#sdflags.rd" name="sdflags.rd"></a>**`__WASI_SHUT_RD`**

    Disables further receive operations.

- <a href="#sdflags.wr" name="sdflags.wr"></a>**`__WASI_SHUT_WR`**

    Disables further send operations.

### <a href="#siflags" name="siflags"></a>`__wasi_siflags_t` (`uint16_t` bitfield)

Flags provided to [`__wasi_sock_send()`](#sock_send). As there are currently no flags
defined, it must be set to zero.

Used by [`__wasi_sock_send()`](#sock_send).

### <a href="#signal" name="signal"></a>`__wasi_signal_t` (`uint8_t`)

Signal condition.

Used by [`__wasi_proc_raise()`](#proc_raise).

Possible values:

- <a href="#signal.abrt" name="signal.abrt"></a>**`__WASI_SIGABRT`**

    Process abort signal.

    Action: Terminates the process.

- <a href="#signal.alrm" name="signal.alrm"></a>**`__WASI_SIGALRM`**

    Alarm clock.

    Action: Terminates the process.

- <a href="#signal.bus" name="signal.bus"></a>**`__WASI_SIGBUS`**

    Access to an undefined portion of a memory object.

    Action: Terminates the process.

- <a href="#signal.chld" name="signal.chld"></a>**`__WASI_SIGCHLD`**

    Child process terminated, stopped, or continued.

    Action: Ignored.

- <a href="#signal.cont" name="signal.cont"></a>**`__WASI_SIGCONT`**

    Continue executing, if stopped.

    Action: Continues executing, if stopped.

- <a href="#signal.fpe" name="signal.fpe"></a>**`__WASI_SIGFPE`**

    Erroneous arithmetic operation.

    Action: Terminates the process.

- <a href="#signal.hup" name="signal.hup"></a>**`__WASI_SIGHUP`**

    Hangup.

    Action: Terminates the process.

- <a href="#signal.ill" name="signal.ill"></a>**`__WASI_SIGILL`**

    Illegal instruction.

    Action: Terminates the process.

- <a href="#signal.int" name="signal.int"></a>**`__WASI_SIGINT`**

    Terminate interrupt signal.

    Action: Terminates the process.

- <a href="#signal.kill" name="signal.kill"></a>**`__WASI_SIGKILL`**

    Kill.

    Action: Terminates the process.

- <a href="#signal.pipe" name="signal.pipe"></a>**`__WASI_SIGPIPE`**

    Write on a pipe with no one to read it.

    Action: Ignored.

- <a href="#signal.quit" name="signal.quit"></a>**`__WASI_SIGQUIT`**

    Terminal quit signal.

    Action: Terminates the process.

- <a href="#signal.segv" name="signal.segv"></a>**`__WASI_SIGSEGV`**

    Invalid memory reference.

    Action: Terminates the process.

- <a href="#signal.stop" name="signal.stop"></a>**`__WASI_SIGSTOP`**

    Stop executing.

    Action: Stops executing.

- <a href="#signal.sys" name="signal.sys"></a>**`__WASI_SIGSYS`**

    Bad system call.

    Action: Terminates the process.

- <a href="#signal.term" name="signal.term"></a>**`__WASI_SIGTERM`**

    Termination signal.

    Action: Terminates the process.

- <a href="#signal.trap" name="signal.trap"></a>**`__WASI_SIGTRAP`**

    Trace/breakpoint trap.

    Action: Terminates the process.

- <a href="#signal.tstp" name="signal.tstp"></a>**`__WASI_SIGTSTP`**

    Terminal stop signal.

    Action: Stops executing.

- <a href="#signal.ttin" name="signal.ttin"></a>**`__WASI_SIGTTIN`**

    Background process attempting read.

    Action: Stops executing.

- <a href="#signal.ttou" name="signal.ttou"></a>**`__WASI_SIGTTOU`**

    Background process attempting write.

    Action: Stops executing.

- <a href="#signal.urg" name="signal.urg"></a>**`__WASI_SIGURG`**

    High bandwidth data is available at a socket.

    Action: Ignored.

- <a href="#signal.usr1" name="signal.usr1"></a>**`__WASI_SIGUSR1`**

    User-defined signal 1.

    Action: Terminates the process.

- <a href="#signal.usr2" name="signal.usr2"></a>**`__WASI_SIGUSR2`**

    User-defined signal 2.

    Action: Terminates the process.

- <a href="#signal.vtalrm" name="signal.vtalrm"></a>**`__WASI_SIGVTALRM`**

    Virtual timer expired.

    Action: Terminates the process.

- <a href="#signal.xcpu" name="signal.xcpu"></a>**`__WASI_SIGXCPU`**

    CPU time limit exceeded.

    Action: Terminates the process.

- <a href="#signal.xfsz" name="signal.xfsz"></a>**`__WASI_SIGXFSZ`**

    File size limit exceeded.

    Action: Terminates the process.

### <a href="#subclockflags" name="subclockflags"></a>`__wasi_subclockflags_t` (`uint16_t` bitfield)

Flags determining how to interpret the timestamp provided in
[`__wasi_subscription_t::u.clock.timeout`](#subscription.u.clock.timeout).

Used by [`__wasi_subscription_t`](#subscription).

Possible values:

- <a href="#subclockflags.abstime" name="subclockflags.abstime"></a>**`__WASI_SUBSCRIPTION_CLOCK_ABSTIME`**

    If set, treat the timestamp provided in
    [`__wasi_subscription_t::u.clock.timeout`]#subscription.u.clock.timeout as an absolute timestamp
    of clock [`__wasi_subscription_t::u.clock.clock_id`]#subscription.u.clock.clock_id.

    If clear, treat the timestamp provided in
    [`__wasi_subscription_t::u.clock.timeout`]#subscription.u.clock.timeout relative to the current
    time value of clock [`__wasi_subscription_t::u.clock.clock_id`]#subscription.u.clock.clock_id.

### <a href="#subscription" name="subscription"></a>`__wasi_subscription_t` (`struct`)

Subscription to an event.

Used by [`__wasi_poll_oneoff()`](#poll_oneoff).

Members:

- <a href="#subscription.userdata" name="subscription.userdata"></a><code>[\_\_wasi\_userdata\_t]#userdata <strong>userdata</strong></code>

    User-provided value that is attached to the subscription in the
    implementation and returned through
    [`__wasi_event_t::userdata`]#event.userdata.

- <a href="#subscription.type" name="subscription.type"></a><code>[\_\_wasi\_eventtype\_t]#eventtype <strong>type</strong></code>

    The type of the event to which to subscribe.

- When `type` is [`__WASI_EVENTTYPE_CLOCK`]#eventtype.u.clock:

    - <a href="#subscription.u.clock" name="subscription.u.clock"></a>**`u.clock`**

        - <a href="#subscription.u.clock.identifier" name="subscription.u.clock.identifier"></a><code>[\_\_wasi\_userdata\_t]#userdata <strong>identifier</strong></code>

            The user-defined unique identifier of the clock.

        - <a href="#subscription.u.clock.clock_id" name="subscription.u.clock.clock_id"></a><code>[\_\_wasi\_clockid\_t]#clockid <strong>clock\_id</strong></code>

            The clock against which to compare the timestamp.

        - <a href="#subscription.u.clock.timeout" name="subscription.u.clock.timeout"></a><code>[\_\_wasi\_timestamp\_t]#timestamp <strong>timeout</strong></code>

            The absolute or relative timestamp.

        - <a href="#subscription.u.clock.precision" name="subscription.u.clock.precision"></a><code>[\_\_wasi\_timestamp\_t]#timestamp <strong>precision</strong></code>

            The amount of time that the implementation may wait additionally
            to coalesce with other events.

        - <a href="#subscription.u.clock.flags" name="subscription.u.clock.flags"></a><code>[\_\_wasi\_subclockflags\_t]#subclockflags <strong>flags</strong></code>

            Flags specifying whether the timeout is absolute or relative.

- When `type` is [`__WASI_EVENTTYPE_FD_READ`]#eventtype.fd_read or [`__WASI_EVENTTYPE_FD_WRITE`]#eventtype.fd_write:

    - <a href="#subscription.u.fd_readwrite" name="subscription.u.fd_readwrite"></a>**`u.fd_readwrite`**

        - <a href="#subscription.u.fd_readwrite.fd" name="subscription.u.fd_readwrite.fd"></a><code>[\_\_wasi\_fd\_t]#fd <strong>fd</strong></code>

            The file descriptor on which to wait for it to become ready
            for reading or writing.

### <a href="#timestamp" name="timestamp"></a>`__wasi_timestamp_t` (`uint64_t`)

Timestamp in nanoseconds.

Used by [`__wasi_filestat_t`](#filestat), [`__wasi_subscription_t`](#subscription), [`__wasi_clock_res_get()`](#clock_res_get), [`__wasi_clock_time_get()`](#clock_time_get), [`__wasi_fd_filestat_set_times()`](#fd_filestat_set_times), and [`__wasi_path_filestat_set_times()`](#path_filestat_set_times).

### <a href="#userdata" name="userdata"></a>`__wasi_userdata_t` (`uint64_t`)

User-provided value that may be attached to objects that is
retained when extracted from the implementation.

Used by [`__wasi_event_t`](#event) and [`__wasi_subscription_t`](#subscription).

### <a href="#whence" name="whence"></a>`__wasi_whence_t` (`uint8_t`)

The position relative to which to set the offset of the file descriptor.

Used by [`__wasi_fd_seek()`](#fd_seek).

Possible values:

- <a href="#whence.cur" name="whence.cur"></a>**`__WASI_WHENCE_CUR`**

    Seek relative to current position.

- <a href="#whence.end" name="whence.end"></a>**`__WASI_WHENCE_END`**

    Seek relative to end-of-file.

- <a href="#whence.set" name="whence.set"></a>**`__WASI_WHENCE_SET`**

    Seek relative to start-of-file.