Commit Graph

33 Commits

Author SHA1 Message Date
Marcin Mielniczuk
8d7e80f440 Refactor error handling in fd_advise 2019-09-13 14:38:17 +02:00
Marcin Mielniczuk
86e3d3e307 Fix a typo in fd_advise 2019-09-13 14:38:17 +02:00
Marcin Mielniczuk
f07392c175 Quick fix for path_filestat_set_times. Closes #95. 2019-09-11 15:01:01 -07:00
Dan Gohman
09ace35295 Clippy: use ptr::add rather than ptr::offset. 2019-09-09 18:07:39 +02:00
Marcin Mielniczuk
3fd0cdcc12 Cleanup 2019-09-09 11:26:06 +02:00
Marcin Mielniczuk
b09f7e860f Refactor try_from and try_into error handing. 2019-09-09 11:26:06 +02:00
Marcin Mielniczuk
14aaffd46f Initial error refactor 2019-09-09 11:26:06 +02:00
Marcin Mielniczuk
85a41d449c Treat FIFOs' type as __WASI_FILETYPE_UNKNOWN. 2019-09-06 20:38:50 -07:00
Marcin Mielniczuk
947eb1fb53 Move fd_advise on Linux to nix 2019-08-30 15:53:07 +02:00
Jakub Konka
3609a82dc9 Fix incorrect fd_readdir behaviour
* when executed twice in a row, need to manually reset the stream
  by calling seekdir with __WASI_DIRCOOKIE_START, if __WASI_DIRCOOKIE_START
  was specified
* fix mapping between d_type and __wasi_filetype_t
* include minor refactor - removes use of wasm32 module on the
  host's side
2019-08-28 22:01:24 +02:00
Marcin Mielniczuk
d617fe67ad Check for socket type in filetype.
The signature for Windows has also been changed, so that the function
can be reused in cross-platform modules.
2019-08-26 15:49:48 +02:00
Marcin Mielniczuk
9950bddee5 Use safe casts in path_filestat_set_times on unix. 2019-08-23 13:02:21 +02:00
Marcin Mielniczuk
065fbea252 Implement path_filestat_set_times using nix instead of libc.
As advised in #16.
2019-08-20 17:28:25 +02:00
Jakub Konka
5c7373959c Fix linter warnings 2019-08-13 21:34:35 +02:00
Marcin Mielniczuk
2f1afc4846 Implement fd_filestat_set_times using the filetime crate. 2019-08-13 21:34:35 +02:00
Marcin Mielniczuk
e731965fbb Implement fd_filestat_set_size using libstd 2019-08-08 18:41:41 +02:00
Marcin Mielniczuk
92c2b563fc Reuse errno_from_ioerror to simplify error handling 2019-08-08 18:22:58 +02:00
Jakub Konka
e18175c556 path_get refactor and implementation of missing path_ hostcalls on Windows (#41)
* Move path_get outside of sys module

* Add implementation of readlinkat

* Clean up path_open; use OpenOptions as much as possible

* Enable close_preopen test

* Implement path_create_directory; fix path_open

* Refactor path concatenation onto a descriptor

* Implement path_remove_directory

* Implement path_unlink_file

* Rewrite path_open using specific access mask

* Fix error mapping when unlinking file

* Fix readlinkat to pass nofollow_errors testcase

* Clean up winerror to WASI conversion

* Spoof creating dangling symlinks on windows (hacky!)

* Add positive testcase for readlink

* Implement path_readlink (for nonzero buffers for now)

* Clean up

* Add Symlink struct immitating *nix symlink

* Fix path_readlink

* Augment interesting_paths testcase with trailing slashes example

* Encapsulate path_get return value as PathGet struct

* Remove dangling symlink emulation

* Extract dangling symlinks into its own testcase

This way, we can re-enable nofollow_errors testcase
on Windows also.

* Return __WASI_ENOTCAPABLE if user lacks perms to symlink
2019-08-08 17:06:01 +02:00
Marcin Mielniczuk
89fbde2c3f Implement fd_filestat_get for all platforms (#42)
* Implement fd_filestat_get for all platforms

* Remove an old comment

* Remove panics from the syscall wrappers

* Return WASI error type

* Reuse Metadata if possible to save syscalls.

* Refactor the change for two separate fd_filestat_get_impl

* Refactor error handling
2019-07-26 19:15:29 +02:00
Jakub Konka
86ae6e3df4 Refactor hostcalls_impl in sys module 2019-07-23 15:02:23 -07:00
Jakub Konka
919262b5b9 Make fd_tell host independent 2019-07-22 16:05:30 -07:00
Jakub Konka
5bbf59e1c5 Make fd_seek host independent 2019-07-22 16:05:30 -07:00
Jakub Konka
0d571a4e6d Move extracting fds from context into hostcalls 2019-07-22 15:56:46 -07:00
Jakub Konka
14391bab56 Clean up more hostcalls 2019-07-22 15:56:46 -07:00
Jakub Konka
13823e2b39 Clean up fd_renumber 2019-07-22 15:56:46 -07:00
Jakub Konka
310ecb5b5b Create helper Result<T> type 2019-07-22 15:56:46 -07:00
Jakub Konka
08aa61f066 WASI paths as &str and String (#37)
* Check if RawString operates on valid encodings

* Use &str and String for WASI paths
2019-07-19 11:09:27 -07: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
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