- Introduced the virtual BUS interface used for RPC between web assembly apps
- Introduced the virtual networking interface used to implement networking
for web assembly apps
- Implemented a local implementation of the virtual networking
(available behind the feature toggle 'host-net' on the 'wasi' package)
- Fixed up some of the examples from the wasmer3 branch
- Refactored the WASI implementations so they support wasm64-wasi
- WASIX is behind its own namespaces for both 32bit and 64bit implementations
- Fixed the wasi_pipes unit test which was using internals that are no longer exposed - instead made the pipes clonable
- Split functionality out of WasiEnv so that it can support multi-threading
- Added methods to the VFS File Trait that supporting polling
- Implemented basic time functionality for WASI
- Incorported a yield callback for when WASI processes idle
- Improved the error handling on WASI IO calls
- Reduce the verbose logging on some critical WASI calls (write/read)
- Implemented the missing poll functionality for WASI processes
- Moved the syspoll functionality behind a feature flag to default to WASI method
- Refactored the thread sleeping functionality for WASI processes
- Fixed the files system benchmark which was not compiling
- Modified the file system trait so that it is SYNC and thus can handle multiple threads
- Removed the large mutex around filesystem state and implemented granular locks instead
(this is needed to fix a deadlock scenario on the terminal)
- Split the inodes object apart from the state to fix the deadlock scenario.
- Few minor fixes to some warnings when not using certain features
- Sleeping will now call a callback that can be used by the runtime operator when
a WASI thread goes to sleep (for instance to do other work)
- Fixed a bug where paths that exist on the real file system are leaking into VFS
- Timing functions now properly return a time precision on WASI
- Some improved macros for error handling within syscalls (wasi_try_ok!)
- Refactored the remove_directory WASI function which was not working properly
- Refactored the unlink WASI function which was not working properly
- Refactored the poll WASI function which was not working properly
- Updates some of the tests to make them compile again
- Rewrote the OutputCapturer so that it does leak into the internals
2807: Run Wasm code on a separate stack r=Amanieu a=Amanieu
This uses the [corosensei](https://crates.io/crates/corosensei) crate to
run Wasm code on a separate stack from the main thread stack.
In trap handlers for stack overflows and memory out of bounds accesses,
we can now check whether we are executing on the Wasm stack and reset
execution back to the main thread stack when returning from the trap
handler.
When Wasm code needs to perform an operation which may modify internal
data structures (e.g. growing a memory) then execution must switch back
to the main thread stack using on_host_stack. This is necessary to avoid
leaving internal data structure in an inconsistent state when a stack
overflow happens.
In the future, this can also be used to suspend execution of a Wasm
module (#1127) by modeling it as an async function call.
Fixes#2757Fixes#2562
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2551: feat(vfs) Add ability to rename a file with `mem_fs` r=Hywan a=Hywan
# Description
This patch updates `wasmer_vfs::mem_fs::FileSystem::rename` to handle file. Directories were handle previously, but not file.
~~Tests must be added though.~~
It solves the last bits of https://github.com/wasmerio/wasmer/pull/2546.
Co-authored-by: Ivan Enderlin <ivan@mnt.io>
This patch adds test cases for renaming a file or a directory, and for
renaming + moving. That's different because this patch also implements
a shortcut when a file or directory is simply renamed, we don't need
to update the parent's children, only the modified time.
When opening a file with the `append` option turned on, all `seek`
operations must be ignored. As described by
[`open(2)`](https://man7.org/linux/man-pages/man2/open.2.html), the
`O_APPEND` option describes this behavior well:
> Before each write(2), the file offset is positioned at
> the end of the file, as if with lseek(2). The
> modification of the file offset and the write operation
> are performed as a single atomic step.
>
> O_APPEND may lead to corrupted files on NFS filesystems
> if more than one process appends data to a file at once.
> This is because NFS does not support appending to a file,
> so the client kernel has to simulate it, which can't be
> done without a race condition.
This patch implements that behavior.
Also, this patch rewind the file cursor if opened in read-mode.
Calling `as_os_str` on `Component::RootDir` returns `\\`, while we
expect `/` on Unix. A better way is to pattern match against
`Component::RootDir` instead of comparing the `OsStr` in this case.
The initial in-memory filesystem, aka `mem_fs`, suffered from several
design issues: dead-locks, data duplications, non-optimal look
up/insertions/deletions algorithms, many unimplemented API etc. This
commit is the first step for the rewrite of `mem_fs` to adopt a new
design.
The new design is closer to `ext4` philosophy. A filesystem is a slab
(think an optimised memory allocations vector,
https://en.wikipedia.org/wiki/Slab_allocation) where indexes represent
inodes, and values are of kind `Node`.
A `Node` is now no longer directly recursive (it's indirectly recursive):
```rust
enum Node {
File { … },
Directory { children: Vec<Inode>, … },
}
```
To represent children, a node directory doesn't contain `Node` but
`Inode`. To traverse directories, we must jump from the filesystem'
slab, to the node, to the filesystem' slab etc. This design allows
very quick insertions and deletions (it's a O(1) operation, just
insert in the slab and update the parent's children). It also allows
to traverse the filesystem much quicker because we don't need to
traverse all the nodes, only the children of the currently traversed
directory, which reduces the iterations dramatically.
Apart from this new design, the code is adapted largely, with no
`unwrap`, more error handlings, no more `unimplemented!()`s or
`todo!()`s etc.
Some implementations were also wrong, like:
* Reading from `Stdin` never moved an internal cursor, so the user was
reading the same data again and again.
* It was possible to read from or to write into a file that doesn't
have the appropriate permissions (e.g. writing into a file with
read-only permissions),
* The `append` and `truncate` flags on files weren't supported,
* No path canonicalization,
* and so on.