diff --git a/CHANGELOG.md b/CHANGELOG.md index cb9c485b35e..51d03c0a5a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -898,7 +898,7 @@ Special thanks to [@ethanfrey](https://github.com/ethanfrey), [@AdamSLevy](https - [#992](https://github.com/wasmerio/wasmer/pull/992) Updates WAPM version to 0.4.1, fix arguments issue introduced in #990 - [#990](https://github.com/wasmerio/wasmer/pull/990) Default wasmer CLI to `run`. Wasmer will now attempt to parse unrecognized command line options as if they were applied to the run command: `wasmer mywasm.wasm --dir=.` now works! - [#987](https://github.com/wasmerio/wasmer/pull/987) Fix `runtime-c-api` header files when compiled by gnuc. -- [#957](https://github.com/wasmerio/wasmer/pull/957) Change the meaning of `wasmer_wasi::is_wasi_module` to detect any type of WASI module, add support for new wasi snapshot_preview1 +- [#957](https://github.com/wasmerio/wasmer/pull/957) Change the meaning of `wasmer_wasix::is_wasi_module` to detect any type of WASI module, add support for new wasi snapshot_preview1 - [#934](https://github.com/wasmerio/wasmer/pull/934) Simplify float expressions in the LLVM backend. ## 0.10.2 - 2019-11-18 diff --git a/Cargo.lock b/Cargo.lock index 4af84bf85fd..d408f1238a8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4369,6 +4369,42 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "virtual-fs" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-trait", + "bytes", + "derivative", + "filetime", + "fs_extra", + "indexmap", + "lazy_static", + "libc", + "pin-project-lite", + "pretty_assertions", + "slab", + "tempfile", + "thiserror", + "tokio", + "tracing", + "typetag", + "webc", +] + +[[package]] +name = "virtual-net" +version = "0.1.0" +dependencies = [ + "async-trait", + "bytes", + "libc", + "thiserror", + "tokio", + "tracing", +] + [[package]] name = "void" version = "1.0.2" @@ -4798,6 +4834,7 @@ dependencies = [ "paste", "thiserror", "typetag", + "virtual-fs", "wasmer", "wasmer-compiler", "wasmer-compiler-cranelift", @@ -4807,8 +4844,7 @@ dependencies = [ "wasmer-inline-c", "wasmer-middlewares", "wasmer-types", - "wasmer-vfs", - "wasmer-wasi", + "wasmer-wasix", "webc", ] @@ -4893,6 +4929,8 @@ dependencies = [ "tracing-subscriber 0.3.16", "unix_mode", "url", + "virtual-fs", + "virtual-net", "walkdir", "wasm-coredump-builder", "wasmer", @@ -4906,12 +4944,9 @@ dependencies = [ "wasmer-registry", "wasmer-toml", "wasmer-types", - "wasmer-vfs", "wasmer-vm", - "wasmer-vnet", - "wasmer-wasi", - "wasmer-wasi-experimental-io-devices", - "wasmer-wasi-local-networking", + "wasmer-wasix", + "wasmer-wasix-experimental-io-devices", "wasmer-wasm-interface", "wasmer-wast", "wasmparser 0.51.4", @@ -5157,7 +5192,7 @@ dependencies = [ [[package]] name = "wasmer-sys-utils" -version = "3.2.0-alpha.1" +version = "0.1.0" dependencies = [ "libc", "region", @@ -5166,7 +5201,7 @@ dependencies = [ "wasmer", "wasmer-types", "wasmer-vm", - "wasmer-wasi", + "wasmer-wasix", ] [[package]] @@ -5202,30 +5237,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "wasmer-vfs" -version = "3.2.0-alpha.1" -dependencies = [ - "anyhow", - "async-trait", - "bytes", - "derivative", - "filetime", - "fs_extra", - "indexmap", - "lazy_static", - "libc", - "pin-project-lite", - "pretty_assertions", - "slab", - "tempfile", - "thiserror", - "tokio", - "tracing", - "typetag", - "webc", -] - [[package]] name = "wasmer-vm" version = "3.2.0-alpha.1" @@ -5252,18 +5263,8 @@ dependencies = [ ] [[package]] -name = "wasmer-vnet" -version = "3.2.0-alpha.1" -dependencies = [ - "async-trait", - "bytes", - "thiserror", - "tracing", -] - -[[package]] -name = "wasmer-wasi" -version = "3.2.0-alpha.1" +name = "wasmer-wasix" +version = "0.1.0" dependencies = [ "anyhow", "async-trait", @@ -5302,6 +5303,8 @@ dependencies = [ "tracing-wasm", "typetag", "urlencoding", + "virtual-fs", + "virtual-net", "wai-bindgen-wasmer", "waker-fn", "wasm-bindgen", @@ -5310,11 +5313,8 @@ dependencies = [ "wasmer-compiler", "wasmer-emscripten", "wasmer-types", - "wasmer-vfs", "wasmer-vm", - "wasmer-vnet", - "wasmer-wasi-local-networking", - "wasmer-wasi-types", + "wasmer-wasix-types", "wcgi", "wcgi-host", "webc", @@ -5323,8 +5323,8 @@ dependencies = [ ] [[package]] -name = "wasmer-wasi-experimental-io-devices" -version = "3.2.0-alpha.1" +name = "wasmer-wasix-experimental-io-devices" +version = "0.1.0" dependencies = [ "minifb", "nix 0.25.1", @@ -5332,25 +5332,13 @@ dependencies = [ "serde", "tracing", "typetag", - "wasmer-wasi", - "wasmer-wasi-types", + "wasmer-wasix", + "wasmer-wasix-types", ] [[package]] -name = "wasmer-wasi-local-networking" -version = "3.2.0-alpha.1" -dependencies = [ - "async-trait", - "bytes", - "libc", - "tokio", - "tracing", - "wasmer-vnet", -] - -[[package]] -name = "wasmer-wasi-types" -version = "3.2.0-alpha.1" +name = "wasmer-wasix-types" +version = "0.1.0" dependencies = [ "anyhow", "bitflags", @@ -5391,9 +5379,9 @@ dependencies = [ "tempfile", "thiserror", "tokio", + "virtual-fs", "wasmer", - "wasmer-vfs", - "wasmer-wasi", + "wasmer-wasix", "wast 38.0.1", ] @@ -5425,7 +5413,7 @@ dependencies = [ "wasmer-emscripten", "wasmer-middlewares", "wasmer-types", - "wasmer-wasi", + "wasmer-wasix", "wasmer-wast", ] diff --git a/Cargo.toml b/Cargo.toml index 2ed45f1da93..5c753eaf9c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ wasmer-compiler-cranelift = { version = "=3.2.0-alpha.1", path = "lib/compiler-c wasmer-compiler-singlepass = { version = "=3.2.0-alpha.1", path = "lib/compiler-singlepass", optional = true } wasmer-compiler-llvm = { version = "=3.2.0-alpha.1", path = "lib/compiler-llvm", optional = true } wasmer-emscripten = { version = "=3.2.0-alpha.1", path = "lib/emscripten", optional = true } -wasmer-wasi = { version = "=3.2.0-alpha.1", path = "lib/wasi", optional = true } +wasmer-wasix = { version = "0.1.0", path = "lib/wasi", optional = true } wasmer-wast = { version = "=3.2.0-alpha.1", path = "tests/lib/wast", optional = true } wasi-test-generator = { version = "=3.2.0-alpha.1", path = "tests/wasi-wast", optional = true } wasmer-cache = { version = "=3.2.0-alpha.1", path = "lib/cache", optional = true } @@ -49,7 +49,6 @@ members = [ "lib/wasi", "lib/wasi-types", "lib/wasi-experimental-io-devices", - "lib/wasi-local-networking", "lib/wasix/wasix-http-client", "lib/wasm-interface", "lib/c-api/tests/wasmer-c-api-test-runner", @@ -106,7 +105,7 @@ engine = ["universal"] universal = [] cache = ["wasmer-cache"] wast = ["wasmer-wast"] -wasi = ["wasmer-wasi"] +wasi = ["wasmer-wasix"] emscripten = ["wasmer-emscripten"] wat = ["wasmer/wat"] compiler = ["wasmer/compiler", "wasmer-compiler/translator"] diff --git a/examples/wasi.rs b/examples/wasi.rs index 15c537a94fa..7ba99086411 100644 --- a/examples/wasi.rs +++ b/examples/wasi.rs @@ -18,7 +18,7 @@ use std::io::Read; use wasmer::{Module, Store}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_wasi::{Pipe, WasiEnv}; +use wasmer_wasix::{Pipe, WasiEnv}; fn main() -> Result<(), Box> { let wasm_path = concat!( diff --git a/examples/wasi_manual_setup.rs b/examples/wasi_manual_setup.rs index 60a1f95b2a5..9967b5cec45 100644 --- a/examples/wasi_manual_setup.rs +++ b/examples/wasi_manual_setup.rs @@ -17,7 +17,7 @@ use wasmer::{Instance, Module, Store}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_wasi::WasiEnv; +use wasmer_wasix::WasiEnv; fn main() -> Result<(), Box> { let wasm_path = concat!( diff --git a/examples/wasi_pipes.rs b/examples/wasi_pipes.rs index ff10933ae19..2629e398291 100644 --- a/examples/wasi_pipes.rs +++ b/examples/wasi_pipes.rs @@ -14,7 +14,7 @@ use std::io::{Read, Write}; use wasmer::{Module, Store}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_wasi::{Pipe, WasiEnv}; +use wasmer_wasix::{Pipe, WasiEnv}; fn main() -> Result<(), Box> { let wasm_path = concat!( diff --git a/lib/c-api/Cargo.toml b/lib/c-api/Cargo.toml index 04413d379ac..14c03c2ef25 100644 --- a/lib/c-api/Cargo.toml +++ b/lib/c-api/Cargo.toml @@ -29,9 +29,9 @@ wasmer-compiler-llvm = { version = "=3.2.0-alpha.1", path = "../compiler-llvm", wasmer-emscripten = { version = "=3.2.0-alpha.1", path = "../emscripten", optional = true } wasmer-compiler = { version = "=3.2.0-alpha.1", path = "../compiler" } wasmer-middlewares = { version = "=3.2.0-alpha.1", path = "../middlewares", optional = true } -wasmer-wasi = { version = "=3.2.0-alpha.1", path = "../wasi", features = ["host-fs", "host-vnet"], optional = true } +wasmer-wasix = { version = "0.1.0", path = "../wasi", features = ["host-fs", "host-vnet"], optional = true } wasmer-types = { version = "=3.2.0-alpha.1", path = "../types" } -wasmer-vfs = { version = "=3.2.0-alpha.1", path = "../vfs", optional = true, default-features = false, features = ["static-fs"] } +virtual-fs = { version = "0.1.0", path = "../vfs", optional = true, default-features = false, features = ["static-fs"] } webc = { version = "5.0.0-rc.5", optional = true } enumset = "1.0.2" cfg-if = "1.0" @@ -59,7 +59,7 @@ default = [ "middlewares", ] wat = ["wasmer-api/wat"] -wasi = ["wasmer-wasi"] +wasi = ["wasmer-wasix"] middlewares = [ "compiler", "wasmer-middlewares", @@ -92,7 +92,7 @@ wasmer-artifact-load = ["wasmer-compiler/wasmer-artifact-load"] wasmer-artifact-create = ["wasmer-compiler/wasmer-artifact-create"] static-artifact-load = ["wasmer-compiler/static-artifact-load"] static-artifact-create = ["wasmer-compiler/static-artifact-create"] -webc_runner = ["wasmer-wasi/webc_runner", "wasmer-vfs", "webc"] +webc_runner = ["wasmer-wasix/webc_runner", "virtual-fs", "webc"] # Deprecated features. jit = ["compiler"] diff --git a/lib/c-api/src/wasm_c_api/wasi/mod.rs b/lib/c-api/src/wasm_c_api/wasi/mod.rs index 4b8afc1bb2b..360ba0ebda8 100644 --- a/lib/c-api/src/wasm_c_api/wasi/mod.rs +++ b/lib/c-api/src/wasm_c_api/wasi/mod.rs @@ -18,8 +18,8 @@ use std::os::raw::c_char; use std::slice; #[cfg(feature = "webc_runner")] use wasmer_api::{AsStoreMut, Imports, Module}; -use wasmer_wasi::{ - default_fs_backing, get_wasi_version, wasmer_vfs::AsyncReadExt, Pipe, VirtualTaskManager, +use wasmer_wasix::{ + default_fs_backing, get_wasi_version, virtual_fs::AsyncReadExt, Pipe, VirtualTaskManager, WasiEnv, WasiEnvBuilder, WasiFile, WasiFunctionEnv, WasiVersion, }; @@ -248,7 +248,7 @@ fn prepare_webc_env( len: usize, package_name: &str, ) -> Option<(WasiFunctionEnv, Imports)> { - use wasmer_vfs::static_fs::StaticFileSystem; + use virtual_fs::static_fs::StaticFileSystem; use webc::v1::{FsEntryType, WebC}; let slice = unsafe { std::slice::from_raw_parts(bytes, len) }; diff --git a/lib/cli/Cargo.toml b/lib/cli/Cargo.toml index fa6a0875e9f..98f31c99863 100644 --- a/lib/cli/Cargo.toml +++ b/lib/cli/Cargo.toml @@ -32,16 +32,15 @@ wasmer-compiler-singlepass = { version = "=3.2.0-alpha.1", path = "../compiler-s wasmer-compiler-llvm = { version = "=3.2.0-alpha.1", path = "../compiler-llvm", optional = true } wasmer-emscripten = { version = "=3.2.0-alpha.1", path = "../emscripten", optional = true } wasmer-vm = { version = "=3.2.0-alpha.1", path = "../vm" } -wasmer-wasi = { version = "=3.2.0-alpha.1", path = "../wasi", optional = true } -wasmer-wasi-experimental-io-devices = { version = "=3.2.0-alpha.1", path = "../wasi-experimental-io-devices", optional = true, features = ["link_external_libs"] } -wasmer-wasi-local-networking = { version = "=3.2.0-alpha.1", path = "../wasi-local-networking", optional = true } +wasmer-wasix = { version = "0.1.0", path = "../wasi", optional = true } +wasmer-wasix-experimental-io-devices = { version = "0.1.0", path = "../wasi-experimental-io-devices", optional = true, features = ["link_external_libs"] } wasmer-wast = { version = "=3.2.0-alpha.1", path = "../../tests/lib/wast", optional = true } wasmer-cache = { version = "=3.2.0-alpha.1", path = "../cache", optional = true } wasmer-types = { version = "=3.2.0-alpha.1", path = "../types", features = ["enable-serde"] } wasmer-registry = { version = "=4.0.0", path = "../registry" } wasmer-object = { version = "=3.2.0-alpha.1", path = "../object", optional = true } -wasmer-vfs = { version = "=3.2.0-alpha.1", path = "../vfs", default-features = false, features = ["host-fs"] } -wasmer-vnet = { version = "=3.2.0-alpha.1", path = "../vnet" } +virtual-fs = { version = "0.1.0", path = "../vfs", default-features = false, features = ["host-fs"] } +virtual-net = { version = "0.1.0", path = "../vnet" } wasmer-wasm-interface = { version = "3.2.0-alpha.1", path = "../wasm-interface" } wasmparser = "0.51.4" atty = "0.2" @@ -116,14 +115,23 @@ default = [ cache = ["wasmer-cache"] cache-blake3-pure = ["wasmer-cache/blake3-pure"] wast = ["wasmer-wast"] -wasi = ["wasmer-wasi", "wasmer-wasi-local-networking"] +wasi = ["wasmer-wasix", "host-net"] +host-net = [ "virtual-net/host-net" ] emscripten = ["wasmer-emscripten"] wat = ["wasmer/wat"] -webc_runner = ["wasi", "wasmer-wasi/webc_runner", "wasmer-wasi/webc_runner_rt_wasi", "wasmer-wasi/webc_runner_rt_wcgi", "wasmer-wasi/webc_runner_rt_emscripten", "nuke-dir", "webc"] +webc_runner = [ + "wasi", + "wasmer-wasix/webc_runner", + "wasmer-wasix/webc_runner_rt_wasi", + "wasmer-wasix/webc_runner_rt_wcgi", + "wasmer-wasix/webc_runner_rt_emscripten", + "nuke-dir", + "webc" +] compiler = [ "wasmer-compiler/translator", "wasmer-compiler/compiler", - "wasmer-wasi/compiler" + "wasmer-wasix/compiler" ] wasmer-artifact-create = ["compiler", "wasmer/wasmer-artifact-load", @@ -149,7 +157,7 @@ static-artifact-load = ["compiler", ] experimental-io-devices = [ - "wasmer-wasi-experimental-io-devices", + "wasmer-wasix-experimental-io-devices", "wasi" ] singlepass = [ @@ -164,8 +172,8 @@ llvm = [ "wasmer-compiler-llvm", "compiler", ] -debug = ["tracing", "wasmer-wasi/logging"] -disable-all-logging = ["wasmer-wasi/disable-all-logging", "log/release_max_level_off"] +debug = ["tracing", "wasmer-wasix/logging"] +disable-all-logging = ["wasmer-wasix/disable-all-logging", "log/release_max_level_off"] headless = [] headless-minimal = ["headless", "disable-all-logging", "wasi"] tracing = [ "dep:tracing", "tracing-subscriber" ] @@ -175,7 +183,7 @@ enable-serde = [ "wasmer/enable-serde", "wasmer-vm/enable-serde", "wasmer-compiler/enable-serde", - "wasmer-wasi/enable-serde", + "wasmer-wasix/enable-serde", ] [target.'cfg(target_os = "windows")'.dependencies] diff --git a/lib/cli/src/commands/run.rs b/lib/cli/src/commands/run.rs index e5b1f4e78b7..3e8b9787f13 100644 --- a/lib/cli/src/commands/run.rs +++ b/lib/cli/src/commands/run.rs @@ -21,7 +21,7 @@ use wasmer::*; use wasmer_cache::{Cache, FileSystemCache, Hash}; use wasmer_types::Type as ValueType; #[cfg(feature = "webc_runner")] -use wasmer_wasi::runners::{Runner, WapmContainer}; +use wasmer_wasix::runners::{Runner, WapmContainer}; #[cfg(feature = "wasi")] mod wasi; @@ -288,7 +288,7 @@ impl RunWithPathBuf { #[cfg(feature = "wasi")] let ret = { use std::collections::BTreeSet; - use wasmer_wasi::WasiVersion; + use wasmer_wasix::WasiVersion; let wasi_versions = Wasi::get_versions(&module); match wasi_versions { @@ -387,14 +387,14 @@ impl RunWithPathBuf { .with_context(|| format!("No metadata found for the command, \"{id}\""))?; let (store, _compiler_type) = self.store.get_store()?; - let mut runner = wasmer_wasi::runners::wasi::WasiRunner::new(store); + let mut runner = wasmer_wasix::runners::wasi::WasiRunner::new(store); runner.set_args(args.to_vec()); if runner.can_run_command(id, command).unwrap_or(false) { return runner.run_cmd(&container, id).context("WASI runner failed"); } let (store, _compiler_type) = self.store.get_store()?; - let mut runner = wasmer_wasi::runners::emscripten::EmscriptenRunner::new(store); + let mut runner = wasmer_wasix::runners::emscripten::EmscriptenRunner::new(store); runner.set_args(args.to_vec()); if runner.can_run_command(id, command).unwrap_or(false) { return runner @@ -402,7 +402,7 @@ impl RunWithPathBuf { .context("Emscripten runner failed"); } - let mut runner = wasmer_wasi::runners::wcgi::WcgiRunner::new(id); + let mut runner = wasmer_wasix::runners::wcgi::WcgiRunner::new(id); let (store, _compiler_type) = self.store.get_store()?; runner .config() diff --git a/lib/cli/src/commands/run/wasi.rs b/lib/cli/src/commands/run/wasi.rs index 7f609d6e3e7..5bd7a31ca3c 100644 --- a/lib/cli/src/commands/run/wasi.rs +++ b/lib/cli/src/commands/run/wasi.rs @@ -4,11 +4,11 @@ use std::collections::HashMap; use std::path::PathBuf; use std::sync::Arc; use std::{collections::BTreeSet, path::Path}; +use virtual_fs::FileSystem; +use virtual_fs::{DeviceFile, PassthruFileSystem, RootFileSystemBuilder}; use wasmer::{AsStoreMut, Instance, Module, RuntimeError, Value}; -use wasmer_vfs::FileSystem; -use wasmer_vfs::{DeviceFile, PassthruFileSystem, RootFileSystemBuilder}; -use wasmer_wasi::types::__WASI_STDIN_FILENO; -use wasmer_wasi::{ +use wasmer_wasix::types::__WASI_STDIN_FILENO; +use wasmer_wasix::{ default_fs_backing, get_wasi_versions, PluggableRuntimeImplementation, WasiEnv, WasiError, WasiFunctionEnv, WasiVersion, }; @@ -121,11 +121,9 @@ impl Wasi { let mut rt = PluggableRuntimeImplementation::default(); if self.networking { - rt.set_networking_implementation( - wasmer_wasi_local_networking::LocalNetworking::default(), - ); + rt.set_networking_implementation(virtual_net::host::LocalNetworking::default()); } else { - rt.set_networking_implementation(wasmer_vnet::UnsupportedVirtualNetworking::default()); + rt.set_networking_implementation(virtual_net::UnsupportedVirtualNetworking::default()); } let engine = store.as_store_mut().engine().clone(); @@ -138,7 +136,7 @@ impl Wasi { .uses(self.uses.clone()) .map_commands(map_commands); - let mut builder = if wasmer_wasi::is_wasix_module(module) { + let mut builder = if wasmer_wasix::is_wasix_module(module) { // If we preopen anything from the host then shallow copy it over let root_fs = RootFileSystemBuilder::new() .with_tty(Box::new(DeviceFile::new(__WASI_STDIN_FILENO))) @@ -169,7 +167,7 @@ impl Wasi { }; if self.http_client { - let caps = wasmer_wasi::http::HttpClientCapabilityV1::new_allow_all(); + let caps = wasmer_wasix::http::HttpClientCapabilityV1::new_allow_all(); builder.capabilities_mut().http_client = caps; } diff --git a/lib/sys-utils/Cargo.toml b/lib/sys-utils/Cargo.toml index 998ec902065..edc0f4a7641 100644 --- a/lib/sys-utils/Cargo.toml +++ b/lib/sys-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasmer-sys-utils" -version = "3.2.0-alpha.1" +version = "0.1.0" description = "Wasmer utilities for a sys environment." categories = ["wasm"] keywords = ["wasm", "webassembly"] @@ -19,7 +19,7 @@ region = { version = "3.0" } libc = { version = "^0.2", default-features = false } [dev-dependencies] -wasmer-wasi = { path = "../wasi", version = "=3.2.0-alpha.1" } +wasmer-wasix = { path = "../wasi", version = "0.1.0" } wasmer = { path = "../api", version = "=3.2.0-alpha.1", default-features = false, features = ["sys", "compiler", "cranelift"] } tracing-subscriber = { version = "0.3.16", features = ["fmt"] } tracing = "0.1.37" diff --git a/lib/sys-utils/tests/fd_mmap_memory.rs b/lib/sys-utils/tests/fd_mmap_memory.rs index 7e2c44418dd..b502b0cd1dc 100644 --- a/lib/sys-utils/tests/fd_mmap_memory.rs +++ b/lib/sys-utils/tests/fd_mmap_memory.rs @@ -3,8 +3,8 @@ // use wasmer::{BaseTunables, Engine, Module, Store, Tunables}; // use wasmer_vm::VMMemory; -// use wasmer_wasi::{ -// bin_factory::spawn_exec_module, wasmer_vfs::host_fs::File, BusSpawnedProcessJoin, +// use wasmer_wasix::{ +// bin_factory::spawn_exec_module, virtual_fs::host_fs::File, BusSpawnedProcessJoin, // PluggableRuntimeImplementation, WasiControlPlane, WasiEnv, WasiRuntime, // WasiState, // }; @@ -101,9 +101,9 @@ // // .clone(); // // Generate an `ImportObject`. -// // let instance = wasmer_wasi::build_wasi_instance(&module, &mut wasi_env, &mut store).unwrap(); +// // let instance = wasmer_wasix::build_wasi_instance(&module, &mut wasi_env, &mut store).unwrap(); -// let config = wasmer_wasi::wasmer_vbus::SpawnOptionsConfig { +// let config = wasmer_wasix::wasmer_vbus::SpawnOptionsConfig { // reuse: false, // env: wasi_env.data(&store).clone(), // remote_instance: None, diff --git a/lib/vfs/Cargo.toml b/lib/vfs/Cargo.toml index 5b11cabb8d6..24a40d778f6 100644 --- a/lib/vfs/Cargo.toml +++ b/lib/vfs/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "wasmer-vfs" -version = "3.2.0-alpha.1" +name = "virtual-fs" +version = "0.1.0" description = "Wasmer Virtual FileSystem" authors = ["Wasmer Engineering Team "] license = "MIT" diff --git a/lib/vfs/src/overlay_fs.rs b/lib/vfs/src/overlay_fs.rs index b1e96a8bd18..d65a81c0ecd 100644 --- a/lib/vfs/src/overlay_fs.rs +++ b/lib/vfs/src/overlay_fs.rs @@ -26,7 +26,7 @@ use crate::{ /// might do something like this: /// /// ```rust -/// use wasmer_vfs::{ +/// use virtual_fs::{ /// mem_fs::FileSystem as MemFS, /// host_fs::FileSystem as HostFS, /// OverlayFileSystem, diff --git a/lib/vfs/src/union_fs.rs b/lib/vfs/src/union_fs.rs index 9685f588110..d85db2da04a 100644 --- a/lib/vfs/src/union_fs.rs +++ b/lib/vfs/src/union_fs.rs @@ -311,7 +311,7 @@ impl FileSystem for UnionFileSystem { Err(err) => { // This fixes a bug when attempting to create the directory /usr when it does not exist // on the x86 version of memfs - // TODO: patch wasmer_vfs and remove + // TODO: patch virtual-fs and remove if let FsError::NotAFile = &err { ret_error = FsError::EntryNotFound; } else { @@ -335,7 +335,7 @@ impl FileSystem for UnionFileSystem { Err(err) => { // This fixes a bug when attempting to create the directory /usr when it does not exist // on the x86 version of memfs - // TODO: patch wasmer_vfs and remove + // TODO: patch virtual-fs and remove if let FsError::NotAFile = &err { ret_error = FsError::EntryNotFound; } else { diff --git a/lib/vnet/Cargo.toml b/lib/vnet/Cargo.toml index 1b04a4aa89c..aa25859a700 100644 --- a/lib/vnet/Cargo.toml +++ b/lib/vnet/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "wasmer-vnet" -version = "3.2.0-alpha.1" +name = "virtual-net" +version = "0.1.0" description = "Wasmer Virtual Networking" authors = ["Wasmer Engineering Team "] license = "MIT" @@ -8,6 +8,11 @@ edition = "2018" [dependencies] thiserror = "1" -bytes = "1" +bytes = "1.1" async-trait = { version = "^0.1" } tracing = "0.1" +tokio = { version = "1", features = [ "sync", "macros", "io-util", "signal" ], default_features = false, optional = true } +libc = { version = "0.2.139", optional = true } + +[features] +host-net = [ "tokio", "libc" ] diff --git a/lib/wasi-local-networking/src/lib.rs b/lib/vnet/src/host.rs similarity index 99% rename from lib/wasi-local-networking/src/lib.rs rename to lib/vnet/src/host.rs index c1485feec0c..0866f1a20f3 100644 --- a/lib/wasi-local-networking/src/lib.rs +++ b/lib/vnet/src/host.rs @@ -1,4 +1,10 @@ #![allow(unused_variables)] +#[allow(unused_imports)] +use crate::{ + IpCidr, IpRoute, NetworkError, Result, SocketStatus, StreamSecurity, VirtualConnectedSocket, + VirtualConnectionlessSocket, VirtualIcmpSocket, VirtualNetworking, VirtualRawSocket, + VirtualSocket, VirtualTcpListener, VirtualTcpSocket, VirtualUdpSocket, +}; use std::future::Future; use std::mem::MaybeUninit; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; @@ -10,12 +16,6 @@ use std::time::Duration; use tokio::sync::mpsc; #[allow(unused_imports, dead_code)] use tracing::{debug, error, info, trace, warn}; -#[allow(unused_imports)] -use wasmer_vnet::{ - IpCidr, IpRoute, NetworkError, Result, SocketStatus, StreamSecurity, VirtualConnectedSocket, - VirtualConnectionlessSocket, VirtualIcmpSocket, VirtualNetworking, VirtualRawSocket, - VirtualSocket, VirtualTcpListener, VirtualTcpSocket, VirtualUdpSocket, -}; #[derive(Debug)] pub struct LocalNetworking { diff --git a/lib/vnet/src/lib.rs b/lib/vnet/src/lib.rs index 4ae1cdc72c9..e48bf2384ea 100644 --- a/lib/vnet/src/lib.rs +++ b/lib/vnet/src/lib.rs @@ -529,3 +529,6 @@ pub enum NetworkError { #[error("unknown error found")] UnknownError, } + +#[cfg(feature = "host-net")] +pub mod host; diff --git a/lib/wasi-experimental-io-devices/Cargo.toml b/lib/wasi-experimental-io-devices/Cargo.toml index 38e6c05399f..f4a4063d97e 100644 --- a/lib/wasi-experimental-io-devices/Cargo.toml +++ b/lib/wasi-experimental-io-devices/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "wasmer-wasi-experimental-io-devices" -version = "3.2.0-alpha.1" -description = "An experimental non-standard WASI extension for graphics" +name = "wasmer-wasix-experimental-io-devices" +version = "0.1.0" +description = "An experimental non-standard WASI/WASIX extension for graphics" categories = ["wasm"] keywords = ["wasm", "webassembly", "types"] authors = ["Wasmer Engineering Team "] @@ -14,8 +14,8 @@ edition = "2018" maintenance = { status = "experimental" } [dependencies] -wasmer-wasi = { version = "=3.2.0-alpha.1", path = "../wasi", default-features=false } -wasmer-wasi-types = { path = "../wasi-types", version = "=3.2.0-alpha.1" } +wasmer-wasix = { version = "0.1.0", path = "../wasi", default-features=false } +wasmer-wasix-types = { path = "../wasi-types", version = "0.1.0" } tracing = "0.1" minifb = { version = "0.24.0", optional = true } nix = "0.25.0" @@ -25,10 +25,10 @@ typetag = "0.1" [features] default = [ - "wasmer-wasi/default" + "wasmer-wasix/default" ] enable-serde = [ - "wasmer-wasi/enable-serde" + "wasmer-wasix/enable-serde" ] # This feature exists, so that "cargo build --all" doesn't # accidentally link libxcbcommon and libwayland into the CLI diff --git a/lib/wasi-experimental-io-devices/src/lib.rs b/lib/wasi-experimental-io-devices/src/lib.rs index 4d9010789f6..8b6e3050b60 100644 --- a/lib/wasi-experimental-io-devices/src/lib.rs +++ b/lib/wasi-experimental-io-devices/src/lib.rs @@ -6,9 +6,9 @@ pub mod link_ext; pub use crate::link_ext::*; #[cfg(not(feature = "link_external_libs"))] -use wasmer_wasi::fs::WasiFs; +use wasmer_wasix::fs::WasiFs; #[cfg(not(feature = "link_external_libs"))] -use wasmer_wasi::fs::WasiInodes; +use wasmer_wasix::fs::WasiInodes; #[cfg(not(feature = "link_external_libs"))] pub fn initialize(_: &WasiInodes, _: &mut WasiFs) -> Result<(), String> { diff --git a/lib/wasi-experimental-io-devices/src/link-ext.rs b/lib/wasi-experimental-io-devices/src/link-ext.rs index 81264838cd1..250d201fc0d 100644 --- a/lib/wasi-experimental-io-devices/src/link-ext.rs +++ b/lib/wasi-experimental-io-devices/src/link-ext.rs @@ -5,9 +5,9 @@ use std::collections::{BTreeSet, VecDeque}; use std::convert::TryInto; use std::io::{Read, Seek, SeekFrom, Write}; use tracing::debug; -use wasmer_wasi::types::{wasi::Filesize, *}; -use wasmer_wasi::{VirtualFile, WasiFsError, ALL_RIGHTS}; -use wasmer_wasi_types::wasi::Fdflags; +use wasmer_wasix::types::{wasi::Filesize, *}; +use wasmer_wasix::{VirtualFile, WasiFsError, ALL_RIGHTS}; +use wasmer_wasix_types::wasi::Fdflags; use minifb::{Key, KeyRepeat, MouseButton, Scale, Window, WindowOptions}; @@ -16,8 +16,8 @@ mod util; use util::*; use std::cell::RefCell; -use wasmer_wasi::os::fs::fd::Fd; -use wasmer_wasi::os::fs::{WasiFs, WasiInodes, VIRTUAL_ROOT_FD}; +use wasmer_wasix::os::fs::fd::Fd; +use wasmer_wasix::os::fs::{WasiFs, WasiInodes, VIRTUAL_ROOT_FD}; std::thread_local! { pub(crate) static FRAMEBUFFER_STATE: RefCell = RefCell::new(FrameBufferState::new() diff --git a/lib/wasi-local-networking/Cargo.toml b/lib/wasi-local-networking/Cargo.toml deleted file mode 100644 index 693ead78b19..00000000000 --- a/lib/wasi-local-networking/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "wasmer-wasi-local-networking" -version = "3.2.0-alpha.1" -description = "An WASIX extension for local networking" -categories = ["wasm"] -keywords = ["wasm", "webassembly", "types"] -authors = ["Wasmer Engineering Team "] -repository = "https://github.com/wasmerio/wasmer" -license = "MIT" -readme = "README.md" -edition = "2018" - -[badges] -maintenance = { status = "experimental" } - -[dependencies] -wasmer-vnet = { version = "=3.2.0-alpha.1", path = "../vnet" } -tracing = "0.1" -bytes = "1.1" -tokio = { version = "1", features = [ "sync", "macros", "io-util", "signal" ], default_features = false } -async-trait = { version = "^0.1" } -libc = "0.2.139" diff --git a/lib/wasi-local-networking/README.md b/lib/wasi-local-networking/README.md deleted file mode 100644 index 52a966a2046..00000000000 --- a/lib/wasi-local-networking/README.md +++ /dev/null @@ -1 +0,0 @@ -This is experimental extension of WASIX for networking. diff --git a/lib/wasi-types/Cargo.toml b/lib/wasi-types/Cargo.toml index cb542b6bced..d6691fb1867 100644 --- a/lib/wasi-types/Cargo.toml +++ b/lib/wasi-types/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "wasmer-wasi-types" -version = "3.2.0-alpha.1" -description = "WASI types for Wasmer WebAssembly runtime" +name = "wasmer-wasix-types" +version = "0.1.0" +description = "WASI and WASIX types for Wasmer WebAssembly runtime" categories = ["wasm", "os"] -keywords = ["wasm", "webassembly", "wasi", "sandbox", "ABI"] +keywords = ["wasm", "webassembly", "wasi", "wasix", "sandbox", "ABI"] authors = ["Wasmer Engineering Team "] repository = "https://github.com/wasmerio/wasmer" license = "MIT" diff --git a/lib/wasi/Cargo.toml b/lib/wasi/Cargo.toml index 425e885ca88..f791f24481c 100644 --- a/lib/wasi/Cargo.toml +++ b/lib/wasi/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "wasmer-wasi" -version = "3.2.0-alpha.1" -description = "WASI implementation library for Wasmer WebAssembly runtime" +name = "wasmer-wasix" +version = "0.1.0" +description = "WASI and WASIX implementation library for Wasmer WebAssembly runtime" categories = ["wasm", "os"] -keywords = ["wasm", "webassembly", "wasi", "sandbox", "ABI"] +keywords = ["wasm", "webassembly", "wasi", "wasix", "sandbox", "ABI"] authors = ["Wasmer Engineering Team "] repository = "https://github.com/wasmerio/wasmer" license = "MIT" @@ -15,13 +15,12 @@ cfg-if = "1.0" thiserror = "1" tracing = { version = "0.1" } getrandom = "0.2" -wasmer-wasi-types = { path = "../wasi-types", version = "=3.2.0-alpha.1" } +wasmer-wasix-types = { path = "../wasi-types", version = "0.1.0" } wasmer-types = { path = "../types", version = "=3.2.0-alpha.1", default-features = false } wasmer = { path = "../api", version = "=3.2.0-alpha.1", default-features = false, features = ["wat", "js-serializable-module"] } -wasmer-vfs = { path = "../vfs", version = "=3.2.0-alpha.1", default-features = false, features = ["webc-fs"] } wasmer-vm = { path = "../vm", version = "=3.2.0-alpha.1", optional = true } -wasmer-vnet = { path = "../vnet", version = "=3.2.0-alpha.1", default-features = false } -wasmer-wasi-local-networking = { path = "../wasi-local-networking", version = "=3.2.0-alpha.1", default-features = false, optional = true } +virtual-fs = { path = "../vfs", version = "0.1.0", default-features = false, features = ["webc-fs"] } +virtual-net = { path = "../vnet", version = "0.1.0", default-features = false } wasmer-emscripten = { path = "../emscripten", version = "=3.2.0-alpha.1", optional = true } typetag = { version = "0.1", optional = true } serde = { version = "1.0", default-features = false, features = ["derive"] } @@ -101,21 +100,21 @@ webc_runner_rt_wasi = [] webc_runner_rt_wcgi = ["hyper", "wcgi", "wcgi-host"] webc_runner_rt_emscripten = ["wasmer-emscripten"] -sys = ["wasmer/sys", "wasmer-wasi-types/sys", "webc/mmap", "wasmer-vm", "time"] +sys = ["wasmer/sys", "wasmer-wasix-types/sys", "webc/mmap", "wasmer-vm", "time"] sys-default = ["wasmer/wat", "wasmer/compiler", "sys", "logging", "host-fs", "sys-poll", "sys-thread", "host-vnet", "host-threads", "host-reqwest" ] sys-poll = [] sys-thread = ["tokio/rt", "tokio/time", "tokio/rt-multi-thread"] compiler = [ "wasmer/compiler", "wasmer-compiler"] -js = ["wasmer/js", "wasmer-vfs/no-time", "getrandom/js", "chrono", "wasmer-wasi-types/js"] +js = ["wasmer/js", "virtual-fs/no-time", "getrandom/js", "chrono", "wasmer-wasix-types/js"] js-default = ["js", "wasmer/js-default"] test-js = ["js", "wasmer/js-default", "wasmer/wat"] -host-vnet = [ "wasmer-wasi-local-networking" ] +host-vnet = [ "virtual-net/host-net" ] host-threads = [] host-reqwest = ["reqwest"] -host-fs = ["wasmer-vfs/host-fs"] +host-fs = ["virtual-fs/host-fs"] host-termios = ["termios", "term_size"] logging = ["tracing/log"] @@ -125,7 +124,7 @@ disable-all-logging = [ ] enable-serde = [ "typetag", - "wasmer-vfs/enable-serde", - "wasmer-wasi-types/enable-serde", + "virtual-fs/enable-serde", + "wasmer-wasix-types/enable-serde", ] diff --git a/lib/wasi/README.md b/lib/wasi/README.md index e65e2508d36..ac56c8069dd 100644 --- a/lib/wasi/README.md +++ b/lib/wasi/README.md @@ -61,7 +61,7 @@ Hello, Some("Gordon") ```rust use wasmer::{Store, Module, Instance}; -use wasmer_wasi::WasiState; +use wasmer_wasix::WasiState; let mut store = Store::default(); let module = Module::from_file(&store, "hello.wasm")?; diff --git a/lib/wasi/src/bin_factory/binary_package.rs b/lib/wasi/src/bin_factory/binary_package.rs index 814be7b8415..ece724168f7 100644 --- a/lib/wasi/src/bin_factory/binary_package.rs +++ b/lib/wasi/src/bin_factory/binary_package.rs @@ -6,8 +6,8 @@ use std::{ }; use derivative::*; -use wasmer_vfs::{FileSystem, TmpFileSystem}; -use wasmer_wasi_types::wasi::Snapshot0Clockid; +use virtual_fs::{FileSystem, TmpFileSystem}; +use wasmer_wasix_types::wasi::Snapshot0Clockid; use super::hash_of_binary; use crate::syscalls::platform_clock_time_get; diff --git a/lib/wasi/src/bin_factory/exec.rs b/lib/wasi/src/bin_factory/exec.rs index 791d9a727d1..92a115ebddc 100644 --- a/lib/wasi/src/bin_factory/exec.rs +++ b/lib/wasi/src/bin_factory/exec.rs @@ -9,7 +9,7 @@ use tracing::*; #[cfg(feature = "sys")] use wasmer::NativeEngineExt; use wasmer::{FunctionEnvMut, Instance, Memory, Module, Store}; -use wasmer_wasi_types::wasi::{Errno, ExitCode}; +use wasmer_wasix_types::wasi::{Errno, ExitCode}; use super::{BinFactory, BinaryPackage, ModuleCache}; use crate::{ diff --git a/lib/wasi/src/bin_factory/mod.rs b/lib/wasi/src/bin_factory/mod.rs index d39becba4d3..8f697fc10cd 100644 --- a/lib/wasi/src/bin_factory/mod.rs +++ b/lib/wasi/src/bin_factory/mod.rs @@ -4,7 +4,7 @@ use std::{ sync::{Arc, RwLock}, }; -use wasmer_vfs::{AsyncReadExt, FileSystem}; +use virtual_fs::{AsyncReadExt, FileSystem}; mod binary_package; mod exec; diff --git a/lib/wasi/src/bin_factory/module_cache.rs b/lib/wasi/src/bin_factory/module_cache.rs index 1cfdb797390..1d7c3547afa 100644 --- a/lib/wasi/src/bin_factory/module_cache.rs +++ b/lib/wasi/src/bin_factory/module_cache.rs @@ -7,7 +7,7 @@ use std::{ }; use wasmer::Module; -use wasmer_wasi_types::wasi::Snapshot0Clockid; +use wasmer_wasix_types::wasi::Snapshot0Clockid; use super::BinaryPackage; use crate::{syscalls::platform_clock_time_get, WasiRuntime}; diff --git a/lib/wasi/src/fs/fd.rs b/lib/wasi/src/fs/fd.rs index e96844dd0ca..94ea01eac8a 100644 --- a/lib/wasi/src/fs/fd.rs +++ b/lib/wasi/src/fs/fd.rs @@ -7,8 +7,8 @@ use std::{ #[cfg(feature = "enable-serde")] use serde_derive::{Deserialize, Serialize}; -use wasmer_vfs::{Pipe, VirtualFile}; -use wasmer_wasi_types::wasi::{Fd as WasiFd, Fdflags, Filestat, Rights}; +use virtual_fs::{Pipe, VirtualFile}; +use wasmer_wasix_types::wasi::{Fd as WasiFd, Fdflags, Filestat, Rights}; use crate::net::socket::InodeSocket; diff --git a/lib/wasi/src/fs/inode_guard.rs b/lib/wasi/src/fs/inode_guard.rs index e02ae40761c..100843ac793 100644 --- a/lib/wasi/src/fs/inode_guard.rs +++ b/lib/wasi/src/fs/inode_guard.rs @@ -9,9 +9,9 @@ use std::{ }; use tokio::io::{AsyncRead, AsyncSeek, AsyncWrite}; -use wasmer_vfs::{FsError, VirtualFile}; -use wasmer_vnet::NetworkError; -use wasmer_wasi_types::{ +use virtual_fs::{FsError, VirtualFile}; +use virtual_net::NetworkError; +use wasmer_wasix_types::{ types::Eventtype, wasi, wasi::{Errno, Event, EventFdReadwrite, EventUnion, Eventrwflags, Subscription}, diff --git a/lib/wasi/src/fs/mod.rs b/lib/wasi/src/fs/mod.rs index f04fafac096..5c081ce93c4 100644 --- a/lib/wasi/src/fs/mod.rs +++ b/lib/wasi/src/fs/mod.rs @@ -18,8 +18,8 @@ use crate::state::{Stderr, Stdin, Stdout}; use serde_derive::{Deserialize, Serialize}; use tokio::io::AsyncWriteExt; use tracing::{debug, trace}; -use wasmer_vfs::{FileSystem, FsError, OpenOptions, VirtualFile}; -use wasmer_wasi_types::{ +use virtual_fs::{FileSystem, FsError, OpenOptions, VirtualFile}; +use wasmer_wasix_types::{ types::{__WASI_STDERR_FILENO, __WASI_STDIN_FILENO, __WASI_STDOUT_FILENO}, wasi::{ Errno, Fd as WasiFd, Fdflags, Fdstat, Filesize, Filestat, Filetype, Preopentype, Prestat, @@ -261,48 +261,48 @@ impl Default for WasiInodes { #[derive(Debug, Clone)] pub enum WasiFsRoot { - Sandbox(Arc), + Sandbox(Arc), Backing(Arc>), } impl FileSystem for WasiFsRoot { - fn read_dir(&self, path: &Path) -> wasmer_vfs::Result { + fn read_dir(&self, path: &Path) -> virtual_fs::Result { match self { WasiFsRoot::Sandbox(fs) => fs.read_dir(path), WasiFsRoot::Backing(fs) => fs.read_dir(path), } } - fn create_dir(&self, path: &Path) -> wasmer_vfs::Result<()> { + fn create_dir(&self, path: &Path) -> virtual_fs::Result<()> { match self { WasiFsRoot::Sandbox(fs) => fs.create_dir(path), WasiFsRoot::Backing(fs) => fs.create_dir(path), } } - fn remove_dir(&self, path: &Path) -> wasmer_vfs::Result<()> { + fn remove_dir(&self, path: &Path) -> virtual_fs::Result<()> { match self { WasiFsRoot::Sandbox(fs) => fs.remove_dir(path), WasiFsRoot::Backing(fs) => fs.remove_dir(path), } } - fn rename(&self, from: &Path, to: &Path) -> wasmer_vfs::Result<()> { + fn rename(&self, from: &Path, to: &Path) -> virtual_fs::Result<()> { match self { WasiFsRoot::Sandbox(fs) => fs.rename(from, to), WasiFsRoot::Backing(fs) => fs.rename(from, to), } } - fn metadata(&self, path: &Path) -> wasmer_vfs::Result { + fn metadata(&self, path: &Path) -> virtual_fs::Result { match self { WasiFsRoot::Sandbox(fs) => fs.metadata(path), WasiFsRoot::Backing(fs) => fs.metadata(path), } } - fn symlink_metadata(&self, path: &Path) -> wasmer_vfs::Result { + fn symlink_metadata(&self, path: &Path) -> virtual_fs::Result { match self { WasiFsRoot::Sandbox(fs) => fs.symlink_metadata(path), WasiFsRoot::Backing(fs) => fs.symlink_metadata(path), } } - fn remove_file(&self, path: &Path) -> wasmer_vfs::Result<()> { + fn remove_file(&self, path: &Path) -> virtual_fs::Result<()> { match self { WasiFsRoot::Sandbox(fs) => fs.remove_file(path), WasiFsRoot::Backing(fs) => fs.remove_file(path), @@ -1763,12 +1763,12 @@ impl std::fmt::Debug for WasiFs { } /// Returns the default filesystem backing -pub fn default_fs_backing() -> Box { +pub fn default_fs_backing() -> Box { cfg_if::cfg_if! { if #[cfg(feature = "host-fs")] { - Box::new(wasmer_vfs::host_fs::FileSystem::default()) + Box::new(virtual_fs::host_fs::FileSystem::default()) } else if #[cfg(not(feature = "host-fs"))] { - Box::new(wasmer_vfs::mem_fs::FileSystem::default()) + Box::new(virtual_fs::mem_fs::FileSystem::default()) } else { Box::new(FallbackFileSystem::default()) } @@ -1785,7 +1785,7 @@ impl FallbackFileSystem { } impl FileSystem for FallbackFileSystem { - fn read_dir(&self, _path: &Path) -> Result { + fn read_dir(&self, _path: &Path) -> Result { Self::fail(); } fn create_dir(&self, _path: &Path) -> Result<(), FsError> { @@ -1797,21 +1797,21 @@ impl FileSystem for FallbackFileSystem { fn rename(&self, _from: &Path, _to: &Path) -> Result<(), FsError> { Self::fail(); } - fn metadata(&self, _path: &Path) -> Result { + fn metadata(&self, _path: &Path) -> Result { Self::fail(); } - fn symlink_metadata(&self, _path: &Path) -> Result { + fn symlink_metadata(&self, _path: &Path) -> Result { Self::fail(); } fn remove_file(&self, _path: &Path) -> Result<(), FsError> { Self::fail(); } - fn new_open_options(&self) -> wasmer_vfs::OpenOptions { + fn new_open_options(&self) -> virtual_fs::OpenOptions { Self::fail(); } } -pub fn virtual_file_type_to_wasi_file_type(file_type: wasmer_vfs::FileType) -> Filetype { +pub fn virtual_file_type_to_wasi_file_type(file_type: virtual_fs::FileType) -> Filetype { // TODO: handle other file types if file_type.is_dir() { Filetype::Directory diff --git a/lib/wasi/src/lib.rs b/lib/wasi/src/lib.rs index bb23dc35660..2034e0eb935 100644 --- a/lib/wasi/src/lib.rs +++ b/lib/wasi/src/lib.rs @@ -65,27 +65,27 @@ use thiserror::Error; use tracing::error; // re-exports needed for OS pub use wasmer; -pub use wasmer_wasi_types; +pub use wasmer_wasix_types; use wasmer::{ imports, namespace, AsStoreMut, Exports, FunctionEnv, Imports, Memory32, MemoryAccessError, MemorySize, RuntimeError, }; -pub use wasmer_vfs; -#[deprecated(since = "2.1.0", note = "Please use `wasmer_vfs::FsError`")] -pub use wasmer_vfs::FsError as WasiFsError; -#[deprecated(since = "2.1.0", note = "Please use `wasmer_vfs::VirtualFile`")] -pub use wasmer_vfs::VirtualFile as WasiFile; -pub use wasmer_vfs::{DuplexPipe, FsError, Pipe, VirtualFile, WasiBidirectionalSharedPipePair}; -pub use wasmer_vnet; -pub use wasmer_vnet::{UnsupportedVirtualNetworking, VirtualNetworking}; +pub use virtual_fs; +#[deprecated(since = "2.1.0", note = "Please use `virtual_fs::FsError`")] +pub use virtual_fs::FsError as WasiFsError; +#[deprecated(since = "2.1.0", note = "Please use `virtual_fs::VirtualFile`")] +pub use virtual_fs::VirtualFile as WasiFile; +pub use virtual_fs::{DuplexPipe, FsError, Pipe, VirtualFile, WasiBidirectionalSharedPipePair}; +pub use virtual_net; +pub use virtual_net::{UnsupportedVirtualNetworking, VirtualNetworking}; #[cfg(feature = "host-vnet")] -pub use wasmer_wasi_local_networking::{ +pub use virtual_net::host::{ io_err_into_net_error, LocalNetworking, LocalTcpListener, LocalTcpStream, LocalUdpSocket, }; -use wasmer_wasi_types::wasi::{BusErrno, Errno, ExitCode}; +use wasmer_wasix_types::wasi::{BusErrno, Errno, ExitCode}; pub use crate::{ fs::{default_fs_backing, Fd, WasiFs, WasiInodes, VIRTUAL_ROOT_FD}, diff --git a/lib/wasi/src/net/mod.rs b/lib/wasi/src/net/mod.rs index e64065ae72b..0a1ade30d8b 100644 --- a/lib/wasi/src/net/mod.rs +++ b/lib/wasi/src/net/mod.rs @@ -4,10 +4,10 @@ use std::{ time::Duration, }; +use virtual_net::{IpCidr, IpRoute, NetworkError}; use wasmer::{MemoryView, WasmPtr}; use wasmer_types::MemorySize; -use wasmer_vnet::{IpCidr, IpRoute, NetworkError}; -use wasmer_wasi_types::{ +use wasmer_wasix_types::{ types::{ OptionTag, OptionTimestamp, Route, __wasi_addr_ip4_t, __wasi_addr_ip6_t, __wasi_addr_port_t, __wasi_addr_port_u, __wasi_addr_t, __wasi_addr_u, __wasi_cidr_t, diff --git a/lib/wasi/src/net/socket.rs b/lib/wasi/src/net/socket.rs index c4d2ddddc02..ba2787ac396 100644 --- a/lib/wasi/src/net/socket.rs +++ b/lib/wasi/src/net/socket.rs @@ -10,12 +10,12 @@ use std::{ #[cfg(feature = "enable-serde")] use serde_derive::{Deserialize, Serialize}; -use wasmer_types::MemorySize; -use wasmer_vnet::{ +use virtual_net::{ VirtualIcmpSocket, VirtualNetworking, VirtualRawSocket, VirtualTcpListener, VirtualTcpSocket, VirtualUdpSocket, }; -use wasmer_wasi_types::wasi::{ +use wasmer_types::MemorySize; +use wasmer_wasix_types::wasi::{ Addressfamily, Errno, Fdflags, Rights, SockProto, Sockoption, Socktype, }; @@ -1213,7 +1213,7 @@ impl InodeSocketProtected { pub fn poll_read_ready( &mut self, cx: &mut std::task::Context<'_>, - ) -> std::task::Poll> { + ) -> std::task::Poll> { match &mut self.kind { InodeSocketKind::TcpListener { socket, .. } => socket.poll_accept_ready(cx), InodeSocketKind::TcpStream { socket, .. } => socket.poll_read_ready(cx), @@ -1221,7 +1221,7 @@ impl InodeSocketProtected { InodeSocketKind::Raw(socket) => socket.poll_read_ready(cx), InodeSocketKind::Icmp(socket) => socket.poll_read_ready(cx), InodeSocketKind::PreSocket { .. } => { - std::task::Poll::Ready(Err(wasmer_vnet::NetworkError::IOError)) + std::task::Poll::Ready(Err(virtual_net::NetworkError::IOError)) } } } @@ -1229,7 +1229,7 @@ impl InodeSocketProtected { pub fn poll_write_ready( &mut self, cx: &mut std::task::Context<'_>, - ) -> std::task::Poll> { + ) -> std::task::Poll> { match &mut self.kind { InodeSocketKind::TcpListener { .. } => std::task::Poll::Pending, InodeSocketKind::TcpStream { socket, .. } => socket.poll_write_ready(cx), @@ -1237,7 +1237,7 @@ impl InodeSocketProtected { InodeSocketKind::Raw(socket) => socket.poll_write_ready(cx), InodeSocketKind::Icmp(socket) => socket.poll_write_ready(cx), InodeSocketKind::PreSocket { .. } => { - std::task::Poll::Ready(Err(wasmer_vnet::NetworkError::IOError)) + std::task::Poll::Ready(Err(virtual_net::NetworkError::IOError)) } } } diff --git a/lib/wasi/src/os/command/builtins/cmd_wasmer.rs b/lib/wasi/src/os/command/builtins/cmd_wasmer.rs index 1b7954f2d99..1bde0402d4b 100644 --- a/lib/wasi/src/os/command/builtins/cmd_wasmer.rs +++ b/lib/wasi/src/os/command/builtins/cmd_wasmer.rs @@ -5,7 +5,7 @@ use crate::{ VirtualBusError, }; use wasmer::{FunctionEnvMut, Store}; -use wasmer_wasi_types::wasi::Errno; +use wasmer_wasix_types::wasi::Errno; use crate::{ bin_factory::{spawn_exec, BinaryPackage, ModuleCache}, diff --git a/lib/wasi/src/os/command/mod.rs b/lib/wasi/src/os/command/mod.rs index dbe78f9c125..cb0093db7a4 100644 --- a/lib/wasi/src/os/command/mod.rs +++ b/lib/wasi/src/os/command/mod.rs @@ -3,7 +3,7 @@ pub mod builtins; use std::{collections::HashMap, sync::Arc}; use wasmer::{FunctionEnvMut, Store}; -use wasmer_wasi_types::wasi::Errno; +use wasmer_wasix_types::wasi::Errno; use crate::{ bin_factory::ModuleCache, syscalls::stderr_write, VirtualBusError, WasiEnv, WasiRuntime, diff --git a/lib/wasi/src/os/console/mod.rs b/lib/wasi/src/os/console/mod.rs index 094b2d9fe83..52ae0ea1050 100644 --- a/lib/wasi/src/os/console/mod.rs +++ b/lib/wasi/src/os/console/mod.rs @@ -16,13 +16,13 @@ use linked_hash_set::LinkedHashSet; use tokio::sync::{mpsc, RwLock}; #[allow(unused_imports, dead_code)] use tracing::{debug, error, info, trace, warn}; -#[cfg(feature = "sys")] -use wasmer::Engine; -use wasmer_vfs::{ +use virtual_fs::{ ArcBoxFile, ArcFile, AsyncWriteExt, CombineFile, DeviceFile, DuplexPipe, FileSystem, Pipe, PipeRx, PipeTx, RootFileSystemBuilder, VirtualFile, }; -use wasmer_wasi_types::{types::__WASI_STDIN_FILENO, wasi::BusErrno}; +#[cfg(feature = "sys")] +use wasmer::Engine; +use wasmer_wasix_types::{types::__WASI_STDIN_FILENO, wasi::BusErrno}; use super::{cconst::ConsoleConst, common::*, task::TaskJoinHandle}; use crate::{ @@ -209,7 +209,7 @@ impl Console { } else { let mut stderr = self.stderr.clone(); tasks.block_on(async { - wasmer_vfs::AsyncWriteExt::write_all( + virtual_fs::AsyncWriteExt::write_all( &mut stderr, format!("package not found [{}]\r\n", webc).as_bytes(), ) @@ -229,7 +229,7 @@ impl Console { if let Err(err) = env.uses(self.uses.clone()) { let mut stderr = self.stderr.clone(); tasks.block_on(async { - wasmer_vfs::AsyncWriteExt::write_all( + virtual_fs::AsyncWriteExt::write_all( &mut stderr, format!("{}\r\n", err).as_bytes(), ) @@ -268,7 +268,7 @@ impl Console { data.insert_str(0, ConsoleConst::TERM_NO_WRAPAROUND); let mut stderr = self.stderr.clone(); - wasmer_vfs::AsyncWriteExt::write_all(&mut stderr, data.as_str().as_bytes()) + virtual_fs::AsyncWriteExt::write_all(&mut stderr, data.as_str().as_bytes()) .await .ok(); } diff --git a/lib/wasi/src/os/task/process.rs b/lib/wasi/src/os/task/process.rs index b2ceb2667b6..0c80b3f2c8a 100644 --- a/lib/wasi/src/os/task/process.rs +++ b/lib/wasi/src/os/task/process.rs @@ -11,7 +11,7 @@ use std::{ use crate::WasiRuntimeError; use tracing::trace; -use wasmer_wasi_types::{ +use wasmer_wasix_types::{ types::Signal, wasi::{Errno, ExitCode, Snapshot0Clockid, TlKey, TlUser, TlVal}, }; diff --git a/lib/wasi/src/os/task/signal.rs b/lib/wasi/src/os/task/signal.rs index 1ed12bd62a3..28462829bab 100644 --- a/lib/wasi/src/os/task/signal.rs +++ b/lib/wasi/src/os/task/signal.rs @@ -1,6 +1,6 @@ use std::time::Duration; -use wasmer_wasi_types::types::Signal; +use wasmer_wasix_types::types::Signal; #[derive(thiserror::Error, Debug)] #[error("Signal could not be delivered")] diff --git a/lib/wasi/src/os/task/task_join_handle.rs b/lib/wasi/src/os/task/task_join_handle.rs index 62b534caf05..c4fa6b14293 100644 --- a/lib/wasi/src/os/task/task_join_handle.rs +++ b/lib/wasi/src/os/task/task_join_handle.rs @@ -4,7 +4,7 @@ use std::{ task::{Context, Poll}, }; -use wasmer_wasi_types::wasi::{Errno, ExitCode}; +use wasmer_wasix_types::wasi::{Errno, ExitCode}; use crate::WasiRuntimeError; diff --git a/lib/wasi/src/os/task/thread.rs b/lib/wasi/src/os/task/thread.rs index 6304f20e7c3..38098ee20de 100644 --- a/lib/wasi/src/os/task/thread.rs +++ b/lib/wasi/src/os/task/thread.rs @@ -6,7 +6,7 @@ use std::{ }; use bytes::{Bytes, BytesMut}; -use wasmer_wasi_types::{ +use wasmer_wasix_types::{ types::Signal, wasi::{Errno, ExitCode}, }; diff --git a/lib/wasi/src/os/tty/mod.rs b/lib/wasi/src/os/tty/mod.rs index 02e29da0edb..f54bc5176b0 100644 --- a/lib/wasi/src/os/tty/mod.rs +++ b/lib/wasi/src/os/tty/mod.rs @@ -5,8 +5,8 @@ use std::{ use derivative::*; use futures::future::BoxFuture; -use wasmer_vfs::{AsyncWriteExt, NullFile, VirtualFile}; -use wasmer_wasi_types::wasi::{Signal, Snapshot0Clockid}; +use virtual_fs::{AsyncWriteExt, NullFile, VirtualFile}; +use wasmer_wasix_types::wasi::{Signal, Snapshot0Clockid}; use crate::syscalls::platform_clock_time_get; diff --git a/lib/wasi/src/runners/container.rs b/lib/wasi/src/runners/container.rs index 31c58fec1a0..66de75a1bca 100644 --- a/lib/wasi/src/runners/container.rs +++ b/lib/wasi/src/runners/container.rs @@ -1,7 +1,7 @@ use std::{path::PathBuf, sync::Arc}; use bytes::Bytes; -use wasmer_vfs::{webc_fs::WebcFileSystem, FileSystem}; +use virtual_fs::{webc_fs::WebcFileSystem, FileSystem}; use webc::{ metadata::Manifest, v1::{ParseOptions, WebC, WebCMmap, WebCOwned}, diff --git a/lib/wasi/src/runners/wcgi/handler.rs b/lib/wasi/src/runners/wcgi/handler.rs index aa5bd5d47dd..9b546a14990 100644 --- a/lib/wasi/src/runners/wcgi/handler.rs +++ b/lib/wasi/src/runners/wcgi/handler.rs @@ -15,8 +15,8 @@ use tokio::{ io::{AsyncBufReadExt, AsyncRead, AsyncWrite, AsyncWriteExt}, runtime::Handle, }; +use virtual_fs::{FileSystem, PassthruFileSystem, RootFileSystemBuilder, TmpFileSystem}; use wasmer::Module; -use wasmer_vfs::{FileSystem, PassthruFileSystem, RootFileSystemBuilder, TmpFileSystem}; use wcgi_host::CgiDialect; use crate::{ diff --git a/lib/wasi/src/runners/wcgi/runner.rs b/lib/wasi/src/runners/wcgi/runner.rs index 516e7bbe532..14e67859a3a 100644 --- a/lib/wasi/src/runners/wcgi/runner.rs +++ b/lib/wasi/src/runners/wcgi/runner.rs @@ -2,8 +2,8 @@ use std::{collections::HashMap, convert::Infallible, net::SocketAddr, path::Path use anyhow::{Context, Error}; use futures::future::AbortHandle; +use virtual_fs::FileSystem; use wasmer::{Engine, Module, Store}; -use wasmer_vfs::FileSystem; use wcgi_host::CgiDialect; use webc::metadata::{ annotations::{Wasi, Wcgi}, diff --git a/lib/wasi/src/runtime/mod.rs b/lib/wasi/src/runtime/mod.rs index f2bc1c367e9..c84e236aa6d 100644 --- a/lib/wasi/src/runtime/mod.rs +++ b/lib/wasi/src/runtime/mod.rs @@ -4,7 +4,7 @@ pub use self::task_manager::{SpawnType, SpawnedMemory, VirtualTaskManager}; use std::{fmt, sync::Arc}; -use wasmer_vnet::{DynVirtualNetworking, VirtualNetworking}; +use virtual_net::{DynVirtualNetworking, VirtualNetworking}; use crate::{http::DynHttpClient, os::TtyBridge}; @@ -83,9 +83,9 @@ impl PluggableRuntimeImplementation { // TODO: the cfg flags below should instead be handled by separate implementations. cfg_if::cfg_if! { if #[cfg(feature = "host-vnet")] { - let networking = Arc::new(wasmer_wasi_local_networking::LocalNetworking::default()); + let networking = Arc::new(virtual_net::host::LocalNetworking::default()); } else { - let networking = Arc::new(wasmer_vnet::UnsupportedVirtualNetworking::default()); + let networking = Arc::new(virtual_net::UnsupportedVirtualNetworking::default()); } } cfg_if::cfg_if! { diff --git a/lib/wasi/src/state/builder.rs b/lib/wasi/src/state/builder.rs index fb86ecc7f15..c761d9cb323 100644 --- a/lib/wasi/src/state/builder.rs +++ b/lib/wasi/src/state/builder.rs @@ -8,8 +8,8 @@ use std::{ use rand::Rng; use thiserror::Error; +use virtual_fs::{ArcFile, FsError, TmpFileSystem, VirtualFile}; use wasmer::{AsStoreMut, Instance, Module}; -use wasmer_vfs::{ArcFile, FsError, TmpFileSystem, VirtualFile}; use crate::{ bin_factory::{BinFactory, ModuleCache}, @@ -27,7 +27,7 @@ use super::env::WasiEnvInit; /// /// Usage: /// ```no_run -/// # use wasmer_wasi::{WasiEnv, WasiStateCreationError}; +/// # use wasmer_wasix::{WasiEnv, WasiStateCreationError}; /// # fn main() -> Result<(), WasiStateCreationError> { /// let mut state_builder = WasiEnv::builder("wasi-prog-name"); /// state_builder @@ -340,7 +340,7 @@ impl WasiEnvBuilder { /// Usage: /// /// ```no_run - /// # use wasmer_wasi::{WasiEnv, WasiStateCreationError}; + /// # use wasmer_wasix::{WasiEnv, WasiStateCreationError}; /// # fn main() -> Result<(), WasiStateCreationError> { /// WasiEnv::builder("program_name") /// .preopen_build(|p| p.directory("src").read(true).write(true).create(true))? @@ -362,7 +362,7 @@ impl WasiEnvBuilder { /// Usage: /// /// ```no_run - /// # use wasmer_wasi::{WasiEnv, WasiStateCreationError}; + /// # use wasmer_wasix::{WasiEnv, WasiStateCreationError}; /// # fn main() -> Result<(), WasiStateCreationError> { /// WasiEnv::builder("program_name") /// .preopen_build(|p| p.directory("src").read(true).write(true).create(true))? @@ -480,19 +480,19 @@ impl WasiEnvBuilder { /// Sets the FileSystem to be used with this WASI instance. /// - /// This is usually used in case a custom `wasmer_vfs::FileSystem` is needed. - pub fn fs(mut self, fs: Box) -> Self { + /// This is usually used in case a custom `virtual_fs::FileSystem` is needed. + pub fn fs(mut self, fs: Box) -> Self { self.set_fs(fs); self } - pub fn set_fs(&mut self, fs: Box) { + pub fn set_fs(&mut self, fs: Box) { self.fs = Some(WasiFsRoot::Backing(Arc::new(fs))); } /// Sets a new sandbox FileSystem to be used with this WASI instance. /// - /// This is usually used in case a custom `wasmer_vfs::FileSystem` is needed. + /// This is usually used in case a custom `virtual_fs::FileSystem` is needed. pub fn sandbox_fs(mut self, fs: TmpFileSystem) -> Self { self.fs = Some(WasiFsRoot::Sandbox(Arc::new(fs))); self diff --git a/lib/wasi/src/state/env.rs b/lib/wasi/src/state/env.rs index 83830d55a47..ce108df9f86 100644 --- a/lib/wasi/src/state/env.rs +++ b/lib/wasi/src/state/env.rs @@ -3,15 +3,15 @@ use std::{collections::HashMap, ops::Deref, path::PathBuf, sync::Arc, time::Dura use derivative::Derivative; use rand::Rng; use tracing::{trace, warn}; +use virtual_fs::{FsError, VirtualFile}; +use virtual_net::DynVirtualNetworking; #[cfg(feature = "sys")] use wasmer::NativeEngineExt; use wasmer::{ AsStoreMut, AsStoreRef, FunctionEnvMut, Global, Instance, Memory, MemoryView, Module, TypedFunction, }; -use wasmer_vfs::{FsError, VirtualFile}; -use wasmer_vnet::DynVirtualNetworking; -use wasmer_wasi_types::{ +use wasmer_wasix_types::{ types::Signal, wasi::{Errno, ExitCode, Snapshot0Clockid}, }; @@ -766,7 +766,7 @@ impl WasiEnv { use std::{borrow::Cow, collections::VecDeque}; #[allow(unused_imports)] - use wasmer_vfs::FileSystem; + use virtual_fs::FileSystem; let mut already: HashMap> = HashMap::new(); @@ -859,7 +859,7 @@ impl WasiEnv { use std::path::Path; #[allow(unused_imports)] - use wasmer_vfs::FileSystem; + use virtual_fs::FileSystem; #[cfg(feature = "sys")] for (command, target) in map_commands.iter() { diff --git a/lib/wasi/src/state/func_env.rs b/lib/wasi/src/state/func_env.rs index 900017f8fa1..2649ca3927c 100644 --- a/lib/wasi/src/state/func_env.rs +++ b/lib/wasi/src/state/func_env.rs @@ -1,6 +1,6 @@ use tracing::trace; use wasmer::{AsStoreMut, AsStoreRef, ExportError, FunctionEnv, Imports, Instance, Memory, Module}; -use wasmer_wasi_types::wasi::ExitCode; +use wasmer_wasix_types::wasi::ExitCode; use crate::{ state::WasiInstanceHandles, diff --git a/lib/wasi/src/state/mod.rs b/lib/wasi/src/state/mod.rs index ef3316eb839..ef221e3035f 100644 --- a/lib/wasi/src/state/mod.rs +++ b/lib/wasi/src/state/mod.rs @@ -32,9 +32,9 @@ use std::{ use derivative::Derivative; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; +use virtual_fs::{FileOpener, FileSystem, FsError, OpenOptions, VirtualFile}; use wasmer::Store; -use wasmer_vfs::{FileOpener, FileSystem, FsError, OpenOptions, VirtualFile}; -use wasmer_wasi_types::wasi::{Errno, Fd as WasiFd, Rights, Snapshot0Clockid}; +use wasmer_wasix_types::wasi::{Errno, Fd as WasiFd, Rights, Snapshot0Clockid}; pub use self::{ builder::*, @@ -61,8 +61,8 @@ impl FileOpener for WasiStateOpener { fn open( &self, path: &Path, - conf: &wasmer_vfs::OpenOptionsConfig, - ) -> wasmer_vfs::Result> { + conf: &virtual_fs::OpenOptionsConfig, + ) -> virtual_fs::Result> { let mut new_options = self.root_fs.new_open_options(); new_options.options(conf.clone()); new_options.open(path) @@ -180,7 +180,7 @@ impl WasiState { pub(crate) fn fs_read_dir>( &self, path: P, - ) -> Result { + ) -> Result { self.fs .root_fs .read_dir(path.as_ref()) diff --git a/lib/wasi/src/state/types.rs b/lib/wasi/src/state/types.rs index 7a0fe98f48d..4b15fc6285f 100644 --- a/lib/wasi/src/state/types.rs +++ b/lib/wasi/src/state/types.rs @@ -5,15 +5,15 @@ use cfg_if::cfg_if; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; -use wasmer_wasi_types::wasi::{BusErrno, Rights}; +use wasmer_wasix_types::wasi::{BusErrno, Rights}; use crate::VirtualBusError; cfg_if! { if #[cfg(feature = "host-fs")] { - pub use wasmer_vfs::host_fs::{Stderr, Stdin, Stdout}; + pub use virtual_fs::host_fs::{Stderr, Stdin, Stdout}; } else { - pub use wasmer_vfs::mem_fs::{Stderr, Stdin, Stdout}; + pub use virtual_fs::mem_fs::{Stderr, Stdin, Stdout}; } } diff --git a/lib/wasi/src/syscalls/legacy/snapshot0.rs b/lib/wasi/src/syscalls/legacy/snapshot0.rs index 3e1bdd696e3..e239fe26227 100644 --- a/lib/wasi/src/syscalls/legacy/snapshot0.rs +++ b/lib/wasi/src/syscalls/legacy/snapshot0.rs @@ -1,6 +1,6 @@ use tracing::{field, instrument, trace_span}; use wasmer::{AsStoreMut, FunctionEnvMut, WasmPtr}; -use wasmer_wasi_types::wasi::{ +use wasmer_wasix_types::wasi::{ Errno, Event, EventFdReadwrite, Eventrwflags, Eventtype, Fd, Filesize, Filestat, Filetype, Snapshot0Event, Snapshot0Filestat, Snapshot0Subscription, Snapshot0Whence, Subscription, Whence, diff --git a/lib/wasi/src/syscalls/mod.rs b/lib/wasi/src/syscalls/mod.rs index e3a3926a160..08622ff8449 100644 --- a/lib/wasi/src/syscalls/mod.rs +++ b/lib/wasi/src/syscalls/mod.rs @@ -1,7 +1,7 @@ #![allow(unused, clippy::too_many_arguments, clippy::cognitive_complexity)] pub mod types { - pub use wasmer_wasi_types::{types::*, wasi}; + pub use wasmer_wasix_types::{types::*, wasi}; } #[cfg(any( @@ -63,16 +63,16 @@ pub use unix::*; #[cfg(any(target_family = "wasm"))] pub use wasm::*; +pub(crate) use virtual_fs::{ + AsyncSeekExt, AsyncWriteExt, DuplexPipe, FileSystem, FsError, VirtualFile, +}; +pub(crate) use virtual_net::StreamSecurity; pub(crate) use wasmer::{ AsStoreMut, AsStoreRef, Extern, Function, FunctionEnv, FunctionEnvMut, Global, Instance, Memory, Memory32, Memory64, MemoryAccessError, MemoryError, MemorySize, MemoryView, Module, OnCalledAction, Pages, RuntimeError, Store, TypedFunction, Value, WasmPtr, WasmSlice, }; -pub(crate) use wasmer_vfs::{ - AsyncSeekExt, AsyncWriteExt, DuplexPipe, FileSystem, FsError, VirtualFile, -}; -pub(crate) use wasmer_vnet::StreamSecurity; -pub(crate) use wasmer_wasi_types::{asyncify::__wasi_asyncify_t, wasi::EventUnion}; +pub(crate) use wasmer_wasix_types::{asyncify::__wasi_asyncify_t, wasi::EventUnion}; #[cfg(any(target_os = "windows"))] pub use windows::*; diff --git a/lib/wasi/src/syscalls/unix/mod.rs b/lib/wasi/src/syscalls/unix/mod.rs index 029390618f2..11b6bd143f0 100644 --- a/lib/wasi/src/syscalls/unix/mod.rs +++ b/lib/wasi/src/syscalls/unix/mod.rs @@ -5,7 +5,7 @@ use libc::{ CLOCK_REALTIME, CLOCK_THREAD_CPUTIME_ID, }; use wasmer::WasmRef; -use wasmer_wasi_types::wasi::{Errno, Snapshot0Clockid, Timestamp}; +use wasmer_wasix_types::wasi::{Errno, Snapshot0Clockid, Timestamp}; use crate::syscalls::types::*; diff --git a/lib/wasi/src/syscalls/wasi/fd_read.rs b/lib/wasi/src/syscalls/wasi/fd_read.rs index d8df4bc6b5c..7d7ad723ad2 100644 --- a/lib/wasi/src/syscalls/wasi/fd_read.rs +++ b/lib/wasi/src/syscalls/wasi/fd_read.rs @@ -1,6 +1,6 @@ use std::{collections::VecDeque, task::Waker}; -use wasmer_vfs::{AsyncReadExt, ReadBuf}; +use virtual_fs::{AsyncReadExt, ReadBuf}; use super::*; use crate::{fs::NotificationInner, syscalls::*}; @@ -280,7 +280,7 @@ fn fd_read_internal( .map_err(mem_error_to_wasi)?; total_read += - wasmer_vfs::AsyncReadExt::read(&mut pipe, buf.as_mut()).await?; + virtual_fs::AsyncReadExt::read(&mut pipe, buf.as_mut()).await?; } Ok(total_read) } diff --git a/lib/wasi/src/syscalls/wasi/path_open.rs b/lib/wasi/src/syscalls/wasi/path_open.rs index 19d505af888..54ceb01e0d3 100644 --- a/lib/wasi/src/syscalls/wasi/path_open.rs +++ b/lib/wasi/src/syscalls/wasi/path_open.rs @@ -109,7 +109,7 @@ pub fn path_open( (false, false, false) }; - wasmer_vfs::OpenOptionsConfig { + virtual_fs::OpenOptionsConfig { read: fs_rights_base.contains(Rights::FD_READ), write: write_permission, create_new: create_permission && o_flags.contains(Oflags::EXCL), @@ -118,7 +118,7 @@ pub fn path_open( truncate: truncate_permission, } } - Err(_) => wasmer_vfs::OpenOptionsConfig { + Err(_) => virtual_fs::OpenOptionsConfig { append: fs_flags.contains(Fdflags::APPEND), write: fs_rights_base.contains(Rights::FD_WRITE), read: fs_rights_base.contains(Rights::FD_READ), @@ -128,7 +128,7 @@ pub fn path_open( }, }; - let parent_rights = wasmer_vfs::OpenOptionsConfig { + let parent_rights = virtual_fs::OpenOptionsConfig { read: working_dir.rights.contains(Rights::FD_READ), write: working_dir.rights.contains(Rights::FD_WRITE), // The parent is a directory, which is why these options diff --git a/lib/wasi/src/syscalls/wasi/poll_oneoff.rs b/lib/wasi/src/syscalls/wasi/poll_oneoff.rs index 6285d56c9c7..479051ea6fe 100644 --- a/lib/wasi/src/syscalls/wasi/poll_oneoff.rs +++ b/lib/wasi/src/syscalls/wasi/poll_oneoff.rs @@ -1,6 +1,6 @@ use std::f32::consts::E; -use wasmer_wasi_types::wasi::SubscriptionClock; +use wasmer_wasix_types::wasi::SubscriptionClock; use super::*; use crate::{ diff --git a/lib/wasi/src/syscalls/wasix/fd_pipe.rs b/lib/wasi/src/syscalls/wasix/fd_pipe.rs index 2f6e4a8d527..99db209d1cb 100644 --- a/lib/wasi/src/syscalls/wasix/fd_pipe.rs +++ b/lib/wasi/src/syscalls/wasix/fd_pipe.rs @@ -1,4 +1,4 @@ -use wasmer_vfs::Pipe; +use virtual_fs::Pipe; use super::*; use crate::syscalls::*; diff --git a/lib/wasi/src/syscalls/wasix/proc_spawn.rs b/lib/wasi/src/syscalls/wasix/proc_spawn.rs index b6ce12fad89..9fb4de0700f 100644 --- a/lib/wasi/src/syscalls/wasix/proc_spawn.rs +++ b/lib/wasi/src/syscalls/wasix/proc_spawn.rs @@ -1,4 +1,4 @@ -use wasmer_vfs::Pipe; +use virtual_fs::Pipe; use super::*; use crate::syscalls::*; diff --git a/lib/wasi/src/syscalls/wasix/sock_send_file.rs b/lib/wasi/src/syscalls/wasix/sock_send_file.rs index 2e3be8e26d5..49e7d149ffa 100644 --- a/lib/wasi/src/syscalls/wasix/sock_send_file.rs +++ b/lib/wasi/src/syscalls/wasix/sock_send_file.rs @@ -1,4 +1,4 @@ -use wasmer_vfs::AsyncReadExt; +use virtual_fs::AsyncReadExt; use super::*; use crate::{syscalls::*, WasiInodes}; @@ -130,7 +130,7 @@ pub fn sock_send_file( // TODO: optimize with MaybeUninit let mut buf = vec![0u8; sub_count as usize]; let amt = - wasmer_vfs::AsyncReadExt::read(pipe, &mut buf[..]) + virtual_fs::AsyncReadExt::read(pipe, &mut buf[..]) .await .map_err(map_io_err)?; buf.truncate(amt); diff --git a/lib/wasi/src/utils/mod.rs b/lib/wasi/src/utils/mod.rs index 260e81b6053..572e9e0fa22 100644 --- a/lib/wasi/src/utils/mod.rs +++ b/lib/wasi/src/utils/mod.rs @@ -8,7 +8,7 @@ pub use self::dummy_waker::WasiDummyWaker; use std::collections::BTreeSet; use wasmer::Module; -use wasmer_wasi_types::wasi::Errno; +use wasmer_wasix_types::wasi::Errno; pub use self::thread_parker::WasiParkingLot; pub(crate) use owned_mutex_guard::{ diff --git a/lib/wasi/src/wapm/mod.rs b/lib/wasi/src/wapm/mod.rs index 721ca216cc2..3be033b89f3 100644 --- a/lib/wasi/src/wapm/mod.rs +++ b/lib/wasi/src/wapm/mod.rs @@ -4,7 +4,7 @@ use std::{ path::{Path, PathBuf}, sync::Arc, }; -use wasmer_vfs::FileSystem; +use virtual_fs::FileSystem; use tracing::*; #[allow(unused_imports)] @@ -364,7 +364,7 @@ where } // Add the file system from the webc - let webc_fs = wasmer_vfs::webc_fs::WebcFileSystem::init_all(ownership.clone()); + let webc_fs = virtual_fs::webc_fs::WebcFileSystem::init_all(ownership.clone()); let top_level_dirs = webc_fs.top_level_dirs().clone(); pck.webc_fs = Some(Arc::new(webc_fs)); pck.webc_top_level_dirs = top_level_dirs; diff --git a/lib/wasi/tests/runners.rs b/lib/wasi/tests/runners.rs index 713ab862e16..6b37c4a8b2a 100644 --- a/lib/wasi/tests/runners.rs +++ b/lib/wasi/tests/runners.rs @@ -4,13 +4,13 @@ use std::{path::Path, time::Duration}; use once_cell::sync::Lazy; use reqwest::Client; -use wasmer_wasi::runners::{Runner, WapmContainer}; +use wasmer_wasix::runners::{Runner, WapmContainer}; #[cfg(feature = "webc_runner_rt_wasi")] mod wasi { use tokio::runtime::Handle; use wasmer::Store; - use wasmer_wasi::{ + use wasmer_wasix::{ runners::wasi::WasiRunner, runtime::task_manager::tokio::TokioTaskManager, WasiError, }; @@ -88,7 +88,7 @@ mod wcgi { use futures::{channel::mpsc::Sender, future::AbortHandle, SinkExt, StreamExt}; use rand::Rng; use tokio::runtime::Handle; - use wasmer_wasi::{runners::wcgi::WcgiRunner, runtime::task_manager::tokio::TokioTaskManager}; + use wasmer_wasix::{runners::wcgi::WcgiRunner, runtime::task_manager::tokio::TokioTaskManager}; use super::*; @@ -162,7 +162,7 @@ mod wcgi { handle: Handle, } - impl wasmer_wasi::runners::wcgi::Callbacks for Callbacks { + impl wasmer_wasix::runners::wcgi::Callbacks for Callbacks { fn started(&self, abort: futures::stream::AbortHandle) { let mut sender = self.sender.clone(); self.handle.spawn(async move { diff --git a/lib/wasi/tests/stdio.rs b/lib/wasi/tests/stdio.rs index e1480720330..b4a695e72ac 100644 --- a/lib/wasi/tests/stdio.rs +++ b/lib/wasi/tests/stdio.rs @@ -1,8 +1,8 @@ use std::sync::Arc; +use virtual_fs::{AsyncReadExt, AsyncWriteExt}; use wasmer::{Module, Store}; -use wasmer_vfs::{AsyncReadExt, AsyncWriteExt}; -use wasmer_wasi::{Pipe, PluggableRuntimeImplementation, WasiEnv}; +use wasmer_wasix::{Pipe, PluggableRuntimeImplementation, WasiEnv}; mod sys { #[tokio::test] diff --git a/tests/lib/wast/Cargo.toml b/tests/lib/wast/Cargo.toml index b57115ab24c..e10fb5e9b06 100644 --- a/tests/lib/wast/Cargo.toml +++ b/tests/lib/wast/Cargo.toml @@ -13,8 +13,8 @@ edition = "2018" [dependencies] anyhow = "1.0" wasmer = { path = "../../../lib/api", version = "=3.2.0-alpha.1", default-features = false } -wasmer-wasi = { path = "../../../lib/wasi", version = "=3.2.0-alpha.1" } -wasmer-vfs = { path = "../../../lib/vfs", version = "=3.2.0-alpha.1" } +wasmer-wasix = { path = "../../../lib/wasi", version = "0.1.0" } +virtual-fs = { path = "../../../lib/vfs", version = "0.1.0" } wast = "38.0" serde = "1" tempfile = "3.4.0" diff --git a/tests/lib/wast/src/wasi_wast.rs b/tests/lib/wast/src/wasi_wast.rs index 4583f803f43..0ba623d1538 100644 --- a/tests/lib/wast/src/wasi_wast.rs +++ b/tests/lib/wast/src/wasi_wast.rs @@ -5,13 +5,13 @@ use std::path::{Path, PathBuf}; use std::pin::Pin; use std::sync::{mpsc, Arc, Mutex}; use std::task::{Context, Poll}; -use wasmer::{FunctionEnv, Imports, Module, Store}; -use wasmer_vfs::{ +use virtual_fs::{ host_fs, mem_fs, passthru_fs, tmp_fs, union_fs, AsyncRead, AsyncSeek, AsyncWrite, AsyncWriteExt, FileSystem, Pipe, ReadBuf, RootFileSystemBuilder, }; -use wasmer_wasi::types::wasi::{Filesize, Timestamp}; -use wasmer_wasi::{ +use wasmer::{FunctionEnv, Imports, Module, Store}; +use wasmer_wasix::types::wasi::{Filesize, Timestamp}; +use wasmer_wasix::{ generate_import_object_from_env, get_wasi_version, FsError, PluggableRuntimeImplementation, VirtualFile, WasiEnv, WasiEnvBuilder, WasiRuntime, WasiVersion, }; @@ -20,22 +20,22 @@ use wast::parser::{self, Parse, ParseBuffer, Parser}; /// The kind of filesystem `WasiTest` is going to use. #[derive(Debug)] pub enum WasiFileSystemKind { - /// Instruct the test runner to use `wasmer_vfs::host_fs`. + /// Instruct the test runner to use `virtual_fs::host_fs`. Host, - /// Instruct the test runner to use `wasmer_vfs::mem_fs`. + /// Instruct the test runner to use `virtual_fs::mem_fs`. InMemory, - /// Instruct the test runner to use `wasmer_vfs::tmp_fs` + /// Instruct the test runner to use `virtual_fs::tmp_fs` Tmp, - /// Instruct the test runner to use `wasmer_vfs::passtru_fs` + /// Instruct the test runner to use `virtual_fs::passtru_fs` PassthruMemory, - /// Instruct the test runner to use `wasmer_vfs::union_fs` + /// Instruct the test runner to use `virtual_fs::union_fs` UnionHostMemory, - /// Instruct the test runner to use the TempFs returned by `wasmer_vfs::builder::RootFileSystemBuilder` + /// Instruct the test runner to use the TempFs returned by `virtual_fs::builder::RootFileSystemBuilder` RootFileSystemBuilder, } @@ -690,7 +690,7 @@ impl AsyncRead for OutputCapturerer { } } -/// When using `wasmer_vfs::mem_fs`, we cannot rely on `BASE_TEST_DIR` +/// When using `virtual_fs::mem_fs`, we cannot rely on `BASE_TEST_DIR` /// because the host filesystem cannot be used. Instead, we are /// copying `BASE_TEST_DIR` to the `mem_fs`. fn map_host_fs_to_mem_fs<'a>(