Commit Graph

76 Commits

Author SHA1 Message Date
Felix Schütt
fef756412f Update 3.0.0-beta -> 3.0.0-beta.2 2022-09-26 12:20:35 +02:00
Manos Pitsidianakis
c570b1471a Bump version to 3.0.0-beta in Cargo manifests 2022-08-08 19:56:35 +03:00
Manos Pitsidianakis
430a7e2e19 Make serde optional everywhere with enable-serde feature flag 2022-08-02 15:45:28 +03:00
Felix Schütt
9f1845a2d1 Fix clippy lints and "make lint" 2022-07-30 11:31:10 +03:00
Felix Schütt
011d36829a Bump 3.0.0-alpha.3 to 3.0.0-alpha.4 2022-07-30 11:31:08 +03:00
Felix Schütt
1c3ffffe46 Bump 3.0.0-alpha.2 to 3.0.0-alpha.3 2022-07-30 11:30:45 +03:00
Felix Schütt
02ee80cf10 Bump version to 3.0.0-alpha.2 2022-07-30 11:30:07 +03:00
Felix Schütt
6c045bff10 Bump version to 3.0.0-alpha.1 to fix botched compiler crate 2022-07-30 11:29:41 +03:00
Felix Schütt
8959008403 Update version to 3.0.0-alpha 2022-07-30 11:29:05 +03:00
ptitSeb
0cd9dfe3e0 Fixed linter warnings/errors 2022-06-15 19:26:57 +03:00
Johnathan Sharratt
b0709e4153 Implemented multithreading and fixed a number of bugs with WASIX 2022-06-15 19:26:57 +03:00
John Sharratt's Shared Account
7bf6d30459 Added stdin, stdout and stderr methods to WasiState for wasmer consumers
And converted the WASI js test into a generic stdio test that works for
both sys and js versions of wasmer (also fixed the tests)
2022-06-15 19:26:57 +03:00
ptitSeb
3e9de243a5 Fix lint warnings/errors 2022-06-15 19:26:57 +03:00
Johnathan Sharratt
62de9c5aad Implemented functionality needed for WASIX and Networking within Web Assembly
- 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
2022-06-15 19:24:40 +03:00
Johnathan Sharratt
7c532813e7 Multiple changes required to implement the wasmer terminal on the browser
- 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
2022-06-15 12:00:24 +02:00
Manos Pitsidianakis
33654c1a1d Release version 2.3.0 2022-06-06 22:27:57 +03:00
Manos Pitsidianakis
77af8ba634 Fix some clippy lints
Before:
```
% make lint 2>&1 | grep warnings | sort | uniq
error: could not compile `wasmer-cli` due to previous error; 25 warnings emitted
warning: `compiler-test-derive` (lib) generated 8 warnings
warning: `test-generator` (lib) generated 4 warnings
warning: `wasi-test-generator` (bin "wasi-test-generator") generated 8 warnings
warning: `wasmer-cache` (lib) generated 4 warnings
warning: `wasmer-cli` (lib) generated 25 warnings
warning: `wasmer-compiler-cranelift` (lib) generated 50 warnings
warning: `wasmer-compiler-singlepass` (lib) generated 228 warnings
warning: `wasmer-compiler` (lib) generated 3 warnings
warning: `wasmer-emscripten` (lib) generated 182 warnings
warning: `wasmer-engine-dummy` (lib) generated 6 warnings
warning: `wasmer-engine-dylib` (lib) generated 37 warnings
warning: `wasmer-engine-staticlib` (lib) generated 16 warnings
warning: `wasmer-engine-staticlib` (lib) generated 7 warnings
warning: `wasmer-engine-universal` (lib) generated 11 warnings
warning: `wasmer-engine` (lib) generated 15 warnings
warning: `wasmer-object` (lib) generated 5 warnings
warning: `wasmer-types` (lib) generated 31 warnings
warning: `wasmer-vfs` (lib) generated 4 warnings
warning: `wasmer-vm` (lib) generated 40 warnings
warning: `wasmer-wasi-experimental-io-devices` (lib) generated 11 warnings
warning: `wasmer-wasi-types` (lib) generated 3 warnings
warning: `wasmer-wasi` (lib) generated 13 warnings
warning: `wasmer-wast` (lib) generated 11 warnings
warning: `wasmer` (lib) generated 54 warnings
```

