Commit Graph

268 Commits

Author SHA1 Message Date
Pat Hickey
c12cd82fc0 careful now 2021-01-29 21:19:24 -08:00
Pat Hickey
e9a7a4094c cap-std-sync Dir::open_file: set the fdflags that OpenOptions cant 2021-01-29 21:08:53 -08:00
Pat Hickey
3d406ff50e Dir::open_file can just pass read/write as bools, centralizing FileCaps decoding
this way the impls of File/Dir don't need to know about any caps!
2021-01-29 21:04:34 -08:00
Pat Hickey
d8f3a62b32 dont try to make a virtfs today. instead, delete virtfs example. 2021-01-29 17:27:05 -08:00
Pat Hickey
95ad13c82d wasi-common: break dep on system-interface by defining our own Advice enum 2021-01-29 17:03:08 -08:00
Pat Hickey
2e10e621c4 stub virtfs 2021-01-29 17:02:57 -08:00
Pat Hickey
897b4fb8ab wasictxbuilder: assert that stdio is provided 2021-01-29 15:48:55 -08:00
Pat Hickey
b48e7fcc5d integrate with c-api 2021-01-29 14:09:44 -08:00
Pat Hickey
d3ba69d865 wasi-common no longer contains code derived from cloudabi-utils
the original C implementation was derived directly from cloudabi-utils.
that implementation is no longer in tree.

acfoltzer's initial Rust implementation included a path_open function
that was ported from cloudabi-utils. this rewrite of wasi-common has
completely delegated all path lookup functionality to cap-std (in the
cap-std-sync impls), and cap-std itself has a completely re-designed
method of path resolution.
2021-01-29 13:28:13 -08:00
Pat Hickey
11821e5bfd Merge remote-tracking branch 'origin/main' into pch/wasi_common_cap_std 2021-01-29 12:38:13 -08:00
Pat Hickey
e498888732 hook run command up to both wasi snapshots
sharing the same context! at long last
2021-01-29 12:29:30 -08:00
Pat Hickey
d738a4a588 preview 0: copy bodies of read, write, and poll_oneoff from snapshot 1 2021-01-29 12:07:21 -08:00
Pat Hickey
ef2cb7b6b7 nearly have snapshot 0 implemented... 2021-01-28 17:00:31 -08:00
Pat Hickey
9bd89abc0c rename everything c2 related to the "real" names 2021-01-28 15:34:03 -08:00
Pat Hickey
47fec44c10 move wasi-c2 into wasi-common 2021-01-28 15:15:50 -08:00
Pat Hickey
dd005208b6 delete wasi-common, yanix, winx 2021-01-28 15:13:45 -08:00
Pat Hickey
32f162aa78 fix windows flags 2021-01-12 09:51:09 -08:00
Pat Hickey
b53aecb367 Merge branch 'pch/wiggle_flags_bitflags' into pch/wasi_common_cap_std 2021-01-11 18:31:43 -08:00
Pat Hickey
75a9dc7fe2 wasi-common: wiggle flags are now bitflags!
this mostly mechanical change is just getting rid of passing to
`contains` by reference.
2021-01-11 18:27:55 -08:00
Pat Hickey
a900d0431d Merge remote-tracking branch 'origin/main' into pch/wasi_common_cap_std 2021-01-07 16:39:27 -08:00
Nick Fitzgerald
5de5bf1565 Merge pull request #2550 from bytecodealliance/pch/wiggle_trapping
wiggle: introduce Trap enum
2021-01-07 16:23:21 -08:00
Pat Hickey
539058b329 fix windows 2021-01-07 14:57:18 -08:00
Nick Fitzgerald
5ad82de3c5 Bump Wasmtime to 0.22.0; Cranelift to 0.69.0 2021-01-07 14:51:12 -08:00
Pat Hickey
13cd7a4a8e Merge branch 'pch/wiggle_trapping' into pch/wasi_common_cap_std 2021-01-07 14:10:59 -08:00
Pat Hickey
b149a03d5d wasi-common: instead of panicking, use an Error::Unsupported that Traps 2021-01-07 14:05:49 -08:00
Pat Hickey
cd3adb1abd Trap::I32Exit is a better name 2021-01-07 11:45:11 -08:00
Pat Hickey
1dab7c8f94 wasi submodule: noreturn annotations are merged into main 2021-01-07 11:45:11 -08:00
Pat Hickey
4a574c14eb wasi-common: port to use wiggle::Trap 2021-01-07 11:45:11 -08:00
Pat Hickey
1c7c18b026 WASI submodule: mark proc_exit funcs as noreturn in the witx 2021-01-07 11:45:11 -08:00
Pat Hickey
01d74ceb73 Merge remote-tracking branch 'origin/main' into pch/wasi_common_cap_std 2021-01-04 11:19:02 -08:00
Sakarias Johansson
22ad43b430 Add filestat_get for stdout, stdin and stderr
This makes fstat work for stdout, stdin and stderr as expected.
This seemed like the only reasonable functions to implement from the
filestat_* set, for stdout, stdin and stderr.

Fixes #2515
2020-12-16 14:33:42 +01:00
Pat Hickey
b5852bf5ff open_dir can never create a dir 2020-12-15 16:44:03 -08:00
whitequark
fc4eeae896 Alias yanix::file::OFlags::RSYNC to SYNC on Android.
Android defines O_RSYNC to be the same as O_SYNC:

35bb46188c/libc/include/fcntl.h (L57)
2020-12-14 22:03:43 -08:00
whitequark
1ec1834d6e Treat Android like Linux in wasi_common::sys::unix.
Just like it happens in `yanix::sys`.
2020-12-14 22:03:43 -08:00
whitequark
476ee59774 Define local seekdir and telldir prototypes on Android.
These functions are not yet defined in the `libc` crate.
See https://github.com/rust-lang/libc/pull/1996.
2020-12-14 22:03:43 -08:00
whitequark
919600d10b Stub out the utimesat emulation logic on Android.
Android always has `utimensat` available, so it is not necessary (or
possible, for that matter) to emulate it. Mark the fallback path as
`unreachable!()`.
2020-12-14 22:03:43 -08:00
Dan Gohman
88a073eac3 rustfmt 2020-12-11 10:52:54 -08:00
Dan Gohman
c3f0471ff2 Fix the return value from wasi-common's fd_readdir.
`fd_readdir` returns a "bufused" value, which indicates the number of
bytes read into the buffer. WASI libc expects this value to be equal
to the size of the buffer if the end of the directory has not yet
been scanned.

Previously, wasi-common's `fd_readdir` was writing as many complete
entries as it could fit and then stopping, but this meant it was
returning size less than the buffer size even when the directory had
more entries. This patch makes it continue writing up until the end
of the buffer, and return that number of bytes, to let WASI libc
know that there's more to be read.

Fixes #2493.
2020-12-11 10:52:54 -08:00
Alex Crichton
efe7f37542 Remove duplication in wasi-common for snapshot_0 (#2444)
This commit deletes the old `snapshot_0` implementation of wasi-common,
along with the `wig` crate that was used to generate bindings for it.
This then reimplements `snapshot_0` in terms of
`wasi_snapshot_preview1`. There were very few changes between the two
snapshots:

* The `nlink` field of `FileStat` was increased from 32 to 64 bits.
* The `set` field of `whence` was reordered.
* Clock subscriptions in polling dropped their redundant userdata field.

This makes all of the syscalls relatively straightforward to simply
delegate to the next snapshot's implementation. Some trickery happens to
avoid extra cost when dealing with iovecs, but since the memory layout
of iovecs remained the same this should still work.

Now that `snapshot_0` is using wiggle we simply have a trait to
implement, and that's implemented for the same `WasiCtx` that has the
`wasi_snapshot_preview1` trait implemented for it as well. While this
theoretically means that you could share the file descriptor table
between the two snapshots that's not supported in the generated bindings
just yet. A separate `WasiCtx` will be created for each WASI module.
2020-11-30 12:27:49 -06:00
Tanya L. Crenshaw
b06ed39c1e Fixes #2418: Enhance wiggle to generate its UserErrorConverstion trait with a function that returns Result<abi_err, String> (#2419)
* Enhance wiggle to generate its UserErrorConverstion trait with a function that returns
a Result<abi_err, String>.  This enhancement allows hostcall implementations using wiggle
to return an actionable error to the instance (the abi_err) or to terminate the instance
using the String as fatal error information.

* Enhance wiggle to generate its UserErrorConverstion trait with a function that returns
a Result<abi_err, String>.  This enhancement allows hostcall implementations using wiggle
to return an actionable error to the instance (the abi_err) or to terminate the instance
using the String as fatal error information.

* Enhance the wiggle/wasmtime integration to leverage new work in ab7e9c6.  Hostcall
implementations generated by wiggle now return an Result<abi_error, Trap>.  As a
result, hostcalls experiencing fatal errors may trap, thereby terminating the
wasmtime instance.  This enhancement has been performed for both wasi snapshot1
and wasi snapshot0.

* Update wasi-nn crate to reflect enhancement in issue #2418.

* Update wiggle test-helpers for wiggle enhancement made in issue #2418.

* Address PR feedback; omit verbose return statement.

* Address PR feedback; manually format within a proc macro.

* Address PR feedback; manually format proc macro.

* Restore return statements to wasi.rs.

* Restore return statements in funcs.rs.

* Address PR feedback; omit TODO and fix formatting.

* Ok-wrap error type in assert statement.
2020-11-24 14:06:57 -06:00
Pat Hickey
26192d6760 wasi-common: opt in to mutable borrowing 2020-11-18 14:43:47 -08:00
Andrew Brown
c9e8889d47 Update clippy annotation to use latest version (#2375) 2020-11-09 09:24:59 -06:00
Alex Crichton
e4c3fc5cf2 Update immediate and transitive dependencies
I don't think this has happened in awhile but I've run a `cargo update`
as well as trimming some of the duplicate/older dependencies in
`Cargo.lock` by updating some of our immediate dependencies as well.
2020-11-05 08:34:09 -08:00
Alex Crichton
ab1958434a Bump to 0.21.0 (#2359) 2020-11-05 09:39:53 -06:00
Andrew Brown
6ebbab61b9 Update cfg-if dependency 2020-10-23 16:50:51 -07:00
Joshua Warner
eb650f6fe0 filesystem example (#2236) 2020-09-29 13:20:14 -05:00
Joshua Warner
d947010181 Don't implicitly create empty files in VirtualDir::openat (#2235)
* Don't implicitly create empty files in VirtualDir::openat

* Add test

* Add note on how to run test-program tests to the README
2020-09-25 19:52:13 -07:00
Alex Crichton
5e08eb3b83 Bump wasmtime to 0.20.0 (#2222)
At the same time bump cranelift crates to 0.67.0
2020-09-23 13:54:02 -05:00
Pat Hickey
b72d5de86c virtfs: import types from handle, drop types:: prefix 2020-09-14 16:42:20 -07:00
Pat Hickey
4763678be2 sys: import types from handle or sched, not wasi. drop types:: prefix. 2020-09-14 16:42:20 -07:00