From 425241885264a118dfef25965d9b71ea94369a4c Mon Sep 17 00:00:00 2001
From: Dan Gohman <sunfish@mozilla.com>
Date: Thu, 7 Mar 2019 14:53:42 -0800
Subject: [PATCH 1/4] Merge `sock_recv` with `fd_read` and `sock_send` with
`fd_write`.
- Use `__WASI_EMSGSIZE` instead of `__WASI_SOCK_RECV_DATA_TRUNCATED`
to report message truncation. WASI libc will check for this and to
continue to implement the POSIX API (`MSG_TRUNC`).
- Rename `sock_shutdown` to `fd_shutdown`, as it's just a file
descriptor operation that happens to depend on a right that only
gets granted for sockets. This was the last remaining `sock_*`
function.
- Add a `__WASI_RIGHT_FD_ISATTY` to indicate whether a file descriptor
is known to be a terminal. This is not a typical right, as it's not
associated with an operation.
- Remove the `fs_filetype` field from the `fdstat_t` struct. This is
beneficial because `fd_fdstat_get` is an otherwise ambient right,
meaning anyone can do it on any open file descriptor, and it's
sometimes useful to pass a file descriptor around without disclosing
what its connected to.
The file type is still accessible, via `fd_filestat_get`, though
that has a corresponding right.
---
docs/WASI-api.md | 123 ++++----------
lib/wasi/js-polyfill/build.sh | 2 +-
lib/wasi/js-polyfill/wasi.js | 30 +---
.../include/wasmtime_ssp.h | 46 ++----
.../sandboxed-system-primitives/src/posix.c | 152 +++++++-----------
.../sandboxed-system-primitives/src/rights.h | 9 +-
lib/wasi/src/instantiate.rs | 4 +-
lib/wasi/src/syscalls.rs | 100 ++----------
lib/wasi/src/translate.rs | 30 +---
lib/wasi/src/wasm32.rs | 26 +--
10 files changed, 141 insertions(+), 381 deletions(-)
diff --git a/docs/WASI-api.md b/docs/WASI-api.md
index 4dfe3744..57a50053 100644
--- a/docs/WASI-api.md
+++ b/docs/WASI-api.md
@@ -56,6 +56,7 @@ Source: https://github.com/NuxiNL/cloudabi
- [`__wasi_fd_readdir()`](#fd_readdir)
- [`__wasi_fd_renumber()`](#fd_renumber)
- [`__wasi_fd_seek()`](#fd_seek)
+- [`__wasi_fd_shutdown()`](#fd_shutdown)
- [`__wasi_fd_sync()`](#fd_sync)
- [`__wasi_fd_tell()`](#fd_tell)
- [`__wasi_fd_write()`](#fd_write)
@@ -74,9 +75,6 @@ Source: https://github.com/NuxiNL/cloudabi
- [`__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="#clock_res_get" name="clock_res_get"></a>`__wasi_clock_res_get()`
@@ -358,7 +356,11 @@ Outputs:
Read from a file descriptor.
-Note: This is similar to `readv` in POSIX.
+Return [`__WASI_EMSGSIZE`](#errno.msgsize) if the message was a datagram
+message and its data was larger than the provided buffers, and was truncated
+to fit.
+
+Note: This is similar to a union of `readv` and `recv` in POSIX.
Inputs:
@@ -370,6 +372,10 @@ Inputs:
List of scatter/gather vectors to which to store data.
+- <a href="#fd_read.ri_flags" name="fd_read.ri_flags"></a><code>[\_\_wasi\_riflags\_t](#riflags) <strong>ri\_flags</strong></code>
+
+ Message flags.
+
Outputs:
- <a href="#fd_read.nread" name="fd_read.nread"></a><code>size\_t <strong>nread</strong></code>
@@ -503,7 +509,7 @@ Outputs:
Write to a file descriptor.
-Note: This is similar to `writev` in POSIX.
+Note: This is similar to a union of `writev` and `send` in POSIX.
Inputs:
@@ -515,6 +521,10 @@ Inputs:
List of scatter/gather vectors from which to retrieve data.
+- <a href="#fd_write.si_flags" name="fd_write.si_flags"></a><code>[\_\_wasi\_siflags\_t](#siflags) <strong>si\_flags</strong></code>
+
+ Message flags.
+
Outputs:
- <a href="#fd_write.nwritten" name="fd_write.nwritten"></a><code>size\_t <strong>nwritten</strong></code>
@@ -847,65 +857,7 @@ 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()`
+### <a href="#fd_shutdown" name="fd_shutdown"></a>`__wasi_fd_shutdown()`
Shut down socket send and receive channels.
@@ -913,11 +865,11 @@ 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>
+- <a href="#fd_shutdown.sock" name="fd_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>
+- <a href="#fd_shutdown.how" name="fd_shutdown.how"></a><code>[\_\_wasi\_sdflags\_t](#sdflags) <strong>how</strong></code>
Which channels on the socket to shut down.
@@ -965,7 +917,7 @@ Possible values:
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).
+Used by [`__wasi_fd_pwrite()`](#fd_pwrite), and [`__wasi_fd_write()`](#fd_write).
Members:
@@ -1502,10 +1454,6 @@ 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.
@@ -1659,7 +1607,7 @@ Used by [`__wasi_dirent_t`](#dirent) and [`__wasi_filestat_t`](#filestat).
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).
+Used by [`__wasi_fd_pread()`](#fd_pread), and [`__wasi_fd_read()`](#fd_read).
Members:
@@ -1712,18 +1660,18 @@ Possible values:
### <a href="#riflags" name="riflags"></a>`__wasi_riflags_t` (`uint16_t` bitfield)
-Flags provided to [`__wasi_sock_recv()`](#sock_recv).
+Flags provided to [`__wasi_fd_read()`](#fd_read).
-Used by [`__wasi_sock_recv()`](#sock_recv).
+Used by [`__wasi_fd_read()`](#fd_read).
Possible values:
-- <a href="#riflags.peek" name="riflags.peek"></a>**`__WASI_SOCK_RECV_PEEK`**
+- <a href="#riflags.peek" name="riflags.peek"></a>**`__WASI_FD_READ_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`**
+- <a href="#riflags.waitall" name="riflags.waitall"></a>**`__WASI_FD_READ_WAITALL`**
On byte-stream sockets, block until the full amount
of data can be returned.
@@ -1746,7 +1694,7 @@ Possible values:
- <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).
+ The right to invoke [`__wasi_fd_read()`](#fd_read).
If [`__WASI_RIGHT_FD_SEEK`](#rights.fd_seek) is set, includes the right to invoke
[`__wasi_fd_pread()`](#fd_pread).
@@ -1776,7 +1724,7 @@ Possible values:
- <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).
+ The right to invoke [`__wasi_fd_write()`](#fd_write).
If [`__WASI_RIGHT_FD_SEEK`](#rights.fd_seek) is set, includes the right to
invoke [`__wasi_fd_pwrite()`](#fd_pwrite).
@@ -1877,28 +1825,27 @@ Possible values:
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`**
+- <a href="#rights.fd_shutdown" name="rights.fd_shutdown"></a>**`__WASI_FD_SHUTDOWN`**
- The right to invoke [`__wasi_sock_shutdown()`](#sock_shutdown).
+ The right to invoke [`__wasi_fd_shutdown()`](#fd_shutdown).
-### <a href="#roflags" name="roflags"></a>`__wasi_roflags_t` (`uint16_t` bitfield)
+- <a href="#rights.fd_peek" name="rights.fd_peek"></a>**`__WASI_RIGHT_FD_READ_PEEK`**
-Flags returned by [`__wasi_sock_recv()`](#sock_recv).
+ The right to invoke [`__wasi_read()`](#fd_read) with [`__WASI_FD_READ_PEEK`](#riflags.peek).
-Used by [`__wasi_sock_recv()`](#sock_recv).
+- <a href="#rights.fd_waitall" name="rights.fd_waitall"></a>**`__WASI_RIGHT_FD_READ_WAITALL`**
-Possible values:
+ The right to invoke [`__wasi_read()`](#fd_read) with [`__WASI_FD_READ_WAITALL`](#riflags.waitall).
-- <a href="#roflags.data_truncated" name="roflags.data_truncated"></a>**`__WASI_SOCK_RECV_DATA_TRUNCATED`**
+- <a href="#rights.fd_isatty" name="rights.fd_isatty"></a>**`__WASI_RIGHT_FD_ISATTY`**
- Returned by [`__wasi_sock_recv()`](#sock_recv): Message data has been
- truncated.
+ The right to know that the output is a terminal.
### <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).
+Used by [`__wasi_fd_shutdown()`](#fd_shutdown).
Possible values:
diff --git a/wasmtime-wasi/js-polyfill/build.sh b/wasmtime-wasi/js-polyfill/build.sh
index ee07e620..8092f952 100755
--- a/wasmtime-wasi/js-polyfill/build.sh
+++ b/wasmtime-wasi/js-polyfill/build.sh
@@ -13,6 +13,6 @@ EMCC=emcc
--shell-file shell.html \
polyfill.c \
-s WARN_ON_UNDEFINED_SYMBOLS=0 \
- -s EXPORTED_FUNCTIONS="['_main', '___wasi_clock_res_get', '___wasi_clock_time_get', '___wasi_fd_close', '___wasi_fd_datasync', '___wasi_fd_pread', '___wasi_fd_pwrite', '___wasi_fd_read', '___wasi_fd_renumber', '___wasi_fd_seek', '___wasi_fd_tell', '___wasi_fd_fdstat_get', '___wasi_fd_fdstat_set_flags', '___wasi_fd_fdstat_set_rights', '___wasi_fd_sync', '___wasi_fd_write', '___wasi_fd_advise', '___wasi_fd_allocate', '___wasi_path_create_directory', '___wasi_path_link', '___wasi_path_open', '___wasi_fd_readdir', '___wasi_path_readlink', '___wasi_path_rename', '___wasi_fd_filestat_get', '___wasi_fd_filestat_set_times', '___wasi_fd_filestat_set_size', '___wasi_path_filestat_get', '___wasi_path_filestat_set_times', '___wasi_path_symlink', '___wasi_path_unlink_file', '___wasi_path_remove_directory', '___wasi_poll_oneoff', '___wasi_proc_exit', '___wasi_proc_raise', '___wasi_random_get', '___wasi_sched_yield', '___wasi_sock_recv', '___wasi_sock_send', '___wasi_sock_shutdown']" \
+ -s EXPORTED_FUNCTIONS="['_main', '___wasi_clock_res_get', '___wasi_clock_time_get', '___wasi_fd_close', '___wasi_fd_datasync', '___wasi_fd_pread', '___wasi_fd_pwrite', '___wasi_fd_read', '___wasi_fd_renumber', '___wasi_fd_seek', '___wasi_fd_tell', '___wasi_fd_fdstat_get', '___wasi_fd_fdstat_set_flags', '___wasi_fd_fdstat_set_rights', '___wasi_fd_sync', '___wasi_fd_write', '___wasi_fd_advise', '___wasi_fd_allocate', '___wasi_path_create_directory', '___wasi_path_link', '___wasi_path_open', '___wasi_fd_readdir', '___wasi_path_readlink', '___wasi_path_rename', '___wasi_fd_filestat_get', '___wasi_fd_filestat_set_times', '___wasi_fd_filestat_set_size', '___wasi_path_filestat_get', '___wasi_path_filestat_set_times', '___wasi_path_symlink', '___wasi_path_unlink_file', '___wasi_path_remove_directory', '___wasi_poll_oneoff', '___wasi_proc_exit', '___wasi_proc_raise', '___wasi_random_get', '___wasi_sched_yield', '___wasi_fd_shutdown']" \
--pre-js wasi.js \
-o polyfill.html
diff --git a/wasmtime-wasi/js-polyfill/wasi.js b/wasmtime-wasi/js-polyfill/wasi.js
index 236bef6f..0560dab0 100644
--- a/wasmtime-wasi/js-polyfill/wasi.js
+++ b/wasmtime-wasi/js-polyfill/wasi.js
@@ -180,10 +180,10 @@ fd_pwrite: function(fd, iovs, iovs_len, offset, nwritten) {
return ret;
},
-fd_read: function(fd, iovs, iovs_len, nread) {
+fd_read: function(fd, iovs, iovs_len, ri_flags, nread) {
let host_iovs = translate_iovs(iovs, iovs_len);
let host_nread = _malloc(4);
- let ret = ___wasi_fd_read(fd, host_iovs, iovs_len, host_nread);
+ let ret = ___wasi_fd_read(fd, host_iovs, iovs_len, ri_flags, host_nread);
copyout_i32(nread, host_nread);
free_iovs(host_iovs, iovs_len);
return ret;
@@ -226,10 +226,10 @@ fd_sync: function(fd) {
return ___wasi_fd_sync(fd);
},
-fd_write: function(fd, iovs, iovs_len, nwritten) {
+fd_write: function(fd, iovs, iovs_len, si_flags, nwritten) {
let host_iovs = translate_ciovs(iovs, iovs_len);
let host_nwritten = _malloc(4);
- let ret = ___wasi_fd_write(fd, host_iovs, iovs_len, host_nwritten);
+ let ret = ___wasi_fd_write(fd, host_iovs, iovs_len, si_flags, host_nwritten);
copyout_i32(nwritten, host_nwritten);
free_ciovs(host_iovs, iovs_len);
return ret;
@@ -399,26 +399,8 @@ sched_yield: function() {
return __wasi_sched_yield();
},
-sock_recv: function(sock, ri_data, ri_data_len, ri_flags, ro_datalen, ro_flags) {
- let host_ri_data = translate_iovs(ri_data, ri_data_len);
- let host_ro_datalen = _malloc(4);
- let ret = ___wasi_sock_recv(sock, host_ri_data, ri_data_len, ri_flags, host_ro_data, ro_flags);
- copyout_i32(ro_datalen, host_ro_datalen);
- free_iovs(host_ri_data, ri_data_len);
- return ret;
-},
-
-sock_send: function(sock, si_data, si_data_len, si_flags, so_datalen) {
- let host_si_data = translate_ciovs(si_data, si_data_len);
- let host_so_datalen = _malloc(4);
- let ret = ___wasi_sock_send(sock, host_si_data, si_data_len, si_flags, host_so_datalen);
- copyout_i32(so_datalen, host_so_datalen);
- free_ciovs(host_si_data, si_data_len);
- return ret;
-},
-
-sock_shutdown: function(sock, how) {
- return __wasi_sock_shutdown(sock, how);
+fd_shutdown: function(sock, how) {
+ return __wasi_fd_shutdown(sock, how);
}
};
diff --git a/wasmtime-wasi/sandboxed-system-primitives/include/wasmtime_ssp.h b/wasmtime-wasi/sandboxed-system-primitives/include/wasmtime_ssp.h
index 20c2efc7..f02786e9 100644
--- a/wasmtime-wasi/sandboxed-system-primitives/include/wasmtime_ssp.h
+++ b/wasmtime-wasi/sandboxed-system-primitives/include/wasmtime_ssp.h
@@ -177,8 +177,8 @@ typedef uint16_t __wasi_oflags_t;
#define __WASI_O_TRUNC (0x0008)
typedef uint16_t __wasi_riflags_t;
-#define __WASI_SOCK_RECV_PEEK (0x0001)
-#define __WASI_SOCK_RECV_WAITALL (0x0002)
+#define __WASI_FD_READ_PEEK (0x0001)
+#define __WASI_FD_READ_WAITALL (0x0002)
typedef uint64_t __wasi_rights_t;
#define __WASI_RIGHT_FD_DATASYNC (0x0000000000000001)
@@ -209,10 +209,10 @@ typedef uint64_t __wasi_rights_t;
#define __WASI_RIGHT_PATH_REMOVE_DIRECTORY (0x0000000002000000)
#define __WASI_RIGHT_PATH_UNLINK_FILE (0x0000000004000000)
#define __WASI_RIGHT_POLL_FD_READWRITE (0x0000000008000000)
-#define __WASI_RIGHT_SOCK_SHUTDOWN (0x0000000010000000)
-
-typedef uint16_t __wasi_roflags_t;
-#define __WASI_SOCK_RECV_DATA_TRUNCATED (0x0001)
+#define __WASI_RIGHT_FD_SHUTDOWN (0x0000000010000000)
+#define __WASI_RIGHT_FD_READ_PEEK (0x0000000020000000)
+#define __WASI_RIGHT_FD_READ_WAITALL (0x0000000040000000)
+#define __WASI_RIGHT_FD_ISATTY (0x0000000080000000)
typedef uint8_t __wasi_sdflags_t;
#define __WASI_SHUT_RD (0x01)
@@ -302,14 +302,11 @@ _Static_assert(sizeof(__wasi_event_t) == 32, "non-wasi data layout");
_Static_assert(_Alignof(__wasi_event_t) == 8, "non-wasi data layout");
typedef struct __wasi_fdstat_t {
- __wasi_filetype_t fs_filetype;
__wasi_fdflags_t fs_flags;
__wasi_rights_t fs_rights_base;
__wasi_rights_t fs_rights_inheriting;
} __wasi_fdstat_t;
-_Static_assert(
- offsetof(__wasi_fdstat_t, fs_filetype) == 0, "non-wasi data layout");
-_Static_assert(offsetof(__wasi_fdstat_t, fs_flags) == 2, "non-wasi data layout");
+_Static_assert(offsetof(__wasi_fdstat_t, fs_flags) == 0, "non-wasi data layout");
_Static_assert(
offsetof(__wasi_fdstat_t, fs_rights_base) == 8, "non-wasi data layout");
_Static_assert(
@@ -481,6 +478,7 @@ __wasi_errno_t wasmtime_ssp_fd_read(
__wasi_fd_t fd,
const __wasi_iovec_t *iovs,
size_t iovs_len,
+ __wasi_riflags_t ri_flags,
size_t *nread
) WASMTIME_SSP_SYSCALL_NAME(fd_read) __attribute__((__warn_unused_result__));
@@ -549,6 +547,7 @@ __wasi_errno_t wasmtime_ssp_fd_write(
__wasi_fd_t fd,
const __wasi_ciovec_t *iovs,
size_t iovs_len,
+ __wasi_siflags_t si_flags,
size_t *nwritten
) WASMTIME_SSP_SYSCALL_NAME(fd_write) __attribute__((__warn_unused_result__));
@@ -745,36 +744,13 @@ __wasi_errno_t wasmtime_ssp_random_get(
size_t buf_len
) WASMTIME_SSP_SYSCALL_NAME(random_get) __attribute__((__warn_unused_result__));
-__wasi_errno_t wasmtime_ssp_sock_recv(
-#if !defined(WASMTIME_SSP_STATIC_CURFDS)
- struct fd_table *curfds,
-#endif
- __wasi_fd_t sock,
- const __wasi_iovec_t *ri_data,
- size_t ri_data_len,
- __wasi_riflags_t ri_flags,
- size_t *ro_datalen,
- __wasi_roflags_t *ro_flags
-) WASMTIME_SSP_SYSCALL_NAME(sock_recv) __attribute__((__warn_unused_result__));
-
-__wasi_errno_t wasmtime_ssp_sock_send(
-#if !defined(WASMTIME_SSP_STATIC_CURFDS)
- struct fd_table *curfds,
-#endif
- __wasi_fd_t sock,
- const __wasi_ciovec_t *si_data,
- size_t si_data_len,
- __wasi_siflags_t si_flags,
- size_t *so_datalen
-) WASMTIME_SSP_SYSCALL_NAME(sock_send) __attribute__((__warn_unused_result__));
-
-__wasi_errno_t wasmtime_ssp_sock_shutdown(
+__wasi_errno_t wasmtime_ssp_fd_shutdown(
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
struct fd_table *curfds,
#endif
__wasi_fd_t sock,
__wasi_sdflags_t how
-) WASMTIME_SSP_SYSCALL_NAME(sock_shutdown) __attribute__((__warn_unused_result__));
+) WASMTIME_SSP_SYSCALL_NAME(fd_shutdown) __attribute__((__warn_unused_result__));
__wasi_errno_t wasmtime_ssp_sched_yield(void)
WASMTIME_SSP_SYSCALL_NAME(sched_yield) __attribute__((__warn_unused_result__));
diff --git a/wasmtime-wasi/sandboxed-system-primitives/src/posix.c b/wasmtime-wasi/sandboxed-system-primitives/src/posix.c
index 5e7bd54a..2a7cbf0f 100644
--- a/wasmtime-wasi/sandboxed-system-primitives/src/posix.c
+++ b/wasmtime-wasi/sandboxed-system-primitives/src/posix.c
@@ -856,18 +856,46 @@ __wasi_errno_t wasmtime_ssp_fd_read(
__wasi_fd_t fd,
const __wasi_iovec_t *iov,
size_t iovcnt,
+ __wasi_riflags_t ri_flags,
size_t *nread
) {
+ int needed = __WASI_RIGHT_FD_READ;
+ if ((ri_flags & __WASI_FD_READ_PEEK) != 0)
+ needed |= __WASI_RIGHT_FD_READ_PEEK;
+ if ((ri_flags & __WASI_FD_READ_WAITALL) != 0)
+ needed |= __WASI_RIGHT_FD_READ_WAITALL;
+
struct fd_object *fo;
- __wasi_errno_t error = fd_object_get(curfds, &fo, fd, __WASI_RIGHT_FD_READ, 0);
+ __wasi_errno_t error = fd_object_get(curfds, &fo, fd, needed, 0);
if (error != 0)
return error;
- ssize_t len = readv(fd_number(fo), (const struct iovec *)iov, iovcnt);
- fd_object_release(fo);
- if (len < 0)
- return convert_errno(errno);
- *nread = len;
+ if (fo->type == __WASI_FILETYPE_SOCKET_STREAM ||
+ fo->type == __WASI_FILETYPE_SOCKET_DGRAM) {
+ int nflags = 0;
+ if ((ri_flags & __WASI_FD_READ_PEEK) != 0)
+ nflags |= MSG_PEEK;
+ if ((ri_flags & __WASI_FD_READ_WAITALL) != 0)
+ nflags |= MSG_WAITALL;
+ struct msghdr hdr = {
+ .msg_iov = (struct iovec *)iov,
+ .msg_iovlen = iovcnt,
+ };
+ ssize_t datalen = recvmsg(fd_number(fo), &hdr, nflags);
+ fd_object_release(fo);
+ if (datalen < 0)
+ return convert_errno(errno);
+
+ *nread = datalen;
+ if ((hdr.msg_flags & MSG_TRUNC) != 0)
+ return __WASI_EMSGSIZE;
+ } else {
+ ssize_t len = readv(fd_number(fo), (const struct iovec *)iov, iovcnt);
+ fd_object_release(fo);
+ if (len < 0)
+ return convert_errno(errno);
+ *nread = len;
+ }
return 0;
}
@@ -992,7 +1020,6 @@ __wasi_errno_t wasmtime_ssp_fd_fdstat_get(
// Extract file descriptor type and rights.
struct fd_object *fo = fe->object;
*buf = (__wasi_fdstat_t){
- .fs_filetype = fo->type,
.fs_rights_base = fe->rights_base,
.fs_rights_inheriting = fe->rights_inheriting,
};
@@ -1115,6 +1142,7 @@ __wasi_errno_t wasmtime_ssp_fd_write(
__wasi_fd_t fd,
const __wasi_ciovec_t *iov,
size_t iovcnt,
+ __wasi_siflags_t si_flags,
size_t *nwritten
) {
struct fd_object *fo;
@@ -1122,11 +1150,28 @@ __wasi_errno_t wasmtime_ssp_fd_write(
if (error != 0)
return error;
- ssize_t len = writev(fd_number(fo), (const struct iovec *)iov, iovcnt);
- fd_object_release(fo);
- if (len < 0)
- return convert_errno(errno);
- *nwritten = len;
+ if (fo->type == __WASI_FILETYPE_SOCKET_STREAM ||
+ fo->type == __WASI_FILETYPE_SOCKET_DGRAM) {
+ // Convert input to msghdr.
+ struct msghdr hdr = {
+ .msg_iov = (struct iovec *)iov,
+ .msg_iovlen = iovcnt,
+ };
+
+ // Send message.
+ ssize_t len = sendmsg(fd_number(fo), &hdr, 0);
+ fd_object_release(fo);
+ if (len < 0) {
+ return convert_errno(errno);
+ }
+ *nwritten = len;
+ } else {
+ ssize_t len = writev(fd_number(fo), (const struct iovec *)iov, iovcnt);
+ fd_object_release(fo);
+ if (len < 0)
+ return convert_errno(errno);
+ *nwritten = len;
+ }
return 0;
}
@@ -2458,86 +2503,7 @@ __wasi_errno_t wasmtime_ssp_random_get(
return 0;
}
-__wasi_errno_t wasmtime_ssp_sock_recv(
-#if !defined(WASMTIME_SSP_STATIC_CURFDS)
- struct fd_table *curfds,
-#endif
- __wasi_fd_t sock,
- const __wasi_iovec_t *ri_data,
- size_t ri_data_len,
- __wasi_riflags_t ri_flags,
- size_t *ro_datalen,
- __wasi_roflags_t *ro_flags
-) {
- // Convert input to msghdr.
- struct msghdr hdr = {
- .msg_iov = (struct iovec *)ri_data,
- .msg_iovlen = ri_data_len,
- };
- int nflags = 0;
- if ((ri_flags & __WASI_SOCK_RECV_PEEK) != 0)
- nflags |= MSG_PEEK;
- if ((ri_flags & __WASI_SOCK_RECV_WAITALL) != 0)
- nflags |= MSG_WAITALL;
-
- struct fd_object *fo;
- __wasi_errno_t error = fd_object_get(curfds, &fo, sock, __WASI_RIGHT_FD_READ, 0);
- if (error != 0) {
- return error;
- }
-
- ssize_t datalen = recvmsg(fd_number(fo), &hdr, nflags);
- fd_object_release(fo);
- if (datalen < 0) {
- return convert_errno(errno);
- }
-
-
- // Convert msghdr to output.
- *ro_datalen = datalen;
- *ro_flags = 0;
- if ((hdr.msg_flags & MSG_TRUNC) != 0)
- *ro_flags |= __WASI_SOCK_RECV_DATA_TRUNCATED;
- return 0;
-}
-
-__wasi_errno_t wasmtime_ssp_sock_send(
-#if !defined(WASMTIME_SSP_STATIC_CURFDS)
- struct fd_table *curfds,
-#endif
- __wasi_fd_t sock,
- const __wasi_ciovec_t *si_data,
- size_t si_data_len,
- __wasi_siflags_t si_flags,
- size_t *so_datalen
-) NO_LOCK_ANALYSIS {
- // Convert input to msghdr.
- struct msghdr hdr = {
- .msg_iov = (struct iovec *)si_data,
- .msg_iovlen = si_data_len,
- };
-
- // Attach file descriptors if present.
- __wasi_errno_t error;
-
- // Send message.
- struct fd_object *fo;
- error = fd_object_get(curfds, &fo, sock, __WASI_RIGHT_FD_WRITE, 0);
- if (error != 0)
- goto out;
- ssize_t len = sendmsg(fd_number(fo), &hdr, 0);
- fd_object_release(fo);
- if (len < 0) {
- error = convert_errno(errno);
- } else {
- *so_datalen = len;
- }
-
-out:
- return error;
-}
-
-__wasi_errno_t wasmtime_ssp_sock_shutdown(
+__wasi_errno_t wasmtime_ssp_fd_shutdown(
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
struct fd_table *curfds,
#endif
@@ -2561,7 +2527,7 @@ __wasi_errno_t wasmtime_ssp_sock_shutdown(
struct fd_object *fo;
__wasi_errno_t error =
- fd_object_get(curfds, &fo, sock, __WASI_RIGHT_SOCK_SHUTDOWN, 0);
+ fd_object_get(curfds, &fo, sock, __WASI_RIGHT_FD_SHUTDOWN, 0);
if (error != 0)
return error;
diff --git a/wasmtime-wasi/sandboxed-system-primitives/src/rights.h b/wasmtime-wasi/sandboxed-system-primitives/src/rights.h
index 04dbc80c..98e5642f 100644
--- a/wasmtime-wasi/sandboxed-system-primitives/src/rights.h
+++ b/wasmtime-wasi/sandboxed-system-primitives/src/rights.h
@@ -28,7 +28,9 @@
__WASI_RIGHT_FD_FILESTAT_SET_SIZE | \
__WASI_RIGHT_PATH_SYMLINK | __WASI_RIGHT_PATH_UNLINK_FILE | \
__WASI_RIGHT_PATH_REMOVE_DIRECTORY | \
- __WASI_RIGHT_POLL_FD_READWRITE | __WASI_RIGHT_SOCK_SHUTDOWN)
+ __WASI_RIGHT_POLL_FD_READWRITE | __WASI_RIGHT_FD_SHUTDOWN | \
+ __WASI_RIGHT_FD_READ_PEEK | __WASI_RIGHT_FD_READ_WAITALL | \
+ __WASI_RIGHT_FD_ISATTY)
// Block and character device interaction is outside the scope of
// CloudABI. Simply allow everything.
@@ -69,14 +71,15 @@
#define RIGHTS_SOCKET_BASE \
(__WASI_RIGHT_FD_READ | __WASI_RIGHT_FD_FDSTAT_SET_FLAGS | \
__WASI_RIGHT_FD_WRITE | __WASI_RIGHT_FD_FILESTAT_GET | \
- __WASI_RIGHT_POLL_FD_READWRITE | __WASI_RIGHT_SOCK_SHUTDOWN)
+ __WASI_RIGHT_POLL_FD_READWRITE | __WASI_RIGHT_FD_SHUTDOWN | \
+ __WASI_RIGHT_FD_READ_PEEK | __WASI_RIGHT_FD_READ_WAITALL)
#define RIGHTS_SOCKET_INHERITING RIGHTS_ALL
// Operations that apply to TTYs.
#define RIGHTS_TTY_BASE \
(__WASI_RIGHT_FD_READ | __WASI_RIGHT_FD_FDSTAT_SET_FLAGS | \
__WASI_RIGHT_FD_WRITE | __WASI_RIGHT_FD_FILESTAT_GET | \
- __WASI_RIGHT_POLL_FD_READWRITE)
+ __WASI_RIGHT_POLL_FD_READWRITE | __WASI_RIGHT_FD_ISATTY)
#define RIGHTS_TTY_INHERITING 0
#endif
diff --git a/wasmtime-wasi/src/instantiate.rs b/wasmtime-wasi/src/instantiate.rs
index 2ad2c4b9..dcf42ddf 100644
--- a/wasmtime-wasi/src/instantiate.rs
+++ b/wasmtime-wasi/src/instantiate.rs
@@ -88,9 +88,7 @@ pub fn instantiate_wasi(
signature!(proc_raise);
signature!(random_get);
signature!(sched_yield);
- signature!(sock_recv);
- signature!(sock_send);
- signature!(sock_shutdown);
+ signature!(fd_shutdown);
let imports = Imports::none();
let data_initializers = Vec::new();
diff --git a/wasmtime-wasi/src/syscalls.rs b/wasmtime-wasi/src/syscalls.rs
index 961441e8..dcdaacee 100644
--- a/wasmtime-wasi/src/syscalls.rs
+++ b/wasmtime-wasi/src/syscalls.rs
@@ -316,13 +316,15 @@ syscalls! {
fd: wasm32::__wasi_fd_t,
iovs: wasm32::uintptr_t,
iovs_len: wasm32::size_t,
+ ri_flags: wasm32::__wasi_riflags_t,
nread: wasm32::uintptr_t,
) -> wasm32::__wasi_errno_t {
trace!(
- "fd_read(fd={:?}, iovs={:#x?}, iovs_len={:?}, nread={:#x?})",
+ "fd_read(fd={:?}, iovs={:#x?}, iovs_len={:?}, ri_flags={:#x?}, nread={:#x?})",
fd,
iovs,
iovs_len,
+ ri_flags,
nread
);
@@ -333,12 +335,13 @@ syscalls! {
Ok(iovs) => iovs,
Err(e) => return return_encoded_errno(e),
};
+ let ri_flags = decode_riflags(ri_flags);
let mut host_nread = match decode_usize_byref(vmctx, nread) {
Ok(host_nread) => host_nread,
Err(e) => return return_encoded_errno(e),
};
- let e = host::wasmtime_ssp_fd_read(curfds, fd, iovs.as_ptr(), iovs.len(), &mut host_nread);
+ let e = host::wasmtime_ssp_fd_read(curfds, fd, iovs.as_ptr(), iovs.len(), ri_flags, &mut host_nread);
trace!(" | *nread={:?}", host_nread);
encode_usize_byref(vmctx, nread, host_nread).unwrap();
@@ -507,13 +510,15 @@ syscalls! {
fd: wasm32::__wasi_fd_t,
iovs: wasm32::uintptr_t,
iovs_len: wasm32::size_t,
+ si_flags: wasm32::__wasi_siflags_t,
nwritten: wasm32::uintptr_t,
) -> wasm32::__wasi_errno_t {
trace!(
- "fd_write(fd={:?}, iovs={:#x?}, iovs_len={:?}, nwritten={:#x?})",
+ "fd_write(fd={:?}, iovs={:#x?}, iovs_len={:?}, si_flags={:#x?}, nwritten={:#x?})",
fd,
iovs,
iovs_len,
+ si_flags,
nwritten
);
@@ -524,12 +529,13 @@ syscalls! {
Ok(iovs) => iovs,
Err(e) => return return_encoded_errno(e),
};
+ si_flags = decode_siflags(si_flags);
let mut host_nwritten = match decode_usize_byref(vmctx, nwritten) {
Ok(host_nwritten) => host_nwritten,
Err(e) => return return_encoded_errno(e),
};
- let e = host::wasmtime_ssp_fd_write(curfds, fd, iovs.as_ptr(), iovs.len(), &mut host_nwritten);
+ let e = host::wasmtime_ssp_fd_write(curfds, fd, iovs.as_ptr(), iovs.len(), si_flags, &mut host_nwritten);
trace!(" | *nwritten={:?}", host_nwritten);
encode_usize_byref(vmctx, nwritten, host_nwritten).unwrap();
@@ -1173,99 +1179,19 @@ syscalls! {
return_encoded_errno(e)
}
- pub unsafe extern "C" fn sock_recv(
- vmctx: *mut VMContext,
- sock: wasm32::__wasi_fd_t,
- ri_data: wasm32::uintptr_t,
- ri_data_len: wasm32::size_t,
- ri_flags: wasm32::__wasi_riflags_t,
- ro_datalen: wasm32::uintptr_t,
- ro_flags: wasm32::uintptr_t,
- ) -> wasm32::__wasi_errno_t {
- trace!(
- "sock_recv(sock={:?}, ri_data={:#x?}, ri_data_len={}, ri_flags={:#x?}, ro_datalen={:#x?}, ro_flags={:#x?})",
- sock,
- ri_data, ri_data_len, ri_flags,
- ro_datalen, ro_flags
- );
-
- let vmctx = &mut *vmctx;
- let curfds = get_curfds(vmctx);
- let sock = decode_fd(sock);
- let ri_data = match decode_iovec_slice(vmctx, ri_data, ri_data_len) {
- Ok(ri_data) => ri_data,
- Err(e) => return return_encoded_errno(e),
- };
- let ri_flags = decode_riflags(ri_flags);
- let mut host_ro_datalen = match decode_usize_byref(vmctx, ro_datalen) {
- Ok(host_ro_datalen) => host_ro_datalen,
- Err(e) => return return_encoded_errno(e),
- };
- let mut host_ro_flags = match decode_roflags_byref(vmctx, ro_flags) {
- Ok(host_ro_flags) => host_ro_flags,
- Err(e) => return return_encoded_errno(e),
- };
-
- let e = host::wasmtime_ssp_sock_recv(curfds, sock, ri_data.as_ptr(), ri_data.len(), ri_flags,
- &mut host_ro_datalen, &mut host_ro_flags);
-
- // TODO: Format the output for tracing.
- trace!(" | *ro_datalen={}", host_ro_datalen);
- trace!(" | *ro_flags={}", host_ro_flags);
- encode_usize_byref(vmctx, ro_datalen, host_ro_datalen).unwrap();
- encode_roflags_byref(vmctx, ro_flags, host_ro_flags).unwrap();
-
- return_encoded_errno(e)
- }
-
- pub unsafe extern "C" fn sock_send(
- vmctx: *mut VMContext,
- sock: wasm32::__wasi_fd_t,
- si_data: wasm32::uintptr_t,
- si_data_len: wasm32::size_t,
- si_flags: wasm32::__wasi_siflags_t,
- so_datalen: wasm32::uintptr_t,
- ) -> wasm32::__wasi_errno_t {
- trace!(
- "sock_send(sock={:?}, si_data={:#x?}, si_data_len={}, si_flags={:#x?}, so_datalen={:#x?})",
- sock,
- si_data, si_data_len, si_flags, so_datalen,
- );
-
- let vmctx = &mut *vmctx;
- let curfds = get_curfds(vmctx);
- let sock = decode_fd(sock);
- let si_data = match decode_ciovec_slice(vmctx, si_data, si_data_len) {
- Ok(si_data) => si_data,
- Err(e) => return return_encoded_errno(e),
- };
- let si_flags = decode_siflags(si_flags);
- let mut host_so_datalen = match decode_usize_byref(vmctx, so_datalen) {
- Ok(so_datalen) => so_datalen,
- Err(e) => return return_encoded_errno(e),
- };
-
- let e = host::wasmtime_ssp_sock_send(curfds, sock, si_data.as_ptr(), si_data.len(), si_flags, &mut host_so_datalen);
-
- trace!(" | *so_datalen={:?}", host_so_datalen);
- encode_usize_byref(vmctx, so_datalen, host_so_datalen).unwrap();
-
- return_encoded_errno(e)
- }
-
- pub unsafe extern "C" fn sock_shutdown(
+ pub unsafe extern "C" fn fd_shutdown(
vmctx: *mut VMContext,
sock: wasm32::__wasi_fd_t,
how: wasm32::__wasi_sdflags_t,
) -> wasm32::__wasi_errno_t {
- trace!("sock_shutdown(sock={:?}, how={:?})", sock, how);
+ trace!("fd_shutdown(sock={:?}, how={:?})", sock, how);
let vmctx = &mut *vmctx;
let curfds = get_curfds(vmctx);
let sock = decode_fd(sock);
let how = decode_sdflags(how);
- let e = host::wasmtime_ssp_sock_shutdown(curfds, sock, how);
+ let e = host::wasmtime_ssp_fd_shutdown(curfds, sock, how);
return_encoded_errno(e)
}
diff --git a/wasmtime-wasi/src/translate.rs b/wasmtime-wasi/src/translate.rs
index cc08774e..abaf5c14 100644
--- a/wasmtime-wasi/src/translate.rs
+++ b/wasmtime-wasi/src/translate.rs
@@ -138,10 +138,6 @@ pub fn decode_lookupflags(lookupflags: wasm32::__wasi_lookupflags_t) -> host::__
lookupflags
}
-pub fn decode_roflags(roflags: wasm32::__wasi_roflags_t) -> host::__wasi_roflags_t {
- roflags
-}
-
pub fn decode_oflags(_oflags: wasm32::__wasi_oflags_t) -> host::__wasi_oflags_t {
unimplemented!("decode_oflags");
}
@@ -195,10 +191,6 @@ pub fn decode_riflags(riflags: wasm32::__wasi_riflags_t) -> host::__wasi_riflags
riflags
}
-pub fn decode_siflags(siflags: wasm32::__wasi_siflags_t) -> host::__wasi_siflags_t {
- siflags
-}
-
pub unsafe fn decode_char_slice(
vmctx: &mut VMContext,
ptr: wasm32::uintptr_t,
@@ -353,25 +345,6 @@ pub unsafe fn encode_filesize_byref(
)
}
-pub unsafe fn decode_roflags_byref(
- vmctx: &mut VMContext,
- roflags_ptr: wasm32::uintptr_t,
-) -> Result<host::__wasi_roflags_t, host::__wasi_errno_t> {
- decode_pointee::<wasm32::__wasi_roflags_t>(vmctx, roflags_ptr).map(decode_roflags)
-}
-
-pub unsafe fn encode_roflags_byref(
- vmctx: &mut VMContext,
- roflags_ptr: wasm32::uintptr_t,
- host_roflags: host::__wasi_roflags_t,
-) -> Result<(), host::__wasi_errno_t> {
- encode_pointee::<wasm32::__wasi_roflags_t>(
- vmctx,
- roflags_ptr,
- wasm32::__wasi_roflags_t::cast(host_roflags),
- )
-}
-
pub unsafe fn decode_usize_byref(
vmctx: &mut VMContext,
usize_ptr: wasm32::uintptr_t,
@@ -394,7 +367,6 @@ pub unsafe fn decode_fdstat_byref(
let wasm32_fdstat = decode_pointee::<wasm32::__wasi_fdstat_t>(vmctx, fdstat_ptr)?;
Ok(host::__wasi_fdstat_t {
- fs_filetype: decode_filetype(wasm32_fdstat.fs_filetype),
fs_flags: decode_fdflags(wasm32_fdstat.fs_flags),
fs_rights_base: decode_rights(wasm32_fdstat.fs_rights_base),
fs_rights_inheriting: decode_rights(wasm32_fdstat.fs_rights_inheriting),
@@ -407,9 +379,9 @@ pub unsafe fn encode_fdstat_byref(
host_fdstat: host::__wasi_fdstat_t,
) -> Result<(), host::__wasi_errno_t> {
let wasm32_fdstat = wasm32::__wasi_fdstat_t {
- fs_filetype: encode_filetype(host_fdstat.fs_filetype),
fs_flags: encode_fdflags(host_fdstat.fs_flags),
__bindgen_padding_0: 0,
+ __bindgen_padding_1: 0,
fs_rights_base: encode_rights(host_fdstat.fs_rights_base),
fs_rights_inheriting: encode_rights(host_fdstat.fs_rights_inheriting),
};
diff --git a/wasmtime-wasi/src/wasm32.rs b/wasmtime-wasi/src/wasm32.rs
index 75e137fb..49780310 100644
--- a/wasmtime-wasi/src/wasm32.rs
+++ b/wasmtime-wasi/src/wasm32.rs
@@ -141,9 +141,7 @@ pub type __wasi_lookupflags_t = u32;
pub type __wasi_oflags_t = u16;
pub type __wasi_riflags_t = u16;
pub type __wasi_rights_t = u64;
-pub type __wasi_roflags_t = u16;
pub type __wasi_sdflags_t = u8;
-pub type __wasi_siflags_t = u16;
pub type __wasi_signal_t = u8;
pub type __wasi_subclockflags_t = u16;
pub type __wasi_timestamp_t = u64;
@@ -382,8 +380,8 @@ fn bindgen_test_layout_wasi_event_t() {
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __wasi_fdstat_t {
- pub fs_filetype: __wasi_filetype_t,
pub fs_flags: __wasi_fdflags_t,
+ pub __bindgen_padding_1: u16,
pub __bindgen_padding_0: u32,
pub fs_rights_base: __wasi_rights_t,
pub fs_rights_inheriting: __wasi_rights_t,
@@ -395,19 +393,9 @@ fn bindgen_test_layout_wasi_fdstat_t() {
24usize,
concat!("Size of: ", stringify!(__wasi_fdstat_t))
);
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<__wasi_fdstat_t>())).fs_filetype as *const _ as usize },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(__wasi_fdstat_t),
- "::",
- stringify!(fs_filetype)
- )
- );
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_fdstat_t>())).fs_flags as *const _ as usize },
- 2usize,
+ 0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_fdstat_t),
@@ -1106,8 +1094,8 @@ pub const __WASI_O_CREAT: __wasi_oflags_t = 1;
pub const __WASI_O_DIRECTORY: __wasi_oflags_t = 2;
pub const __WASI_O_EXCL: __wasi_oflags_t = 4;
pub const __WASI_O_TRUNC: __wasi_oflags_t = 8;
-pub const __WASI_SOCK_RECV_PEEK: __wasi_riflags_t = 1;
-pub const __WASI_SOCK_RECV_WAITALL: __wasi_riflags_t = 2;
+pub const __WASI_FD_READ_PEEK: __wasi_riflags_t = 1;
+pub const __WASI_FD_READ_WAITALL: __wasi_riflags_t = 2;
pub const __WASI_RIGHT_FD_DATASYNC: __wasi_rights_t = 1;
pub const __WASI_RIGHT_FD_READ: __wasi_rights_t = 2;
pub const __WASI_RIGHT_FD_SEEK: __wasi_rights_t = 4;
@@ -1136,8 +1124,10 @@ pub const __WASI_RIGHT_PATH_SYMLINK: __wasi_rights_t = 16777216;
pub const __WASI_RIGHT_PATH_REMOVE_DIRECTORY: __wasi_rights_t = 33554432;
pub const __WASI_RIGHT_PATH_UNLINK_FILE: __wasi_rights_t = 67108864;
pub const __WASI_RIGHT_POLL_FD_READWRITE: __wasi_rights_t = 134217728;
-pub const __WASI_RIGHT_SOCK_SHUTDOWN: __wasi_rights_t = 268435456;
-pub const __WASI_SOCK_RECV_DATA_TRUNCATED: __wasi_roflags_t = 1;
+pub const __WASI_RIGHT_FD_SHUTDOWN: __wasi_rights_t = 268435456;
+pub const __WASI_RIGHT_FD_READ_PEEK: __wasi_rights_t = 536870912;
+pub const __WASI_RIGHT_FD_READ_WAITALL: __wasi_rights_t = 1073741824;
+pub const __WASI_RIGHT_FD_ISATTY: __wasi_rights_t = 2147483648;
pub const __WASI_SHUT_RD: __wasi_sdflags_t = 1;
pub const __WASI_SHUT_WR: __wasi_sdflags_t = 2;
pub const __WASI_SIGHUP: __wasi_signal_t = 1;
--
2.17.1