* a certain subset of io::Errors are expected - these we have
a (platform-specific, because windows) method to translate into
one of the wasi errno variants in the Error enum.
* some io::Errors are unexpected - wasi-common doesnt expect them from
the underlying OS. rather than preserve any fidelity in reporting
those to the user (only the unix impl attempts this), lets collect
those as an `Error::UnexpectedIo(#[source] std::io::Error)`.
Rather than trace at the conversion site, we rely on the wiggle error
conversion hooks to trace the `Error`'s `Debug` impl, and then
we convert all of these unexpected into `Errno::Io` for returning
to the guest.
This is a different behavior from before, and I don't have any firm
guarantees that nobody was depending on the old behavior, but it
appears to me that none of those unexpected errnos were reasonable
to expect from any of the filesystem syscalls wasi-common is making.
this is a bug - the TODO was never resolved, even when the code to
implement it was added right below :)
tracing is already in the transitive deps via wiggle, so no extra
trouble there. tracing::debug is more appropriate than eprintln
tracing is already the dep that wiggle uses.
I used tracing structured arguments wherever I could, but I skipped over
it in all of the snapshot_0 code, because I'm going to delete that code
and replace it with wiggle-based stuff real soon.
* virtfs file: update cursor position on fd_read
If a handle is backed by InMemoryFile, fd_read (turned into
Handle::read_vectored) doesn't update the cursor position properly and
thus prevents the caller from detecting EOF.
* virtfs file: fd_{pread,pwrite}: update offset in iovec iteration
If multiple iovec's are supplied, fd_pread and fd_pwrite previously
access data at the same offset for each iovec.
* Use AsRef<Path> instead of AsRef<OsStr> in yanix functions.
`AsRef<Path>` makes these more consistent with `std` interfaces, making
them easier to use outside of wasi-common.
Also, refactor the conversion to `CString` into a helper function.
* Reduce clutter from fully-qualifying names.
* rustfmt
* The underlying `R`/`W` doesnt need to be Clone, since we just need to
clone the Arc it sits behind.
* The rights actually shouldn't be behind an Arc - those get mutated
separately in each clone.