Commit Graph

75 Commits

Author SHA1 Message Date
Jakub Konka
c3994bf57b Use Travis for Win builds as well 2019-07-16 08:41:20 +02:00
Jakub Konka
667f272edd Rewrite majority of impl reusing libstd (#34)
* Rewrite FdEntry reusing as much libstd as possible

* Use the new FdEntry, FdObject, Descriptor struct in *nix impl

* Adapt Windows impl

* Remove unnecessary check in fd_read

Check `host_nread == 0` caused premature FdEntry closure and removal
which ultimately was resulting in an attempt at "double closing" of
the same file descriptor at the end of the Wasm program:
...
fd_close(fd=4)
    -> errno=WASI_ESUCCESS
fd_close(fd=4)
    -> errno=WASI_EBADF

* Use libstd vectored IO

* Use std:🧵:yield_now to implement sched_yield

* Add logging to integration tests

* Add preliminary support for host-specific errors

* Operate on std::fs::File in path_get on *nix

* Add cross-platform RawString type encapsulating OsStrExt

* Fix Windows build

* Update Travis and README to Rust v1.36

* Remove unused winx::handle::close helper

* Refactor Descriptor into raw handles/fds

* Strip readlinkat in prep for path_get host-independent

* Strip openat in prep for path_get host-independent

* Move ManuallyDrop up one level from Descriptor to FdObject

* Make (c)iovec host fns unsafe

* Swap unwraps/expects for Results in fdentry_impl on nix

* Rewrite fd_pread/write and implement for Win

* Use File::sync_all to impl fd_sync

* Use File::sync_data to impl fd_datasync

* Rewind file cursor after fd_p{read, write} on Windows

* Add fd_p{read, write} tests

* Handle errors instead of panicking in path_get

* Use File::set_len to impl fd_allocate

* Add test for fd_allocate

* Replace all panics with Results

* Document the point of RawString
2019-07-15 15:34:28 -07:00
Jakub Konka
93e1657bae Update cranelift 2019-07-05 16:51:54 +02:00
Jakub Konka
b4280d6cd6 Use ManuallyDrop instead of forget 2019-07-02 12:52:27 -07:00
Jakub Konka
7287767a3f Add enough Windows functionality to run WASI tutorial (#22)
* Add partial impl of determine_type_rights fn

* Add draft of fd_fdstat_get hostcall

* Add writev wrapper for writing IoVec in RawHandle

* Move IoVec and writev to separate helper crate

* Add Win error handling

Clean up closing and duplicating RawHandle

* Wrap Win file type result

* Add draft impl of fd_close and fd_read

* Refactor getting file access rights

* Remove winapi from the main Cargo.toml

* Add very rough draft of open_path (very incomplete)

* Clean up WinError with macro

* Ignore dir handle in openat if path absolute

* Decode oflags and advance open_path hostcall

* Clean up AccessRight and FlagsAndAttributes flags

* Implement path_get (without symlink expansion yet!)

* Add ShareMode and fix path_get for nested paths

* Add some error mappings between Win and WASI

* Clean up fdflags conversions

* Fix sharing violation when calling openat at '.'

* Apply Alex's fix of using ManuallyDrop instead forget

* Clean up

* Explicitly specify workspace to avoid comp errors at tests
2019-06-27 17:10:15 -07:00
Jakub Konka
22c69f46f9 Use build.rs to generate test cases automatically
Now, test binaries are bundled with the repo, and
just like in CraneStation/wasmtime, the test cases
are generated automatically using build.rs. So all
it takes is to drop a new test binary in the
testsuite dir to get the test case for it generated
(with some caveats to do with handling preopens).
2019-06-26 15:24:21 -07:00
Jakub Konka
656112d00b Patch wasmtime-wasi to use this wasi-common version 2019-06-26 15:24:21 -07:00
Jakub Konka
81b673f908 Fix typos 2019-06-26 15:24:21 -07:00
Jakub Konka
b9c04d431f Move workspace creation outside of runtime instantiation 2019-06-26 15:24:21 -07:00
Jakub Konka
d0eac815f0 Fix Windows CI 2019-06-26 15:24:21 -07:00
Jakub Konka
ae63b33a23 Refactor 2019-06-26 15:24:21 -07:00
Jakub Konka
20d228f29e Modify test-all.sh script 2019-06-26 15:24:21 -07:00
Jakub Konka
982dbab1f2 Add misc-tests as a submodule dep 2019-06-26 15:24:21 -07:00
Jakub Konka
6ca01ce546 Add wasmtime as default runtime for integration tests 2019-06-26 15:24:21 -07:00
Jakub Konka
513429f1b8 Port trace log from wasmtime-wasi-c crate 2019-06-24 22:47:41 +02:00
Jakub Konka
dc05d89a08 Fix path_readlink: with a 0-sized buffer should succeed 2019-06-24 11:54:18 -07:00
Jakub Konka
7fef91c1e4 Fix fd_renumber when trying to renumber a preopen 2019-06-24 11:54:18 -07:00
Jakub Konka
a11f2b1d3a Refactor path_get and fix flags in path_open 2019-06-24 11:54:18 -07:00
Jakub Konka
b35719fe4a Add fixes so that misc-tests pass 2019-06-24 11:54:18 -07:00
Jakub Konka
54a897cf91 Move common functionality into hostcalls mod 2019-06-18 06:00:22 -07:00
Jakub Konka
c113ff32e6 Move preopen_dir handlers from wasmtime to wasi-common 2019-06-17 02:40:42 -07:00
Dan Gohman
9a66400cd8 Use try_from instead of the cast crate.
`try_from` is newly stable in the standard library starting in Rust 1.34.
2019-05-31 21:09:43 +02:00
Jakub Konka
51fc39e0e6 Backport path_get fix discovered in Win branch 2019-05-31 20:32:42 +02:00
Jakub Konka
0143ed548d Update README 2019-05-24 11:02:03 -07:00
Jakub Konka
b1764e18eb Add appveyor for automated Win testing 2019-05-24 11:02:03 -07:00
Jakub Konka
9ae766db2f Add convenience batch script for Win 2019-05-24 11:02:03 -07:00
Jakub Konka
c3ff3cf075 Add template for Windows impl 2019-05-24 11:02:03 -07:00
Jakub Konka
7605584691 Move *nix specific implementation to separate module 2019-05-24 11:02:03 -07:00
Dan Gohman
3372e47e5a Fix fd_fdstat_set_rights to set the rights.
After checking that no new rights are being added, actually set the
rights, which may be a subset of the original rights.
2019-05-20 10:22:07 +02:00
Dan Gohman
c5bda1f4e1 Fix symlink resolution on Linux and FreeBSD.
Linux's open returns ENOTDIR when used with O_DIRECTORY|O_NOFOLLOW and
the path is a symlink. Update the code to expect this.

FreeBSD's open returns EMLINK instead of ELOOP when using O_NOFOLLOW on
symlink. Update the code to expect this.
2019-05-20 10:22:07 +02:00
Dan Gohman
9823bf6196 Change path_open to not create files with execute privleges.
WASI currently lacks the ability to specify the full UNIX access control
information when creating files and directories, so for now just avoid
creating executable files and rely on the umask.
2019-05-20 10:22:07 +02:00
Dan Gohman
32da43f600 Handle set-size rights correctly when truncating a file.
If a path_open call is requesting __WASI_RIGHT_FD_FILESTAT_SET_SIZE,
interpret that as a request for write privleges. If it is requesting
O_TRUNC, require __WASI_RIGHT_PATH_FILESTAT_SET_SIZE, since this is
a path operation rather than a FD operation.
2019-05-20 10:22:07 +02:00
Dan Gohman
d20d787bb7 Don't grant __WASI_RIGHT_FD_FILESTAT_SET_SIZE for directories.
RIGHTS_DIRECTORY_BASE should not include
__WASI_RIGHT_FD_FILESTAT_SET_SIZE, because that would imply the ability
to set the size of a directory.
2019-05-20 10:22:07 +02:00
Jakub Konka
f95af95d87 Update README 2019-05-18 15:43:58 -07:00
Jakub Konka
14ba585edf Reorganise hostcalls into submodules 2019-05-18 15:43:58 -07:00
Jakub Konka
b9871648b2 Import all changes from lucet-wasi 2019-05-18 15:43:58 -07:00
Jakub Konka
bbdaf7b686 Re-enable cargo cache in travis ci 2019-05-16 06:10:23 -07:00
Jakub Konka
5ff4f57f97 Disable cargo cache in travis ci temporarily 2019-05-15 13:57:06 -07:00
Jakub Konka
5aa598520c Rename C prefix from __wasi to wasi_common_ 2019-05-15 13:57:06 -07:00
Jakub Konka
52eda1498a Correctly unpack &mut [T] into *mut T and usize 2019-05-15 13:57:06 -07:00
Jakub Konka
006198eb92 Generate C bindings for all hostcalls 2019-05-15 13:57:06 -07:00
Jakub Konka
9ad16cc702 Add sanity tests 2019-05-15 13:57:06 -07:00
Jakub Konka
7f3c325cdf Dereference pointers and call the hostcall fn 2019-05-15 13:57:06 -07:00
Jakub Konka
4a5910b4a3 Capture correct return type 2019-05-15 13:57:06 -07:00
Jakub Konka
7791166859 Generate C fn name prefixed with __wasi_ 2019-05-15 13:57:06 -07:00
Jakub Konka
e552b19dfe Add placeholder for cbindgen proc_macro_attribute 2019-05-15 13:57:06 -07:00
Dan Gohman
eb1cf8b0a1 Make users of dec_slice_of safe.
Make `dec_slice_of` return a slice rather than a pointer-length pair,
freeing its users from having to call the unsafe `slice::from_raw_parts`.

This requires splitting `dec_slice_of` and `dec_ptr` into mut and
non-mut versions, and reorganizing poll_oneoff a little to avoid
borrow-checker errors -- decoded slices do alias the main memory, so
make sure functions only need one or the other.
2019-05-14 16:14:22 -07:00
Jakub Konka
8a68375f89 Move TODO about proc_exit from wasmtime 2019-05-14 06:17:35 -07:00
Jakub Konka
8b09f321ac Make memory fns safe wherever possible 2019-05-13 14:27:56 -07:00
Dan Gohman
251504e8a7 Merge pull request #11 from CraneStation/docs
Clean up docs; specify minimum Rust version
2019-05-13 13:28:40 -07:00