mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-24 14:11:32 +00:00
Merge branch 'master' into ctx-drop-finalizer
This commit is contained in:
12
CHANGELOG.md
12
CHANGELOG.md
@ -5,6 +5,18 @@ All PRs to the Wasmer repository must add to this file.
|
||||
Blocks of changes will separated by version increments.
|
||||
|
||||
## **[Unreleased]**
|
||||
- [#555](https://github.com/wasmerio/wasmer/pull/555) WASI filesystem rewrite. Major improvements
|
||||
- adds virtual root showing all preopened directories
|
||||
- improved sandboxing and code-reuse
|
||||
- symlinks work in a lot more situations
|
||||
- many various improvements to most syscalls touching the filesystem
|
||||
|
||||
## 0.5.6
|
||||
- [#565](https://github.com/wasmerio/wasmer/pull/565) Update wapm and bump version to 0.5.6
|
||||
- [#563](https://github.com/wasmerio/wasmer/pull/563) Improve wasi testing infrastructure
|
||||
- fixes arg parsing from comments & fixes the mapdir test to have the native code doing the same thing as the WASI code
|
||||
- makes wasitests-generate output stdout/stderr by default & adds function to print stdout and stderr for a command if it fails
|
||||
- compiles wasm with size optimizations & strips generated wasm with wasm-strip
|
||||
- [#554](https://github.com/wasmerio/wasmer/pull/554) Finish implementation of `wasi::fd_seek`, fix bug in filestat
|
||||
|
||||
## 0.5.5
|
||||
|
120
Cargo.lock
generated
120
Cargo.lock
generated
@ -1377,7 +1377,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmer"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
dependencies = [
|
||||
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1386,23 +1386,23 @@ dependencies = [
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"structopt 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmer-clif-backend 0.5.5",
|
||||
"wasmer-dev-utils 0.5.5",
|
||||
"wasmer-emscripten 0.5.5",
|
||||
"wasmer-emscripten-tests 0.5.5",
|
||||
"wasmer-clif-backend 0.5.6",
|
||||
"wasmer-dev-utils 0.5.6",
|
||||
"wasmer-emscripten 0.5.6",
|
||||
"wasmer-emscripten-tests 0.5.6",
|
||||
"wasmer-kernel-loader 0.1.0",
|
||||
"wasmer-llvm-backend 0.5.5",
|
||||
"wasmer-middleware-common 0.5.5",
|
||||
"wasmer-runtime 0.5.5",
|
||||
"wasmer-runtime-core 0.5.5",
|
||||
"wasmer-singlepass-backend 0.5.5",
|
||||
"wasmer-wasi 0.5.5",
|
||||
"wasmer-wasi-tests 0.5.5",
|
||||
"wasmer-llvm-backend 0.5.6",
|
||||
"wasmer-middleware-common 0.5.6",
|
||||
"wasmer-runtime 0.5.6",
|
||||
"wasmer-runtime-core 0.5.6",
|
||||
"wasmer-singlepass-backend 0.5.6",
|
||||
"wasmer-wasi 0.5.6",
|
||||
"wasmer-wasi-tests 0.5.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-clif-backend"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
dependencies = [
|
||||
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cranelift-codegen 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1419,8 +1419,8 @@ dependencies = [
|
||||
"target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmer-clif-fork-frontend 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmer-clif-fork-wasm 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmer-runtime-core 0.5.5",
|
||||
"wasmer-win-exception-handler 0.5.5",
|
||||
"wasmer-runtime-core 0.5.6",
|
||||
"wasmer-win-exception-handler 0.5.6",
|
||||
"wasmparser 0.32.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
@ -1451,14 +1451,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-dev-utils"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
dependencies = [
|
||||
"libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-emscripten"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
dependencies = [
|
||||
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1466,21 +1466,21 @@ dependencies = [
|
||||
"libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmer-runtime-core 0.5.5",
|
||||
"wasmer-runtime-core 0.5.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-emscripten-tests"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
dependencies = [
|
||||
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmer-clif-backend 0.5.5",
|
||||
"wasmer-dev-utils 0.5.5",
|
||||
"wasmer-emscripten 0.5.5",
|
||||
"wasmer-llvm-backend 0.5.5",
|
||||
"wasmer-runtime-core 0.5.5",
|
||||
"wasmer-singlepass-backend 0.5.5",
|
||||
"wasmer-clif-backend 0.5.6",
|
||||
"wasmer-dev-utils 0.5.6",
|
||||
"wasmer-emscripten 0.5.6",
|
||||
"wasmer-llvm-backend 0.5.6",
|
||||
"wasmer-runtime-core 0.5.6",
|
||||
"wasmer-singlepass-backend 0.5.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1488,12 +1488,12 @@ name = "wasmer-kernel-loader"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmer-runtime-core 0.5.5",
|
||||
"wasmer-runtime-core 0.5.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-llvm-backend"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
dependencies = [
|
||||
"capstone 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1508,50 +1508,50 @@ dependencies = [
|
||||
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmer-runtime-core 0.5.5",
|
||||
"wasmer-runtime-core 0.5.6",
|
||||
"wasmparser 0.32.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-middleware-common"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
dependencies = [
|
||||
"criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmer-clif-backend 0.5.5",
|
||||
"wasmer-llvm-backend 0.5.5",
|
||||
"wasmer-runtime-core 0.5.5",
|
||||
"wasmer-singlepass-backend 0.5.5",
|
||||
"wasmer-clif-backend 0.5.6",
|
||||
"wasmer-llvm-backend 0.5.6",
|
||||
"wasmer-runtime-core 0.5.6",
|
||||
"wasmer-singlepass-backend 0.5.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-runtime"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
dependencies = [
|
||||
"criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmer-clif-backend 0.5.5",
|
||||
"wasmer-llvm-backend 0.5.5",
|
||||
"wasmer-runtime-core 0.5.5",
|
||||
"wasmer-singlepass-backend 0.5.5",
|
||||
"wasmer-clif-backend 0.5.6",
|
||||
"wasmer-llvm-backend 0.5.6",
|
||||
"wasmer-runtime-core 0.5.6",
|
||||
"wasmer-singlepass-backend 0.5.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-runtime-c-api"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
dependencies = [
|
||||
"cbindgen 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmer-runtime 0.5.5",
|
||||
"wasmer-runtime-core 0.5.5",
|
||||
"wasmer-runtime 0.5.6",
|
||||
"wasmer-runtime-core 0.5.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-runtime-core"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
dependencies = [
|
||||
"bincode 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"blake2b_simd 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1580,7 +1580,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-singlepass-backend"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
dependencies = [
|
||||
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"colored 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1591,24 +1591,24 @@ dependencies = [
|
||||
"libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmer-runtime-core 0.5.5",
|
||||
"wasmer-runtime-core 0.5.6",
|
||||
"wasmparser 0.32.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-spectests"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
dependencies = [
|
||||
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmer-clif-backend 0.5.5",
|
||||
"wasmer-llvm-backend 0.5.5",
|
||||
"wasmer-runtime-core 0.5.5",
|
||||
"wasmer-singlepass-backend 0.5.5",
|
||||
"wasmer-clif-backend 0.5.6",
|
||||
"wasmer-llvm-backend 0.5.6",
|
||||
"wasmer-runtime-core 0.5.6",
|
||||
"wasmer-singlepass-backend 0.5.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-wasi"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
dependencies = [
|
||||
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"generational-arena 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1616,32 +1616,32 @@ dependencies = [
|
||||
"libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmer-runtime-core 0.5.5",
|
||||
"wasmer-runtime-core 0.5.6",
|
||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-wasi-tests"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
dependencies = [
|
||||
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmer-clif-backend 0.5.5",
|
||||
"wasmer-dev-utils 0.5.5",
|
||||
"wasmer-llvm-backend 0.5.5",
|
||||
"wasmer-runtime-core 0.5.5",
|
||||
"wasmer-singlepass-backend 0.5.5",
|
||||
"wasmer-wasi 0.5.5",
|
||||
"wasmer-clif-backend 0.5.6",
|
||||
"wasmer-dev-utils 0.5.6",
|
||||
"wasmer-llvm-backend 0.5.6",
|
||||
"wasmer-runtime-core 0.5.6",
|
||||
"wasmer-singlepass-backend 0.5.6",
|
||||
"wasmer-wasi 0.5.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-win-exception-handler"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
dependencies = [
|
||||
"bindgen 0.46.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cmake 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmer-runtime-core 0.5.5",
|
||||
"wasmer-runtime-core 0.5.6",
|
||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wasmer"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
edition = "2018"
|
||||
repository = "https://github.com/wasmerio/wasmer"
|
||||
|
8
Makefile
8
Makefile
@ -8,7 +8,13 @@ generate-emtests:
|
||||
WASM_EMSCRIPTEN_GENERATE_EMTESTS=1 cargo build -p wasmer-emscripten-tests --release
|
||||
|
||||
generate-wasitests:
|
||||
WASM_WASI_GENERATE_WASITESTS=1 cargo build -p wasmer-wasi-tests --release
|
||||
WASM_WASI_GENERATE_WASITESTS=1 cargo build -p wasmer-wasi-tests --release -vv \
|
||||
&& echo "formatting" \
|
||||
&& cargo fmt
|
||||
|
||||
spectests-generate: generate-spectests
|
||||
emtests-generate: generate-emtests
|
||||
wasitests-generate: generate-wasitests
|
||||
|
||||
generate: generate-spectests generate-emtests generate-wasitests
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wasmer-clif-backend"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
description = "Wasmer runtime Cranelift compiler backend"
|
||||
license = "MIT"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
@ -8,7 +8,7 @@ repository = "https://github.com/wasmerio/wasmer"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.5" }
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.6" }
|
||||
cranelift-native = { version = "0.31" }
|
||||
cranelift-codegen = { version = "0.31" }
|
||||
cranelift-entity = { version = "0.31" }
|
||||
@ -34,7 +34,7 @@ version = "0.0.7"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = { version = "0.3", features = ["errhandlingapi", "minwindef", "minwinbase", "winnt"] }
|
||||
wasmer-win-exception-handler = { path = "../win-exception-handler", version = "0.5.5" }
|
||||
wasmer-win-exception-handler = { path = "../win-exception-handler", version = "0.5.6" }
|
||||
|
||||
[features]
|
||||
debug = ["wasmer-runtime-core/debug"]
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wasmer-dev-utils"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
description = "Wasmer runtime core library"
|
||||
license = "MIT"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wasmer-emscripten-tests"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
description = "Tests for our Emscripten implementation"
|
||||
license = "MIT"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
@ -9,15 +9,15 @@ publish = false
|
||||
build = "build/mod.rs"
|
||||
|
||||
[dependencies]
|
||||
wasmer-emscripten = { path = "../emscripten", version = "0.5.5" }
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.5" }
|
||||
wasmer-clif-backend = { path = "../clif-backend", version = "0.5.5" }
|
||||
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.5.5", optional = true }
|
||||
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.5", optional = true }
|
||||
wasmer-emscripten = { path = "../emscripten", version = "0.5.6" }
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.6" }
|
||||
wasmer-clif-backend = { path = "../clif-backend", version = "0.5.6" }
|
||||
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.5.6", optional = true }
|
||||
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.6", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
wabt = "0.7.2"
|
||||
wasmer-dev-utils = { path = "../dev-utils", version = "0.5.5"}
|
||||
wasmer-dev-utils = { path = "../dev-utils", version = "0.5.6"}
|
||||
|
||||
[build-dependencies]
|
||||
glob = "0.2.11"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wasmer-emscripten"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
description = "Wasmer runtime emscripten implementation library"
|
||||
license = "MIT"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
@ -13,7 +13,7 @@ hashbrown = "0.1"
|
||||
lazy_static = "1.2.0"
|
||||
libc = "0.2.49"
|
||||
time = "0.1.41"
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.5" }
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.6" }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
rand = "0.6"
|
||||
|
@ -1,11 +1,11 @@
|
||||
[package]
|
||||
name = "wasmer-llvm-backend"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
authors = ["Lachlan Sneff <lachlan.sneff@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.5" }
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.6" }
|
||||
inkwell = { git = "https://github.com/wasmerio/inkwell", branch = "llvm7-0" }
|
||||
wasmparser = "0.32.1"
|
||||
hashbrown = "0.1.8"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wasmer-middleware-common"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
repository = "https://github.com/wasmerio/wasmer"
|
||||
description = "Wasmer runtime common middlewares"
|
||||
license = "MIT"
|
||||
@ -9,9 +9,9 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
wasmer-runtime-core = { path = "../runtime-core" }
|
||||
wasmer-clif-backend = { path = "../clif-backend", version = "0.5.5" }
|
||||
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.5.5", optional = true }
|
||||
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.5", optional = true }
|
||||
wasmer-clif-backend = { path = "../clif-backend", version = "0.5.6" }
|
||||
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.5.6", optional = true }
|
||||
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.6", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
wabt = "0.7.4"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wasmer-runtime-abi"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
description = "Wasmer runtime core library"
|
||||
license = "MIT"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wasmer-runtime-c-api"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
description = "Wasmer C API library"
|
||||
license = "MIT"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
@ -16,11 +16,11 @@ libc = "0.2"
|
||||
|
||||
[dependencies.wasmer-runtime]
|
||||
path = "../runtime"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
|
||||
[dependencies.wasmer-runtime-core]
|
||||
path = "../runtime-core"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
|
||||
[features]
|
||||
debug = ["wasmer-runtime/debug"]
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wasmer-runtime-core"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
description = "Wasmer runtime core library"
|
||||
license = "MIT"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
|
@ -126,6 +126,15 @@ impl<T: Copy + ValueType> WasmPtr<T, Array> {
|
||||
[index as usize..slice_full_len];
|
||||
Some(cell_ptrs)
|
||||
}
|
||||
|
||||
pub fn get_utf8_string<'a>(self, memory: &'a Memory, str_len: u32) -> Option<&'a str> {
|
||||
if self.offset as usize + str_len as usize > memory.size().bytes().0 {
|
||||
return None;
|
||||
}
|
||||
let ptr = unsafe { memory.view::<u8>().as_ptr().add(self.offset as usize) as *const u8 };
|
||||
let slice: &[u8] = unsafe { std::slice::from_raw_parts(ptr, str_len as usize) };
|
||||
std::str::from_utf8(slice).ok()
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<T: Copy, Ty> WasmExternType for WasmPtr<T, Ty> {
|
||||
|
@ -42,7 +42,7 @@ pub struct Ctx {
|
||||
pub import_backing: *mut ImportBacking,
|
||||
pub module: *const ModuleInner,
|
||||
|
||||
//// This is intended to be user-supplied, per-instance
|
||||
/// This is intended to be user-supplied, per-instance
|
||||
/// contextual data. There are currently some issue with it,
|
||||
/// notably that it cannot be set before running the `start`
|
||||
/// function in a WebAssembly module.
|
||||
@ -88,7 +88,7 @@ pub struct InternalCtx {
|
||||
/// A pointer to an array of locally-defined globals, indexed by `GlobalIndex`.
|
||||
pub globals: *mut *mut LocalGlobal,
|
||||
|
||||
/// A pointer to an array of imported memories, indexed by `MemoryIndex,
|
||||
/// A pointer to an array of imported memories, indexed by `MemoryIndex`,
|
||||
pub imported_memories: *mut *mut LocalMemory,
|
||||
|
||||
/// A pointer to an array of imported tables, indexed by `TableIndex`.
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wasmer-runtime"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
description = "Wasmer runtime library"
|
||||
license = "MIT"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
@ -9,17 +9,17 @@ edition = "2018"
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.5", optional = true }
|
||||
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.6", optional = true }
|
||||
lazy_static = "1.2.0"
|
||||
memmap = "0.7.0"
|
||||
|
||||
[dependencies.wasmer-runtime-core]
|
||||
path = "../runtime-core"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
|
||||
[dependencies.wasmer-clif-backend]
|
||||
path = "../clif-backend"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
optional = true
|
||||
|
||||
[dev-dependencies]
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wasmer-singlepass-backend"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
repository = "https://github.com/wasmerio/wasmer"
|
||||
description = "Wasmer runtime single pass compiler backend"
|
||||
license = "MIT"
|
||||
@ -8,7 +8,7 @@ authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.5" }
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.6" }
|
||||
wasmparser = "0.32.1"
|
||||
dynasm = "0.3.2"
|
||||
dynasmrt = "0.3.1"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wasmer-spectests"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
description = "Wasmer spectests library"
|
||||
license = "MIT"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
@ -9,10 +9,10 @@ edition = "2018"
|
||||
build = "build/mod.rs"
|
||||
|
||||
[dependencies]
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.5" }
|
||||
wasmer-clif-backend = { path = "../clif-backend", version = "0.5.5" }
|
||||
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.5.5", optional = true }
|
||||
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.5", optional = true }
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.6" }
|
||||
wasmer-clif-backend = { path = "../clif-backend", version = "0.5.6" }
|
||||
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.5.6", optional = true }
|
||||
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.6", optional = true }
|
||||
|
||||
[build-dependencies]
|
||||
wabt = "0.7.2"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wasmer-wasi-tests"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
description = "Tests for our WASI implementation"
|
||||
license = "MIT"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
@ -9,19 +9,19 @@ publish = false
|
||||
build = "build/mod.rs"
|
||||
|
||||
[dependencies]
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.5" }
|
||||
wasmer-wasi = { path = "../wasi", version = "0.5.5" }
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.6" }
|
||||
wasmer-wasi = { path = "../wasi", version = "0.5.6" }
|
||||
# hack to get tests to work
|
||||
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.5", optional = true }
|
||||
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.5.5", optional = true }
|
||||
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.5.6", optional = true }
|
||||
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.5.6", optional = true }
|
||||
|
||||
|
||||
[build-dependencies]
|
||||
glob = "0.2.11"
|
||||
|
||||
[dev-dependencies]
|
||||
wasmer-clif-backend = { path = "../clif-backend", version = "0.5.5" }
|
||||
wasmer-dev-utils = { path = "../dev-utils", version = "0.5.5"}
|
||||
wasmer-clif-backend = { path = "../clif-backend", version = "0.5.6" }
|
||||
wasmer-dev-utils = { path = "../dev-utils", version = "0.5.6"}
|
||||
|
||||
[features]
|
||||
clif = []
|
||||
|
@ -20,7 +20,6 @@ static BANNER: &str = "// !!! THIS IS A GENERATED FILE !!!
|
||||
// Files autogenerated with cargo build (build/wasitests.rs).\n";
|
||||
|
||||
pub fn compile(file: &str, ignores: &HashSet<String>) -> Option<String> {
|
||||
dbg!(file);
|
||||
let mut output_path = PathBuf::from(file);
|
||||
output_path.set_extension("out");
|
||||
|
||||
@ -31,12 +30,14 @@ pub fn compile(file: &str, ignores: &HashSet<String>) -> Option<String> {
|
||||
nn
|
||||
};
|
||||
|
||||
Command::new("rustc")
|
||||
println!("Compiling program {} to native", file);
|
||||
let native_out = Command::new("rustc")
|
||||
.arg(file)
|
||||
.arg("-o")
|
||||
.arg(&normalized_name)
|
||||
.output()
|
||||
.expect("Failed to compile program to native code");
|
||||
print_info_on_error(&native_out, "COMPILATION FAILED");
|
||||
|
||||
#[cfg(unix)]
|
||||
{
|
||||
@ -57,18 +58,29 @@ pub fn compile(file: &str, ignores: &HashSet<String>) -> Option<String> {
|
||||
let result = Command::new(&normalized_name)
|
||||
.output()
|
||||
.expect("Failed to execute native program");
|
||||
print_info_on_error(&result, "NATIVE PROGRAM FAILED");
|
||||
|
||||
std::fs::remove_file(&normalized_name).expect("could not delete executable");
|
||||
let wasm_out_name = format!("{}.wasm", &normalized_name);
|
||||
|
||||
Command::new("rustc")
|
||||
let wasm_compilation_out = Command::new("rustc")
|
||||
.arg("+nightly")
|
||||
.arg("--target=wasm32-wasi")
|
||||
.arg("-C")
|
||||
.arg("opt-level=s")
|
||||
.arg(file)
|
||||
.arg("-o")
|
||||
.arg(&wasm_out_name)
|
||||
.output()
|
||||
.expect("Failed to compile program to native code");
|
||||
print_info_on_error(&wasm_compilation_out, "WASM COMPILATION");
|
||||
|
||||
// to prevent commiting huge binary blobs forever
|
||||
let wasm_strip_out = Command::new("wasm-strip")
|
||||
.arg(&wasm_out_name)
|
||||
.output()
|
||||
.expect("Failed to strip compiled wasm module");
|
||||
print_info_on_error(&wasm_strip_out, "STRIPPING WASM");
|
||||
|
||||
let ignored = if ignores.contains(&rs_module_name) {
|
||||
"\n#[ignore]"
|
||||
@ -77,7 +89,7 @@ pub fn compile(file: &str, ignores: &HashSet<String>) -> Option<String> {
|
||||
};
|
||||
|
||||
let src_code = fs::read_to_string(file).expect("read src file");
|
||||
let args = extract_args_from_source_file(&src_code).unwrap_or_default();
|
||||
let args: Args = extract_args_from_source_file(&src_code).unwrap_or_default();
|
||||
|
||||
let mapdir_args = {
|
||||
let mut out_str = String::new();
|
||||
@ -104,12 +116,25 @@ pub fn compile(file: &str, ignores: &HashSet<String>) -> Option<String> {
|
||||
out_str
|
||||
};
|
||||
|
||||
let dir_args = {
|
||||
let mut out_str = String::new();
|
||||
out_str.push_str("vec![");
|
||||
|
||||
for entry in args.po_dirs {
|
||||
out_str.push_str(&format!("\"{}\".to_string(),", entry));
|
||||
}
|
||||
|
||||
out_str.push_str("]");
|
||||
out_str
|
||||
};
|
||||
|
||||
let contents = format!(
|
||||
"#[test]{ignore}
|
||||
fn test_{rs_module_name}() {{
|
||||
assert_wasi_output!(
|
||||
\"../../{module_path}\",
|
||||
\"{rs_module_name}\",
|
||||
{dir_args},
|
||||
{mapdir_args},
|
||||
{envvar_args},
|
||||
\"../../{test_output_path}\"
|
||||
@ -120,6 +145,7 @@ fn test_{rs_module_name}() {{
|
||||
module_path = wasm_out_name,
|
||||
rs_module_name = rs_module_name,
|
||||
test_output_path = format!("{}.out", normalized_name),
|
||||
dir_args = dir_args,
|
||||
mapdir_args = mapdir_args,
|
||||
envvar_args = envvar_args
|
||||
);
|
||||
@ -180,6 +206,8 @@ fn read_ignore_list() -> HashSet<String> {
|
||||
struct Args {
|
||||
pub mapdir: Vec<(String, String)>,
|
||||
pub envvars: Vec<(String, String)>,
|
||||
/// pre-opened directories
|
||||
pub po_dirs: Vec<String>,
|
||||
}
|
||||
|
||||
/// Pulls args to the program out of a comment at the top of the file starting with "// Args:"
|
||||
@ -193,27 +221,41 @@ fn extract_args_from_source_file(source_code: &str) -> Option<Args> {
|
||||
{
|
||||
let tokenized = arg_line
|
||||
.split_whitespace()
|
||||
// skip trailing space
|
||||
.skip(1)
|
||||
.map(String::from)
|
||||
.collect::<Vec<String>>();
|
||||
match tokenized[1].as_ref() {
|
||||
let command_name = {
|
||||
let mut cn = tokenized[0].clone();
|
||||
assert_eq!(
|
||||
cn.pop(),
|
||||
Some(':'),
|
||||
"Final character of argname must be a colon"
|
||||
);
|
||||
cn
|
||||
};
|
||||
|
||||
match command_name.as_ref() {
|
||||
"mapdir" => {
|
||||
if let [alias, real_dir] = &tokenized[2].split(':').collect::<Vec<&str>>()[..] {
|
||||
if let [alias, real_dir] = &tokenized[1].split(':').collect::<Vec<&str>>()[..] {
|
||||
args.mapdir.push((alias.to_string(), real_dir.to_string()));
|
||||
} else {
|
||||
eprintln!(
|
||||
"Parse error in mapdir {} not parsed correctly",
|
||||
&tokenized[2]
|
||||
&tokenized[1]
|
||||
);
|
||||
}
|
||||
}
|
||||
"env" => {
|
||||
if let [name, val] = &tokenized[2].split('=').collect::<Vec<&str>>()[..] {
|
||||
if let [name, val] = &tokenized[1].split('=').collect::<Vec<&str>>()[..] {
|
||||
args.envvars.push((name.to_string(), val.to_string()));
|
||||
} else {
|
||||
eprintln!("Parse error in env {} not parsed correctly", &tokenized[2]);
|
||||
eprintln!("Parse error in env {} not parsed correctly", &tokenized[1]);
|
||||
}
|
||||
}
|
||||
"dir" => {
|
||||
args.po_dirs.push(tokenized[1].to_string());
|
||||
}
|
||||
e => {
|
||||
eprintln!("WARN: comment arg: {} is not supported", e);
|
||||
}
|
||||
@ -223,3 +265,17 @@ fn extract_args_from_source_file(source_code: &str) -> Option<Args> {
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn print_info_on_error(output: &std::process::Output, context: &str) {
|
||||
if !output.status.success() {
|
||||
println!("{}", context);
|
||||
println!(
|
||||
"stdout:\n{}",
|
||||
std::str::from_utf8(&output.stdout[..]).unwrap()
|
||||
);
|
||||
eprintln!(
|
||||
"stderr:\n{}",
|
||||
std::str::from_utf8(&output.stderr[..]).unwrap()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
5
lib/wasi-tests/tests/README.md
Normal file
5
lib/wasi-tests/tests/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
Most of the files here are generated.
|
||||
|
||||
`_common.rs` is a file containing a macro that the generated tests use to avoid code duplication.
|
||||
|
||||
If you want to add new features, edit `_common.rs` and `wasi-tests/build/wasitests.rs` to use the changed macro.
|
@ -1,5 +1,5 @@
|
||||
macro_rules! assert_wasi_output {
|
||||
($file:expr, $name:expr, $mapdir_args:expr, $envvar_args:expr, $expected:expr) => {{
|
||||
($file:expr, $name:expr, $po_dir_args: expr, $mapdir_args:expr, $envvar_args:expr, $expected:expr) => {{
|
||||
use wasmer_dev_utils::stdio::StdioCapturer;
|
||||
use wasmer_runtime_core::{backend::Compiler, Func};
|
||||
use wasmer_wasi::generate_import_object;
|
||||
@ -33,8 +33,7 @@ macro_rules! assert_wasi_output {
|
||||
let module = wasmer_runtime_core::compile_with(&wasm_bytes[..], &get_compiler())
|
||||
.expect("WASM can't be compiled");
|
||||
|
||||
let import_object =
|
||||
generate_import_object(vec![], vec![], vec![".".to_string()], $mapdir_args);
|
||||
let import_object = generate_import_object(vec![], vec![], $po_dir_args, $mapdir_args);
|
||||
|
||||
let instance = module
|
||||
.instantiate(&import_object)
|
||||
|
@ -1,9 +1,9 @@
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_create_dir() {
|
||||
assert_wasi_output!(
|
||||
"../../wasitests/create_dir.wasm",
|
||||
"create_dir",
|
||||
vec![".".to_string(),],
|
||||
vec![],
|
||||
vec![],
|
||||
"../../wasitests/create_dir.out"
|
||||
|
@ -5,6 +5,7 @@ fn test_envvar() {
|
||||
"envvar",
|
||||
vec![],
|
||||
vec![],
|
||||
vec!["DOG=1".to_string(), "CAT=2".to_string(),],
|
||||
"../../wasitests/envvar.out"
|
||||
);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ fn test_file_metadata() {
|
||||
assert_wasi_output!(
|
||||
"../../wasitests/file_metadata.wasm",
|
||||
"file_metadata",
|
||||
vec![".".to_string(),],
|
||||
vec![],
|
||||
vec![],
|
||||
"../../wasitests/file_metadata.out"
|
||||
|
@ -5,6 +5,7 @@ fn test_fs_sandbox_test() {
|
||||
"fs_sandbox_test",
|
||||
vec![],
|
||||
vec![],
|
||||
vec![],
|
||||
"../../wasitests/fs_sandbox_test.out"
|
||||
);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ fn test_fseek() {
|
||||
assert_wasi_output!(
|
||||
"../../wasitests/fseek.wasm",
|
||||
"fseek",
|
||||
vec![],
|
||||
vec![(
|
||||
".".to_string(),
|
||||
::std::path::PathBuf::from("wasitests/test_fs/hamlet")
|
||||
|
@ -5,6 +5,7 @@ fn test_hello() {
|
||||
"hello",
|
||||
vec![],
|
||||
vec![],
|
||||
vec![],
|
||||
"../../wasitests/hello.out"
|
||||
);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ fn test_mapdir() {
|
||||
assert_wasi_output!(
|
||||
"../../wasitests/mapdir.wasm",
|
||||
"mapdir",
|
||||
vec![],
|
||||
vec![(
|
||||
".".to_string(),
|
||||
::std::path::PathBuf::from("wasitests/test_fs/hamlet")
|
||||
|
@ -13,3 +13,6 @@ mod fseek;
|
||||
mod hello;
|
||||
mod mapdir;
|
||||
mod quine;
|
||||
mod readlink;
|
||||
mod wasi_sees_virtual_root;
|
||||
mod writing;
|
||||
|
@ -3,6 +3,7 @@ fn test_quine() {
|
||||
assert_wasi_output!(
|
||||
"../../wasitests/quine.wasm",
|
||||
"quine",
|
||||
vec![".".to_string(),],
|
||||
vec![],
|
||||
vec![],
|
||||
"../../wasitests/quine.out"
|
||||
|
14
lib/wasi-tests/tests/wasitests/readlink.rs
Normal file
14
lib/wasi-tests/tests/wasitests/readlink.rs
Normal file
@ -0,0 +1,14 @@
|
||||
#[test]
|
||||
fn test_readlink() {
|
||||
assert_wasi_output!(
|
||||
"../../wasitests/readlink.wasm",
|
||||
"readlink",
|
||||
vec![],
|
||||
vec![(
|
||||
".".to_string(),
|
||||
::std::path::PathBuf::from("wasitests/test_fs/hamlet")
|
||||
),],
|
||||
vec![],
|
||||
"../../wasitests/readlink.out"
|
||||
);
|
||||
}
|
24
lib/wasi-tests/tests/wasitests/wasi_sees_virtual_root.rs
Normal file
24
lib/wasi-tests/tests/wasitests/wasi_sees_virtual_root.rs
Normal file
@ -0,0 +1,24 @@
|
||||
#[test]
|
||||
fn test_wasi_sees_virtual_root() {
|
||||
assert_wasi_output!(
|
||||
"../../wasitests/wasi_sees_virtual_root.wasm",
|
||||
"wasi_sees_virtual_root",
|
||||
vec![],
|
||||
vec![
|
||||
(
|
||||
"act1".to_string(),
|
||||
::std::path::PathBuf::from("wasitests/test_fs/hamlet/act1")
|
||||
),
|
||||
(
|
||||
"act2".to_string(),
|
||||
::std::path::PathBuf::from("wasitests/test_fs/hamlet/act2")
|
||||
),
|
||||
(
|
||||
"act1-again".to_string(),
|
||||
::std::path::PathBuf::from("wasitests/test_fs/hamlet/act1")
|
||||
),
|
||||
],
|
||||
vec![],
|
||||
"../../wasitests/wasi_sees_virtual_root.out"
|
||||
);
|
||||
}
|
24
lib/wasi-tests/tests/wasitests/writing.rs
Normal file
24
lib/wasi-tests/tests/wasitests/writing.rs
Normal file
@ -0,0 +1,24 @@
|
||||
#[test]
|
||||
fn test_writing() {
|
||||
assert_wasi_output!(
|
||||
"../../wasitests/writing.wasm",
|
||||
"writing",
|
||||
vec![],
|
||||
vec![
|
||||
(
|
||||
"act1".to_string(),
|
||||
::std::path::PathBuf::from("wasitests/test_fs/hamlet/act1")
|
||||
),
|
||||
(
|
||||
"act2".to_string(),
|
||||
::std::path::PathBuf::from("wasitests/test_fs/hamlet/act2")
|
||||
),
|
||||
(
|
||||
"act1-again".to_string(),
|
||||
::std::path::PathBuf::from("wasitests/test_fs/hamlet/act1")
|
||||
),
|
||||
],
|
||||
vec![],
|
||||
"../../wasitests/writing.out"
|
||||
);
|
||||
}
|
@ -1,3 +1,6 @@
|
||||
// Args:
|
||||
// dir: .
|
||||
|
||||
use std::fs;
|
||||
use std::io::{Read, Seek, SeekFrom, Write};
|
||||
use std::path::*;
|
||||
|
Binary file not shown.
Binary file not shown.
@ -1,3 +1,3 @@
|
||||
is dir: false
|
||||
filetype: false true false
|
||||
file info: 456
|
||||
file info: 476
|
||||
|
@ -1,3 +1,6 @@
|
||||
// Args:
|
||||
// dir: .
|
||||
|
||||
use std::fs;
|
||||
use std::io::Read;
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
create_dir
|
||||
|
||||
|
@ -4,3 +4,4 @@
|
||||
"./act3"
|
||||
"./act4"
|
||||
"./act5"
|
||||
"./bookmarks"
|
||||
|
@ -4,9 +4,9 @@
|
||||
use std::fs;
|
||||
|
||||
fn main() {
|
||||
// #[cfg(not(target_os = "wasi"))]
|
||||
// let read_dir = fs::read_dir("wasitests/test_fs/hamlet").unwrap();
|
||||
// #[cfg(target_os = "wasi")]
|
||||
#[cfg(not(target_os = "wasi"))]
|
||||
std::env::set_current_dir("wasitests/test_fs/hamlet").unwrap();
|
||||
|
||||
let read_dir = fs::read_dir(".").unwrap();
|
||||
let mut out = vec![];
|
||||
for entry in read_dir {
|
||||
|
Binary file not shown.
@ -1,3 +1,6 @@
|
||||
// Args:
|
||||
// dir: .
|
||||
|
||||
use std::fs;
|
||||
use std::io::Read;
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
// Args:
|
||||
// dir: .
|
||||
|
||||
use std::fs;
|
||||
use std::io::Read;
|
||||
|
||||
|
Binary file not shown.
4
lib/wasi-tests/wasitests/readlink.out
Normal file
4
lib/wasi-tests/wasitests/readlink.out
Normal file
@ -0,0 +1,4 @@
|
||||
../act1/scene2.txt
|
||||
SCENE II. A room of state in the castle.
|
||||
|
||||
Enter KING CLAUDIUS, QUEEN GERTRUDE, HAMLET, POLONIUS, LAERTES, VOLTIMAND, CORNELI
|
21
lib/wasi-tests/wasitests/readlink.rs
Normal file
21
lib/wasi-tests/wasitests/readlink.rs
Normal file
@ -0,0 +1,21 @@
|
||||
// Args:
|
||||
// mapdir: .:wasitests/test_fs/hamlet
|
||||
use std::io::Read;
|
||||
|
||||
fn main() {
|
||||
#[cfg(not(target_os = "wasi"))]
|
||||
std::env::set_current_dir("wasitests/test_fs/hamlet").unwrap();
|
||||
|
||||
let sym_link_path = "bookmarks/2019-07-16";
|
||||
|
||||
let link_path = std::fs::read_link(sym_link_path).unwrap();
|
||||
println!("{}", link_path.to_string_lossy());
|
||||
|
||||
let mut some_contents = std::fs::File::open(sym_link_path).unwrap();
|
||||
|
||||
let mut buffer = [0; 128];
|
||||
|
||||
assert_eq!(some_contents.read(&mut buffer).unwrap(), 128);
|
||||
let str_val = std::str::from_utf8(&buffer[..]).unwrap();
|
||||
println!("{}", str_val);
|
||||
}
|
BIN
lib/wasi-tests/wasitests/readlink.wasm
Executable file
BIN
lib/wasi-tests/wasitests/readlink.wasm
Executable file
Binary file not shown.
1
lib/wasi-tests/wasitests/test_fs/hamlet/bookmarks/2019-07-16
Symbolic link
1
lib/wasi-tests/wasitests/test_fs/hamlet/bookmarks/2019-07-16
Symbolic link
@ -0,0 +1 @@
|
||||
../act1/scene2.txt
|
13
lib/wasi-tests/wasitests/wasi_sees_virtual_root.out
Normal file
13
lib/wasi-tests/wasitests/wasi_sees_virtual_root.out
Normal file
@ -0,0 +1,13 @@
|
||||
"/act1"
|
||||
"/act1-again"
|
||||
"/act2"
|
||||
"/act1"
|
||||
"/act1-again"
|
||||
"/act2"
|
||||
"/act1"
|
||||
"/act1-again"
|
||||
"/act2"
|
||||
"/act1"
|
||||
"/act1-again"
|
||||
"/act2"
|
||||
ROOT IS SAFE
|
59
lib/wasi-tests/wasitests/wasi_sees_virtual_root.rs
Normal file
59
lib/wasi-tests/wasitests/wasi_sees_virtual_root.rs
Normal file
@ -0,0 +1,59 @@
|
||||
// Args:
|
||||
// mapdir: act1:wasitests/test_fs/hamlet/act1
|
||||
// mapdir: act2:wasitests/test_fs/hamlet/act2
|
||||
// mapdir: act1-again:wasitests/test_fs/hamlet/act1
|
||||
|
||||
use std::fs;
|
||||
|
||||
fn main() {
|
||||
// just cheat in this test because there is no comparison for native
|
||||
#[cfg(not(target_os = "wasi"))]
|
||||
let results = {
|
||||
let start = vec!["\"/act1\"", "\"/act1-again\"", "\"/act2\""];
|
||||
|
||||
let mut out = vec![];
|
||||
for _ in 0..4 {
|
||||
for path_str in &start {
|
||||
out.push(path_str.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
out.push("ROOT IS SAFE".to_string());
|
||||
out
|
||||
};
|
||||
|
||||
#[cfg(target_os = "wasi")]
|
||||
let results = {
|
||||
let mut out = vec![];
|
||||
|
||||
let read_dir = fs::read_dir("/").unwrap();
|
||||
for entry in read_dir {
|
||||
out.push(format!("{:?}", entry.unwrap().path()))
|
||||
}
|
||||
let read_dir = fs::read_dir("act1/..").unwrap();
|
||||
for entry in read_dir {
|
||||
out.push(format!("{:?}", entry.unwrap().path()))
|
||||
}
|
||||
let read_dir = fs::read_dir("act1/../../..").unwrap();
|
||||
for entry in read_dir {
|
||||
out.push(format!("{:?}", entry.unwrap().path()))
|
||||
}
|
||||
let read_dir = fs::read_dir("act1/../../act2/../act1/../../../").unwrap();
|
||||
for entry in read_dir {
|
||||
out.push(format!("{:?}", entry.unwrap().path()))
|
||||
}
|
||||
let f = fs::OpenOptions::new().write(true).open("/abc");
|
||||
|
||||
if f.is_ok() {
|
||||
out.push("ROOT IS NOT SAFE".to_string());
|
||||
} else {
|
||||
out.push("ROOT IS SAFE".to_string());
|
||||
}
|
||||
|
||||
out
|
||||
};
|
||||
|
||||
for result in results {
|
||||
println!("{}", result);
|
||||
}
|
||||
}
|
BIN
lib/wasi-tests/wasitests/wasi_sees_virtual_root.wasm
Executable file
BIN
lib/wasi-tests/wasitests/wasi_sees_virtual_root.wasm
Executable file
Binary file not shown.
2
lib/wasi-tests/wasitests/writing.out
Normal file
2
lib/wasi-tests/wasitests/writing.out
Normal file
@ -0,0 +1,2 @@
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
file is gone
|
41
lib/wasi-tests/wasitests/writing.rs
Normal file
41
lib/wasi-tests/wasitests/writing.rs
Normal file
@ -0,0 +1,41 @@
|
||||
// Args:
|
||||
// mapdir: act1:wasitests/test_fs/hamlet/act1
|
||||
// mapdir: act2:wasitests/test_fs/hamlet/act2
|
||||
// mapdir: act1-again:wasitests/test_fs/hamlet/act1
|
||||
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
|
||||
pub const BYTE_STR: &'static [u8] = b"abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
fn main() {
|
||||
#[cfg(not(target_os = "wasi"))]
|
||||
do_logic_on_path(
|
||||
"wasitests/test_fs/hamlet/act1/abc",
|
||||
"wasitests/test_fs/hamlet/act1/abc",
|
||||
);
|
||||
|
||||
#[cfg(target_os = "wasi")]
|
||||
do_logic_on_path("/act1/abc", "act1-again/abc");
|
||||
}
|
||||
|
||||
fn do_logic_on_path(path: &'static str, alt_path: &'static str) {
|
||||
{
|
||||
let mut f = fs::OpenOptions::new()
|
||||
.create_new(true)
|
||||
.write(true)
|
||||
.open(path)
|
||||
.unwrap();
|
||||
f.write_all(BYTE_STR).unwrap();
|
||||
}
|
||||
|
||||
println!("{}", fs::read_to_string(alt_path).unwrap());
|
||||
fs::remove_file(path).unwrap();
|
||||
|
||||
let file_path = std::path::Path::new(path);
|
||||
if file_path.exists() {
|
||||
println!("file is here");
|
||||
} else {
|
||||
println!("file is gone")
|
||||
}
|
||||
}
|
BIN
lib/wasi-tests/wasitests/writing.wasm
Executable file
BIN
lib/wasi-tests/wasitests/writing.wasm
Executable file
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wasmer-wasi"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
description = "Wasmer runtime WASI implementation library"
|
||||
license = "MIT"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
@ -8,7 +8,7 @@ repository = "https://github.com/wasmerio/wasmer"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.5" }
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.6" }
|
||||
libc = "0.2.50"
|
||||
rand = "0.6.5"
|
||||
# wasmer-runtime-abi = { path = "../runtime-abi" }
|
||||
|
@ -1,7 +1,5 @@
|
||||
#![deny(unused_imports, unused_variables, unused_unsafe, unreachable_patterns)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
#[cfg(target = "windows")]
|
||||
extern crate winapi;
|
||||
|
||||
|
@ -12,7 +12,7 @@ macro_rules! wasi_try {
|
||||
}
|
||||
}
|
||||
}};
|
||||
($expr:expr; $e:expr) => {{
|
||||
($expr:expr, $e:expr) => {{
|
||||
let opt: Option<_> = $expr;
|
||||
wasi_try!(opt.ok_or($e))
|
||||
}};
|
||||
|
@ -75,4 +75,9 @@ impl<T: Copy + ValueType> WasmPtr<T, ptr::Array> {
|
||||
) -> Result<&'a [Cell<T>], __wasi_errno_t> {
|
||||
self.0.deref(memory, index, length).ok_or(__WASI_EFAULT)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn get_utf8_string<'a>(self, memory: &'a Memory, str_len: u32) -> Option<&'a str> {
|
||||
self.0.get_utf8_string(memory, str_len)
|
||||
}
|
||||
}
|
||||
|
@ -3,24 +3,32 @@
|
||||
// file_like::{FileLike, Metadata};
|
||||
// };
|
||||
use crate::syscalls::types::*;
|
||||
use generational_arena::{Arena, Index as Inode};
|
||||
use generational_arena::Arena;
|
||||
pub use generational_arena::Index as Inode;
|
||||
use hashbrown::hash_map::{Entry, HashMap};
|
||||
use std::{
|
||||
borrow::Borrow,
|
||||
cell::Cell,
|
||||
fs,
|
||||
io::{self, Read, Seek, Write},
|
||||
path::PathBuf,
|
||||
path::{Path, PathBuf},
|
||||
time::SystemTime,
|
||||
};
|
||||
use wasmer_runtime_core::debug;
|
||||
|
||||
pub const MAX_SYMLINKS: usize = 100;
|
||||
/// A completely aribtrary "big enough" number used as the upper limit for
|
||||
/// the number of symlinks that can be traversed when resolving a path
|
||||
pub const MAX_SYMLINKS: u32 = 128;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum WasiFile {
|
||||
HostFile(fs::File),
|
||||
}
|
||||
|
||||
impl WasiFile {
|
||||
pub fn close(self) {}
|
||||
}
|
||||
|
||||
impl Write for WasiFile {
|
||||
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
||||
match self {
|
||||
@ -81,6 +89,7 @@ impl Seek for WasiFile {
|
||||
}
|
||||
}
|
||||
|
||||
/// A file that Wasi knows about that may or may not be open
|
||||
#[derive(Debug)]
|
||||
pub struct InodeVal {
|
||||
pub stat: __wasi_filestat_t,
|
||||
@ -89,54 +98,14 @@ pub struct InodeVal {
|
||||
pub kind: Kind,
|
||||
}
|
||||
|
||||
impl InodeVal {
|
||||
// TODO: clean this up
|
||||
pub fn from_file_metadata(
|
||||
metadata: &std::fs::Metadata,
|
||||
name: String,
|
||||
is_preopened: bool,
|
||||
kind: Kind,
|
||||
) -> Self {
|
||||
InodeVal {
|
||||
stat: __wasi_filestat_t {
|
||||
st_filetype: if metadata.is_dir() {
|
||||
__WASI_FILETYPE_DIRECTORY
|
||||
} else {
|
||||
__WASI_FILETYPE_REGULAR_FILE
|
||||
},
|
||||
st_size: metadata.len(),
|
||||
st_atim: metadata
|
||||
.accessed()
|
||||
.ok()
|
||||
.and_then(|sys_time| sys_time.duration_since(SystemTime::UNIX_EPOCH).ok())
|
||||
.map(|duration| duration.as_nanos() as u64)
|
||||
.unwrap_or(0),
|
||||
st_ctim: metadata
|
||||
.created()
|
||||
.ok()
|
||||
.and_then(|sys_time| sys_time.duration_since(SystemTime::UNIX_EPOCH).ok())
|
||||
.map(|duration| duration.as_nanos() as u64)
|
||||
.unwrap_or(0),
|
||||
st_mtim: metadata
|
||||
.modified()
|
||||
.ok()
|
||||
.and_then(|sys_time| sys_time.duration_since(SystemTime::UNIX_EPOCH).ok())
|
||||
.map(|duration| duration.as_nanos() as u64)
|
||||
.unwrap_or(0),
|
||||
..__wasi_filestat_t::default()
|
||||
},
|
||||
is_preopened,
|
||||
name,
|
||||
kind,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
pub enum Kind {
|
||||
File {
|
||||
handle: WasiFile,
|
||||
/// the open file, if it's open
|
||||
handle: Option<WasiFile>,
|
||||
/// the path to the file
|
||||
path: PathBuf,
|
||||
},
|
||||
Dir {
|
||||
/// Parent directory
|
||||
@ -147,8 +116,26 @@ pub enum Kind {
|
||||
/// The entries of a directory are lazily filled.
|
||||
entries: HashMap<String, Inode>,
|
||||
},
|
||||
/// The same as Dir but without the irrelevant bits
|
||||
/// The root is immutable after creation; generally the Kind::Root
|
||||
/// branch of whatever code you're writing will be a simpler version of
|
||||
/// your Kind::Dir logic
|
||||
Root {
|
||||
entries: HashMap<String, Inode>,
|
||||
},
|
||||
/// The first two fields are data _about_ the symlink
|
||||
/// the last field is the data _inside_ the symlink
|
||||
///
|
||||
/// `base_po_dir` should never be the root because:
|
||||
/// - Right now symlinks are not allowed in the immutable root
|
||||
/// - There is always a closer pre-opened dir to the symlink file (by definition of the root being a collection of preopened dirs)
|
||||
Symlink {
|
||||
forwarded: Inode,
|
||||
/// The preopened dir that this symlink file is relative to (via `path_to_symlink`)
|
||||
base_po_dir: __wasi_fd_t,
|
||||
/// The path to the symlink from the `base_po_dir`
|
||||
path_to_symlink: PathBuf,
|
||||
/// the value of the symlink as a relative path
|
||||
relative_path: PathBuf,
|
||||
},
|
||||
Buffer {
|
||||
buffer: Vec<u8>,
|
||||
@ -167,11 +154,12 @@ pub struct Fd {
|
||||
#[derive(Debug)]
|
||||
pub struct WasiFs {
|
||||
//pub repo: Repo,
|
||||
pub preopen_fds: Vec<u32>,
|
||||
pub name_map: HashMap<String, Inode>,
|
||||
pub inodes: Arena<InodeVal>,
|
||||
pub fd_map: HashMap<u32, Fd>,
|
||||
pub next_fd: Cell<u32>,
|
||||
pub inode_counter: Cell<u64>,
|
||||
inode_counter: Cell<u64>,
|
||||
}
|
||||
|
||||
impl WasiFs {
|
||||
@ -182,12 +170,41 @@ impl WasiFs {
|
||||
debug!("wasi::fs::inodes");
|
||||
let inodes = Arena::new();
|
||||
let mut wasi_fs = Self {
|
||||
preopen_fds: vec![],
|
||||
name_map: HashMap::new(),
|
||||
inodes: inodes,
|
||||
inodes,
|
||||
fd_map: HashMap::new(),
|
||||
next_fd: Cell::new(3),
|
||||
inode_counter: Cell::new(1000),
|
||||
inode_counter: Cell::new(1024),
|
||||
};
|
||||
// create virtual root
|
||||
let root_inode = {
|
||||
let all_rights = 0x1FFFFFFF;
|
||||
// TODO: make this a list of positive rigths instead of negative ones
|
||||
// root gets all right for now
|
||||
let root_rights = all_rights
|
||||
/*& (!__WASI_RIGHT_FD_WRITE)
|
||||
& (!__WASI_RIGHT_FD_ALLOCATE)
|
||||
& (!__WASI_RIGHT_PATH_CREATE_DIRECTORY)
|
||||
& (!__WASI_RIGHT_PATH_CREATE_FILE)
|
||||
& (!__WASI_RIGHT_PATH_LINK_SOURCE)
|
||||
& (!__WASI_RIGHT_PATH_RENAME_SOURCE)
|
||||
& (!__WASI_RIGHT_PATH_RENAME_TARGET)
|
||||
& (!__WASI_RIGHT_PATH_FILESTAT_SET_SIZE)
|
||||
& (!__WASI_RIGHT_PATH_FILESTAT_SET_TIMES)
|
||||
& (!__WASI_RIGHT_FD_FILESTAT_SET_SIZE)
|
||||
& (!__WASI_RIGHT_FD_FILESTAT_SET_TIMES)
|
||||
& (!__WASI_RIGHT_PATH_SYMLINK)
|
||||
& (!__WASI_RIGHT_PATH_UNLINK_FILE)
|
||||
& (!__WASI_RIGHT_PATH_REMOVE_DIRECTORY)*/;
|
||||
let inode = wasi_fs.create_virtual_root();
|
||||
let fd = wasi_fs
|
||||
.create_fd(root_rights, root_rights, 0, inode)
|
||||
.expect("Could not create root fd");
|
||||
wasi_fs.preopen_fds.push(fd);
|
||||
inode
|
||||
};
|
||||
|
||||
debug!("wasi::fs::preopen_dirs");
|
||||
for dir in preopened_dirs {
|
||||
debug!("Attempting to preopen {}", &dir);
|
||||
@ -197,7 +214,7 @@ impl WasiFs {
|
||||
let cur_dir_metadata = cur_dir.metadata().expect("Could not find directory");
|
||||
let kind = if cur_dir_metadata.is_dir() {
|
||||
Kind::Dir {
|
||||
parent: None,
|
||||
parent: Some(root_inode),
|
||||
path: cur_dir.clone(),
|
||||
entries: Default::default(),
|
||||
}
|
||||
@ -208,14 +225,22 @@ impl WasiFs {
|
||||
));
|
||||
};
|
||||
// TODO: handle nested pats in `file`
|
||||
let inode_val =
|
||||
InodeVal::from_file_metadata(&cur_dir_metadata, dir.clone(), true, kind);
|
||||
|
||||
let inode = wasi_fs.inodes.insert(inode_val);
|
||||
wasi_fs.inodes[inode].stat.st_ino = wasi_fs.inode_counter.get();
|
||||
wasi_fs
|
||||
let inode = wasi_fs
|
||||
.create_inode(kind, true, dir.to_string())
|
||||
.map_err(|e| {
|
||||
format!(
|
||||
"Failed to create inode for preopened dir: WASI error code: {}",
|
||||
e
|
||||
)
|
||||
})?;
|
||||
let fd = wasi_fs
|
||||
.create_fd(default_rights, default_rights, 0, inode)
|
||||
.expect("Could not open fd");
|
||||
if let Kind::Root { entries } = &mut wasi_fs.inodes[root_inode].kind {
|
||||
// todo handle collisions
|
||||
assert!(entries.insert(dir.to_string(), inode).is_none())
|
||||
}
|
||||
wasi_fs.preopen_fds.push(fd);
|
||||
}
|
||||
debug!("wasi::fs::mapped_dirs");
|
||||
for (alias, real_dir) in mapped_dirs {
|
||||
@ -227,7 +252,7 @@ impl WasiFs {
|
||||
.expect("mapped dir not at previously verified location");
|
||||
let kind = if cur_dir_metadata.is_dir() {
|
||||
Kind::Dir {
|
||||
parent: None,
|
||||
parent: Some(root_inode),
|
||||
path: real_dir.clone(),
|
||||
entries: Default::default(),
|
||||
}
|
||||
@ -238,19 +263,34 @@ impl WasiFs {
|
||||
));
|
||||
};
|
||||
// TODO: handle nested pats in `file`
|
||||
let inode_val =
|
||||
InodeVal::from_file_metadata(&cur_dir_metadata, alias.clone(), true, kind);
|
||||
|
||||
let inode = wasi_fs.inodes.insert(inode_val);
|
||||
wasi_fs.inodes[inode].stat.st_ino = wasi_fs.inode_counter.get();
|
||||
wasi_fs
|
||||
let inode = wasi_fs
|
||||
.create_inode(kind, true, alias.clone())
|
||||
.map_err(|e| {
|
||||
format!(
|
||||
"Failed to create inode for preopened dir: WASI error code: {}",
|
||||
e
|
||||
)
|
||||
})?;
|
||||
let fd = wasi_fs
|
||||
.create_fd(default_rights, default_rights, 0, inode)
|
||||
.expect("Could not open fd");
|
||||
if let Kind::Root { entries } = &mut wasi_fs.inodes[root_inode].kind {
|
||||
// todo handle collisions
|
||||
assert!(entries.insert(alias.clone(), inode).is_none());
|
||||
}
|
||||
wasi_fs.preopen_fds.push(fd);
|
||||
}
|
||||
|
||||
debug!("wasi::fs::end");
|
||||
Ok(wasi_fs)
|
||||
}
|
||||
|
||||
fn get_next_inode_index(&mut self) -> u64 {
|
||||
let next = self.inode_counter.get();
|
||||
self.inode_counter.set(next + 1);
|
||||
next
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn get_inode(&mut self, path: &str) -> Option<Inode> {
|
||||
Some(match self.name_map.entry(path.to_string()) {
|
||||
@ -311,6 +351,7 @@ impl WasiFs {
|
||||
})
|
||||
}
|
||||
|
||||
/*
|
||||
#[allow(dead_code)]
|
||||
fn filestat_inode(
|
||||
&self,
|
||||
@ -318,8 +359,13 @@ impl WasiFs {
|
||||
flags: __wasi_lookupflags_t,
|
||||
) -> Result<__wasi_filestat_t, __wasi_errno_t> {
|
||||
let inode_val = &self.inodes[inode];
|
||||
if let (true, Kind::Symlink { mut forwarded }) =
|
||||
(flags & __WASI_LOOKUP_SYMLINK_FOLLOW != 0, &inode_val.kind)
|
||||
if let (
|
||||
true,
|
||||
Kind::Symlink {
|
||||
mut forwarded,
|
||||
path,
|
||||
},
|
||||
) = (flags & __WASI_LOOKUP_SYMLINK_FOLLOW != 0, &inode_val.kind)
|
||||
{
|
||||
// Time to follow the symlink.
|
||||
let mut counter = 0;
|
||||
@ -355,6 +401,224 @@ impl WasiFs {
|
||||
|
||||
self.filestat_inode(inode, flags)
|
||||
}
|
||||
*/
|
||||
|
||||
fn get_inode_at_path_inner(
|
||||
&mut self,
|
||||
base: __wasi_fd_t,
|
||||
path: &str,
|
||||
mut symlink_count: u32,
|
||||
follow_symlinks: bool,
|
||||
) -> Result<Inode, __wasi_errno_t> {
|
||||
if symlink_count > MAX_SYMLINKS {
|
||||
return Err(__WASI_EMLINK);
|
||||
}
|
||||
|
||||
let base_dir = self.get_fd(base)?;
|
||||
let path: &Path = Path::new(path);
|
||||
|
||||
let mut cur_inode = base_dir.inode;
|
||||
// TODO: rights checks
|
||||
'path_iter: for component in path.components() {
|
||||
// for each component traverse file structure
|
||||
// loading inodes as necessary
|
||||
'symlink_resolution: while symlink_count < MAX_SYMLINKS {
|
||||
match &mut self.inodes[cur_inode].kind {
|
||||
Kind::Buffer { .. } => unimplemented!("state::get_inode_at_path for buffers"),
|
||||
Kind::Dir {
|
||||
ref mut entries,
|
||||
ref path,
|
||||
ref parent,
|
||||
..
|
||||
} => {
|
||||
match component.as_os_str().to_string_lossy().borrow() {
|
||||
".." => {
|
||||
if let Some(p) = parent {
|
||||
cur_inode = *p;
|
||||
continue 'path_iter;
|
||||
} else {
|
||||
return Err(__WASI_EACCES);
|
||||
}
|
||||
}
|
||||
"." => continue 'path_iter,
|
||||
_ => (),
|
||||
}
|
||||
// used for full resolution of symlinks
|
||||
let mut loop_for_symlink = false;
|
||||
if let Some(entry) =
|
||||
entries.get(component.as_os_str().to_string_lossy().as_ref())
|
||||
{
|
||||
cur_inode = *entry;
|
||||
} else {
|
||||
let file = {
|
||||
let mut cd = path.clone();
|
||||
cd.push(component);
|
||||
cd
|
||||
};
|
||||
// TODO: verify this returns successfully when given a non-symlink
|
||||
let metadata = file.symlink_metadata().ok().ok_or(__WASI_EINVAL)?;
|
||||
let file_type = metadata.file_type();
|
||||
|
||||
let kind = if file_type.is_dir() {
|
||||
// load DIR
|
||||
Kind::Dir {
|
||||
parent: Some(cur_inode),
|
||||
path: file.clone(),
|
||||
entries: Default::default(),
|
||||
}
|
||||
} else if file_type.is_file() {
|
||||
// load file
|
||||
Kind::File {
|
||||
handle: None,
|
||||
path: file.clone(),
|
||||
}
|
||||
} else if file_type.is_symlink() {
|
||||
let link_value = file.read_link().ok().ok_or(__WASI_EIO)?;
|
||||
debug!("attempting to decompose path {:?}", link_value);
|
||||
|
||||
let (pre_open_dir_fd, relative_path) = if link_value.is_relative() {
|
||||
self.path_into_pre_open_and_relative_path(&file)?
|
||||
} else {
|
||||
unimplemented!("Absolute symlinks are not yet supported");
|
||||
};
|
||||
loop_for_symlink = true;
|
||||
symlink_count += 1;
|
||||
Kind::Symlink {
|
||||
base_po_dir: pre_open_dir_fd,
|
||||
path_to_symlink: relative_path,
|
||||
relative_path: link_value,
|
||||
}
|
||||
} else {
|
||||
unimplemented!("state::get_inode_at_path unknown file type: not file, directory, or symlink");
|
||||
};
|
||||
|
||||
cur_inode =
|
||||
self.create_inode(kind, false, file.to_string_lossy().to_string())?;
|
||||
if loop_for_symlink && follow_symlinks {
|
||||
continue 'symlink_resolution;
|
||||
}
|
||||
}
|
||||
}
|
||||
Kind::Root { entries } => {
|
||||
match component.as_os_str().to_string_lossy().borrow() {
|
||||
// the root's parent is the root
|
||||
".." => continue 'path_iter,
|
||||
// the root's current directory is the root
|
||||
"." => continue 'path_iter,
|
||||
_ => (),
|
||||
}
|
||||
|
||||
if let Some(entry) =
|
||||
entries.get(component.as_os_str().to_string_lossy().as_ref())
|
||||
{
|
||||
cur_inode = *entry;
|
||||
} else {
|
||||
return Err(__WASI_EINVAL);
|
||||
}
|
||||
}
|
||||
Kind::File { .. } => {
|
||||
return Err(__WASI_ENOTDIR);
|
||||
}
|
||||
Kind::Symlink {
|
||||
base_po_dir,
|
||||
path_to_symlink,
|
||||
relative_path,
|
||||
} => {
|
||||
let new_base_dir = *base_po_dir;
|
||||
// allocate to reborrow mutabily to recur
|
||||
let new_path = {
|
||||
/*if let Kind::Root { .. } = self.inodes[base_po_dir].kind {
|
||||
assert!(false, "symlinks should never be relative to the root");
|
||||
}*/
|
||||
let mut base = path_to_symlink.clone();
|
||||
// remove the symlink file itself from the path, leaving just the path from the base
|
||||
// to the dir containing the symlink
|
||||
base.pop();
|
||||
base.push(relative_path);
|
||||
base.to_string_lossy().to_string()
|
||||
};
|
||||
let symlink_inode = self.get_inode_at_path_inner(
|
||||
new_base_dir,
|
||||
&new_path,
|
||||
symlink_count + 1,
|
||||
follow_symlinks,
|
||||
)?;
|
||||
cur_inode = symlink_inode;
|
||||
//continue 'symlink_resolution;
|
||||
}
|
||||
}
|
||||
break 'symlink_resolution;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(cur_inode)
|
||||
}
|
||||
|
||||
fn path_into_pre_open_and_relative_path(
|
||||
&self,
|
||||
path: &Path,
|
||||
) -> Result<(__wasi_fd_t, PathBuf), __wasi_errno_t> {
|
||||
// for each preopened directory
|
||||
for po_fd in &self.preopen_fds {
|
||||
let po_inode = self.fd_map[po_fd].inode;
|
||||
let po_path = match &self.inodes[po_inode].kind {
|
||||
Kind::Dir { path, .. } => &**path,
|
||||
Kind::Root { .. } => Path::new("/"),
|
||||
_ => unreachable!("Preopened FD that's not a directory or the root"),
|
||||
};
|
||||
// stem path based on it
|
||||
if let Ok(rest) = path.strip_prefix(po_path) {
|
||||
// if any path meets this criteria
|
||||
// (verify that all remaining components are not symlinks except for maybe last? (or do the more complex logic of resolving intermediary symlinks))
|
||||
// return preopened dir and the rest of the path
|
||||
|
||||
return Ok((*po_fd, rest.to_owned()));
|
||||
}
|
||||
}
|
||||
Err(__WASI_EINVAL) // this may not make sense
|
||||
}
|
||||
|
||||
/// gets a host file from a base directory and a path
|
||||
/// this function ensures the fs remains sandboxed
|
||||
// NOTE: follow symlinks is super weird right now
|
||||
// even if it's false, it still follows symlinks, just not the last
|
||||
// symlink so
|
||||
// This will be resolved when we have tests asserting the correct behavior
|
||||
pub fn get_inode_at_path(
|
||||
&mut self,
|
||||
base: __wasi_fd_t,
|
||||
path: &str,
|
||||
follow_symlinks: bool,
|
||||
) -> Result<Inode, __wasi_errno_t> {
|
||||
self.get_inode_at_path_inner(base, path, 0, follow_symlinks)
|
||||
}
|
||||
|
||||
/// Returns the parent Dir or Root that the file at a given path is in and the file name
|
||||
/// stripped off
|
||||
pub fn get_parent_inode_at_path(
|
||||
&mut self,
|
||||
base: __wasi_fd_t,
|
||||
path: &Path,
|
||||
follow_symlinks: bool,
|
||||
) -> Result<(Inode, String), __wasi_errno_t> {
|
||||
let mut parent_dir = std::path::PathBuf::new();
|
||||
let mut components = path.components().rev();
|
||||
let new_entity_name = components
|
||||
.next()
|
||||
.ok_or(__WASI_EINVAL)?
|
||||
.as_os_str()
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
for comp in components.rev() {
|
||||
parent_dir.push(comp);
|
||||
}
|
||||
self.get_inode_at_path(base, &parent_dir.to_string_lossy(), follow_symlinks)
|
||||
.map(|v| (v, new_entity_name))
|
||||
}
|
||||
|
||||
pub fn get_fd(&self, fd: __wasi_fd_t) -> Result<&Fd, __wasi_errno_t> {
|
||||
self.fd_map.get(&fd).ok_or(__WASI_EBADF)
|
||||
}
|
||||
|
||||
pub fn filestat_fd(&self, fd: __wasi_fd_t) -> Result<__wasi_filestat_t, __wasi_errno_t> {
|
||||
let fd = self.fd_map.get(&fd).ok_or(__WASI_EBADF)?;
|
||||
@ -414,17 +678,39 @@ impl WasiFs {
|
||||
let inode = &mut self.inodes[fd.inode];
|
||||
|
||||
match &mut inode.kind {
|
||||
Kind::File { handle } => handle.flush().map_err(|_| __WASI_EIO)?,
|
||||
Kind::File {
|
||||
handle: Some(handle),
|
||||
..
|
||||
} => handle.flush().map_err(|_| __WASI_EIO)?,
|
||||
// TODO: verify this behavior
|
||||
Kind::Dir { .. } => return Err(__WASI_EISDIR),
|
||||
Kind::Symlink { .. } => unimplemented!(),
|
||||
Kind::Buffer { .. } => (),
|
||||
_ => return Err(__WASI_EIO),
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Creates an inode and inserts it given a Kind and some extra data
|
||||
pub fn create_inode(
|
||||
&mut self,
|
||||
kind: Kind,
|
||||
is_preopened: bool,
|
||||
name: String,
|
||||
) -> Result<Inode, __wasi_errno_t> {
|
||||
let mut stat = self.get_stat_for_kind(&kind).ok_or(__WASI_EIO)?;
|
||||
stat.st_ino = self.get_next_inode_index();
|
||||
|
||||
Ok(self.inodes.insert(InodeVal {
|
||||
stat: stat,
|
||||
is_preopened,
|
||||
name,
|
||||
kind,
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn create_fd(
|
||||
&mut self,
|
||||
rights: __wasi_rights_t,
|
||||
@ -447,11 +733,90 @@ impl WasiFs {
|
||||
Ok(idx)
|
||||
}
|
||||
|
||||
pub fn get_base_path_for_directory(&self, directory: Inode) -> Option<String> {
|
||||
if let Kind::Dir { path, .. } = &self.inodes[directory].kind {
|
||||
return Some(path.to_string_lossy().to_string());
|
||||
/// This function is unsafe because it's the caller's responsibility to ensure that
|
||||
/// all refences to the given inode have been removed from the filesystem
|
||||
///
|
||||
/// returns true if the inode existed and was removed
|
||||
pub unsafe fn remove_inode(&mut self, inode: Inode) -> bool {
|
||||
self.inodes.remove(inode).is_some()
|
||||
}
|
||||
None
|
||||
|
||||
fn create_virtual_root(&mut self) -> Inode {
|
||||
let stat = __wasi_filestat_t {
|
||||
st_filetype: __WASI_FILETYPE_DIRECTORY,
|
||||
st_ino: self.get_next_inode_index(),
|
||||
..__wasi_filestat_t::default()
|
||||
};
|
||||
let root_kind = Kind::Root {
|
||||
entries: HashMap::new(),
|
||||
};
|
||||
|
||||
self.inodes.insert(InodeVal {
|
||||
stat: stat,
|
||||
is_preopened: true,
|
||||
name: "/".to_string(),
|
||||
kind: root_kind,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_stat_for_kind(&self, kind: &Kind) -> Option<__wasi_filestat_t> {
|
||||
let md = match kind {
|
||||
Kind::File { handle, path } => match handle {
|
||||
Some(WasiFile::HostFile(hf)) => hf.metadata().ok()?,
|
||||
None => path.metadata().ok()?,
|
||||
},
|
||||
Kind::Dir { path, .. } => path.metadata().ok()?,
|
||||
Kind::Symlink {
|
||||
base_po_dir,
|
||||
path_to_symlink,
|
||||
..
|
||||
} => {
|
||||
let base_po_inode = &self.fd_map[base_po_dir].inode;
|
||||
let base_po_inode_v = &self.inodes[*base_po_inode];
|
||||
match &base_po_inode_v.kind {
|
||||
Kind::Root { .. } => {
|
||||
path_to_symlink.clone().symlink_metadata().ok()?
|
||||
}
|
||||
Kind::Dir { path, .. } => {
|
||||
let mut real_path = path.clone();
|
||||
// PHASE 1: ignore all possible symlinks in `relative_path`
|
||||
// TODO: walk the segments of `relative_path` via the entries of the Dir
|
||||
// use helper function to avoid duplicating this logic (walking this will require
|
||||
// &self to be &mut sel
|
||||
// TODO: adjust size of symlink, too
|
||||
// for all paths adjusted think about this
|
||||
real_path.push(path_to_symlink);
|
||||
real_path.symlink_metadata().ok()?
|
||||
}
|
||||
// if this triggers, there's a bug in the symlink code
|
||||
_ => unreachable!("Symlink pointing to something that's not a directory as its base preopened directory"),
|
||||
}
|
||||
}
|
||||
__ => return None,
|
||||
};
|
||||
Some(__wasi_filestat_t {
|
||||
st_filetype: host_file_type_to_wasi_file_type(md.file_type()),
|
||||
st_size: md.len(),
|
||||
st_atim: md
|
||||
.accessed()
|
||||
.ok()?
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.ok()?
|
||||
.as_nanos() as u64,
|
||||
st_mtim: md
|
||||
.modified()
|
||||
.ok()?
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.ok()?
|
||||
.as_nanos() as u64,
|
||||
st_ctim: md
|
||||
.created()
|
||||
.ok()
|
||||
.and_then(|ct| ct.duration_since(SystemTime::UNIX_EPOCH).ok())
|
||||
.map(|ct| ct.as_nanos() as u64)
|
||||
.unwrap_or(0),
|
||||
..__wasi_filestat_t::default()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -474,64 +839,3 @@ pub fn host_file_type_to_wasi_file_type(file_type: fs::FileType) -> __wasi_filet
|
||||
__WASI_FILETYPE_UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_stat_for_kind(kind: &Kind) -> Option<__wasi_filestat_t> {
|
||||
match kind {
|
||||
Kind::File { handle } => match handle {
|
||||
WasiFile::HostFile(hf) => {
|
||||
let md = hf.metadata().ok()?;
|
||||
|
||||
Some(__wasi_filestat_t {
|
||||
st_filetype: host_file_type_to_wasi_file_type(md.file_type()),
|
||||
st_size: md.len(),
|
||||
st_atim: md
|
||||
.accessed()
|
||||
.ok()?
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.ok()?
|
||||
.as_nanos() as u64,
|
||||
st_mtim: md
|
||||
.modified()
|
||||
.ok()?
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.ok()?
|
||||
.as_nanos() as u64,
|
||||
st_ctim: md
|
||||
.created()
|
||||
.ok()
|
||||
.and_then(|ct| ct.duration_since(SystemTime::UNIX_EPOCH).ok())
|
||||
.map(|ct| ct.as_nanos() as u64)
|
||||
.unwrap_or(0),
|
||||
..__wasi_filestat_t::default()
|
||||
})
|
||||
}
|
||||
},
|
||||
Kind::Dir { path, .. } => {
|
||||
let md = path.metadata().ok()?;
|
||||
Some(__wasi_filestat_t {
|
||||
st_filetype: host_file_type_to_wasi_file_type(md.file_type()),
|
||||
st_size: md.len(),
|
||||
st_atim: md
|
||||
.accessed()
|
||||
.ok()?
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.ok()?
|
||||
.as_nanos() as u64,
|
||||
st_mtim: md
|
||||
.modified()
|
||||
.ok()?
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.ok()?
|
||||
.as_nanos() as u64,
|
||||
st_ctim: md
|
||||
.created()
|
||||
.ok()
|
||||
.and_then(|ct| ct.duration_since(SystemTime::UNIX_EPOCH).ok())
|
||||
.map(|ct| ct.as_nanos() as u64)
|
||||
.unwrap_or(0),
|
||||
..__wasi_filestat_t::default()
|
||||
})
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
||||
use crate::syscalls::types::*;
|
||||
use std::cell::Cell;
|
||||
use wasmer_runtime_core::debug;
|
||||
|
||||
pub fn platform_clock_res_get(
|
||||
clock_id: __wasi_clockid_t,
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wasmer-win-exception-handler"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
description = "Wasmer runtime exception handling for Windows"
|
||||
license = "MIT"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
@ -8,7 +8,7 @@ repository = "https://github.com/wasmerio/wasmer"
|
||||
edition = "2018"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.5" }
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.6" }
|
||||
winapi = { version = "0.3", features = ["winbase", "errhandlingapi", "minwindef", "minwinbase", "winnt"] }
|
||||
libc = "0.2.49"
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
ignore = [
|
||||
"src/spectests",
|
||||
"src/emtests",
|
||||
"src/emscripten-tests",
|
||||
"src/wasi-tests",
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
PREVIOUS_VERSION='0.5.4'
|
||||
NEXT_VERSION='0.5.5'
|
||||
PREVIOUS_VERSION='0.5.5'
|
||||
NEXT_VERSION='0.5.6'
|
||||
|
||||
# quick hack
|
||||
fd Cargo.toml --exec sed -i '' "s/version = \"$PREVIOUS_VERSION\"/version = \"$NEXT_VERSION\"/"
|
||||
|
2
wapm-cli
2
wapm-cli
Submodule wapm-cli updated: e2aefd4b6b...192cd2cebd
Reference in New Issue
Block a user