Update WASI to cap-std 0.25 and windows-sys. (#4302)

This updates to rustix 0.35.6, and updates wasi-common to use cap-std 0.25 and
windows-sys (instead of winapi).

Changes include:

 - Better error code mappings on Windows.
 - Fixes undefined references to `utimensat` on Darwin.
 - Fixes undefined references to `preadv64` and `pwritev64` on Android.
 - Updates to io-lifetimes 0.7, which matches the io_safety API in Rust.
 - y2038 bug fixes for 32-bit platforms
This commit is contained in:
Dan Gohman
2022-06-23 10:47:15 -07:00
committed by GitHub
parent 445cc87a06
commit fa36e86f2c
27 changed files with 317 additions and 186 deletions

View File

@@ -15,23 +15,28 @@ include = ["src/**/*", "README.md", "LICENSE" ]
wasi-common = { path = "../", version = "=0.39.0" }
async-trait = "0.1"
anyhow = "1.0"
cap-std = "0.24.1"
cap-fs-ext = "0.24.1"
cap-time-ext = "0.24.1"
cap-rand = "0.24.1"
fs-set-times = "0.15.0"
system-interface = { version = "0.20.0", features = ["cap_std_impls"] }
cap-std = "0.25.0"
cap-fs-ext = "0.25.0"
cap-time-ext = "0.25.0"
cap-rand = "0.25.0"
fs-set-times = "0.17.0"
system-interface = { version = "0.21.0", features = ["cap_std_impls"] }
tracing = "0.1.19"
io-lifetimes = { version = "0.5.0", default-features = false }
is-terminal = "0.1.0"
io-lifetimes = { version = "0.7.0", default-features = false }
is-terminal = "0.3.0"
[target.'cfg(unix)'.dependencies]
rustix = "0.33.7"
rustix = { version = "0.35.6", features = ["fs"] }
[target.'cfg(windows)'.dependencies]
winapi = "0.3"
lazy_static = "1.4"
io-extras = "0.13.0"
io-extras = "0.15.0"
[target.'cfg(windows)'.dependencies.windows-sys]
version = "0.36.0"
features = [
"Win32_Foundation",
]
[dev-dependencies]
tempfile = "3.1.0"

View File

@@ -171,7 +171,9 @@ impl WasiDir for Dir {
// can't get a full metadata for.
#[cfg(windows)]
let entries = entries.filter(|entry: &Result<_, wasi_common::Error>| {
use winapi::shared::winerror::{ERROR_ACCESS_DENIED, ERROR_SHARING_VIOLATION};
use windows_sys::Win32::Foundation::{
ERROR_ACCESS_DENIED, ERROR_SHARING_VIOLATION,
};
if let Err(err) = entry {
if let Some(err) = err.downcast_ref::<std::io::Error>() {
if err.raw_os_error() == Some(ERROR_SHARING_VIOLATION as i32)

View File

@@ -213,12 +213,12 @@ macro_rules! wasi_stream_write_impl {
bufs: &mut [io::IoSliceMut<'a>],
) -> Result<u64, Error> {
use std::io::Read;
let n = Read::read_vectored(&mut *self.as_socketlike_view::<$std_ty>(), bufs)?;
let n = Read::read_vectored(&mut &*self.as_socketlike_view::<$std_ty>(), bufs)?;
Ok(n.try_into()?)
}
async fn write_vectored<'a>(&mut self, bufs: &[io::IoSlice<'a>]) -> Result<u64, Error> {
use std::io::Write;
let n = Write::write_vectored(&mut *self.as_socketlike_view::<$std_ty>(), bufs)?;
let n = Write::write_vectored(&mut &*self.as_socketlike_view::<$std_ty>(), bufs)?;
Ok(n.try_into()?)
}
async fn peek(&mut self, buf: &mut [u8]) -> Result<u64, Error> {

View File

@@ -46,7 +46,7 @@ pub async fn poll_oneoff<'a>(poll: &mut Poll<'a>) -> Result<(), Error> {
);
match rustix::io::poll(&mut pollfds, poll_timeout) {
Ok(ready) => break ready,
Err(rustix::io::Error::INTR) => continue,
Err(rustix::io::Errno::INTR) => continue,
Err(err) => return Err(err.into()),
}
};

View File

@@ -48,7 +48,7 @@ impl WasiFile for Stdin {
}
}
async fn read_vectored<'a>(&mut self, bufs: &mut [io::IoSliceMut<'a>]) -> Result<u64, Error> {
let n = self.0.as_filelike_view::<File>().read_vectored(bufs)?;
let n = (&*self.0.as_filelike_view::<File>()).read_vectored(bufs)?;
Ok(n.try_into().map_err(|_| Error::range())?)
}
async fn read_vectored_at<'a>(
@@ -140,7 +140,7 @@ macro_rules! wasi_file_write_impl {
})
}
async fn write_vectored<'a>(&mut self, bufs: &[io::IoSlice<'a>]) -> Result<u64, Error> {
let n = self.0.as_filelike_view::<File>().write_vectored(bufs)?;
let n = (&*self.0.as_filelike_view::<File>()).write_vectored(bufs)?;
Ok(n.try_into().map_err(|c| Error::range().context(c))?)
}
async fn write_vectored_at<'a>(