After:
```
warning: `wasmer-cli` (lib) generated 16 warnings
warning: `wasmer-compiler-cranelift` (lib) generated 48 warnings
warning: `wasmer-compiler-singlepass` (lib) generated 213 warnings
warning: `wasmer-emscripten` (lib) generated 170 warnings
warning: `wasmer-engine-dummy` (lib) generated 6 warnings
warning: `wasmer-engine-dylib` (lib) generated 4 warnings
warning: `wasmer-engine-staticlib` (lib) generated 14 warnings
warning: `wasmer-engine-staticlib` (lib) generated 5 warnings
warning: `wasmer-engine-universal` (lib) generated 9 warnings
warning: `wasmer-engine` (lib) generated 12 warnings
warning: `wasmer-object` (lib) generated 3 warnings
warning: `wasmer-types` (lib) generated 7 warnings
warning: `wasmer-vm` (lib) generated 36 warnings
warning: `wasmer-wasi-experimental-io-devices` (lib) generated 6 warnings
warning: `wasmer-wasi-types` (lib) generated 3 warnings
warning: `wasmer-wasi` (lib) generated 9 warnings
warning: `wasmer-wast` (lib) generated 9 warnings
warning: `wasmer` (lib) generated 42 warnings
```
2022-04-20 18:25:04 +03:00
bors[bot]
fc794ab4e3 Merge #2807
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 #2757
Fixes #2562


Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2022-03-16 13:24:50 +00:00
Amanieu d'Antras
fe9d2d8d22 Release version 2.2.1 2022-03-15 11:02:31 +00:00
Amanieu d'Antras
83fd79057e Fix unused field lint 2022-03-14 22:14:22 +00:00
Amanieu d'Antras
4dd1634218 Release version 2.2.0 2022-02-28 17:19:14 +00:00
Amanieu d'Antras
15f9d2646f Release version 2.2.0-rc1 2022-02-15 19:10:24 +00:00
Amanieu d'Antras
4e27e1164c Release version 2.2.0-rc1 2022-01-27 23:59:27 +00:00
Amanieu d'Antras
ebcea4a5c4 Release v2.1.1 2021-12-21 12:19:50 +01:00
Amanieu d'Antras
c650ffea33 Version 2.1.0 2021-11-30 23:46:54 +00:00
Syrus Akbary
65ee1c95a9 Improvements to the FS API 2021-11-30 20:50:01 +01:00
Benjamin Coenen
e0e12f9d9f feat(wasi): add rename for a directory + fix remove_dir
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2021-09-07 13:55:24 +02:00
Benjamin Coenen
08580b5331 wip
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2021-09-06 13:55:31 +02:00
bors[bot]
d07997e337 Merge #2551
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>
2021-09-03 08:39:02 +00:00
Ivan Enderlin
3d27db87d1 feat(vfs) Add test cases for mem_fs::FileSystem::rename.
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.
2021-09-03 10:26:17 +02:00
Ivan Enderlin
af6dc307e9 feat(vfs) Add ability to rename a file with mem_fs. 2021-09-02 16:33:03 +02:00
Ivan Enderlin
9581dec15f feat(vfs) Update Metadata.len when updating the file buffer. 2021-09-02 15:56:50 +02:00
Ivan Enderlin
8d202682a7 fix(vfs) Opening in append-mode must ignore seek operations.
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.
2021-08-31 15:08:46 +02:00
Ivan Enderlin
87558a9b0e feat(vfs) mem-fs does not support enable-serde. 2021-08-30 17:32:47 +02:00
Ivan Enderlin
bb47a47f27 chore(vfs) Remove Clippy warnings. 2021-08-30 16:01:05 +02:00
Ivan Enderlin
d0a95ac81b fix(vfs) Fix 4f5908392. 2021-08-30 15:56:54 +02:00
Ivan Enderlin
e0a18a38cf fix(vfs) Better handle path canonicalization on Windows.
`C:\` is considered as a root, but we expect it to fail because we
don't accept such path as valid for the moment.
2021-08-30 15:37:21 +02:00
Ivan Enderlin
dac47a8dcc fix(vfs) Fix inode_of on Windows.
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.
2021-08-30 15:03:13 +02:00
Ivan Enderlin
4f59083925 fix(vfs) Remove a Clippy error. 2021-08-30 12:12:08 +02:00
Ivan Enderlin
ac95425a97 test(vfs) Turn on host-fs _and_ mem-fs on by default. 2021-08-30 11:31:04 +02:00
Ivan Enderlin
0613f87c95 fix(vfs) Metadata returns 0 for accessed & co times on error. 2021-08-30 10:40:37 +02:00
Ivan Enderlin
2df47f6272 fix(vfs) Correct support of Windows for FileDescriptor. 2021-08-27 15:46:15 +02:00
Ivan Enderlin
bea626bd4f fix(vfs) Add the no-time feature if std::time is not available. 2021-08-27 14:56:30 +02:00
Ivan Enderlin
31f5c1a9a9 fix(vfs) Fix a type error on Windows. 2021-08-27 14:35:52 +02:00
Ivan Enderlin
047256f937 feat(vfs) Continue the rewrite of the in-memory filesystem. 2021-08-27 14:34:44 +02:00
Ivan Enderlin
9e6a427449 feat(vfs) Continue the rewrite of the in-memory filesystem. 2021-08-27 14:34:19 +02:00
Ivan Enderlin
e617937089 feat(vfs) Rewrite the in-memory filesystem.
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.
2021-08-27 14:20:04 +02:00
Ivan Enderlin
743e302401 test(vfs) Add test cases for mem_fs::FileSystem::remove_dir. 2021-08-19 12:48:23 +02:00
Ivan Enderlin
56d2cf05e0 fix(vfs) Do not unwrap in remove_dir.
In 2 cases:

1. When the path has a parent that doesn't exist,
2. When the directory doesn't exist.
2021-08-17 16:01:25 +02:00
Ivan Enderlin
3017a37532 test(vfs) Add tests for FileSystem::craete_dir. 2021-08-17 15:57:12 +02:00