mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-10 22:58:18 +00:00
Merge branch 'master' into fix-3197
This commit is contained in:
496
Cargo.lock
generated
496
Cargo.lock
generated
@@ -46,15 +46,6 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ansi_term"
|
|
||||||
version = "0.12.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
|
|
||||||
dependencies = [
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.65"
|
version = "1.0.65"
|
||||||
@@ -96,6 +87,17 @@ dependencies = [
|
|||||||
"wait-timeout",
|
"wait-timeout",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-trait"
|
||||||
|
version = "0.1.57"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "76464446b8bc32758d7e88ee1a804d9914cd9b1cb264c029899680b0be29826f"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atty"
|
name = "atty"
|
||||||
version = "0.2.14"
|
version = "0.2.14"
|
||||||
@@ -149,34 +151,11 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bindgen"
|
|
||||||
version = "0.56.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2da379dbebc0b76ef63ca68d8fc6e71c0f13e59432e0987e508c1820e6ab5239"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"cexpr",
|
|
||||||
"clang-sys",
|
|
||||||
"clap 2.34.0",
|
|
||||||
"env_logger",
|
|
||||||
"lazy_static",
|
|
||||||
"lazycell",
|
|
||||||
"log",
|
|
||||||
"peeking_take_while",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"regex",
|
|
||||||
"rustc-hash",
|
|
||||||
"shlex",
|
|
||||||
"which",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "1.2.1"
|
version = "1.3.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "blake3"
|
name = "blake3"
|
||||||
@@ -280,7 +259,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "a6358dedf60f4d9b8db43ad187391afe959746101346fe51bb978126bec61dfb"
|
checksum = "a6358dedf60f4d9b8db43ad187391afe959746101346fe51bb978126bec61dfb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap 3.2.21",
|
"clap 3.2.21",
|
||||||
"heck",
|
"heck 0.4.0",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"log",
|
"log",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -301,15 +280,6 @@ dependencies = [
|
|||||||
"jobserver",
|
"jobserver",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cexpr"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27"
|
|
||||||
dependencies = [
|
|
||||||
"nom 5.1.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
version = "0.1.10"
|
version = "0.1.10"
|
||||||
@@ -336,30 +306,15 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "clang-sys"
|
|
||||||
version = "1.3.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5a050e2153c5be08febd6734e29298e844fdb0fa21aeddd63b4eb7baa106c69b"
|
|
||||||
dependencies = [
|
|
||||||
"glob",
|
|
||||||
"libc",
|
|
||||||
"libloading",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "2.34.0"
|
version = "2.34.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
|
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_term",
|
|
||||||
"atty",
|
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"strsim 0.8.0",
|
|
||||||
"textwrap 0.11.0",
|
"textwrap 0.11.0",
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
"vec_map",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -374,7 +329,7 @@ dependencies = [
|
|||||||
"clap_lex",
|
"clap_lex",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"strsim 0.10.0",
|
"strsim",
|
||||||
"termcolor",
|
"termcolor",
|
||||||
"textwrap 0.15.0",
|
"textwrap 0.15.0",
|
||||||
]
|
]
|
||||||
@@ -385,7 +340,7 @@ version = "3.2.18"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65"
|
checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck",
|
"heck 0.4.0",
|
||||||
"proc-macro-error",
|
"proc-macro-error",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -487,6 +442,12 @@ version = "0.1.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
|
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "convert_case"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fb4a24b1aaf0fd0ce8b45161144d6f42cd91677fd5940fd431183eb023b3a2b8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "core-foundation-sys"
|
name = "core-foundation-sys"
|
||||||
version = "0.8.3"
|
version = "0.8.3"
|
||||||
@@ -844,6 +805,15 @@ version = "0.4.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6d9d8664cf849d7d0f3114a3a387d2f5e4303176d746d5a951aaddc66dfe9240"
|
checksum = "6d9d8664cf849d7d0f3114a3a387d2f5e4303176d746d5a951aaddc66dfe9240"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dlib"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ac1b7517328c04c2aa68422fc60a41b92208182142ed04a25879c26c8f878794"
|
||||||
|
dependencies = [
|
||||||
|
"libloading",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "doc-comment"
|
name = "doc-comment"
|
||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
@@ -929,19 +899,6 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "env_logger"
|
|
||||||
version = "0.8.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
|
|
||||||
dependencies = [
|
|
||||||
"atty",
|
|
||||||
"humantime",
|
|
||||||
"log",
|
|
||||||
"regex",
|
|
||||||
"termcolor",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "erased-serde"
|
name = "erased-serde"
|
||||||
version = "0.3.23"
|
version = "0.3.23"
|
||||||
@@ -1013,6 +970,95 @@ version = "1.0.7"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures"
|
||||||
|
version = "0.3.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c"
|
||||||
|
dependencies = [
|
||||||
|
"futures-channel",
|
||||||
|
"futures-core",
|
||||||
|
"futures-executor",
|
||||||
|
"futures-io",
|
||||||
|
"futures-sink",
|
||||||
|
"futures-task",
|
||||||
|
"futures-util",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-channel"
|
||||||
|
version = "0.3.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"futures-sink",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-core"
|
||||||
|
version = "0.3.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-executor"
|
||||||
|
version = "0.3.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"futures-task",
|
||||||
|
"futures-util",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-io"
|
||||||
|
version = "0.3.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-macro"
|
||||||
|
version = "0.3.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-sink"
|
||||||
|
version = "0.3.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "21b20ba5a92e727ba30e72834706623d94ac93a725410b6a6b6fbc1b07f7ba56"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-task"
|
||||||
|
version = "0.3.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-util"
|
||||||
|
version = "0.3.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90"
|
||||||
|
dependencies = [
|
||||||
|
"futures-channel",
|
||||||
|
"futures-core",
|
||||||
|
"futures-io",
|
||||||
|
"futures-macro",
|
||||||
|
"futures-sink",
|
||||||
|
"futures-task",
|
||||||
|
"memchr",
|
||||||
|
"pin-project-lite",
|
||||||
|
"pin-utils",
|
||||||
|
"slab",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fxhash"
|
name = "fxhash"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
@@ -1136,6 +1182,15 @@ dependencies = [
|
|||||||
"ahash",
|
"ahash",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "heck"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-segmentation",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heck"
|
name = "heck"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
@@ -1169,12 +1224,6 @@ dependencies = [
|
|||||||
"webpki-roots",
|
"webpki-roots",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "humantime"
|
|
||||||
version = "2.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iana-time-zone"
|
name = "iana-time-zone"
|
||||||
version = "0.1.48"
|
version = "0.1.48"
|
||||||
@@ -1189,6 +1238,12 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "id-arena"
|
||||||
|
version = "2.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ident_case"
|
name = "ident_case"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
@@ -1267,6 +1322,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
|
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1324,12 +1382,6 @@ version = "1.4.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lazycell"
|
|
||||||
version = "1.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "leb128"
|
name = "leb128"
|
||||||
version = "0.2.5"
|
version = "0.2.5"
|
||||||
@@ -1449,21 +1501,28 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "minifb"
|
name = "minifb"
|
||||||
version = "0.19.3"
|
version = "0.23.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7b6e41119d1667465608d36488fa5dcd228057a26c156e25f17f492f38435124"
|
checksum = "d9e21c5f89bb820c7878c300c5b944e65de0f1b2a75e0be92ce670b95943740e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
|
"dlib",
|
||||||
|
"futures",
|
||||||
|
"instant",
|
||||||
|
"js-sys",
|
||||||
|
"lazy_static",
|
||||||
|
"libc",
|
||||||
"orbclient",
|
"orbclient",
|
||||||
"raw-window-handle 0.3.4",
|
"raw-window-handle 0.4.3",
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
"wasm-bindgen-futures",
|
||||||
"wayland-client",
|
"wayland-client",
|
||||||
"wayland-cursor",
|
"wayland-cursor",
|
||||||
"wayland-protocols",
|
"wayland-protocols",
|
||||||
"winapi",
|
"winapi",
|
||||||
"x11-dl",
|
"x11-dl",
|
||||||
"xkb",
|
|
||||||
"xkbcommon-sys",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1498,25 +1557,28 @@ checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nix"
|
name = "nix"
|
||||||
version = "0.20.2"
|
version = "0.24.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f5e06129fb611568ef4e868c14b326274959aa70ff7776e9d55323531c374945"
|
checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cc",
|
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"libc",
|
"libc",
|
||||||
"memoffset",
|
"memoffset",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nom"
|
name = "nix"
|
||||||
version = "5.1.2"
|
version = "0.25.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af"
|
checksum = "e322c04a9e3440c327fca7b6c8a63e6890a32fa2ad689db972425f07e0d22abb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"autocfg",
|
||||||
"version_check",
|
"bitflags",
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"libc",
|
||||||
|
"memoffset",
|
||||||
|
"pin-utils",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1658,12 +1720,6 @@ version = "1.0.9"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1"
|
checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "peeking_take_while"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pest"
|
name = "pest"
|
||||||
version = "2.3.1"
|
version = "2.3.1"
|
||||||
@@ -1680,6 +1736,12 @@ version = "0.2.9"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
|
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pin-utils"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pkg-config"
|
name = "pkg-config"
|
||||||
version = "0.3.25"
|
version = "0.3.25"
|
||||||
@@ -1845,6 +1907,17 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pulldown-cmark"
|
||||||
|
version = "0.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"memchr",
|
||||||
|
"unicase",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.21"
|
version = "1.0.21"
|
||||||
@@ -1877,9 +1950,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand_core"
|
name = "rand_core"
|
||||||
version = "0.6.3"
|
version = "0.6.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
|
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom",
|
"getrandom",
|
||||||
]
|
]
|
||||||
@@ -2068,12 +2141,6 @@ version = "0.1.21"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
|
checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-hash"
|
|
||||||
version = "1.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc_version"
|
name = "rustc_version"
|
||||||
version = "0.2.3"
|
version = "0.2.3"
|
||||||
@@ -2335,12 +2402,6 @@ dependencies = [
|
|||||||
"lazy_static",
|
"lazy_static",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "shlex"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slab"
|
name = "slab"
|
||||||
version = "0.4.7"
|
version = "0.4.7"
|
||||||
@@ -2432,12 +2493,6 @@ version = "0.1.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0"
|
checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "strsim"
|
|
||||||
version = "0.8.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strsim"
|
name = "strsim"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
@@ -2637,6 +2692,21 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tinyvec"
|
||||||
|
version = "1.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
|
||||||
|
dependencies = [
|
||||||
|
"tinyvec_macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tinyvec_macros"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml"
|
name = "toml"
|
||||||
version = "0.5.9"
|
version = "0.5.9"
|
||||||
@@ -2771,12 +2841,33 @@ version = "1.0.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd"
|
checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-normalization"
|
||||||
|
version = "0.1.21"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6"
|
||||||
|
dependencies = [
|
||||||
|
"tinyvec",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-segmentation"
|
||||||
|
version = "1.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-width"
|
name = "unicode-width"
|
||||||
version = "0.1.10"
|
version = "0.1.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
|
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-xid"
|
||||||
|
version = "0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unix_mode"
|
name = "unix_mode"
|
||||||
version = "0.1.3"
|
version = "0.1.3"
|
||||||
@@ -2789,12 +2880,6 @@ version = "0.7.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
|
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "vec_map"
|
|
||||||
version = "0.8.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version-compare"
|
name = "version-compare"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -2845,6 +2930,14 @@ dependencies = [
|
|||||||
"wast 24.0.0",
|
"wast 24.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi-types-generator-extra"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"convert_case",
|
||||||
|
"wasmer-wit-parser",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen"
|
name = "wasm-bindgen"
|
||||||
version = "0.2.83"
|
version = "0.2.83"
|
||||||
@@ -3399,7 +3492,7 @@ name = "wasmer-wasi-experimental-io-devices"
|
|||||||
version = "3.0.0-beta.2"
|
version = "3.0.0-beta.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"minifb",
|
"minifb",
|
||||||
"nix",
|
"nix 0.25.0",
|
||||||
"ref_thread_local",
|
"ref_thread_local",
|
||||||
"serde",
|
"serde",
|
||||||
"tracing",
|
"tracing",
|
||||||
@@ -3422,10 +3515,16 @@ name = "wasmer-wasi-types"
|
|||||||
version = "3.0.0-beta.2"
|
version = "3.0.0-beta.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
|
"pretty_assertions",
|
||||||
"serde",
|
"serde",
|
||||||
"time",
|
"time",
|
||||||
|
"wasmer",
|
||||||
"wasmer-derive",
|
"wasmer-derive",
|
||||||
"wasmer-types",
|
"wasmer-types",
|
||||||
|
"wasmer-wit-bindgen-gen-core",
|
||||||
|
"wasmer-wit-bindgen-gen-rust-wasm",
|
||||||
|
"wasmer-wit-bindgen-rust",
|
||||||
|
"wasmer-wit-parser",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3442,6 +3541,73 @@ dependencies = [
|
|||||||
"wast 38.0.1",
|
"wast 38.0.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasmer-wit-bindgen-gen-core"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ff8aa5be5ae5d61f5e151dc2c0e603093fe28395d2083b65ef7a3547844054fe"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"wasmer-wit-parser",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasmer-wit-bindgen-gen-rust"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "438bce7c4589842bf100cc9b312443a9b5fc6440e58ab0b8c114e460219c3c3b"
|
||||||
|
dependencies = [
|
||||||
|
"heck 0.3.3",
|
||||||
|
"wasmer-wit-bindgen-gen-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasmer-wit-bindgen-gen-rust-wasm"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "505f5168cfee591840e13e158a5c5e2f95d6df1df710839021564f36bee7bafc"
|
||||||
|
dependencies = [
|
||||||
|
"heck 0.3.3",
|
||||||
|
"wasmer-wit-bindgen-gen-core",
|
||||||
|
"wasmer-wit-bindgen-gen-rust",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasmer-wit-bindgen-rust"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "968747f1271f74aab9b70d9c5d4921db9bd13b4ec3ba5506506e6e7dc58c918c"
|
||||||
|
dependencies = [
|
||||||
|
"async-trait",
|
||||||
|
"bitflags",
|
||||||
|
"wasmer-wit-bindgen-rust-impl",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasmer-wit-bindgen-rust-impl"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bd26fe00d08bd2119870b017d13413dfbd51e7750b6634d649fc7a7bbc057b85"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"syn",
|
||||||
|
"wasmer-wit-bindgen-gen-core",
|
||||||
|
"wasmer-wit-bindgen-gen-rust-wasm",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasmer-wit-parser"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f46c9a15086be8a2eb3790613902b9d3a9a687833b17cd021de263a20378585a"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"id-arena",
|
||||||
|
"pulldown-cmark",
|
||||||
|
"unicode-normalization",
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasmer-workspace"
|
name = "wasmer-workspace"
|
||||||
version = "3.0.0-beta.2"
|
version = "3.0.0-beta.2"
|
||||||
@@ -3540,14 +3706,15 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wayland-client"
|
name = "wayland-client"
|
||||||
version = "0.28.6"
|
version = "0.29.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e3ab332350e502f159382201394a78e3cc12d0f04db863429260164ea40e0355"
|
checksum = "3f3b068c05a039c9f755f881dc50f01732214f5685e379829759088967c46715"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"downcast-rs",
|
"downcast-rs",
|
||||||
"libc",
|
"libc",
|
||||||
"nix",
|
"nix 0.24.2",
|
||||||
|
"scoped-tls",
|
||||||
"wayland-commons",
|
"wayland-commons",
|
||||||
"wayland-scanner",
|
"wayland-scanner",
|
||||||
"wayland-sys",
|
"wayland-sys",
|
||||||
@@ -3555,11 +3722,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wayland-commons"
|
name = "wayland-commons"
|
||||||
version = "0.28.6"
|
version = "0.29.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a21817947c7011bbd0a27e11b17b337bfd022e8544b071a2641232047966fbda"
|
checksum = "8691f134d584a33a6606d9d717b95c4fa20065605f798a3f350d78dced02a902"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nix",
|
"nix 0.24.2",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"wayland-sys",
|
"wayland-sys",
|
||||||
@@ -3567,20 +3734,20 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wayland-cursor"
|
name = "wayland-cursor"
|
||||||
version = "0.28.6"
|
version = "0.29.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "be610084edd1586d45e7bdd275fe345c7c1873598caa464c4fb835dee70fa65a"
|
checksum = "6865c6b66f13d6257bef1cd40cbfe8ef2f150fb8ebbdb1e8e873455931377661"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nix",
|
"nix 0.24.2",
|
||||||
"wayland-client",
|
"wayland-client",
|
||||||
"xcursor",
|
"xcursor",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wayland-protocols"
|
name = "wayland-protocols"
|
||||||
version = "0.28.6"
|
version = "0.29.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "286620ea4d803bacf61fa087a4242ee316693099ee5a140796aaba02b29f861f"
|
checksum = "b950621f9354b322ee817a23474e479b34be96c2e909c14f7bc0100e9a970bc6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"wayland-client",
|
"wayland-client",
|
||||||
@@ -3590,9 +3757,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wayland-scanner"
|
name = "wayland-scanner"
|
||||||
version = "0.28.6"
|
version = "0.29.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ce923eb2deb61de332d1f356ec7b6bf37094dc5573952e1c8936db03b54c03f1"
|
checksum = "8f4303d8fa22ab852f789e75a967f0a2cdc430a607751c0499bada3e451cbd53"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -3601,10 +3768,12 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wayland-sys"
|
name = "wayland-sys"
|
||||||
version = "0.28.6"
|
version = "0.29.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d841fca9aed7febf9bed2e9796c49bf58d4152ceda8ac949ebe00868d8f0feb8"
|
checksum = "be12ce1a3c39ec7dba25594b97b42cb3195d54953ddb9d3d95a7c3902bc6e9d4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"dlib",
|
||||||
|
"lazy_static",
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -3637,15 +3806,6 @@ dependencies = [
|
|||||||
"webpki",
|
"webpki",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "which"
|
|
||||||
version = "3.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
@@ -3780,29 +3940,7 @@ version = "0.3.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "463705a63313cd4301184381c5e8042f0a7e9b4bb63653f216311d4ae74690b7"
|
checksum = "463705a63313cd4301184381c5e8042f0a7e9b4bb63653f216311d4ae74690b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nom 7.1.1",
|
"nom",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "xkb"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "aec02bc5de902aa579f3d2f2c522edaf40fa42963cbaffe645b058ddcc68fdb2"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"libc",
|
|
||||||
"xkbcommon-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "xkbcommon-sys"
|
|
||||||
version = "0.7.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "59a001b79d45b0b4541c228a501177f2b35db976bf7ee3f7fce8fa2381554ab5"
|
|
||||||
dependencies = [
|
|
||||||
"bindgen",
|
|
||||||
"libc",
|
|
||||||
"pkg-config",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ members = [
|
|||||||
"lib/vm",
|
"lib/vm",
|
||||||
"lib/wasi",
|
"lib/wasi",
|
||||||
"lib/wasi-types",
|
"lib/wasi-types",
|
||||||
|
"lib/wasi-types/wasi-types-generator-extra",
|
||||||
"lib/wasi-experimental-io-devices",
|
"lib/wasi-experimental-io-devices",
|
||||||
"lib/wasi-local-networking",
|
"lib/wasi-local-networking",
|
||||||
"lib/c-api/tests/wasmer-c-api-test-runner",
|
"lib/c-api/tests/wasmer-c-api-test-runner",
|
||||||
|
|||||||
29
lib/api/src/js/externals/memory_view.rs
vendored
29
lib/api/src/js/externals/memory_view.rs
vendored
@@ -58,6 +58,35 @@ impl<'a> MemoryView<'a> {
|
|||||||
self.size
|
self.size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: do we want a proper implementation here instead?
|
||||||
|
/// Retrieve a slice of the memory contents.
|
||||||
|
///
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
|
/// Until the returned slice is dropped, it is undefined behaviour to
|
||||||
|
/// modify the memory contents in any way including by calling a wasm
|
||||||
|
/// function that writes to the memory or by resizing the memory.
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub unsafe fn data_unchecked(&self) -> &[u8] {
|
||||||
|
unimplemented!("direct data pointer access is not possible in JavaScript");
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: do we want a proper implementation here instead?
|
||||||
|
/// Retrieve a mutable slice of the memory contents.
|
||||||
|
///
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
|
/// This method provides interior mutability without an UnsafeCell. Until
|
||||||
|
/// the returned value is dropped, it is undefined behaviour to read or
|
||||||
|
/// write to the pointed-to memory in any way except through this slice,
|
||||||
|
/// including by calling a wasm function that reads the memory contents or
|
||||||
|
/// by resizing this Memory.
|
||||||
|
#[allow(clippy::mut_from_ref)]
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub unsafe fn data_unchecked_mut(&self) -> &mut [u8] {
|
||||||
|
unimplemented!("direct data pointer access is not possible in JavaScript");
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the size (in [`Pages`]) of the `Memory`.
|
/// Returns the size (in [`Pages`]) of the `Memory`.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
|
|||||||
@@ -234,7 +234,9 @@ impl Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Serializes a module into a binary representation that the `Engine`
|
/// Serializes a module into a binary representation that the `Engine`
|
||||||
/// can later process via [`Module::deserialize`].
|
/// can later process via
|
||||||
|
#[cfg_attr(feature = "compiler", doc = "[`Module::deserialize`].")]
|
||||||
|
#[cfg_attr(not(feature = "compiler"), doc = "`Module::deserialize`.")]
|
||||||
///
|
///
|
||||||
/// # Usage
|
/// # Usage
|
||||||
///
|
///
|
||||||
@@ -252,7 +254,9 @@ impl Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Serializes a module into a file that the `Engine`
|
/// Serializes a module into a file that the `Engine`
|
||||||
/// can later process via [`Module::deserialize_from_file`].
|
/// can later process via
|
||||||
|
#[cfg_attr(feature = "compiler", doc = "[`Module::deserialize_from_file`].")]
|
||||||
|
#[cfg_attr(not(feature = "compiler"), doc = "`Module::deserialize_from_file`.")]
|
||||||
///
|
///
|
||||||
/// # Usage
|
/// # Usage
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ pub(crate) struct StoreInner {
|
|||||||
///
|
///
|
||||||
/// The `Store` holds the engine (that is —amongst many things— used to compile
|
/// The `Store` holds the engine (that is —amongst many things— used to compile
|
||||||
/// the Wasm bytes into a valid module artifact), in addition to the
|
/// the Wasm bytes into a valid module artifact), in addition to the
|
||||||
/// [`Tunables`] (that are used to create the memories, tables and globals).
|
#[cfg_attr(feature = "compiler", doc = "[`Tunables`]")]
|
||||||
|
#[cfg_attr(not(feature = "compiler"), doc = "`Tunables`")]
|
||||||
|
/// (that are used to create the memories, tables and globals).
|
||||||
///
|
///
|
||||||
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#store>
|
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#store>
|
||||||
pub struct Store {
|
pub struct Store {
|
||||||
|
|||||||
@@ -178,11 +178,12 @@ mod tests {
|
|||||||
use std::cell::UnsafeCell;
|
use std::cell::UnsafeCell;
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use wasmer_types::{MemoryError, MemoryStyle, MemoryType, Pages, WASM_PAGE_SIZE};
|
use wasmer_types::{MemoryError, MemoryStyle, MemoryType, Pages, WASM_PAGE_SIZE};
|
||||||
use wasmer_vm::{LinearMemory, MaybeInstanceOwned};
|
use wasmer_vm::LinearMemory;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct VMTinyMemory {
|
struct VMTinyMemory {
|
||||||
mem: [u8; WASM_PAGE_SIZE],
|
mem: Vec<u8>,
|
||||||
|
memory_definition: Option<UnsafeCell<VMMemoryDefinition>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for VMTinyMemory {}
|
unsafe impl Send for VMTinyMemory {}
|
||||||
@@ -190,26 +191,35 @@ mod tests {
|
|||||||
|
|
||||||
impl VMTinyMemory {
|
impl VMTinyMemory {
|
||||||
pub fn new() -> Result<Self, MemoryError> {
|
pub fn new() -> Result<Self, MemoryError> {
|
||||||
Ok(VMTinyMemory {
|
let sz = 18 * WASM_PAGE_SIZE;
|
||||||
mem: [0; WASM_PAGE_SIZE],
|
let mut memory = Vec::new();
|
||||||
})
|
memory.resize(sz, 0);
|
||||||
|
let mut ret = VMTinyMemory {
|
||||||
|
mem: memory,
|
||||||
|
memory_definition: None,
|
||||||
|
};
|
||||||
|
ret.memory_definition = Some(UnsafeCell::new(VMMemoryDefinition {
|
||||||
|
base: ret.mem.as_ptr() as _,
|
||||||
|
current_length: sz,
|
||||||
|
}));
|
||||||
|
Ok(ret)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LinearMemory for VMTinyMemory {
|
impl LinearMemory for VMTinyMemory {
|
||||||
fn ty(&self) -> MemoryType {
|
fn ty(&self) -> MemoryType {
|
||||||
MemoryType {
|
MemoryType {
|
||||||
minimum: Pages::from(1u32),
|
minimum: Pages::from(18u32),
|
||||||
maximum: Some(Pages::from(1u32)),
|
maximum: Some(Pages::from(18u32)),
|
||||||
shared: false,
|
shared: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn size(&self) -> Pages {
|
fn size(&self) -> Pages {
|
||||||
Pages::from(1u32)
|
Pages::from(18u32)
|
||||||
}
|
}
|
||||||
fn style(&self) -> MemoryStyle {
|
fn style(&self) -> MemoryStyle {
|
||||||
MemoryStyle::Static {
|
MemoryStyle::Static {
|
||||||
bound: Pages::from(1u32),
|
bound: Pages::from(18u32),
|
||||||
offset_guard_size: 0,
|
offset_guard_size: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,15 +230,28 @@ mod tests {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
fn vmmemory(&self) -> NonNull<VMMemoryDefinition> {
|
fn vmmemory(&self) -> NonNull<VMMemoryDefinition> {
|
||||||
MaybeInstanceOwned::Host(Box::new(UnsafeCell::new(VMMemoryDefinition {
|
unsafe {
|
||||||
base: self.mem.as_ptr() as _,
|
NonNull::new(
|
||||||
current_length: WASM_PAGE_SIZE,
|
self.memory_definition
|
||||||
})))
|
.as_ref()
|
||||||
.as_ptr()
|
.unwrap()
|
||||||
|
.get()
|
||||||
|
.as_mut()
|
||||||
|
.unwrap() as _,
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn try_clone(&self) -> Option<Box<dyn LinearMemory + 'static>> {
|
fn try_clone(&self) -> Option<Box<dyn LinearMemory + 'static>> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
// this code allow custom memory to be ignoring init_memory
|
||||||
|
use wasmer_vm::Trap;
|
||||||
|
unsafe fn initialize_with_data(&self, _start: usize, _data: &[u8]) -> Result<(), Trap> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<VMTinyMemory> for wasmer_vm::VMMemory {
|
impl From<VMTinyMemory> for wasmer_vm::VMMemory {
|
||||||
@@ -241,7 +264,7 @@ mod tests {
|
|||||||
impl Tunables for TinyTunables {
|
impl Tunables for TinyTunables {
|
||||||
fn memory_style(&self, _memory: &MemoryType) -> MemoryStyle {
|
fn memory_style(&self, _memory: &MemoryType) -> MemoryStyle {
|
||||||
MemoryStyle::Static {
|
MemoryStyle::Static {
|
||||||
bound: Pages::from(1u32),
|
bound: Pages::from(18u32),
|
||||||
offset_guard_size: 0,
|
offset_guard_size: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -262,9 +285,16 @@ mod tests {
|
|||||||
&self,
|
&self,
|
||||||
_ty: &MemoryType,
|
_ty: &MemoryType,
|
||||||
_style: &MemoryStyle,
|
_style: &MemoryStyle,
|
||||||
_vm_definition_location: NonNull<VMMemoryDefinition>,
|
vm_definition_location: NonNull<VMMemoryDefinition>,
|
||||||
) -> Result<VMMemory, MemoryError> {
|
) -> Result<VMMemory, MemoryError> {
|
||||||
let memory = VMTinyMemory::new().unwrap();
|
let memory = VMTinyMemory::new().unwrap();
|
||||||
|
// now, it's important to update vm_definition_location with the memory information!
|
||||||
|
let mut ptr = vm_definition_location;
|
||||||
|
let md = ptr.as_mut();
|
||||||
|
let unsafecell = memory.memory_definition.as_ref().unwrap();
|
||||||
|
let def = unsafecell.get().as_ref().unwrap();
|
||||||
|
md.base = def.base;
|
||||||
|
md.current_length = def.current_length;
|
||||||
Ok(memory.into())
|
Ok(memory.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,13 +323,13 @@ mod tests {
|
|||||||
let vmmemory = tunables.create_host_memory(
|
let vmmemory = tunables.create_host_memory(
|
||||||
&MemoryType::new(1u32, Some(100u32), true),
|
&MemoryType::new(1u32, Some(100u32), true),
|
||||||
&MemoryStyle::Static {
|
&MemoryStyle::Static {
|
||||||
bound: Pages::from(1u32),
|
bound: Pages::from(18u32),
|
||||||
offset_guard_size: 0u64,
|
offset_guard_size: 0u64,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
let mut vmmemory = vmmemory.unwrap();
|
let mut vmmemory = vmmemory.unwrap();
|
||||||
assert!(vmmemory.grow(Pages::from(2u32)).is_err());
|
assert!(vmmemory.grow(Pages::from(50u32)).is_err());
|
||||||
assert_eq!(vmmemory.size(), Pages::from(1u32));
|
assert_eq!(vmmemory.size(), Pages::from(18u32));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
vmmemory.grow(Pages::from(0u32)).err().unwrap(),
|
vmmemory.grow(Pages::from(0u32)).err().unwrap(),
|
||||||
MemoryError::CouldNotGrow {
|
MemoryError::CouldNotGrow {
|
||||||
@@ -308,4 +338,42 @@ mod tests {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn check_customtunables() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
use crate::{imports, wat2wasm, Instance, Memory, Module, Store};
|
||||||
|
use wasmer_compiler_cranelift::Cranelift;
|
||||||
|
|
||||||
|
let wasm_bytes = wat2wasm(
|
||||||
|
br#"(module
|
||||||
|
(memory (;0;) 18)
|
||||||
|
(global (;0;) (mut i32) i32.const 1048576)
|
||||||
|
(export "memory" (memory 0))
|
||||||
|
(data (;0;) (i32.const 1048576) "*\00\00\00")
|
||||||
|
)"#,
|
||||||
|
)?;
|
||||||
|
let compiler = Cranelift::default();
|
||||||
|
|
||||||
|
let tunables = TinyTunables {};
|
||||||
|
let mut store = Store::new_with_tunables(compiler, tunables);
|
||||||
|
//let mut store = Store::new(compiler);
|
||||||
|
let module = Module::new(&store, wasm_bytes)?;
|
||||||
|
let import_object = imports! {};
|
||||||
|
let instance = Instance::new(&mut store, &module, &import_object)?;
|
||||||
|
|
||||||
|
let mut memories: Vec<Memory> = instance
|
||||||
|
.exports
|
||||||
|
.iter()
|
||||||
|
.memories()
|
||||||
|
.map(|pair| pair.1.clone())
|
||||||
|
.collect();
|
||||||
|
assert_eq!(memories.len(), 1);
|
||||||
|
let first_memory = memories.pop().unwrap();
|
||||||
|
assert_eq!(first_memory.ty(&store).maximum.unwrap(), Pages(18));
|
||||||
|
let view = first_memory.view(&store);
|
||||||
|
let x = unsafe { view.data_unchecked_mut() }[0];
|
||||||
|
assert_eq!(x, 0);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ macro_rules! primitives {
|
|||||||
)*)
|
)*)
|
||||||
}
|
}
|
||||||
primitives! {
|
primitives! {
|
||||||
|
bool
|
||||||
i8 u8
|
i8 u8
|
||||||
i16 u16
|
i16 u16
|
||||||
i32 u32
|
i32 u32
|
||||||
|
|||||||
@@ -206,6 +206,7 @@ impl Instance {
|
|||||||
unsafe { self.vmctx_plus_offset(self.offsets.vmctx_tables_begin()) }
|
unsafe { self.vmctx_plus_offset(self.offsets.vmctx_tables_begin()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
/// Get a locally defined or imported memory.
|
/// Get a locally defined or imported memory.
|
||||||
fn get_memory(&self, index: MemoryIndex) -> VMMemoryDefinition {
|
fn get_memory(&self, index: MemoryIndex) -> VMMemoryDefinition {
|
||||||
if let Some(local_index) = self.module.local_memory_index(index) {
|
if let Some(local_index) = self.module.local_memory_index(index) {
|
||||||
@@ -240,6 +241,21 @@ impl Instance {
|
|||||||
unsafe { self.vmctx_plus_offset(self.offsets.vmctx_memories_begin()) }
|
unsafe { self.vmctx_plus_offset(self.offsets.vmctx_memories_begin()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get a locally defined or imported memory.
|
||||||
|
fn get_vmmemory(&self, index: MemoryIndex) -> &VMMemory {
|
||||||
|
if let Some(local_index) = self.module.local_memory_index(index) {
|
||||||
|
unsafe {
|
||||||
|
self.memories
|
||||||
|
.get(local_index)
|
||||||
|
.unwrap()
|
||||||
|
.get(self.context.as_ref().unwrap())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let import = self.imported_memory(index);
|
||||||
|
unsafe { import.handle.get(self.context.as_ref().unwrap()) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Return the indexed `VMGlobalDefinition`.
|
/// Return the indexed `VMGlobalDefinition`.
|
||||||
fn global(&self, index: LocalGlobalIndex) -> VMGlobalDefinition {
|
fn global(&self, index: LocalGlobalIndex) -> VMGlobalDefinition {
|
||||||
unsafe { self.global_ptr(index).as_ref().clone() }
|
unsafe { self.global_ptr(index).as_ref().clone() }
|
||||||
@@ -701,29 +717,22 @@ impl Instance {
|
|||||||
) -> Result<(), Trap> {
|
) -> Result<(), Trap> {
|
||||||
// https://webassembly.github.io/bulk-memory-operations/core/exec/instructions.html#exec-memory-init
|
// https://webassembly.github.io/bulk-memory-operations/core/exec/instructions.html#exec-memory-init
|
||||||
|
|
||||||
let memory = self.get_memory(memory_index);
|
let memory = self.get_vmmemory(memory_index);
|
||||||
let passive_data = self.passive_data.borrow();
|
let passive_data = self.passive_data.borrow();
|
||||||
let data = passive_data.get(&data_index).map_or(&[][..], |d| &**d);
|
let data = passive_data.get(&data_index).map_or(&[][..], |d| &**d);
|
||||||
|
|
||||||
|
let current_length = unsafe { memory.vmmemory().as_ref().current_length };
|
||||||
if src
|
if src
|
||||||
.checked_add(len)
|
.checked_add(len)
|
||||||
.map_or(true, |n| n as usize > data.len())
|
.map_or(true, |n| n as usize > data.len())
|
||||||
|| dst.checked_add(len).map_or(true, |m| {
|
|| dst
|
||||||
usize::try_from(m).unwrap() > memory.current_length
|
.checked_add(len)
|
||||||
})
|
.map_or(true, |m| usize::try_from(m).unwrap() > current_length)
|
||||||
{
|
{
|
||||||
return Err(Trap::lib(TrapCode::HeapAccessOutOfBounds));
|
return Err(Trap::lib(TrapCode::HeapAccessOutOfBounds));
|
||||||
}
|
}
|
||||||
|
|
||||||
let src_slice = &data[src as usize..(src + len) as usize];
|
let src_slice = &data[src as usize..(src + len) as usize];
|
||||||
|
unsafe { memory.initialize_with_data(dst as usize, src_slice) }
|
||||||
unsafe {
|
|
||||||
let dst_start = memory.base.add(dst as usize);
|
|
||||||
let dst_slice = slice::from_raw_parts_mut(dst_start, len as usize);
|
|
||||||
dst_slice.copy_from_slice(src_slice);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Drop the given data segment, truncating its length to zero.
|
/// Drop the given data segment, truncating its length to zero.
|
||||||
@@ -1147,6 +1156,7 @@ fn get_memory_init_start(init: &DataInitializer<'_>, instance: &Instance) -> usi
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::mut_from_ref)]
|
#[allow(clippy::mut_from_ref)]
|
||||||
|
#[allow(dead_code)]
|
||||||
/// Return a byte-slice view of a memory's data.
|
/// Return a byte-slice view of a memory's data.
|
||||||
unsafe fn get_memory_slice<'instance>(
|
unsafe fn get_memory_slice<'instance>(
|
||||||
init: &DataInitializer<'_>,
|
init: &DataInitializer<'_>,
|
||||||
@@ -1242,21 +1252,18 @@ fn initialize_memories(
|
|||||||
data_initializers: &[DataInitializer<'_>],
|
data_initializers: &[DataInitializer<'_>],
|
||||||
) -> Result<(), Trap> {
|
) -> Result<(), Trap> {
|
||||||
for init in data_initializers {
|
for init in data_initializers {
|
||||||
let memory = instance.get_memory(init.location.memory_index);
|
let memory = instance.get_vmmemory(init.location.memory_index);
|
||||||
|
|
||||||
let start = get_memory_init_start(init, instance);
|
let start = get_memory_init_start(init, instance);
|
||||||
if start
|
|
||||||
.checked_add(init.data.len())
|
|
||||||
.map_or(true, |end| end > memory.current_length)
|
|
||||||
{
|
|
||||||
return Err(Trap::lib(TrapCode::HeapAccessOutOfBounds));
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let mem_slice = get_memory_slice(init, instance);
|
let current_length = memory.vmmemory().as_ref().current_length;
|
||||||
let end = start + init.data.len();
|
if start
|
||||||
let to_init = &mut mem_slice[start..end];
|
.checked_add(init.data.len())
|
||||||
to_init.copy_from_slice(init.data);
|
.map_or(true, |end| end > current_length)
|
||||||
|
{
|
||||||
|
return Err(Trap::lib(TrapCode::HeapAccessOutOfBounds));
|
||||||
|
}
|
||||||
|
memory.initialize_with_data(start, init.data)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ pub use crate::function_env::VMFunctionEnvironment;
|
|||||||
pub use crate::global::*;
|
pub use crate::global::*;
|
||||||
pub use crate::imports::Imports;
|
pub use crate::imports::Imports;
|
||||||
pub use crate::instance::{InstanceAllocator, InstanceHandle};
|
pub use crate::instance::{InstanceAllocator, InstanceHandle};
|
||||||
pub use crate::memory::{LinearMemory, VMMemory};
|
pub use crate::memory::{initialize_memory_with_data, LinearMemory, VMMemory};
|
||||||
pub use crate::mmap::Mmap;
|
pub use crate::mmap::Mmap;
|
||||||
pub use crate::probestack::PROBESTACK;
|
pub use crate::probestack::PROBESTACK;
|
||||||
pub use crate::sig_registry::SignatureRegistry;
|
pub use crate::sig_registry::SignatureRegistry;
|
||||||
|
|||||||
@@ -5,11 +5,13 @@
|
|||||||
//!
|
//!
|
||||||
//! `Memory` is to WebAssembly linear memories what `Table` is to WebAssembly tables.
|
//! `Memory` is to WebAssembly linear memories what `Table` is to WebAssembly tables.
|
||||||
|
|
||||||
|
use crate::trap::Trap;
|
||||||
use crate::{mmap::Mmap, store::MaybeInstanceOwned, vmcontext::VMMemoryDefinition};
|
use crate::{mmap::Mmap, store::MaybeInstanceOwned, vmcontext::VMMemoryDefinition};
|
||||||
use more_asserts::assert_ge;
|
use more_asserts::assert_ge;
|
||||||
use std::cell::UnsafeCell;
|
use std::cell::UnsafeCell;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
use std::slice;
|
||||||
use wasmer_types::{Bytes, MemoryError, MemoryStyle, MemoryType, Pages};
|
use wasmer_types::{Bytes, MemoryError, MemoryStyle, MemoryType, Pages};
|
||||||
|
|
||||||
// The memory mapped area
|
// The memory mapped area
|
||||||
@@ -342,6 +344,11 @@ impl LinearMemory for VMMemory {
|
|||||||
fn try_clone(&self) -> Option<Box<dyn LinearMemory + 'static>> {
|
fn try_clone(&self) -> Option<Box<dyn LinearMemory + 'static>> {
|
||||||
self.0.try_clone()
|
self.0.try_clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Initialize memory with data
|
||||||
|
unsafe fn initialize_with_data(&self, start: usize, data: &[u8]) -> Result<(), Trap> {
|
||||||
|
self.0.initialize_with_data(start, data)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VMMemory {
|
impl VMMemory {
|
||||||
@@ -385,6 +392,21 @@ impl VMMemory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
/// Default implementation to initialize memory with data
|
||||||
|
pub unsafe fn initialize_memory_with_data(
|
||||||
|
memory: &VMMemoryDefinition,
|
||||||
|
start: usize,
|
||||||
|
data: &[u8],
|
||||||
|
) -> Result<(), Trap> {
|
||||||
|
let mem_slice = slice::from_raw_parts_mut(memory.base, memory.current_length);
|
||||||
|
let end = start + data.len();
|
||||||
|
let to_init = &mut mem_slice[start..end];
|
||||||
|
to_init.copy_from_slice(data);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Represents memory that is used by the WebAsssembly module
|
/// Represents memory that is used by the WebAsssembly module
|
||||||
pub trait LinearMemory
|
pub trait LinearMemory
|
||||||
where
|
where
|
||||||
@@ -410,4 +432,14 @@ where
|
|||||||
|
|
||||||
/// Attempts to clone this memory (if its clonable)
|
/// Attempts to clone this memory (if its clonable)
|
||||||
fn try_clone(&self) -> Option<Box<dyn LinearMemory + 'static>>;
|
fn try_clone(&self) -> Option<Box<dyn LinearMemory + 'static>>;
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
/// # Safety
|
||||||
|
/// This function is unsafe because WebAssembly specification requires that data is always set at initialization time.
|
||||||
|
/// It should be the implementors responsibility to make sure this respects the spec
|
||||||
|
unsafe fn initialize_with_data(&self, start: usize, data: &[u8]) -> Result<(), Trap> {
|
||||||
|
let memory = self.vmmemory().as_ref();
|
||||||
|
|
||||||
|
initialize_memory_with_data(memory, start, data)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ maintenance = { status = "experimental" }
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
wasmer-wasi = { version = "=3.0.0-beta.2", path = "../wasi", default-features=false }
|
wasmer-wasi = { version = "=3.0.0-beta.2", path = "../wasi", default-features=false }
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
minifb = { version = "0.19", optional = true }
|
minifb = { version = "0.23", optional = true }
|
||||||
nix = "0.20.2"
|
nix = "0.25.0"
|
||||||
ref_thread_local = "0.1"
|
ref_thread_local = "0.1"
|
||||||
serde = "1"
|
serde = "1"
|
||||||
typetag = "0.1"
|
typetag = "0.1"
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ use std::collections::{BTreeSet, VecDeque};
|
|||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use std::io::{Read, Seek, SeekFrom, Write};
|
use std::io::{Read, Seek, SeekFrom, Write};
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
use wasmer_wasi::{types::*, WasiInodes};
|
use wasmer_wasi::{
|
||||||
|
types::{wasi::Filesize, *},
|
||||||
|
WasiInodes,
|
||||||
|
};
|
||||||
use wasmer_wasi::{Fd, VirtualFile, WasiFs, WasiFsError, ALL_RIGHTS, VIRTUAL_ROOT_FD};
|
use wasmer_wasi::{Fd, VirtualFile, WasiFs, WasiFsError, ALL_RIGHTS, VIRTUAL_ROOT_FD};
|
||||||
|
|
||||||
use minifb::{Key, KeyRepeat, MouseButton, Scale, Window, WindowOptions};
|
use minifb::{Key, KeyRepeat, MouseButton, Scale, Window, WindowOptions};
|
||||||
@@ -417,7 +420,7 @@ impl VirtualFile for FrameBuffer {
|
|||||||
fn size(&self) -> u64 {
|
fn size(&self) -> u64 {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
fn set_len(&mut self, _new_size: __wasi_filesize_t) -> Result<(), WasiFsError> {
|
fn set_len(&mut self, _new_size: Filesize) -> Result<(), WasiFsError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn unlink(&mut self) -> Result<(), WasiFsError> {
|
fn unlink(&mut self) -> Result<(), WasiFsError> {
|
||||||
|
|||||||
1
lib/wasi-types/.gitignore
vendored
Normal file
1
lib/wasi-types/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
wit-bindgen/
|
||||||
@@ -10,12 +10,24 @@ license = "MIT"
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
wasmer = { default-features = false, path = "../api", version = "3.0.0-beta" }
|
||||||
|
wit-bindgen-rust = { package = "wasmer-wit-bindgen-rust", version = "0.1.1" }
|
||||||
|
wit-bindgen-rust-wasm = { package = "wasmer-wit-bindgen-gen-rust-wasm", version = "0.1.1" }
|
||||||
|
wit-bindgen-core = { package = "wasmer-wit-bindgen-gen-core", version = "0.1.1" }
|
||||||
|
wit-parser = { package = "wasmer-wit-parser", version = "0.1.1" }
|
||||||
wasmer-types = { path = "../types", version = "=3.0.0-beta.2" }
|
wasmer-types = { path = "../types", version = "=3.0.0-beta.2" }
|
||||||
wasmer-derive = { path = "../derive", version = "=3.0.0-beta.2" }
|
wasmer-derive = { path = "../derive", version = "=3.0.0-beta.2" }
|
||||||
serde = { version = "1.0", features = ["derive"], optional = true }
|
serde = { version = "1.0", features = ["derive"], optional = true }
|
||||||
byteorder = "1.3"
|
byteorder = "1.3"
|
||||||
time = "0.2"
|
time = "0.2"
|
||||||
|
|
||||||
|
[dev-dependencies.pretty_assertions]
|
||||||
|
version = "1.3.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
enable-serde = ["serde", "wasmer-types/serde"]
|
enable-serde = ["serde", "wasmer-types/serde"]
|
||||||
|
js = ["wasmer/js"]
|
||||||
|
sys = ["wasmer/sys"]
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
# `wasmer-wasi-types` [](https://github.com/wasmerio/wasmer/actions?query=workflow%3Abuild) [](https://slack.wasmer.io) [](https://github.com/wasmerio/wasmer/blob/master/LICENSE) [](https://crates.io/crates/wasmer-wasi-types)
|
# `wasmer-wasi-types` [](https://github.com/wasmerio/wasmer/actions?query=workflow%3Abuild) [](https://slack.wasmer.io) [](https://github.com/wasmerio/wasmer/blob/master/LICENSE) [](https://crates.io/crates/wasmer-wasi-types)
|
||||||
|
|
||||||
This crate contains the WASI types necessary for `wasmer-wasi`. Please check this crate to learn more!
|
This crate contains the WASI types necessary for `wasmer-wasi`. Please check this crate to learn more!
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Run `regenerate.sh` to regenerate the wasi-types from
|
||||||
|
the `wasi-clean/typenames.wit` into the final Rust bindings.
|
||||||
|
|
||||||
|
The `wasi-types-generator-extra` generates some extra code
|
||||||
|
that wit-bindgen currently can't provide.
|
||||||
33
lib/wasi-types/regenerate.sh
Executable file
33
lib/wasi-types/regenerate.sh
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
BASEDIR=$(dirname "$0")
|
||||||
|
|
||||||
|
rm -f \
|
||||||
|
"$BASEDIR"/src/bindings.rs \
|
||||||
|
"$BASEDIR"/src/*/bindings.rs
|
||||||
|
|
||||||
|
cat "$BASEDIR"/wit-clean/typenames.wit "$BASEDIR"/wit-clean/wasi_unstable.wit > "$BASEDIR"/wit-clean/output.wit
|
||||||
|
|
||||||
|
git clone https://github.com/wasmerio/wit-bindgen --branch force-generate-structs --single-branch
|
||||||
|
git pull origin force-generate-structs
|
||||||
|
cd wit-bindgen
|
||||||
|
cargo build
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
./wit-bindgen/target/debug/wit-bindgen rust-wasm \
|
||||||
|
--import "$BASEDIR"/wit-clean/output.wit \
|
||||||
|
--force-generate-structs \
|
||||||
|
--out-dir "$BASEDIR"/src/wasi \
|
||||||
|
|
||||||
|
awk '{sub(/mod output/,"pub mod output")}1' src/wasi/bindings.rs > src/wasi/bindings2.rs
|
||||||
|
cargo fmt --all
|
||||||
|
cp src/wasi/bindings2.rs src/wasi/bindings.rs
|
||||||
|
rm src/wasi/bindings2.rs
|
||||||
|
|
||||||
|
cd ./wasi-types-generator-extra
|
||||||
|
cargo build
|
||||||
|
pwd
|
||||||
|
../../../target/debug/wasi-types-generator-extra
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
cargo fmt --all
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
pub type __wasi_advice_t = u8;
|
|
||||||
pub const __WASI_ADVICE_NORMAL: u8 = 0;
|
|
||||||
pub const __WASI_ADVICE_SEQUENTIAL: u8 = 1;
|
|
||||||
pub const __WASI_ADVICE_RANDOM: u8 = 2;
|
|
||||||
pub const __WASI_ADVICE_WILLNEED: u8 = 3;
|
|
||||||
pub const __WASI_ADVICE_DONTNEED: u8 = 4;
|
|
||||||
pub const __WASI_ADVICE_NOREUSE: u8 = 5;
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
use super::*;
|
|
||||||
use wasmer_derive::ValueType;
|
|
||||||
use wasmer_types::MemorySize;
|
|
||||||
|
|
||||||
pub type __wasi_busdataformat_t = u8;
|
|
||||||
pub const __WASI_BUS_DATA_FORMAT_RAW: __wasi_busdataformat_t = 0;
|
|
||||||
pub const __WASI_BUS_DATA_FORMAT_BINCODE: __wasi_busdataformat_t = 1;
|
|
||||||
pub const __WASI_BUS_DATA_FORMAT_MESSAGE_PACK: __wasi_busdataformat_t = 2;
|
|
||||||
pub const __WASI_BUS_DATA_FORMAT_JSON: __wasi_busdataformat_t = 3;
|
|
||||||
pub const __WASI_BUS_DATA_FORMAT_YAML: __wasi_busdataformat_t = 4;
|
|
||||||
pub const __WASI_BUS_DATA_FORMAT_XML: __wasi_busdataformat_t = 5;
|
|
||||||
pub const __WASI_BUS_DATA_FORMAT_RKYV: __wasi_busdataformat_t = 6;
|
|
||||||
|
|
||||||
pub type __wasi_buseventtype_t = u8;
|
|
||||||
pub const __WASI_BUS_EVENT_TYPE_NOOP: __wasi_buseventtype_t = 0;
|
|
||||||
pub const __WASI_BUS_EVENT_TYPE_EXIT: __wasi_buseventtype_t = 1;
|
|
||||||
pub const __WASI_BUS_EVENT_TYPE_CALL: __wasi_buseventtype_t = 2;
|
|
||||||
pub const __WASI_BUS_EVENT_TYPE_RESULT: __wasi_buseventtype_t = 3;
|
|
||||||
pub const __WASI_BUS_EVENT_TYPE_FAULT: __wasi_buseventtype_t = 4;
|
|
||||||
pub const __WASI_BUS_EVENT_TYPE_CLOSE: __wasi_buseventtype_t = 5;
|
|
||||||
|
|
||||||
pub type __wasi_bid_t = u32;
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_option_bid_t {
|
|
||||||
pub tag: __wasi_option_t,
|
|
||||||
pub bid: __wasi_bid_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type __wasi_cid_t = u8;
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_option_fd_t {
|
|
||||||
pub tag: __wasi_option_t,
|
|
||||||
pub fd: __wasi_fd_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_option_cid_t {
|
|
||||||
pub tag: __wasi_option_t,
|
|
||||||
pub cid: __wasi_cid_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_bus_handles_t {
|
|
||||||
pub bid: __wasi_bid_t,
|
|
||||||
pub stdin: __wasi_option_fd_t,
|
|
||||||
pub stdout: __wasi_option_fd_t,
|
|
||||||
pub stderr: __wasi_option_fd_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_busevent_exit_t {
|
|
||||||
pub bid: __wasi_bid_t,
|
|
||||||
pub rval: __wasi_exitcode_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_busevent_call_t<M: MemorySize> {
|
|
||||||
pub parent: __wasi_option_cid_t,
|
|
||||||
pub cid: __wasi_cid_t,
|
|
||||||
pub format: __wasi_busdataformat_t,
|
|
||||||
pub topic_ptr: M::Offset,
|
|
||||||
pub topic_len: M::Offset,
|
|
||||||
pub buf_ptr: M::Offset,
|
|
||||||
pub buf_len: M::Offset,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_busevent_result_t<M: MemorySize> {
|
|
||||||
pub format: __wasi_busdataformat_t,
|
|
||||||
pub cid: __wasi_cid_t,
|
|
||||||
pub buf_ptr: M::Offset,
|
|
||||||
pub buf_len: M::Offset,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_busevent_fault_t {
|
|
||||||
pub cid: __wasi_cid_t,
|
|
||||||
pub err: __bus_errno_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_busevent_close_t {
|
|
||||||
pub cid: __wasi_cid_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub union __wasi_busevent_u<M: MemorySize> {
|
|
||||||
pub noop: u8,
|
|
||||||
pub exit: __wasi_busevent_exit_t,
|
|
||||||
pub call: __wasi_busevent_call_t<M>,
|
|
||||||
pub result: __wasi_busevent_result_t<M>,
|
|
||||||
pub fault: __wasi_busevent_fault_t,
|
|
||||||
pub close: __wasi_busevent_close_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_busevent_t<M: MemorySize> {
|
|
||||||
pub tag: __wasi_buseventtype_t,
|
|
||||||
pub u: __wasi_busevent_u<M>,
|
|
||||||
}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
use crate::*;
|
|
||||||
use std::mem;
|
|
||||||
use wasmer_derive::ValueType;
|
|
||||||
|
|
||||||
pub type __wasi_dircookie_t = u64;
|
|
||||||
pub const __WASI_DIRCOOKIE_START: u64 = 0;
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_dirent_t {
|
|
||||||
pub d_next: __wasi_dircookie_t,
|
|
||||||
pub d_ino: __wasi_inode_t,
|
|
||||||
pub d_namlen: u32,
|
|
||||||
pub d_type: __wasi_filetype_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn dirent_to_le_bytes(ent: &__wasi_dirent_t) -> Vec<u8> {
|
|
||||||
let out: Vec<u8> = std::iter::empty()
|
|
||||||
.chain(ent.d_next.to_le_bytes())
|
|
||||||
.chain(ent.d_ino.to_le_bytes())
|
|
||||||
.chain(ent.d_namlen.to_le_bytes())
|
|
||||||
.chain(u32::from(ent.d_type).to_le_bytes())
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
assert_eq!(out.len(), mem::size_of::<__wasi_dirent_t>());
|
|
||||||
out
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::{__wasi_dirent_t, dirent_to_le_bytes};
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_dirent_to_le_bytes() {
|
|
||||||
let s = __wasi_dirent_t {
|
|
||||||
d_next: 0x0123456789abcdef,
|
|
||||||
d_ino: 0xfedcba9876543210,
|
|
||||||
d_namlen: 0xaabbccdd,
|
|
||||||
d_type: 0x99,
|
|
||||||
};
|
|
||||||
|
|
||||||
assert_eq!(
|
|
||||||
vec![
|
|
||||||
// d_next
|
|
||||||
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01,
|
|
||||||
//
|
|
||||||
// d_ino
|
|
||||||
0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe,
|
|
||||||
//
|
|
||||||
// d_namelen
|
|
||||||
0xdd, 0xcc, 0xbb, 0xaa,
|
|
||||||
//
|
|
||||||
// d_type
|
|
||||||
// plus padding
|
|
||||||
0x99, 0x00, 0x00, 0x00,
|
|
||||||
],
|
|
||||||
dirent_to_le_bytes(&s)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
pub type __wasi_errno_t = u16;
|
|
||||||
pub const __WASI_ESUCCESS: u16 = 0;
|
|
||||||
pub const __WASI_E2BIG: u16 = 1;
|
|
||||||
pub const __WASI_EACCES: u16 = 2;
|
|
||||||
pub const __WASI_EADDRINUSE: u16 = 3;
|
|
||||||
pub const __WASI_EADDRNOTAVAIL: u16 = 4;
|
|
||||||
pub const __WASI_EAFNOSUPPORT: u16 = 5;
|
|
||||||
pub const __WASI_EAGAIN: u16 = 6;
|
|
||||||
pub const __WASI_EALREADY: u16 = 7;
|
|
||||||
pub const __WASI_EBADF: u16 = 8;
|
|
||||||
pub const __WASI_EBADMSG: u16 = 9;
|
|
||||||
pub const __WASI_EBUSY: u16 = 10;
|
|
||||||
pub const __WASI_ECANCELED: u16 = 11;
|
|
||||||
pub const __WASI_ECHILD: u16 = 12;
|
|
||||||
pub const __WASI_ECONNABORTED: u16 = 13;
|
|
||||||
pub const __WASI_ECONNREFUSED: u16 = 14;
|
|
||||||
pub const __WASI_ECONNRESET: u16 = 15;
|
|
||||||
pub const __WASI_EDEADLK: u16 = 16;
|
|
||||||
pub const __WASI_EDESTADDRREQ: u16 = 17;
|
|
||||||
pub const __WASI_EDOM: u16 = 18;
|
|
||||||
pub const __WASI_EDQUOT: u16 = 19;
|
|
||||||
pub const __WASI_EEXIST: u16 = 20;
|
|
||||||
pub const __WASI_EFAULT: u16 = 21;
|
|
||||||
pub const __WASI_EFBIG: u16 = 22;
|
|
||||||
pub const __WASI_EHOSTUNREACH: u16 = 23;
|
|
||||||
pub const __WASI_EIDRM: u16 = 24;
|
|
||||||
pub const __WASI_EILSEQ: u16 = 25;
|
|
||||||
pub const __WASI_EINPROGRESS: u16 = 26;
|
|
||||||
pub const __WASI_EINTR: u16 = 27;
|
|
||||||
pub const __WASI_EINVAL: u16 = 28;
|
|
||||||
pub const __WASI_EIO: u16 = 29;
|
|
||||||
pub const __WASI_EISCONN: u16 = 30;
|
|
||||||
pub const __WASI_EISDIR: u16 = 31;
|
|
||||||
pub const __WASI_ELOOP: u16 = 32;
|
|
||||||
pub const __WASI_EMFILE: u16 = 33;
|
|
||||||
pub const __WASI_EMLINK: u16 = 34;
|
|
||||||
pub const __WASI_EMSGSIZE: u16 = 35;
|
|
||||||
pub const __WASI_EMULTIHOP: u16 = 36;
|
|
||||||
pub const __WASI_ENAMETOOLONG: u16 = 37;
|
|
||||||
pub const __WASI_ENETDOWN: u16 = 38;
|
|
||||||
pub const __WASI_ENETRESET: u16 = 39;
|
|
||||||
pub const __WASI_ENETUNREACH: u16 = 40;
|
|
||||||
pub const __WASI_ENFILE: u16 = 41;
|
|
||||||
pub const __WASI_ENOBUFS: u16 = 42;
|
|
||||||
pub const __WASI_ENODEV: u16 = 43;
|
|
||||||
pub const __WASI_ENOENT: u16 = 44;
|
|
||||||
pub const __WASI_ENOEXEC: u16 = 45;
|
|
||||||
pub const __WASI_ENOLCK: u16 = 46;
|
|
||||||
pub const __WASI_ENOLINK: u16 = 47;
|
|
||||||
pub const __WASI_ENOMEM: u16 = 48;
|
|
||||||
pub const __WASI_ENOMSG: u16 = 49;
|
|
||||||
pub const __WASI_ENOPROTOOPT: u16 = 50;
|
|
||||||
pub const __WASI_ENOSPC: u16 = 51;
|
|
||||||
pub const __WASI_ENOSYS: u16 = 52;
|
|
||||||
pub const __WASI_ENOTCONN: u16 = 53;
|
|
||||||
pub const __WASI_ENOTDIR: u16 = 54;
|
|
||||||
pub const __WASI_ENOTEMPTY: u16 = 55;
|
|
||||||
pub const __WASI_ENOTRECOVERABLE: u16 = 56;
|
|
||||||
pub const __WASI_ENOTSOCK: u16 = 57;
|
|
||||||
pub const __WASI_ENOTSUP: u16 = 58;
|
|
||||||
pub const __WASI_ENOTTY: u16 = 59;
|
|
||||||
pub const __WASI_ENXIO: u16 = 60;
|
|
||||||
pub const __WASI_EOVERFLOW: u16 = 61;
|
|
||||||
pub const __WASI_EOWNERDEAD: u16 = 62;
|
|
||||||
pub const __WASI_EPERM: u16 = 63;
|
|
||||||
pub const __WASI_EPIPE: u16 = 64;
|
|
||||||
pub const __WASI_EPROTO: u16 = 65;
|
|
||||||
pub const __WASI_EPROTONOSUPPORT: u16 = 66;
|
|
||||||
pub const __WASI_EPROTOTYPE: u16 = 67;
|
|
||||||
pub const __WASI_ERANGE: u16 = 68;
|
|
||||||
pub const __WASI_EROFS: u16 = 69;
|
|
||||||
pub const __WASI_ESPIPE: u16 = 70;
|
|
||||||
pub const __WASI_ESRCH: u16 = 71;
|
|
||||||
pub const __WASI_ESTALE: u16 = 72;
|
|
||||||
pub const __WASI_ETIMEDOUT: u16 = 73;
|
|
||||||
pub const __WASI_ETXTBSY: u16 = 74;
|
|
||||||
pub const __WASI_EXDEV: u16 = 75;
|
|
||||||
pub const __WASI_ENOTCAPABLE: u16 = 76;
|
|
||||||
|
|
||||||
pub type __bus_errno_t = u32;
|
|
||||||
pub const __BUS_ESUCCESS: u32 = 0;
|
|
||||||
pub const __BUS_ESER: u32 = 1;
|
|
||||||
pub const __BUS_EDES: u32 = 2;
|
|
||||||
pub const __BUS_EWAPM: u32 = 3;
|
|
||||||
pub const __BUS_EFETCH: u32 = 4;
|
|
||||||
pub const __BUS_ECOMPILE: u32 = 5;
|
|
||||||
pub const __BUS_EABI: u32 = 6;
|
|
||||||
pub const __BUS_EABORTED: u32 = 7;
|
|
||||||
pub const __BUS_EBADHANDLE: u32 = 8;
|
|
||||||
pub const __BUS_ETOPIC: u32 = 9;
|
|
||||||
pub const __BUS_EBADCB: u32 = 10;
|
|
||||||
pub const __BUS_EUNSUPPORTED: u32 = 11;
|
|
||||||
pub const __BUS_EBADREQUEST: u32 = 12;
|
|
||||||
pub const __BUS_EDENIED: u32 = 13;
|
|
||||||
pub const __BUS_EINTERNAL: u32 = 14;
|
|
||||||
pub const __BUS_EALLOC: u32 = 15;
|
|
||||||
pub const __BUS_EINVOKE: u32 = 16;
|
|
||||||
pub const __BUS_ECONSUMED: u32 = 17;
|
|
||||||
pub const __BUS_EMEMVIOLATION: u32 = 18;
|
|
||||||
pub const __BUS_EUNKNOWN: u32 = 19;
|
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
use crate::*;
|
|
||||||
use std::{
|
|
||||||
fmt,
|
|
||||||
mem::{self, MaybeUninit},
|
|
||||||
};
|
|
||||||
use wasmer_derive::ValueType;
|
|
||||||
use wasmer_types::ValueType;
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_event_fd_readwrite_t {
|
|
||||||
pub nbytes: __wasi_filesize_t,
|
|
||||||
pub flags: __wasi_eventrwflags_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub union __wasi_event_u {
|
|
||||||
pub fd_readwrite: __wasi_event_fd_readwrite_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: remove this implementation of Debug when `__wasi_event_u` gets more than 1 variant
|
|
||||||
impl fmt::Debug for __wasi_event_u {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
f.debug_struct("__wasi_event_u")
|
|
||||||
.field("fd_readwrite", unsafe { &self.fd_readwrite })
|
|
||||||
.finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
|
||||||
pub enum EventEnum {
|
|
||||||
FdReadWrite {
|
|
||||||
nbytes: __wasi_filesize_t,
|
|
||||||
flags: __wasi_eventrwflags_t,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
impl EventEnum {
|
|
||||||
pub fn untagged(self) -> __wasi_event_u {
|
|
||||||
match self {
|
|
||||||
EventEnum::FdReadWrite { nbytes, flags } => __wasi_event_u {
|
|
||||||
fd_readwrite: __wasi_event_fd_readwrite_t { nbytes, flags },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_event_t {
|
|
||||||
pub userdata: __wasi_userdata_t,
|
|
||||||
pub error: __wasi_errno_t,
|
|
||||||
pub type_: __wasi_eventtype_t,
|
|
||||||
pub u: __wasi_event_u,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl __wasi_event_t {
|
|
||||||
pub fn tagged(&self) -> Option<EventEnum> {
|
|
||||||
match self.type_ {
|
|
||||||
__WASI_EVENTTYPE_FD_READ | __WASI_EVENTTYPE_FD_WRITE => Some(EventEnum::FdReadWrite {
|
|
||||||
nbytes: unsafe { self.u.fd_readwrite.nbytes },
|
|
||||||
flags: unsafe { self.u.fd_readwrite.flags },
|
|
||||||
}),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl ValueType for __wasi_event_t {
|
|
||||||
fn zero_padding_bytes(&self, bytes: &mut [MaybeUninit<u8>]) {
|
|
||||||
macro_rules! field {
|
|
||||||
($($f:tt)*) => {
|
|
||||||
&self.$($f)* as *const _ as usize - self as *const _ as usize
|
|
||||||
};
|
|
||||||
}
|
|
||||||
macro_rules! field_end {
|
|
||||||
($($f:tt)*) => {
|
|
||||||
field!($($f)*) + mem::size_of_val(&self.$($f)*)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
macro_rules! zero {
|
|
||||||
($start:expr, $end:expr) => {
|
|
||||||
for i in $start..$end {
|
|
||||||
bytes[i] = MaybeUninit::new(0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
self.userdata
|
|
||||||
.zero_padding_bytes(&mut bytes[field!(userdata)..field_end!(userdata)]);
|
|
||||||
zero!(field_end!(userdata), field!(error));
|
|
||||||
self.error
|
|
||||||
.zero_padding_bytes(&mut bytes[field!(error)..field_end!(error)]);
|
|
||||||
zero!(field_end!(error), field!(type_));
|
|
||||||
self.type_
|
|
||||||
.zero_padding_bytes(&mut bytes[field!(type_)..field_end!(type_)]);
|
|
||||||
zero!(field_end!(type_), field!(u));
|
|
||||||
match self.type_ {
|
|
||||||
__WASI_EVENTTYPE_FD_READ | __WASI_EVENTTYPE_FD_WRITE => unsafe {
|
|
||||||
self.u.fd_readwrite.zero_padding_bytes(
|
|
||||||
&mut bytes[field!(u.fd_readwrite)..field_end!(u.fd_readwrite)],
|
|
||||||
);
|
|
||||||
zero!(field_end!(u.fd_readwrite), field_end!(u));
|
|
||||||
},
|
|
||||||
_ => zero!(field!(u), field_end!(u)),
|
|
||||||
}
|
|
||||||
zero!(field_end!(u), mem::size_of_val(self));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type __wasi_eventrwflags_t = u16;
|
|
||||||
pub const __WASI_EVENT_FD_READWRITE_HANGUP: u16 = 1 << 0;
|
|
||||||
|
|
||||||
pub type __wasi_eventtype_t = u8;
|
|
||||||
pub const __WASI_EVENTTYPE_CLOCK: u8 = 0;
|
|
||||||
pub const __WASI_EVENTTYPE_FD_READ: u8 = 1;
|
|
||||||
pub const __WASI_EVENTTYPE_FD_WRITE: u8 = 2;
|
|
||||||
|
|
||||||
pub fn eventtype_to_str(event_type: __wasi_eventtype_t) -> &'static str {
|
|
||||||
match event_type {
|
|
||||||
__WASI_EVENTTYPE_CLOCK => "__WASI_EVENTTYPE_CLOCK",
|
|
||||||
__WASI_EVENTTYPE_FD_READ => "__WASI_EVENTTYPE_FD_READ",
|
|
||||||
__WASI_EVENTTYPE_FD_WRITE => "__WASI_EVENTTYPE_FD_WRITE",
|
|
||||||
_ => "INVALID EVENTTYPE",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,337 +0,0 @@
|
|||||||
use crate::*;
|
|
||||||
#[cfg(feature = "enable-serde")]
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::{
|
|
||||||
fmt,
|
|
||||||
mem::{self, MaybeUninit},
|
|
||||||
};
|
|
||||||
use wasmer_derive::ValueType;
|
|
||||||
use wasmer_types::ValueType;
|
|
||||||
|
|
||||||
pub type __wasi_device_t = u64;
|
|
||||||
|
|
||||||
pub type __wasi_fd_t = u32;
|
|
||||||
pub const __WASI_STDIN_FILENO: __wasi_fd_t = 0;
|
|
||||||
pub const __WASI_STDOUT_FILENO: __wasi_fd_t = 1;
|
|
||||||
pub const __WASI_STDERR_FILENO: __wasi_fd_t = 2;
|
|
||||||
|
|
||||||
pub type __wasi_pid_t = u32;
|
|
||||||
pub type __wasi_tid_t = u32;
|
|
||||||
|
|
||||||
pub type __wasi_fdflags_t = u16;
|
|
||||||
pub const __WASI_FDFLAG_APPEND: __wasi_fdflags_t = 1 << 0;
|
|
||||||
pub const __WASI_FDFLAG_DSYNC: __wasi_fdflags_t = 1 << 1;
|
|
||||||
pub const __WASI_FDFLAG_NONBLOCK: __wasi_fdflags_t = 1 << 2;
|
|
||||||
pub const __WASI_FDFLAG_RSYNC: __wasi_fdflags_t = 1 << 3;
|
|
||||||
pub const __WASI_FDFLAG_SYNC: __wasi_fdflags_t = 1 << 4;
|
|
||||||
|
|
||||||
pub type __wasi_eventfdflags = u16;
|
|
||||||
pub const __WASI_EVENTFDFLAGS_SEMAPHORE: __wasi_eventfdflags = 1 << 0;
|
|
||||||
|
|
||||||
pub type __wasi_preopentype_t = u8;
|
|
||||||
pub const __WASI_PREOPENTYPE_DIR: __wasi_preopentype_t = 0;
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_prestat_u_dir_t {
|
|
||||||
pub pr_name_len: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub union __wasi_prestat_u {
|
|
||||||
dir: __wasi_prestat_u_dir_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for __wasi_prestat_u {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "__wasi_prestat_u")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_prestat_t {
|
|
||||||
pub pr_type: __wasi_preopentype_t,
|
|
||||||
pub u: __wasi_prestat_u,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
pub enum PrestatEnum {
|
|
||||||
Dir { pr_name_len: u32 },
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PrestatEnum {
|
|
||||||
pub fn untagged(self) -> __wasi_prestat_u {
|
|
||||||
match self {
|
|
||||||
PrestatEnum::Dir { pr_name_len } => __wasi_prestat_u {
|
|
||||||
dir: __wasi_prestat_u_dir_t { pr_name_len },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl __wasi_prestat_t {
|
|
||||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
|
||||||
pub fn tagged(&self) -> Option<PrestatEnum> {
|
|
||||||
match self.pr_type {
|
|
||||||
__WASI_PREOPENTYPE_DIR => Some(PrestatEnum::Dir {
|
|
||||||
pr_name_len: unsafe { self.u.dir.pr_name_len },
|
|
||||||
}),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl ValueType for __wasi_prestat_t {
|
|
||||||
fn zero_padding_bytes(&self, bytes: &mut [MaybeUninit<u8>]) {
|
|
||||||
macro_rules! field {
|
|
||||||
($($f:tt)*) => {
|
|
||||||
&self.$($f)* as *const _ as usize - self as *const _ as usize
|
|
||||||
};
|
|
||||||
}
|
|
||||||
macro_rules! field_end {
|
|
||||||
($($f:tt)*) => {
|
|
||||||
field!($($f)*) + mem::size_of_val(&self.$($f)*)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
macro_rules! zero {
|
|
||||||
($start:expr, $end:expr) => {
|
|
||||||
for i in $start..$end {
|
|
||||||
bytes[i] = MaybeUninit::new(0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
self.pr_type
|
|
||||||
.zero_padding_bytes(&mut bytes[field!(pr_type)..field_end!(pr_type)]);
|
|
||||||
zero!(field_end!(pr_type), field!(u));
|
|
||||||
match self.pr_type {
|
|
||||||
__WASI_PREOPENTYPE_DIR => unsafe {
|
|
||||||
self.u
|
|
||||||
.dir
|
|
||||||
.zero_padding_bytes(&mut bytes[field!(u.dir)..field_end!(u.dir)]);
|
|
||||||
zero!(field_end!(u.dir), field_end!(u));
|
|
||||||
},
|
|
||||||
_ => zero!(field!(u), field_end!(u)),
|
|
||||||
}
|
|
||||||
zero!(field_end!(u), mem::size_of_val(self));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_fdstat_t {
|
|
||||||
pub fs_filetype: __wasi_filetype_t,
|
|
||||||
pub fs_flags: __wasi_fdflags_t,
|
|
||||||
pub fs_rights_base: __wasi_rights_t,
|
|
||||||
pub fs_rights_inheriting: __wasi_rights_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type __wasi_filedelta_t = i64;
|
|
||||||
|
|
||||||
pub type __wasi_filesize_t = u64;
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_filestat_t {
|
|
||||||
pub st_dev: __wasi_device_t,
|
|
||||||
pub st_ino: __wasi_inode_t,
|
|
||||||
pub st_filetype: __wasi_filetype_t,
|
|
||||||
pub st_nlink: __wasi_linkcount_t,
|
|
||||||
pub st_size: __wasi_filesize_t,
|
|
||||||
pub st_atim: __wasi_timestamp_t,
|
|
||||||
pub st_mtim: __wasi_timestamp_t,
|
|
||||||
pub st_ctim: __wasi_timestamp_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for __wasi_filestat_t {
|
|
||||||
fn default() -> Self {
|
|
||||||
__wasi_filestat_t {
|
|
||||||
st_dev: Default::default(),
|
|
||||||
st_ino: Default::default(),
|
|
||||||
st_filetype: __WASI_FILETYPE_UNKNOWN,
|
|
||||||
st_nlink: 1,
|
|
||||||
st_size: Default::default(),
|
|
||||||
st_atim: Default::default(),
|
|
||||||
st_mtim: Default::default(),
|
|
||||||
st_ctim: Default::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for __wasi_filestat_t {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
let convert_ts_into_time_string = |ts| {
|
|
||||||
let tspec = ::time::OffsetDateTime::from_unix_timestamp_nanos(ts);
|
|
||||||
format!("{} ({})", tspec.format("%a, %d %b %Y %T %z"), ts)
|
|
||||||
};
|
|
||||||
f.debug_struct("__wasi_filestat_t")
|
|
||||||
.field("st_dev", &self.st_dev)
|
|
||||||
.field("st_ino", &self.st_ino)
|
|
||||||
.field(
|
|
||||||
"st_filetype",
|
|
||||||
&format!(
|
|
||||||
"{} ({})",
|
|
||||||
wasi_filetype_to_name(self.st_filetype),
|
|
||||||
self.st_filetype,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.field("st_nlink", &self.st_nlink)
|
|
||||||
.field("st_size", &self.st_size)
|
|
||||||
.field(
|
|
||||||
"st_atim",
|
|
||||||
&convert_ts_into_time_string(self.st_atim as i128),
|
|
||||||
)
|
|
||||||
.field(
|
|
||||||
"st_mtim",
|
|
||||||
&convert_ts_into_time_string(self.st_mtim as i128),
|
|
||||||
)
|
|
||||||
.field(
|
|
||||||
"st_ctim",
|
|
||||||
&convert_ts_into_time_string(self.st_ctim as i128),
|
|
||||||
)
|
|
||||||
.finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn wasi_filetype_to_name(ft: __wasi_filetype_t) -> &'static str {
|
|
||||||
match ft {
|
|
||||||
__WASI_FILETYPE_UNKNOWN => "Unknown",
|
|
||||||
__WASI_FILETYPE_BLOCK_DEVICE => "Block device",
|
|
||||||
__WASI_FILETYPE_CHARACTER_DEVICE => "Character device",
|
|
||||||
__WASI_FILETYPE_DIRECTORY => "Directory",
|
|
||||||
__WASI_FILETYPE_REGULAR_FILE => "Regular file",
|
|
||||||
__WASI_FILETYPE_SOCKET_DGRAM => "Socket dgram",
|
|
||||||
__WASI_FILETYPE_SOCKET_STREAM => "Socket stream",
|
|
||||||
__WASI_FILETYPE_SYMBOLIC_LINK => "Symbolic link",
|
|
||||||
_ => "Invalid",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type __wasi_filetype_t = u8;
|
|
||||||
pub const __WASI_FILETYPE_UNKNOWN: __wasi_filetype_t = 0;
|
|
||||||
pub const __WASI_FILETYPE_BLOCK_DEVICE: __wasi_filetype_t = 1;
|
|
||||||
pub const __WASI_FILETYPE_CHARACTER_DEVICE: __wasi_filetype_t = 2;
|
|
||||||
pub const __WASI_FILETYPE_DIRECTORY: __wasi_filetype_t = 3;
|
|
||||||
pub const __WASI_FILETYPE_REGULAR_FILE: __wasi_filetype_t = 4;
|
|
||||||
pub const __WASI_FILETYPE_SOCKET_DGRAM: __wasi_filetype_t = 5;
|
|
||||||
pub const __WASI_FILETYPE_SOCKET_STREAM: __wasi_filetype_t = 6;
|
|
||||||
pub const __WASI_FILETYPE_SYMBOLIC_LINK: __wasi_filetype_t = 7;
|
|
||||||
pub const __WASI_FILETYPE_SOCKET_RAW: __wasi_filetype_t = 8;
|
|
||||||
pub const __WASI_FILETYPE_SOCKET_SEQPACKET: __wasi_filetype_t = 9;
|
|
||||||
|
|
||||||
pub type __wasi_fstflags_t = u16;
|
|
||||||
pub const __WASI_FILESTAT_SET_ATIM: __wasi_fstflags_t = 1 << 0;
|
|
||||||
pub const __WASI_FILESTAT_SET_ATIM_NOW: __wasi_fstflags_t = 1 << 1;
|
|
||||||
pub const __WASI_FILESTAT_SET_MTIM: __wasi_fstflags_t = 1 << 2;
|
|
||||||
pub const __WASI_FILESTAT_SET_MTIM_NOW: __wasi_fstflags_t = 1 << 3;
|
|
||||||
|
|
||||||
pub type __wasi_inode_t = u64;
|
|
||||||
|
|
||||||
pub type __wasi_linkcount_t = u64;
|
|
||||||
|
|
||||||
pub type __wasi_lookupflags_t = u32;
|
|
||||||
pub const __WASI_LOOKUP_SYMLINK_FOLLOW: __wasi_lookupflags_t = 1 << 0;
|
|
||||||
|
|
||||||
pub type __wasi_oflags_t = u16;
|
|
||||||
pub const __WASI_O_CREAT: __wasi_oflags_t = 1 << 0;
|
|
||||||
pub const __WASI_O_DIRECTORY: __wasi_oflags_t = 1 << 1;
|
|
||||||
pub const __WASI_O_EXCL: __wasi_oflags_t = 1 << 2;
|
|
||||||
pub const __WASI_O_TRUNC: __wasi_oflags_t = 1 << 3;
|
|
||||||
|
|
||||||
pub type __wasi_rights_t = u64;
|
|
||||||
pub const __WASI_RIGHT_FD_DATASYNC: __wasi_rights_t = 1 << 0;
|
|
||||||
pub const __WASI_RIGHT_FD_READ: __wasi_rights_t = 1 << 1;
|
|
||||||
pub const __WASI_RIGHT_FD_SEEK: __wasi_rights_t = 1 << 2;
|
|
||||||
pub const __WASI_RIGHT_FD_FDSTAT_SET_FLAGS: __wasi_rights_t = 1 << 3;
|
|
||||||
pub const __WASI_RIGHT_FD_SYNC: __wasi_rights_t = 1 << 4;
|
|
||||||
pub const __WASI_RIGHT_FD_TELL: __wasi_rights_t = 1 << 5;
|
|
||||||
pub const __WASI_RIGHT_FD_WRITE: __wasi_rights_t = 1 << 6;
|
|
||||||
pub const __WASI_RIGHT_FD_ADVISE: __wasi_rights_t = 1 << 7;
|
|
||||||
pub const __WASI_RIGHT_FD_ALLOCATE: __wasi_rights_t = 1 << 8;
|
|
||||||
pub const __WASI_RIGHT_PATH_CREATE_DIRECTORY: __wasi_rights_t = 1 << 9;
|
|
||||||
pub const __WASI_RIGHT_PATH_CREATE_FILE: __wasi_rights_t = 1 << 10;
|
|
||||||
pub const __WASI_RIGHT_PATH_LINK_SOURCE: __wasi_rights_t = 1 << 11;
|
|
||||||
pub const __WASI_RIGHT_PATH_LINK_TARGET: __wasi_rights_t = 1 << 12;
|
|
||||||
pub const __WASI_RIGHT_PATH_OPEN: __wasi_rights_t = 1 << 13;
|
|
||||||
pub const __WASI_RIGHT_FD_READDIR: __wasi_rights_t = 1 << 14;
|
|
||||||
pub const __WASI_RIGHT_PATH_READLINK: __wasi_rights_t = 1 << 15;
|
|
||||||
pub const __WASI_RIGHT_PATH_RENAME_SOURCE: __wasi_rights_t = 1 << 16;
|
|
||||||
pub const __WASI_RIGHT_PATH_RENAME_TARGET: __wasi_rights_t = 1 << 17;
|
|
||||||
pub const __WASI_RIGHT_PATH_FILESTAT_GET: __wasi_rights_t = 1 << 18;
|
|
||||||
pub const __WASI_RIGHT_PATH_FILESTAT_SET_SIZE: __wasi_rights_t = 1 << 19;
|
|
||||||
pub const __WASI_RIGHT_PATH_FILESTAT_SET_TIMES: __wasi_rights_t = 1 << 20;
|
|
||||||
pub const __WASI_RIGHT_FD_FILESTAT_GET: __wasi_rights_t = 1 << 21;
|
|
||||||
pub const __WASI_RIGHT_FD_FILESTAT_SET_SIZE: __wasi_rights_t = 1 << 22;
|
|
||||||
pub const __WASI_RIGHT_FD_FILESTAT_SET_TIMES: __wasi_rights_t = 1 << 23;
|
|
||||||
pub const __WASI_RIGHT_PATH_SYMLINK: __wasi_rights_t = 1 << 24;
|
|
||||||
pub const __WASI_RIGHT_PATH_REMOVE_DIRECTORY: __wasi_rights_t = 1 << 25;
|
|
||||||
pub const __WASI_RIGHT_PATH_UNLINK_FILE: __wasi_rights_t = 1 << 26;
|
|
||||||
pub const __WASI_RIGHT_POLL_FD_READWRITE: __wasi_rights_t = 1 << 27;
|
|
||||||
pub const __WASI_RIGHT_SOCK_SHUTDOWN: __wasi_rights_t = 1 << 28;
|
|
||||||
pub const __WASI_RIGHT_SOCK_ACCEPT: __wasi_rights_t = 1 << 29;
|
|
||||||
pub const __WASI_RIGHT_SOCK_CONNECT: __wasi_rights_t = 1 << 30;
|
|
||||||
pub const __WASI_RIGHT_SOCK_LISTEN: __wasi_rights_t = 1 << 31;
|
|
||||||
pub const __WASI_RIGHT_SOCK_BIND: __wasi_rights_t = 1 << 32;
|
|
||||||
pub const __WASI_RIGHT_SOCK_RECV: __wasi_rights_t = 1 << 33;
|
|
||||||
pub const __WASI_RIGHT_SOCK_SEND: __wasi_rights_t = 1 << 34;
|
|
||||||
pub const __WASI_RIGHT_SOCK_ADDR_LOCAL: __wasi_rights_t = 1 << 35;
|
|
||||||
pub const __WASI_RIGHT_SOCK_ADDR_REMOTE: __wasi_rights_t = 1 << 36;
|
|
||||||
pub const __WASI_RIGHT_SOCK_RECV_FROM: __wasi_rights_t = 1 << 37;
|
|
||||||
pub const __WASI_RIGHT_SOCK_SEND_TO: __wasi_rights_t = 1 << 38;
|
|
||||||
|
|
||||||
/// function for debugging rights issues
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn print_right_set(rights: __wasi_rights_t) {
|
|
||||||
// BTreeSet for consistent order
|
|
||||||
let mut right_set = std::collections::BTreeSet::new();
|
|
||||||
for i in 0..28 {
|
|
||||||
let cur_right = rights & (1 << i);
|
|
||||||
if cur_right != 0 {
|
|
||||||
right_set.insert(right_to_string(cur_right).unwrap_or("INVALID RIGHT"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
println!("{:#?}", right_set);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// expects a single right, returns None if out of bounds or > 1 bit set
|
|
||||||
pub fn right_to_string(right: __wasi_rights_t) -> Option<&'static str> {
|
|
||||||
Some(match right {
|
|
||||||
__WASI_RIGHT_FD_DATASYNC => "__WASI_RIGHT_FD_DATASYNC",
|
|
||||||
__WASI_RIGHT_FD_READ => "__WASI_RIGHT_FD_READ",
|
|
||||||
__WASI_RIGHT_FD_SEEK => "__WASI_RIGHT_FD_SEEK",
|
|
||||||
__WASI_RIGHT_FD_FDSTAT_SET_FLAGS => "__WASI_RIGHT_FD_FDSTAT_SET_FLAGS",
|
|
||||||
__WASI_RIGHT_FD_SYNC => "__WASI_RIGHT_FD_SYNC",
|
|
||||||
__WASI_RIGHT_FD_TELL => "__WASI_RIGHT_FD_TELL",
|
|
||||||
__WASI_RIGHT_FD_WRITE => "__WASI_RIGHT_FD_WRITE",
|
|
||||||
__WASI_RIGHT_FD_ADVISE => "__WASI_RIGHT_FD_ADVISE",
|
|
||||||
__WASI_RIGHT_FD_ALLOCATE => "__WASI_RIGHT_FD_ALLOCATE",
|
|
||||||
__WASI_RIGHT_PATH_CREATE_DIRECTORY => "__WASI_RIGHT_PATH_CREATE_DIRECTORY",
|
|
||||||
__WASI_RIGHT_PATH_CREATE_FILE => "__WASI_RIGHT_PATH_CREATE_FILE",
|
|
||||||
__WASI_RIGHT_PATH_LINK_SOURCE => "__WASI_RIGHT_PATH_LINK_SOURCE",
|
|
||||||
__WASI_RIGHT_PATH_LINK_TARGET => "__WASI_RIGHT_PATH_LINK_TARGET",
|
|
||||||
__WASI_RIGHT_PATH_OPEN => "__WASI_RIGHT_PATH_OPEN",
|
|
||||||
__WASI_RIGHT_FD_READDIR => "__WASI_RIGHT_FD_READDIR",
|
|
||||||
__WASI_RIGHT_PATH_READLINK => "__WASI_RIGHT_PATH_READLINK",
|
|
||||||
__WASI_RIGHT_PATH_RENAME_SOURCE => "__WASI_RIGHT_PATH_RENAME_SOURCE",
|
|
||||||
__WASI_RIGHT_PATH_RENAME_TARGET => "__WASI_RIGHT_PATH_RENAME_TARGET",
|
|
||||||
__WASI_RIGHT_PATH_FILESTAT_GET => "__WASI_RIGHT_PATH_FILESTAT_GET",
|
|
||||||
__WASI_RIGHT_PATH_FILESTAT_SET_SIZE => "__WASI_RIGHT_PATH_FILESTAT_SET_SIZE",
|
|
||||||
__WASI_RIGHT_PATH_FILESTAT_SET_TIMES => "__WASI_RIGHT_PATH_FILESTAT_SET_TIMES",
|
|
||||||
__WASI_RIGHT_FD_FILESTAT_GET => "__WASI_RIGHT_FD_FILESTAT_GET",
|
|
||||||
__WASI_RIGHT_FD_FILESTAT_SET_SIZE => "__WASI_RIGHT_FD_FILESTAT_SET_SIZE",
|
|
||||||
__WASI_RIGHT_FD_FILESTAT_SET_TIMES => "__WASI_RIGHT_FD_FILESTAT_SET_TIMES",
|
|
||||||
__WASI_RIGHT_PATH_SYMLINK => "__WASI_RIGHT_PATH_SYMLINK",
|
|
||||||
__WASI_RIGHT_PATH_UNLINK_FILE => "__WASI_RIGHT_PATH_UNLINK_FILE",
|
|
||||||
__WASI_RIGHT_PATH_REMOVE_DIRECTORY => "__WASI_RIGHT_PATH_REMOVE_DIRECTORY",
|
|
||||||
__WASI_RIGHT_POLL_FD_READWRITE => "__WASI_RIGHT_POLL_FD_READWRITE",
|
|
||||||
__WASI_RIGHT_SOCK_SHUTDOWN => "__WASI_RIGHT_SOCK_SHUTDOWN",
|
|
||||||
_ => return None,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type __wasi_whence_t = u8;
|
|
||||||
pub const __WASI_WHENCE_SET: __wasi_whence_t = 0;
|
|
||||||
pub const __WASI_WHENCE_CUR: __wasi_whence_t = 1;
|
|
||||||
pub const __WASI_WHENCE_END: __wasi_whence_t = 2;
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
use wasmer_derive::ValueType;
|
|
||||||
use wasmer_types::MemorySize;
|
|
||||||
|
|
||||||
use crate::__wasi_fd_t;
|
|
||||||
|
|
||||||
pub type __wasi_count_t = u32;
|
|
||||||
|
|
||||||
pub type __wasi_option_t = u8;
|
|
||||||
pub const __WASI_OPTION_NONE: __wasi_option_t = 0;
|
|
||||||
pub const __WASI_OPTION_SOME: __wasi_option_t = 1;
|
|
||||||
|
|
||||||
pub type __wasi_bool_t = u8;
|
|
||||||
pub const __WASI_BOOL_FALSE: __wasi_bool_t = 0;
|
|
||||||
pub const __WASI_BOOL_TRUE: __wasi_bool_t = 1;
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_ciovec_t<M: MemorySize> {
|
|
||||||
pub buf: M::Offset,
|
|
||||||
pub buf_len: M::Offset,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_iovec_t<M: MemorySize> {
|
|
||||||
pub buf: M::Offset,
|
|
||||||
pub buf_len: M::Offset,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_tty_t {
|
|
||||||
pub cols: u32,
|
|
||||||
pub rows: u32,
|
|
||||||
pub width: u32,
|
|
||||||
pub height: u32,
|
|
||||||
pub stdin_tty: __wasi_bool_t,
|
|
||||||
pub stdout_tty: __wasi_bool_t,
|
|
||||||
pub stderr_tty: __wasi_bool_t,
|
|
||||||
pub echo: __wasi_bool_t,
|
|
||||||
pub line_buffered: __wasi_bool_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_pipe_handles_t {
|
|
||||||
pub pipe: __wasi_fd_t,
|
|
||||||
pub other: __wasi_fd_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type __wasi_stdiomode_t = u8;
|
|
||||||
pub const __WASI_STDIO_MODE_PIPED: __wasi_stdiomode_t = 1;
|
|
||||||
pub const __WASI_STDIO_MODE_INHERIT: __wasi_stdiomode_t = 2;
|
|
||||||
pub const __WASI_STDIO_MODE_NULL: __wasi_stdiomode_t = 3;
|
|
||||||
pub const __WASI_STDIO_MODE_LOG: __wasi_stdiomode_t = 4;
|
|
||||||
@@ -1,42 +1,43 @@
|
|||||||
#![deny(unused_mut)]
|
pub mod types;
|
||||||
#![doc(html_favicon_url = "https://wasmer.io/images/icons/favicon-32x32.png")]
|
pub mod wasi;
|
||||||
#![doc(html_logo_url = "https://github.com/wasmerio.png?size=200")]
|
|
||||||
#![allow(non_camel_case_types, clippy::identity_op)]
|
|
||||||
|
|
||||||
//! Wasmer's WASI types implementation.
|
// Prevent the CI from passing if the wasi/bindings.rs is not
|
||||||
//!
|
// up to date with the output.wit file
|
||||||
//! Those types aim at being used by [the `wasmer-wasi`
|
#[test]
|
||||||
//! crate](https://github.com/wasmerio/wasmer/blob/master/lib/wasi).
|
#[cfg(feature = "sys")]
|
||||||
|
fn fail_if_wit_files_arent_up_to_date() {
|
||||||
|
use wit_bindgen_core::Generator;
|
||||||
|
|
||||||
// Needed for #[derive(ValueType)]
|
let output_wit = concat!(env!("CARGO_MANIFEST_DIR"), "/wit-clean/output.wit");
|
||||||
extern crate wasmer_types as wasmer;
|
let bindings_target =
|
||||||
|
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/wasi/bindings.rs"));
|
||||||
mod advice;
|
let mut generator = wit_bindgen_rust_wasm::Opts {
|
||||||
mod bus;
|
..wit_bindgen_rust_wasm::Opts::default()
|
||||||
mod directory;
|
}
|
||||||
mod error;
|
.build();
|
||||||
mod event;
|
let output_wit_parsed = wit_parser::Interface::parse_file(output_wit).unwrap();
|
||||||
mod file;
|
let imports = vec![output_wit_parsed];
|
||||||
mod io;
|
let exports = vec![];
|
||||||
mod net;
|
let mut files = Default::default();
|
||||||
mod signal;
|
generator.generate_all(
|
||||||
mod subscription;
|
&imports, &exports, &mut files, /* generate_structs */ true,
|
||||||
mod time;
|
);
|
||||||
mod versions;
|
let generated = files
|
||||||
|
.iter()
|
||||||
pub use crate::time::*;
|
.filter_map(|(k, v)| if k == "bindings.rs" { Some(v) } else { None })
|
||||||
pub use advice::*;
|
.next()
|
||||||
pub use bus::*;
|
.unwrap();
|
||||||
pub use directory::*;
|
let generated_str = String::from_utf8_lossy(generated);
|
||||||
pub use error::*;
|
let generated_str = generated_str
|
||||||
pub use event::*;
|
.lines()
|
||||||
pub use file::*;
|
.map(|s| s.to_string())
|
||||||
pub use io::*;
|
.collect::<Vec<String>>()
|
||||||
pub use net::*;
|
.join("\r\n");
|
||||||
pub use signal::*;
|
let generated_str = generated_str.replace("mod output {", "pub mod output {");
|
||||||
pub use subscription::*;
|
let bindings_target = bindings_target
|
||||||
pub use versions::*;
|
.lines()
|
||||||
|
.map(|s| s.to_string())
|
||||||
pub type __wasi_exitcode_t = u32;
|
.collect::<Vec<String>>()
|
||||||
|
.join("\r\n");
|
||||||
pub type __wasi_userdata_t = u64;
|
pretty_assertions::assert_eq!(generated_str, bindings_target); // output.wit out of date? regenerate bindings.rs
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,494 +0,0 @@
|
|||||||
use super::*;
|
|
||||||
use wasmer_derive::ValueType;
|
|
||||||
|
|
||||||
use crate::__wasi_option_timestamp_t;
|
|
||||||
|
|
||||||
pub type __wasi_socktype_t = u16;
|
|
||||||
pub const __WASI_SOCK_TYPE_DGRAM: __wasi_socktype_t = 0;
|
|
||||||
pub const __WASI_SOCK_TYPE_STREAM: __wasi_socktype_t = 1;
|
|
||||||
pub const __WASI_SOCK_TYPE_RAW: __wasi_socktype_t = 2;
|
|
||||||
pub const __WASI_SOCK_TYPE_SEQPACKET: __wasi_socktype_t = 3;
|
|
||||||
|
|
||||||
pub type __wasi_sockstatus_t = u8;
|
|
||||||
pub const __WASI_SOCK_STATUS_OPENING: __wasi_sockstatus_t = 0;
|
|
||||||
pub const __WASI_SOCK_STATUS_OPENED: __wasi_sockstatus_t = 1;
|
|
||||||
pub const __WASI_SOCK_STATUS_CLOSED: __wasi_sockstatus_t = 2;
|
|
||||||
pub const __WASI_SOCK_STATUS_FAILED: __wasi_sockstatus_t = 3;
|
|
||||||
|
|
||||||
pub type __wasi_sockoption_t = u8;
|
|
||||||
pub const __WASI_SOCK_OPTION_NOOP: __wasi_sockoption_t = 0;
|
|
||||||
pub const __WASI_SOCK_OPTION_REUSE_PORT: __wasi_sockoption_t = 1;
|
|
||||||
pub const __WASI_SOCK_OPTION_REUSE_ADDR: __wasi_sockoption_t = 2;
|
|
||||||
pub const __WASI_SOCK_OPTION_NO_DELAY: __wasi_sockoption_t = 3;
|
|
||||||
pub const __WASI_SOCK_OPTION_DONT_ROUTE: __wasi_sockoption_t = 4;
|
|
||||||
pub const __WASI_SOCK_OPTION_ONLY_V6: __wasi_sockoption_t = 5;
|
|
||||||
pub const __WASI_SOCK_OPTION_BROADCAST: __wasi_sockoption_t = 6;
|
|
||||||
pub const __WASI_SOCK_OPTION_MULTICAST_LOOP_V4: __wasi_sockoption_t = 7;
|
|
||||||
pub const __WASI_SOCK_OPTION_MULTICAST_LOOP_V6: __wasi_sockoption_t = 8;
|
|
||||||
pub const __WASI_SOCK_OPTION_PROMISCUOUS: __wasi_sockoption_t = 9;
|
|
||||||
pub const __WASI_SOCK_OPTION_LISTENING: __wasi_sockoption_t = 10;
|
|
||||||
pub const __WASI_SOCK_OPTION_LAST_ERROR: __wasi_sockoption_t = 11;
|
|
||||||
pub const __WASI_SOCK_OPTION_KEEP_ALIVE: __wasi_sockoption_t = 12;
|
|
||||||
pub const __WASI_SOCK_OPTION_LINGER: __wasi_sockoption_t = 13;
|
|
||||||
pub const __WASI_SOCK_OPTION_OOB_INLINE: __wasi_sockoption_t = 14;
|
|
||||||
pub const __WASI_SOCK_OPTION_RECV_BUF_SIZE: __wasi_sockoption_t = 15;
|
|
||||||
pub const __WASI_SOCK_OPTION_SEND_BUF_SIZE: __wasi_sockoption_t = 16;
|
|
||||||
pub const __WASI_SOCK_OPTION_RECV_LOWAT: __wasi_sockoption_t = 17;
|
|
||||||
pub const __WASI_SOCK_OPTION_SEND_LOWAT: __wasi_sockoption_t = 18;
|
|
||||||
pub const __WASI_SOCK_OPTION_RECV_TIMEOUT: __wasi_sockoption_t = 19;
|
|
||||||
pub const __WASI_SOCK_OPTION_SEND_TIMEOUT: __wasi_sockoption_t = 20;
|
|
||||||
pub const __WASI_SOCK_OPTION_CONNECT_TIMEOUT: __wasi_sockoption_t = 21;
|
|
||||||
pub const __WASI_SOCK_OPTION_ACCEPT_TIMEOUT: __wasi_sockoption_t = 22;
|
|
||||||
pub const __WASI_SOCK_OPTION_TTL: __wasi_sockoption_t = 23;
|
|
||||||
pub const __WASI_SOCK_OPTION_MULTICAST_TTL_V4: __wasi_sockoption_t = 24;
|
|
||||||
pub const __WASI_SOCK_OPTION_TYPE: __wasi_sockoption_t = 25;
|
|
||||||
pub const __WASI_SOCK_OPTION_PROTO: __wasi_sockoption_t = 26;
|
|
||||||
|
|
||||||
pub type __wasi_streamsecurity_t = u8;
|
|
||||||
pub const __WASI_STREAM_SECURITY_UNENCRYPTED: __wasi_streamsecurity_t = 0;
|
|
||||||
pub const __WASI_STREAM_SECURITY_ANY_ENCRYPTION: __wasi_streamsecurity_t = 1;
|
|
||||||
pub const __WASI_STREAM_SECURITY_CLASSIC_ENCRYPTION: __wasi_streamsecurity_t = 2;
|
|
||||||
pub const __WASI_STREAM_SECURITY_DOUBLE_ENCRYPTION: __wasi_streamsecurity_t = 3;
|
|
||||||
|
|
||||||
pub type __wasi_sockproto_t = u16;
|
|
||||||
pub const __WASI_SOCK_PROTO_IP: __wasi_sockproto_t = 0;
|
|
||||||
pub const __WASI_SOCK_PROTO_ICMP: __wasi_sockproto_t = 1;
|
|
||||||
pub const __WASI_SOCK_PROTO_IGMP: __wasi_sockproto_t = 2;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_3: __wasi_sockproto_t = 3;
|
|
||||||
pub const __WASI_SOCK_PROTO_IPIP: __wasi_sockproto_t = 4;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_5: __wasi_sockproto_t = 5;
|
|
||||||
pub const __WASI_SOCK_PROTO_TCP: __wasi_sockproto_t = 6;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_7: __wasi_sockproto_t = 7;
|
|
||||||
pub const __WASI_SOCK_PROTO_EGP: __wasi_sockproto_t = 8;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_9: __wasi_sockproto_t = 9;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_10: __wasi_sockproto_t = 10;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_11: __wasi_sockproto_t = 11;
|
|
||||||
pub const __WASI_SOCK_PROTO_PUP: __wasi_sockproto_t = 12;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_13: __wasi_sockproto_t = 13;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_14: __wasi_sockproto_t = 14;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_15: __wasi_sockproto_t = 15;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_16: __wasi_sockproto_t = 16;
|
|
||||||
pub const __WASI_SOCK_PROTO_UDP: __wasi_sockproto_t = 17;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_18: __wasi_sockproto_t = 18;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_19: __wasi_sockproto_t = 19;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_20: __wasi_sockproto_t = 20;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_21: __wasi_sockproto_t = 21;
|
|
||||||
pub const __WASI_SOCK_PROTO_IDP: __wasi_sockproto_t = 22;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_23: __wasi_sockproto_t = 23;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_24: __wasi_sockproto_t = 24;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_25: __wasi_sockproto_t = 25;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_26: __wasi_sockproto_t = 26;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_27: __wasi_sockproto_t = 27;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_28: __wasi_sockproto_t = 28;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_TP: __wasi_sockproto_t = 29;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_30: __wasi_sockproto_t = 30;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_31: __wasi_sockproto_t = 31;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_32: __wasi_sockproto_t = 32;
|
|
||||||
pub const __WASI_SOCK_PROTO_DCCP: __wasi_sockproto_t = 33;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_34: __wasi_sockproto_t = 34;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_35: __wasi_sockproto_t = 35;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_36: __wasi_sockproto_t = 36;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_37: __wasi_sockproto_t = 37;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_38: __wasi_sockproto_t = 38;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_39: __wasi_sockproto_t = 39;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_40: __wasi_sockproto_t = 40;
|
|
||||||
pub const __WASI_SOCK_PROTO_IPV6: __wasi_sockproto_t = 41;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_42: __wasi_sockproto_t = 42;
|
|
||||||
pub const __WASI_SOCK_PROTO_ROUTING: __wasi_sockproto_t = 43;
|
|
||||||
pub const __WASI_SOCK_PROTO_FRAGMENT: __wasi_sockproto_t = 44;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_45: __wasi_sockproto_t = 45;
|
|
||||||
pub const __WASI_SOCK_PROTO_RSVP: __wasi_sockproto_t = 46;
|
|
||||||
pub const __WASI_SOCK_PROTO_GRE: __wasi_sockproto_t = 47;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_48: __wasi_sockproto_t = 48;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_49: __wasi_sockproto_t = 49;
|
|
||||||
pub const __WASI_SOCK_PROTO_ESP: __wasi_sockproto_t = 50;
|
|
||||||
pub const __WASI_SOCK_PROTO_AH: __wasi_sockproto_t = 51;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_52: __wasi_sockproto_t = 52;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_53: __wasi_sockproto_t = 53;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_54: __wasi_sockproto_t = 54;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_55: __wasi_sockproto_t = 55;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_56: __wasi_sockproto_t = 56;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_57: __wasi_sockproto_t = 57;
|
|
||||||
pub const __WASI_SOCK_PROTO_ICMPV6: __wasi_sockproto_t = 58;
|
|
||||||
pub const __WASI_SOCK_PROTO_NONE: __wasi_sockproto_t = 59;
|
|
||||||
pub const __WASI_SOCK_PROTO_DSTOPTS: __wasi_sockproto_t = 60;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_61: __wasi_sockproto_t = 61;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_62: __wasi_sockproto_t = 62;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_63: __wasi_sockproto_t = 63;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_64: __wasi_sockproto_t = 64;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_65: __wasi_sockproto_t = 65;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_66: __wasi_sockproto_t = 66;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_67: __wasi_sockproto_t = 67;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_68: __wasi_sockproto_t = 68;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_69: __wasi_sockproto_t = 69;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_70: __wasi_sockproto_t = 70;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_71: __wasi_sockproto_t = 71;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_72: __wasi_sockproto_t = 72;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_73: __wasi_sockproto_t = 73;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_74: __wasi_sockproto_t = 74;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_75: __wasi_sockproto_t = 75;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_76: __wasi_sockproto_t = 76;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_77: __wasi_sockproto_t = 77;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_78: __wasi_sockproto_t = 78;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_79: __wasi_sockproto_t = 79;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_80: __wasi_sockproto_t = 80;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_81: __wasi_sockproto_t = 81;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_82: __wasi_sockproto_t = 82;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_83: __wasi_sockproto_t = 83;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_84: __wasi_sockproto_t = 84;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_85: __wasi_sockproto_t = 85;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_86: __wasi_sockproto_t = 86;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_87: __wasi_sockproto_t = 87;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_88: __wasi_sockproto_t = 88;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_89: __wasi_sockproto_t = 89;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_90: __wasi_sockproto_t = 90;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_91: __wasi_sockproto_t = 91;
|
|
||||||
pub const __WASI_SOCK_PROTO_MTP: __wasi_sockproto_t = 92;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_93: __wasi_sockproto_t = 93;
|
|
||||||
pub const __WASI_SOCK_PROTO_BEETPH: __wasi_sockproto_t = 94;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_95: __wasi_sockproto_t = 95;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_96: __wasi_sockproto_t = 96;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_97: __wasi_sockproto_t = 97;
|
|
||||||
pub const __WASI_SOCK_PROTO_ENCAP: __wasi_sockproto_t = 98;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_99: __wasi_sockproto_t = 99;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_100: __wasi_sockproto_t = 100;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_101: __wasi_sockproto_t = 101;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_102: __wasi_sockproto_t = 102;
|
|
||||||
pub const __WASI_SOCK_PROTO_PIM: __wasi_sockproto_t = 103;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_104: __wasi_sockproto_t = 104;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_105: __wasi_sockproto_t = 105;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_106: __wasi_sockproto_t = 106;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_107: __wasi_sockproto_t = 107;
|
|
||||||
pub const __WASI_SOCK_PROTO_COMP: __wasi_sockproto_t = 108;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_109: __wasi_sockproto_t = 109;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_110: __wasi_sockproto_t = 110;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_111: __wasi_sockproto_t = 111;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_112: __wasi_sockproto_t = 112;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_113: __wasi_sockproto_t = 113;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_114: __wasi_sockproto_t = 114;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_115: __wasi_sockproto_t = 115;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_116: __wasi_sockproto_t = 116;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_117: __wasi_sockproto_t = 117;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_118: __wasi_sockproto_t = 118;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_119: __wasi_sockproto_t = 119;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_120: __wasi_sockproto_t = 120;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_121: __wasi_sockproto_t = 121;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_122: __wasi_sockproto_t = 122;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_123: __wasi_sockproto_t = 123;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_124: __wasi_sockproto_t = 124;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_125: __wasi_sockproto_t = 125;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_126: __wasi_sockproto_t = 126;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_127: __wasi_sockproto_t = 127;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_128: __wasi_sockproto_t = 128;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_129: __wasi_sockproto_t = 129;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_130: __wasi_sockproto_t = 130;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_131: __wasi_sockproto_t = 131;
|
|
||||||
pub const __WASI_SOCK_PROTO_SCTP: __wasi_sockproto_t = 132;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_133: __wasi_sockproto_t = 133;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_134: __wasi_sockproto_t = 134;
|
|
||||||
pub const __WASI_SOCK_PROTO_MH: __wasi_sockproto_t = 135;
|
|
||||||
pub const __WASI_SOCK_PROTO_UDPLITE: __wasi_sockproto_t = 136;
|
|
||||||
pub const __WASI_SOCK_PROTO_MPLS: __wasi_sockproto_t = 137;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_138: __wasi_sockproto_t = 138;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_139: __wasi_sockproto_t = 139;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_140: __wasi_sockproto_t = 140;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_141: __wasi_sockproto_t = 141;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_142: __wasi_sockproto_t = 142;
|
|
||||||
pub const __WASI_SOCK_PROTO_ETHERNET: __wasi_sockproto_t = 143;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_144: __wasi_sockproto_t = 144;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_145: __wasi_sockproto_t = 145;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_146: __wasi_sockproto_t = 146;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_147: __wasi_sockproto_t = 147;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_148: __wasi_sockproto_t = 148;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_149: __wasi_sockproto_t = 149;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_150: __wasi_sockproto_t = 150;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_151: __wasi_sockproto_t = 151;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_152: __wasi_sockproto_t = 152;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_153: __wasi_sockproto_t = 153;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_154: __wasi_sockproto_t = 154;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_155: __wasi_sockproto_t = 155;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_156: __wasi_sockproto_t = 156;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_157: __wasi_sockproto_t = 157;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_158: __wasi_sockproto_t = 158;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_159: __wasi_sockproto_t = 159;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_160: __wasi_sockproto_t = 160;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_161: __wasi_sockproto_t = 161;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_162: __wasi_sockproto_t = 162;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_163: __wasi_sockproto_t = 163;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_164: __wasi_sockproto_t = 164;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_165: __wasi_sockproto_t = 165;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_166: __wasi_sockproto_t = 166;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_167: __wasi_sockproto_t = 167;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_168: __wasi_sockproto_t = 168;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_169: __wasi_sockproto_t = 169;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_170: __wasi_sockproto_t = 170;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_171: __wasi_sockproto_t = 171;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_172: __wasi_sockproto_t = 172;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_173: __wasi_sockproto_t = 173;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_174: __wasi_sockproto_t = 174;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_175: __wasi_sockproto_t = 175;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_176: __wasi_sockproto_t = 176;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_177: __wasi_sockproto_t = 177;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_178: __wasi_sockproto_t = 178;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_179: __wasi_sockproto_t = 179;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_180: __wasi_sockproto_t = 180;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_181: __wasi_sockproto_t = 181;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_182: __wasi_sockproto_t = 182;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_183: __wasi_sockproto_t = 183;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_184: __wasi_sockproto_t = 184;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_185: __wasi_sockproto_t = 185;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_186: __wasi_sockproto_t = 186;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_187: __wasi_sockproto_t = 187;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_188: __wasi_sockproto_t = 188;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_189: __wasi_sockproto_t = 189;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_190: __wasi_sockproto_t = 190;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_191: __wasi_sockproto_t = 191;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_192: __wasi_sockproto_t = 192;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_193: __wasi_sockproto_t = 193;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_194: __wasi_sockproto_t = 194;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_195: __wasi_sockproto_t = 195;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_196: __wasi_sockproto_t = 196;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_197: __wasi_sockproto_t = 197;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_198: __wasi_sockproto_t = 198;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_199: __wasi_sockproto_t = 199;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_200: __wasi_sockproto_t = 200;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_201: __wasi_sockproto_t = 201;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_202: __wasi_sockproto_t = 202;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_203: __wasi_sockproto_t = 203;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_204: __wasi_sockproto_t = 204;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_205: __wasi_sockproto_t = 205;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_206: __wasi_sockproto_t = 206;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_207: __wasi_sockproto_t = 207;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_208: __wasi_sockproto_t = 208;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_209: __wasi_sockproto_t = 209;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_210: __wasi_sockproto_t = 210;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_211: __wasi_sockproto_t = 211;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_212: __wasi_sockproto_t = 212;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_213: __wasi_sockproto_t = 213;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_214: __wasi_sockproto_t = 214;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_215: __wasi_sockproto_t = 215;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_216: __wasi_sockproto_t = 216;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_217: __wasi_sockproto_t = 217;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_218: __wasi_sockproto_t = 218;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_219: __wasi_sockproto_t = 219;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_220: __wasi_sockproto_t = 220;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_221: __wasi_sockproto_t = 221;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_222: __wasi_sockproto_t = 222;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_223: __wasi_sockproto_t = 223;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_224: __wasi_sockproto_t = 224;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_225: __wasi_sockproto_t = 225;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_226: __wasi_sockproto_t = 226;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_227: __wasi_sockproto_t = 227;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_228: __wasi_sockproto_t = 228;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_229: __wasi_sockproto_t = 229;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_230: __wasi_sockproto_t = 230;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_231: __wasi_sockproto_t = 231;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_232: __wasi_sockproto_t = 232;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_233: __wasi_sockproto_t = 233;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_234: __wasi_sockproto_t = 234;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_235: __wasi_sockproto_t = 235;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_236: __wasi_sockproto_t = 236;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_237: __wasi_sockproto_t = 237;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_238: __wasi_sockproto_t = 238;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_239: __wasi_sockproto_t = 239;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_240: __wasi_sockproto_t = 240;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_241: __wasi_sockproto_t = 241;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_242: __wasi_sockproto_t = 242;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_243: __wasi_sockproto_t = 243;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_244: __wasi_sockproto_t = 244;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_245: __wasi_sockproto_t = 245;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_246: __wasi_sockproto_t = 246;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_247: __wasi_sockproto_t = 247;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_248: __wasi_sockproto_t = 248;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_249: __wasi_sockproto_t = 249;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_250: __wasi_sockproto_t = 250;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_251: __wasi_sockproto_t = 251;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_252: __wasi_sockproto_t = 252;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_253: __wasi_sockproto_t = 253;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_254: __wasi_sockproto_t = 254;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_RAW: __wasi_sockproto_t = 255;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_256: __wasi_sockproto_t = 256;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_257: __wasi_sockproto_t = 257;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_258: __wasi_sockproto_t = 258;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_259: __wasi_sockproto_t = 259;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_260: __wasi_sockproto_t = 260;
|
|
||||||
pub const __WASI_SOCK_PROTO_PROTO_261: __wasi_sockproto_t = 261;
|
|
||||||
pub const __WASI_SOCK_PROTO_MPTCP: __wasi_sockproto_t = 262;
|
|
||||||
pub const __WASI_SOCK_PROTO_MAX: __wasi_sockproto_t = 263;
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_hardwareaddress_t {
|
|
||||||
pub octs: [u8; 6],
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type __wasi_addressfamily_t = u16;
|
|
||||||
pub const __WASI_ADDRESS_FAMILY_UNSPEC: __wasi_addressfamily_t = 0;
|
|
||||||
pub const __WASI_ADDRESS_FAMILY_INET4: __wasi_addressfamily_t = 1;
|
|
||||||
pub const __WASI_ADDRESS_FAMILY_INET6: __wasi_addressfamily_t = 2;
|
|
||||||
pub const __WASI_ADDRESS_FAMILY_UNIX: __wasi_addressfamily_t = 3;
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_addr_unspec_t {
|
|
||||||
pub n0: u8,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_addr_unspec_port_t {
|
|
||||||
pub port: u16,
|
|
||||||
pub addr: __wasi_addr_unspec_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_cidr_unspec_t {
|
|
||||||
pub addr: __wasi_addr_unspec_t,
|
|
||||||
pub prefix: u8,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_addr_ip4_t {
|
|
||||||
pub octs: [u8; 4],
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_addr_ip4_port_t {
|
|
||||||
pub port: u16,
|
|
||||||
pub ip: __wasi_addr_ip4_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_cidr_ip4_t {
|
|
||||||
pub ip: __wasi_addr_ip4_t,
|
|
||||||
pub prefix: u8,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_addr_unix_t {
|
|
||||||
pub octs: [u8; 16],
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_addr_unix_port_t {
|
|
||||||
pub port: u16,
|
|
||||||
pub unix: __wasi_addr_unix_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_cidr_unix_t {
|
|
||||||
pub unix: __wasi_addr_unix_t,
|
|
||||||
pub prefix: u8,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_addr_ip6_t {
|
|
||||||
pub segs: [u8; 16],
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_addr_ip6_port_t {
|
|
||||||
pub port: u16,
|
|
||||||
pub ip: __wasi_addr_ip6_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_cidr_ip6_t {
|
|
||||||
pub ip: __wasi_addr_ip6_t,
|
|
||||||
pub prefix: u8,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_addr_u {
|
|
||||||
pub octs: [u8; 16],
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_addr_t {
|
|
||||||
pub tag: __wasi_addressfamily_t,
|
|
||||||
pub u: __wasi_addr_u,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_addr_port_u {
|
|
||||||
pub octs: [u8; 18],
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_addr_port_t {
|
|
||||||
pub tag: __wasi_addressfamily_t,
|
|
||||||
pub u: __wasi_addr_port_u,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_cidr_u {
|
|
||||||
pub octs: [u8; 17],
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_cidr_t {
|
|
||||||
pub tag: __wasi_addressfamily_t,
|
|
||||||
pub u: __wasi_cidr_u,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_route_t {
|
|
||||||
pub cidr: __wasi_cidr_t,
|
|
||||||
pub via_router: __wasi_addr_t,
|
|
||||||
pub preferred_until: __wasi_option_timestamp_t,
|
|
||||||
pub expires_at: __wasi_option_timestamp_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_http_handles_t {
|
|
||||||
pub req: __wasi_fd_t,
|
|
||||||
pub res: __wasi_fd_t,
|
|
||||||
pub hdr: __wasi_fd_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_http_status_t {
|
|
||||||
pub ok: __wasi_bool_t,
|
|
||||||
pub redirect: __wasi_bool_t,
|
|
||||||
pub size: __wasi_filesize_t,
|
|
||||||
pub status: u16,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type __wasi_riflags_t = u16;
|
|
||||||
pub const __WASI_SOCK_RECV_INPUT_PEEK: __wasi_riflags_t = 1 << 0;
|
|
||||||
pub const __WASI_SOCK_RECV_INPUT_WAITALL: __wasi_riflags_t = 1 << 1;
|
|
||||||
pub const __WASI_SOCK_RECV_INPUT_DATA_TRUNCATED: __wasi_riflags_t = 1 << 2;
|
|
||||||
|
|
||||||
pub type __wasi_roflags_t = u16;
|
|
||||||
pub const __WASI_SOCK_RECV_OUTPUT_DATA_TRUNCATED: __wasi_roflags_t = 1 << 0;
|
|
||||||
|
|
||||||
pub type __wasi_sdflags_t = u8;
|
|
||||||
pub const __WASI_SHUT_RD: __wasi_sdflags_t = 1 << 0;
|
|
||||||
pub const __WASI_SHUT_WR: __wasi_sdflags_t = 1 << 1;
|
|
||||||
|
|
||||||
pub type __wasi_siflags_t = u16;
|
|
||||||
|
|
||||||
pub type __wasi_timeout_t = u8;
|
|
||||||
pub const __WASI_TIMEOUT_READ: __wasi_timeout_t = 0;
|
|
||||||
pub const __WASI_TIMEOUT_WRITE: __wasi_timeout_t = 1;
|
|
||||||
pub const __WASI_TIMEOUT_CONNECT: __wasi_timeout_t = 2;
|
|
||||||
pub const __WASI_TIMEOUT_ACCEPT: __wasi_timeout_t = 3;
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
pub type __wasi_signal_t = u8;
|
|
||||||
pub const __WASI_SIGHUP: u8 = 1;
|
|
||||||
pub const __WASI_SIGINT: u8 = 2;
|
|
||||||
pub const __WASI_SIGQUIT: u8 = 3;
|
|
||||||
pub const __WASI_SIGILL: u8 = 4;
|
|
||||||
pub const __WASI_SIGTRAP: u8 = 5;
|
|
||||||
pub const __WASI_SIGABRT: u8 = 6;
|
|
||||||
pub const __WASI_SIGBUS: u8 = 7;
|
|
||||||
pub const __WASI_SIGFPE: u8 = 8;
|
|
||||||
pub const __WASI_SIGKILL: u8 = 9;
|
|
||||||
pub const __WASI_SIGUSR1: u8 = 10;
|
|
||||||
pub const __WASI_SIGSEGV: u8 = 11;
|
|
||||||
pub const __WASI_SIGUSR2: u8 = 12;
|
|
||||||
pub const __WASI_SIGPIPE: u8 = 13;
|
|
||||||
pub const __WASI_SIGALRM: u8 = 14;
|
|
||||||
pub const __WASI_SIGTERM: u8 = 15;
|
|
||||||
pub const __WASI_SIGCHLD: u8 = 16;
|
|
||||||
pub const __WASI_SIGCONT: u8 = 17;
|
|
||||||
pub const __WASI_SIGSTOP: u8 = 18;
|
|
||||||
pub const __WASI_SIGTSTP: u8 = 19;
|
|
||||||
pub const __WASI_SIGTTIN: u8 = 20;
|
|
||||||
pub const __WASI_SIGTTOU: u8 = 21;
|
|
||||||
pub const __WASI_SIGURG: u8 = 22;
|
|
||||||
pub const __WASI_SIGXCPU: u8 = 23;
|
|
||||||
pub const __WASI_SIGXFSZ: u8 = 24;
|
|
||||||
pub const __WASI_SIGVTALRM: u8 = 25;
|
|
||||||
pub const __WASI_SIGPROF: u8 = 26;
|
|
||||||
pub const __WASI_SIGWINCH: u8 = 27;
|
|
||||||
pub const __WASI_SIGPOLL: u8 = 28;
|
|
||||||
pub const __WASI_SIGPWR: u8 = 29;
|
|
||||||
pub const __WASI_SIGSYS: u8 = 30;
|
|
||||||
@@ -1,188 +0,0 @@
|
|||||||
use crate::*;
|
|
||||||
use std::convert::TryFrom;
|
|
||||||
use std::fmt;
|
|
||||||
use std::mem::{self, MaybeUninit};
|
|
||||||
use wasmer_derive::ValueType;
|
|
||||||
use wasmer_types::ValueType;
|
|
||||||
|
|
||||||
pub type __wasi_subclockflags_t = u16;
|
|
||||||
pub const __WASI_SUBSCRIPTION_CLOCK_ABSTIME: u16 = 1 << 0;
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_subscription_clock_t {
|
|
||||||
pub clock_id: __wasi_clockid_t,
|
|
||||||
pub timeout: __wasi_timestamp_t,
|
|
||||||
pub precision: __wasi_timestamp_t,
|
|
||||||
pub flags: __wasi_subclockflags_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_subscription_fs_readwrite_t {
|
|
||||||
pub fd: __wasi_fd_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub union __wasi_subscription_u {
|
|
||||||
pub clock: __wasi_subscription_clock_t,
|
|
||||||
pub fd_readwrite: __wasi_subscription_fs_readwrite_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_subscription_t {
|
|
||||||
pub userdata: __wasi_userdata_t,
|
|
||||||
pub type_: __wasi_eventtype_t,
|
|
||||||
pub u: __wasi_subscription_u,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Safe Rust wrapper around `__wasi_subscription_t::type_` and `__wasi_subscription_t::u`
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub enum EventType {
|
|
||||||
Clock(__wasi_subscription_clock_t),
|
|
||||||
Read(__wasi_subscription_fs_readwrite_t),
|
|
||||||
Write(__wasi_subscription_fs_readwrite_t),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl EventType {
|
|
||||||
pub fn raw_tag(&self) -> __wasi_eventtype_t {
|
|
||||||
match self {
|
|
||||||
EventType::Clock(_) => __WASI_EVENTTYPE_CLOCK,
|
|
||||||
EventType::Read(_) => __WASI_EVENTTYPE_FD_READ,
|
|
||||||
EventType::Write(_) => __WASI_EVENTTYPE_FD_WRITE,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Safe Rust wrapper around `__wasi_subscription_t`
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub struct WasiSubscription {
|
|
||||||
pub user_data: __wasi_userdata_t,
|
|
||||||
pub event_type: EventType,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TryFrom<__wasi_subscription_t> for WasiSubscription {
|
|
||||||
type Error = __wasi_errno_t;
|
|
||||||
|
|
||||||
fn try_from(ws: __wasi_subscription_t) -> Result<Self, Self::Error> {
|
|
||||||
Ok(Self {
|
|
||||||
user_data: ws.userdata,
|
|
||||||
event_type: match ws.type_ {
|
|
||||||
__WASI_EVENTTYPE_CLOCK => EventType::Clock(unsafe { ws.u.clock }),
|
|
||||||
__WASI_EVENTTYPE_FD_READ => EventType::Read(unsafe { ws.u.fd_readwrite }),
|
|
||||||
__WASI_EVENTTYPE_FD_WRITE => EventType::Write(unsafe { ws.u.fd_readwrite }),
|
|
||||||
_ => return Err(__WASI_EINVAL),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TryFrom<WasiSubscription> for __wasi_subscription_t {
|
|
||||||
type Error = __wasi_errno_t;
|
|
||||||
|
|
||||||
fn try_from(ws: WasiSubscription) -> Result<Self, Self::Error> {
|
|
||||||
#[allow(unreachable_patterns)]
|
|
||||||
let (type_, u) = match ws.event_type {
|
|
||||||
EventType::Clock(c) => (__WASI_EVENTTYPE_CLOCK, __wasi_subscription_u { clock: c }),
|
|
||||||
EventType::Read(rw) => (
|
|
||||||
__WASI_EVENTTYPE_FD_READ,
|
|
||||||
__wasi_subscription_u { fd_readwrite: rw },
|
|
||||||
),
|
|
||||||
EventType::Write(rw) => (
|
|
||||||
__WASI_EVENTTYPE_FD_WRITE,
|
|
||||||
__wasi_subscription_u { fd_readwrite: rw },
|
|
||||||
),
|
|
||||||
_ => return Err(__WASI_EINVAL),
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(Self {
|
|
||||||
userdata: ws.user_data,
|
|
||||||
type_,
|
|
||||||
u,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for __wasi_subscription_t {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
f.debug_struct("__wasi_subscription_t")
|
|
||||||
.field("userdata", &self.userdata)
|
|
||||||
.field("type", &eventtype_to_str(self.type_))
|
|
||||||
.field(
|
|
||||||
"u",
|
|
||||||
match self.type_ {
|
|
||||||
__WASI_EVENTTYPE_CLOCK => unsafe { &self.u.clock },
|
|
||||||
__WASI_EVENTTYPE_FD_READ | __WASI_EVENTTYPE_FD_WRITE => unsafe {
|
|
||||||
&self.u.fd_readwrite
|
|
||||||
},
|
|
||||||
_ => &"INVALID EVENTTYPE",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl ValueType for __wasi_subscription_t {
|
|
||||||
fn zero_padding_bytes(&self, bytes: &mut [MaybeUninit<u8>]) {
|
|
||||||
macro_rules! field {
|
|
||||||
($($f:tt)*) => {
|
|
||||||
&self.$($f)* as *const _ as usize - self as *const _ as usize
|
|
||||||
};
|
|
||||||
}
|
|
||||||
macro_rules! field_end {
|
|
||||||
($($f:tt)*) => {
|
|
||||||
field!($($f)*) + mem::size_of_val(&self.$($f)*)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
macro_rules! zero {
|
|
||||||
($start:expr, $end:expr) => {
|
|
||||||
for i in $start..$end {
|
|
||||||
bytes[i] = MaybeUninit::new(0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
self.userdata
|
|
||||||
.zero_padding_bytes(&mut bytes[field!(userdata)..field_end!(userdata)]);
|
|
||||||
zero!(field_end!(userdata), field!(type_));
|
|
||||||
self.type_
|
|
||||||
.zero_padding_bytes(&mut bytes[field!(type_)..field_end!(type_)]);
|
|
||||||
zero!(field_end!(type_), field!(u));
|
|
||||||
match self.type_ {
|
|
||||||
__WASI_EVENTTYPE_FD_READ | __WASI_EVENTTYPE_FD_WRITE => unsafe {
|
|
||||||
self.u.fd_readwrite.zero_padding_bytes(
|
|
||||||
&mut bytes[field!(u.fd_readwrite)..field_end!(u.fd_readwrite)],
|
|
||||||
);
|
|
||||||
zero!(field_end!(u.fd_readwrite), field_end!(u));
|
|
||||||
},
|
|
||||||
__WASI_EVENTTYPE_CLOCK => unsafe {
|
|
||||||
self.u
|
|
||||||
.clock
|
|
||||||
.zero_padding_bytes(&mut bytes[field!(u.clock)..field_end!(u.clock)]);
|
|
||||||
zero!(field_end!(u.clock), field_end!(u));
|
|
||||||
},
|
|
||||||
_ => zero!(field!(u), field_end!(u)),
|
|
||||||
}
|
|
||||||
zero!(field_end!(u), mem::size_of_val(self));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub enum SubscriptionEnum {
|
|
||||||
Clock(__wasi_subscription_clock_t),
|
|
||||||
FdReadWrite(__wasi_subscription_fs_readwrite_t),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl __wasi_subscription_t {
|
|
||||||
pub fn tagged(&self) -> Option<SubscriptionEnum> {
|
|
||||||
match self.type_ {
|
|
||||||
__WASI_EVENTTYPE_CLOCK => Some(SubscriptionEnum::Clock(unsafe { self.u.clock })),
|
|
||||||
__WASI_EVENTTYPE_FD_READ | __WASI_EVENTTYPE_FD_WRITE => {
|
|
||||||
Some(SubscriptionEnum::FdReadWrite(unsafe {
|
|
||||||
self.u.fd_readwrite
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
use super::io::__wasi_option_t;
|
|
||||||
use wasmer_derive::ValueType;
|
|
||||||
|
|
||||||
pub type __wasi_clockid_t = u32;
|
|
||||||
pub const __WASI_CLOCK_REALTIME: __wasi_clockid_t = 0;
|
|
||||||
pub const __WASI_CLOCK_MONOTONIC: __wasi_clockid_t = 1;
|
|
||||||
pub const __WASI_CLOCK_PROCESS_CPUTIME_ID: __wasi_clockid_t = 2;
|
|
||||||
pub const __WASI_CLOCK_THREAD_CPUTIME_ID: __wasi_clockid_t = 3;
|
|
||||||
|
|
||||||
pub type __wasi_timestamp_t = u64;
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_option_timestamp_t {
|
|
||||||
pub tag: __wasi_option_t,
|
|
||||||
pub u: __wasi_timestamp_t,
|
|
||||||
}
|
|
||||||
347
lib/wasi-types/src/types.rs
Normal file
347
lib/wasi-types/src/types.rs
Normal file
@@ -0,0 +1,347 @@
|
|||||||
|
#![deny(unused_mut)]
|
||||||
|
#![doc(html_favicon_url = "https://wasmer.io/images/icons/favicon-32x32.png")]
|
||||||
|
#![doc(html_logo_url = "https://github.com/wasmerio.png?size=200")]
|
||||||
|
#![allow(non_camel_case_types, clippy::identity_op)]
|
||||||
|
|
||||||
|
//! Wasmer's WASI types implementation.
|
||||||
|
//!
|
||||||
|
//! Those types aim at being used by [the `wasmer-wasi`
|
||||||
|
//! crate](https://github.com/wasmerio/wasmer/blob/master/lib/wasi).
|
||||||
|
|
||||||
|
// Needed for #[derive(ValueType)]
|
||||||
|
extern crate wasmer_types as wasmer;
|
||||||
|
|
||||||
|
pub use crate::types::time::*;
|
||||||
|
pub use bus::*;
|
||||||
|
pub use directory::*;
|
||||||
|
pub use file::*;
|
||||||
|
pub use io::*;
|
||||||
|
pub use net::*;
|
||||||
|
pub use signal::*;
|
||||||
|
pub use subscription::*;
|
||||||
|
|
||||||
|
pub type __wasi_exitcode_t = u32;
|
||||||
|
pub type __wasi_userdata_t = u64;
|
||||||
|
|
||||||
|
pub mod bus {
|
||||||
|
use crate::wasi::{
|
||||||
|
BusDataFormat, BusEventClose, BusEventExit, BusEventFault, BusEventType, Cid, OptionCid,
|
||||||
|
};
|
||||||
|
use wasmer_derive::ValueType;
|
||||||
|
use wasmer_types::MemorySize;
|
||||||
|
|
||||||
|
// Not sure how to port these types to .wit with generics ...
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_busevent_call_t<M: MemorySize> {
|
||||||
|
pub parent: OptionCid,
|
||||||
|
pub cid: Cid,
|
||||||
|
pub format: BusDataFormat,
|
||||||
|
pub topic_ptr: M::Offset,
|
||||||
|
pub topic_len: M::Offset,
|
||||||
|
pub buf_ptr: M::Offset,
|
||||||
|
pub buf_len: M::Offset,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub union __wasi_busevent_u<M: MemorySize> {
|
||||||
|
pub noop: u8,
|
||||||
|
pub exit: BusEventExit,
|
||||||
|
pub call: __wasi_busevent_call_t<M>,
|
||||||
|
pub result: __wasi_busevent_result_t<M>,
|
||||||
|
pub fault: BusEventFault,
|
||||||
|
pub close: BusEventClose,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_busevent_result_t<M: MemorySize> {
|
||||||
|
pub format: BusDataFormat,
|
||||||
|
pub cid: Cid,
|
||||||
|
pub buf_ptr: M::Offset,
|
||||||
|
pub buf_len: M::Offset,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_busevent_t<M: MemorySize> {
|
||||||
|
pub tag: BusEventType,
|
||||||
|
pub u: __wasi_busevent_u<M>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod file {
|
||||||
|
use crate::wasi::{Fd, Rights};
|
||||||
|
|
||||||
|
pub use crate::wasi::{EventFdFlags, FileDelta, LookupFlags, Oflags};
|
||||||
|
|
||||||
|
pub const __WASI_STDIN_FILENO: Fd = 0;
|
||||||
|
pub const __WASI_STDOUT_FILENO: Fd = 1;
|
||||||
|
pub const __WASI_STDERR_FILENO: Fd = 2;
|
||||||
|
|
||||||
|
pub const EVENT_FD_FLAGS_SEMAPHORE: EventFdFlags = 1;
|
||||||
|
|
||||||
|
pub const __WASI_LOOKUP_SYMLINK_FOLLOW: LookupFlags = 1;
|
||||||
|
|
||||||
|
/// function for debugging rights issues
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn print_right_set(rights: Rights) {
|
||||||
|
// BTreeSet for consistent order
|
||||||
|
let mut right_set = std::collections::BTreeSet::new();
|
||||||
|
for i in 0..28 {
|
||||||
|
let cur_right = rights & Rights::from_bits(1 << i).unwrap();
|
||||||
|
if !cur_right.is_empty() {
|
||||||
|
right_set.insert(cur_right.to_str().unwrap_or("INVALID RIGHT"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println!("{:#?}", right_set);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod directory {
|
||||||
|
use crate::wasi;
|
||||||
|
use std::mem;
|
||||||
|
|
||||||
|
pub const __WASI_DIRCOOKIE_START: wasi::Dircookie = 0;
|
||||||
|
|
||||||
|
pub fn dirent_to_le_bytes(ent: &wasi::Dirent) -> Vec<u8> {
|
||||||
|
let out: Vec<u8> = std::iter::empty()
|
||||||
|
.chain(ent.d_next.to_le_bytes())
|
||||||
|
.chain(ent.d_ino.to_le_bytes())
|
||||||
|
.chain(ent.d_namlen.to_le_bytes())
|
||||||
|
.chain(u32::from(ent.d_type as u8).to_le_bytes())
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
assert_eq!(out.len(), mem::size_of::<wasi::Dirent>());
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::dirent_to_le_bytes;
|
||||||
|
use crate::wasi;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_dirent_to_le_bytes() {
|
||||||
|
let s = wasi::Dirent {
|
||||||
|
d_next: 0x0123456789abcdef,
|
||||||
|
d_ino: 0xfedcba9876543210,
|
||||||
|
d_namlen: 0xaabbccdd,
|
||||||
|
d_type: wasi::Filetype::Directory,
|
||||||
|
};
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
vec![
|
||||||
|
// d_next
|
||||||
|
0xef,
|
||||||
|
0xcd,
|
||||||
|
0xab,
|
||||||
|
0x89,
|
||||||
|
0x67,
|
||||||
|
0x45,
|
||||||
|
0x23,
|
||||||
|
0x01,
|
||||||
|
//
|
||||||
|
// d_ino
|
||||||
|
0x10,
|
||||||
|
0x32,
|
||||||
|
0x54,
|
||||||
|
0x76,
|
||||||
|
0x98,
|
||||||
|
0xba,
|
||||||
|
0xdc,
|
||||||
|
0xfe,
|
||||||
|
//
|
||||||
|
// d_namelen
|
||||||
|
0xdd,
|
||||||
|
0xcc,
|
||||||
|
0xbb,
|
||||||
|
0xaa,
|
||||||
|
//
|
||||||
|
// d_type
|
||||||
|
// plus padding
|
||||||
|
wasi::Filetype::Directory as u8,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
],
|
||||||
|
dirent_to_le_bytes(&s)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod io {
|
||||||
|
use wasmer_derive::ValueType;
|
||||||
|
use wasmer_types::MemorySize;
|
||||||
|
|
||||||
|
pub use crate::wasi::Bool;
|
||||||
|
pub use crate::wasi::Count;
|
||||||
|
pub use crate::wasi::OptionTag;
|
||||||
|
pub use crate::wasi::StdioMode;
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_ciovec_t<M: MemorySize> {
|
||||||
|
pub buf: M::Offset,
|
||||||
|
pub buf_len: M::Offset,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_iovec_t<M: MemorySize> {
|
||||||
|
pub buf: M::Offset,
|
||||||
|
pub buf_len: M::Offset,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod time {
|
||||||
|
pub use crate::wasi::OptionTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod net {
|
||||||
|
use crate::wasi::Addressfamily;
|
||||||
|
use wasmer_derive::ValueType;
|
||||||
|
|
||||||
|
use crate::wasi::OptionTimestamp;
|
||||||
|
|
||||||
|
pub use crate::wasi::{
|
||||||
|
AddrUnspec, AddrUnspecPort, CidrUnspec, HttpHandles, HttpStatus, RiFlags, RoFlags, SdFlags,
|
||||||
|
SiFlags, SockProto, Timeout,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_hardwareaddress_t {
|
||||||
|
pub octs: [u8; 6],
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_addr_ip4_t {
|
||||||
|
pub octs: [u8; 4],
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_addr_ip4_port_t {
|
||||||
|
pub port: u16,
|
||||||
|
pub ip: __wasi_addr_ip4_t,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_cidr_ip4_t {
|
||||||
|
pub ip: __wasi_addr_ip4_t,
|
||||||
|
pub prefix: u8,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_addr_unix_t {
|
||||||
|
pub octs: [u8; 16],
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_addr_unix_port_t {
|
||||||
|
pub port: u16,
|
||||||
|
pub unix: __wasi_addr_unix_t,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_cidr_unix_t {
|
||||||
|
pub unix: __wasi_addr_unix_t,
|
||||||
|
pub prefix: u8,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_addr_ip6_t {
|
||||||
|
pub segs: [u8; 16],
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_addr_ip6_port_t {
|
||||||
|
pub port: u16,
|
||||||
|
pub ip: __wasi_addr_ip6_t,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_cidr_ip6_t {
|
||||||
|
pub ip: __wasi_addr_ip6_t,
|
||||||
|
pub prefix: u8,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_addr_u {
|
||||||
|
pub octs: [u8; 16],
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_addr_t {
|
||||||
|
pub tag: Addressfamily,
|
||||||
|
pub u: __wasi_addr_u,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_addr_port_u {
|
||||||
|
pub octs: [u8; 18],
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_addr_port_t {
|
||||||
|
pub tag: Addressfamily,
|
||||||
|
pub u: __wasi_addr_port_u,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_cidr_u {
|
||||||
|
pub octs: [u8; 17],
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct __wasi_cidr_t {
|
||||||
|
pub tag: Addressfamily,
|
||||||
|
pub u: __wasi_cidr_u,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, ValueType)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct Route {
|
||||||
|
pub cidr: __wasi_cidr_t,
|
||||||
|
pub via_router: __wasi_addr_t,
|
||||||
|
pub preferred_until: OptionTimestamp,
|
||||||
|
pub expires_at: OptionTimestamp,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const __WASI_SOCK_RECV_INPUT_PEEK: RiFlags = 1 << 0;
|
||||||
|
pub const __WASI_SOCK_RECV_INPUT_WAITALL: RiFlags = 1 << 1;
|
||||||
|
pub const __WASI_SOCK_RECV_INPUT_DATA_TRUNCATED: RiFlags = 1 << 2;
|
||||||
|
|
||||||
|
pub const __WASI_SOCK_RECV_OUTPUT_DATA_TRUNCATED: RoFlags = 1 << 0;
|
||||||
|
|
||||||
|
pub const __WASI_SHUT_RD: SdFlags = 1 << 0;
|
||||||
|
pub const __WASI_SHUT_WR: SdFlags = 1 << 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod signal {
|
||||||
|
pub use crate::wasi::Signal;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod subscription {
|
||||||
|
pub use crate::wasi::{
|
||||||
|
Eventtype, SubscriptionClock, SubscriptionEnum as EventType, SubscriptionFsReadwrite,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
pub mod snapshot0;
|
|
||||||
@@ -1,151 +0,0 @@
|
|||||||
use crate::*;
|
|
||||||
#[cfg(feature = "enable-serde")]
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::fmt;
|
|
||||||
use std::mem::{self, MaybeUninit};
|
|
||||||
use wasmer_derive::ValueType;
|
|
||||||
use wasmer_types::ValueType;
|
|
||||||
|
|
||||||
pub type __wasi_linkcount_t = u32;
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_subscription_clock_t {
|
|
||||||
pub userdata: __wasi_userdata_t,
|
|
||||||
pub clock_id: __wasi_clockid_t,
|
|
||||||
pub timeout: __wasi_timestamp_t,
|
|
||||||
pub precision: __wasi_timestamp_t,
|
|
||||||
pub flags: __wasi_subclockflags_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub union __wasi_subscription_u {
|
|
||||||
pub clock: __wasi_subscription_clock_t,
|
|
||||||
pub fd_readwrite: __wasi_subscription_fs_readwrite_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_subscription_t {
|
|
||||||
pub userdata: __wasi_userdata_t,
|
|
||||||
pub type_: __wasi_eventtype_t,
|
|
||||||
pub u: __wasi_subscription_u,
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl ValueType for __wasi_subscription_t {
|
|
||||||
fn zero_padding_bytes(&self, bytes: &mut [MaybeUninit<u8>]) {
|
|
||||||
macro_rules! field {
|
|
||||||
($($f:tt)*) => {
|
|
||||||
&self.$($f)* as *const _ as usize - self as *const _ as usize
|
|
||||||
};
|
|
||||||
}
|
|
||||||
macro_rules! field_end {
|
|
||||||
($($f:tt)*) => {
|
|
||||||
field!($($f)*) + mem::size_of_val(&self.$($f)*)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
macro_rules! zero {
|
|
||||||
($start:expr, $end:expr) => {
|
|
||||||
for i in $start..$end {
|
|
||||||
bytes[i] = MaybeUninit::new(0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
self.userdata
|
|
||||||
.zero_padding_bytes(&mut bytes[field!(userdata)..field_end!(userdata)]);
|
|
||||||
zero!(field_end!(userdata), field!(type_));
|
|
||||||
self.type_
|
|
||||||
.zero_padding_bytes(&mut bytes[field!(type_)..field_end!(type_)]);
|
|
||||||
zero!(field_end!(type_), field!(u));
|
|
||||||
match self.type_ {
|
|
||||||
__WASI_EVENTTYPE_FD_READ | __WASI_EVENTTYPE_FD_WRITE => unsafe {
|
|
||||||
self.u.fd_readwrite.zero_padding_bytes(
|
|
||||||
&mut bytes[field!(u.fd_readwrite)..field_end!(u.fd_readwrite)],
|
|
||||||
);
|
|
||||||
zero!(field_end!(u.fd_readwrite), field_end!(u));
|
|
||||||
},
|
|
||||||
__WASI_EVENTTYPE_CLOCK => unsafe {
|
|
||||||
self.u
|
|
||||||
.clock
|
|
||||||
.zero_padding_bytes(&mut bytes[field!(u.clock)..field_end!(u.clock)]);
|
|
||||||
zero!(field_end!(u.clock), field_end!(u));
|
|
||||||
},
|
|
||||||
_ => zero!(field!(u), field_end!(u)),
|
|
||||||
}
|
|
||||||
zero!(field_end!(u), mem::size_of_val(self));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type __wasi_whence_t = u8;
|
|
||||||
pub const __WASI_WHENCE_CUR: u8 = 0;
|
|
||||||
pub const __WASI_WHENCE_END: u8 = 1;
|
|
||||||
pub const __WASI_WHENCE_SET: u8 = 2;
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, ValueType)]
|
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct __wasi_filestat_t {
|
|
||||||
pub st_dev: __wasi_device_t,
|
|
||||||
pub st_ino: __wasi_inode_t,
|
|
||||||
pub st_filetype: __wasi_filetype_t,
|
|
||||||
pub st_nlink: __wasi_linkcount_t,
|
|
||||||
pub st_size: __wasi_filesize_t,
|
|
||||||
pub st_atim: __wasi_timestamp_t,
|
|
||||||
pub st_mtim: __wasi_timestamp_t,
|
|
||||||
pub st_ctim: __wasi_timestamp_t,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for __wasi_filestat_t {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
let convert_ts_into_time_string = |ts| {
|
|
||||||
let tspec = ::time::OffsetDateTime::from_unix_timestamp_nanos(ts);
|
|
||||||
format!("{} ({})", tspec.format("%a, %d %b %Y %T %z"), ts)
|
|
||||||
};
|
|
||||||
f.debug_struct("__wasi_filestat_t")
|
|
||||||
.field("st_dev", &self.st_dev)
|
|
||||||
.field("st_ino", &self.st_ino)
|
|
||||||
.field(
|
|
||||||
"st_filetype",
|
|
||||||
&format!(
|
|
||||||
"{} ({})",
|
|
||||||
wasi_filetype_to_name(self.st_filetype),
|
|
||||||
self.st_filetype,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.field("st_nlink", &self.st_nlink)
|
|
||||||
.field("st_size", &self.st_size)
|
|
||||||
.field(
|
|
||||||
"st_atim",
|
|
||||||
&convert_ts_into_time_string(self.st_atim as i128),
|
|
||||||
)
|
|
||||||
.field(
|
|
||||||
"st_mtim",
|
|
||||||
&convert_ts_into_time_string(self.st_mtim as i128),
|
|
||||||
)
|
|
||||||
.field(
|
|
||||||
"st_ctim",
|
|
||||||
&convert_ts_into_time_string(self.st_ctim as i128),
|
|
||||||
)
|
|
||||||
.finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for __wasi_subscription_t {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
f.debug_struct("__wasi_subscription_t")
|
|
||||||
.field("userdata", &self.userdata)
|
|
||||||
.field("type", &eventtype_to_str(self.type_))
|
|
||||||
.field(
|
|
||||||
"u",
|
|
||||||
match self.type_ {
|
|
||||||
__WASI_EVENTTYPE_CLOCK => unsafe { &self.u.clock },
|
|
||||||
__WASI_EVENTTYPE_FD_READ | __WASI_EVENTTYPE_FD_WRITE => unsafe {
|
|
||||||
&self.u.fd_readwrite
|
|
||||||
},
|
|
||||||
_ => &"INVALID EVENTTYPE",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
2998
lib/wasi-types/src/wasi/bindings.rs
Normal file
2998
lib/wasi-types/src/wasi/bindings.rs
Normal file
File diff suppressed because it is too large
Load Diff
3982
lib/wasi-types/src/wasi/extra.rs
Normal file
3982
lib/wasi-types/src/wasi/extra.rs
Normal file
File diff suppressed because it is too large
Load Diff
328
lib/wasi-types/src/wasi/extra_manual.rs
Normal file
328
lib/wasi-types/src/wasi/extra_manual.rs
Normal file
@@ -0,0 +1,328 @@
|
|||||||
|
use crate::wasi::extra::*;
|
||||||
|
|
||||||
|
impl Rights {
|
||||||
|
pub const fn all_socket() -> Self {
|
||||||
|
Self::from_bits_truncate(
|
||||||
|
Self::FD_FDSTAT_SET_FLAGS.bits()
|
||||||
|
| Self::FD_FILESTAT_GET.bits()
|
||||||
|
| Self::FD_READ.bits()
|
||||||
|
| Self::FD_WRITE.bits()
|
||||||
|
| Self::POLL_FD_READWRITE.bits()
|
||||||
|
| Self::SOCK_SHUTDOWN.bits()
|
||||||
|
| Self::SOCK_CONNECT.bits()
|
||||||
|
| Self::SOCK_LISTEN.bits()
|
||||||
|
| Self::SOCK_BIND.bits()
|
||||||
|
| Self::SOCK_ACCEPT.bits()
|
||||||
|
| Self::SOCK_RECV.bits()
|
||||||
|
| Self::SOCK_SEND.bits()
|
||||||
|
| Self::SOCK_ADDR_LOCAL.bits()
|
||||||
|
| Self::SOCK_ADDR_REMOTE.bits()
|
||||||
|
| Self::SOCK_RECV_FROM.bits()
|
||||||
|
| Self::SOCK_SEND_TO.bits(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// expects a single right, returns None if out of bounds or > 1 bit set
|
||||||
|
pub fn to_str(self) -> Option<&'static str> {
|
||||||
|
Some(match self {
|
||||||
|
Rights::FD_DATASYNC => "Rights::FD_DATASYNC",
|
||||||
|
Rights::FD_READ => "Rights::FD_READ",
|
||||||
|
Rights::FD_SEEK => "Rights::FD_SEEK",
|
||||||
|
Rights::FD_FDSTAT_SET_FLAGS => "Rights::FD_FDSTAT_SET_FLAGS",
|
||||||
|
Rights::FD_SYNC => "Rights::FD_SYNC",
|
||||||
|
Rights::FD_TELL => "Rights::FD_TELL",
|
||||||
|
Rights::FD_WRITE => "Rights::FD_WRITE",
|
||||||
|
Rights::FD_ADVISE => "Rights::FD_ADVISE",
|
||||||
|
Rights::FD_ALLOCATE => "Rights::FD_ALLOCATE",
|
||||||
|
Rights::PATH_CREATE_DIRECTORY => "Rights::PATH_CREATE_DIRECTORY",
|
||||||
|
Rights::PATH_CREATE_FILE => "Rights::PATH_CREATE_FILE",
|
||||||
|
Rights::PATH_LINK_SOURCE => "Rights::PATH_LINK_SOURCE",
|
||||||
|
Rights::PATH_LINK_TARGET => "Rights::PATH_LINK_TARGET",
|
||||||
|
Rights::PATH_OPEN => "Rights::PATH_OPEN",
|
||||||
|
Rights::FD_READDIR => "Rights::FD_READDIR",
|
||||||
|
Rights::PATH_READLINK => "Rights::PATH_READLINK",
|
||||||
|
Rights::PATH_RENAME_SOURCE => "Rights::PATH_RENAME_SOURCE",
|
||||||
|
Rights::PATH_RENAME_TARGET => "Rights::PATH_RENAME_TARGET",
|
||||||
|
Rights::PATH_FILESTAT_GET => "Rights::PATH_FILESTAT_GET",
|
||||||
|
Rights::PATH_FILESTAT_SET_SIZE => "Rights::PATH_FILESTAT_SET_SIZE",
|
||||||
|
Rights::PATH_FILESTAT_SET_TIMES => "Rights::PATH_FILESTAT_SET_TIMES",
|
||||||
|
Rights::FD_FILESTAT_GET => "Rights::FD_FILESTAT_GET",
|
||||||
|
Rights::FD_FILESTAT_SET_SIZE => "Rights::FD_FILESTAT_SET_SIZE",
|
||||||
|
Rights::FD_FILESTAT_SET_TIMES => "Rights::FD_FILESTAT_SET_TIMES",
|
||||||
|
Rights::PATH_SYMLINK => "Rights::PATH_SYMLINK",
|
||||||
|
Rights::PATH_REMOVE_DIRECTORY => "Rights::PATH_REMOVE_DIRECTORY",
|
||||||
|
Rights::PATH_UNLINK_FILE => "Rights::PATH_UNLINK_FILE",
|
||||||
|
Rights::POLL_FD_READWRITE => "Rights::POLL_FD_READWRITE",
|
||||||
|
Rights::SOCK_SHUTDOWN => "Rights::SOCK_SHUTDOWN",
|
||||||
|
Rights::SOCK_ACCEPT => "Rights::SOCK_ACCEPT",
|
||||||
|
Rights::SOCK_CONNECT => "Rights::SOCK_CONNECT",
|
||||||
|
Rights::SOCK_LISTEN => "Rights::SOCK_LISTEN",
|
||||||
|
Rights::SOCK_BIND => "Rights::SOCK_BIND",
|
||||||
|
Rights::SOCK_RECV => "Rights::SOCK_RECV",
|
||||||
|
Rights::SOCK_SEND => "Rights::SOCK_SEND",
|
||||||
|
Rights::SOCK_ADDR_LOCAL => "Rights::SOCK_ADDR_LOCAL",
|
||||||
|
Rights::SOCK_ADDR_REMOTE => "Rights::SOCK_ADDR_REMOTE",
|
||||||
|
Rights::SOCK_RECV_FROM => "Rights::SOCK_RECV_FROM",
|
||||||
|
Rights::SOCK_SEND_TO => "Rights::SOCK_SEND_TO",
|
||||||
|
_ => return None,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Filestat {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
st_dev: Default::default(),
|
||||||
|
st_ino: Default::default(),
|
||||||
|
st_filetype: Filetype::Unknown,
|
||||||
|
st_nlink: 1,
|
||||||
|
st_size: Default::default(),
|
||||||
|
st_atim: Default::default(),
|
||||||
|
st_mtim: Default::default(),
|
||||||
|
st_ctim: Default::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Workaround implementation because `wit-bindgen` does not generate
|
||||||
|
/// type aliases, but instead creates the same filetype in each module
|
||||||
|
/// for `use` statements in the `.wit` file.
|
||||||
|
impl From<Clockid> for Snapshot0Clockid {
|
||||||
|
fn from(other: Clockid) -> Self {
|
||||||
|
match other {
|
||||||
|
Clockid::Realtime => Self::Realtime,
|
||||||
|
Clockid::Monotonic => Self::Monotonic,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Snapshot0Clockid> for Clockid {
|
||||||
|
fn from(other: Snapshot0Clockid) -> Self {
|
||||||
|
match other {
|
||||||
|
Snapshot0Clockid::Realtime => Self::Realtime,
|
||||||
|
Snapshot0Clockid::Monotonic => Self::Monotonic,
|
||||||
|
Snapshot0Clockid::ProcessCputimeId => todo!("not implemented for now"),
|
||||||
|
Snapshot0Clockid::ThreadCputimeId => todo!("not implemented for now"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Snapshot0SubscriptionClock> for SubscriptionClock {
|
||||||
|
fn from(other: Snapshot0SubscriptionClock) -> Self {
|
||||||
|
// TODO: this removes Snapshot0SubscriptionClock::identifier, I don't
|
||||||
|
// think this is how it should be
|
||||||
|
Self {
|
||||||
|
clock_id: Clockid::from(other.id),
|
||||||
|
timeout: other.timeout,
|
||||||
|
precision: other.precision,
|
||||||
|
flags: other.flags,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Snapshot0SubscriptionEnum> for SubscriptionEnum {
|
||||||
|
fn from(other: Snapshot0SubscriptionEnum) -> Self {
|
||||||
|
match other {
|
||||||
|
Snapshot0SubscriptionEnum::Clock(d) => Self::Clock(SubscriptionClock::from(d)),
|
||||||
|
Snapshot0SubscriptionEnum::Read(d) => Self::Read(d),
|
||||||
|
Snapshot0SubscriptionEnum::Write(d) => Self::Write(d),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Snapshot0Subscription> for Subscription {
|
||||||
|
fn from(other: Snapshot0Subscription) -> Self {
|
||||||
|
Self {
|
||||||
|
userdata: other.userdata,
|
||||||
|
data: SubscriptionEnum::from(other.data),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Display for BusDataFormat {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{:?}", self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Display for Sockoption {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
let s = match *self {
|
||||||
|
Self::Noop => "Sockoption::Noop",
|
||||||
|
Self::ReusePort => "Sockoption::ReusePort",
|
||||||
|
Self::ReuseAddr => "Sockoption::ReuseAddr",
|
||||||
|
Self::NoDelay => "Sockoption::NoDelay",
|
||||||
|
Self::DontRoute => "Sockoption::DontRoute",
|
||||||
|
Self::OnlyV6 => "Sockoption::OnlyV6",
|
||||||
|
Self::Broadcast => "Sockoption::Broadcast",
|
||||||
|
Self::MulticastLoopV4 => "Sockoption::MulticastLoopV4",
|
||||||
|
Self::MulticastLoopV6 => "Sockoption::MulticastLoopV6",
|
||||||
|
Self::Promiscuous => "Sockoption::Promiscuous",
|
||||||
|
Self::Listening => "Sockoption::Listening",
|
||||||
|
Self::LastError => "Sockoption::LastError",
|
||||||
|
Self::KeepAlive => "Sockoption::KeepAlive",
|
||||||
|
Self::Linger => "Sockoption::Linger",
|
||||||
|
Self::OobInline => "Sockoption::OobInline",
|
||||||
|
Self::RecvBufSize => "Sockoption::RecvBufSize",
|
||||||
|
Self::SendBufSize => "Sockoption::SendBufSize",
|
||||||
|
Self::RecvLowat => "Sockoption::RecvLowat",
|
||||||
|
Self::SendLowat => "Sockoption::SendLowat",
|
||||||
|
Self::RecvTimeout => "Sockoption::RecvTimeout",
|
||||||
|
Self::SendTimeout => "Sockoption::SendTimeout",
|
||||||
|
Self::ConnectTimeout => "Sockoption::ConnectTimeout",
|
||||||
|
Self::AcceptTimeout => "Sockoption::AcceptTimeout",
|
||||||
|
Self::Ttl => "Sockoption::Ttl",
|
||||||
|
Self::MulticastTtlV4 => "Sockoption::MulticastTtlV4",
|
||||||
|
Self::Type => "Sockoption::Type",
|
||||||
|
Self::Proto => "Sockoption::Proto",
|
||||||
|
};
|
||||||
|
write!(f, "{}", s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: if necessary, must be implemented in wit-bindgen
|
||||||
|
unsafe impl wasmer::FromToNativeWasmType for Fdflags {
|
||||||
|
type Native = i32;
|
||||||
|
|
||||||
|
fn to_native(self) -> Self::Native {
|
||||||
|
self.bits() as i32
|
||||||
|
}
|
||||||
|
fn from_native(n: Self::Native) -> Self {
|
||||||
|
Self::from_bits_truncate(n as u16)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_from_store(&self, _store: &impl wasmer::AsStoreRef) -> bool {
|
||||||
|
// TODO: find correct implementation
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: if necessary, must be implemented in wit-bindgen
|
||||||
|
unsafe impl wasmer::FromToNativeWasmType for Rights {
|
||||||
|
type Native = i64;
|
||||||
|
|
||||||
|
fn to_native(self) -> Self::Native {
|
||||||
|
self.bits() as i64
|
||||||
|
}
|
||||||
|
|
||||||
|
fn from_native(n: Self::Native) -> Self {
|
||||||
|
Self::from_bits_truncate(n as u64)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_from_store(&self, _store: &impl wasmer::AsStoreRef) -> bool {
|
||||||
|
// TODO: find correct implementation
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: if necessary, must be implemented in wit-bindgen
|
||||||
|
unsafe impl wasmer::FromToNativeWasmType for Fstflags {
|
||||||
|
type Native = i32;
|
||||||
|
|
||||||
|
fn to_native(self) -> Self::Native {
|
||||||
|
self.bits() as i32
|
||||||
|
}
|
||||||
|
fn from_native(n: Self::Native) -> Self {
|
||||||
|
Self::from_bits_truncate(n as u16)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_from_store(&self, _store: &impl wasmer::AsStoreRef) -> bool {
|
||||||
|
// TODO: find correct implementation
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: if necessary, must be implemented in wit-bindgen
|
||||||
|
unsafe impl wasmer::FromToNativeWasmType for Oflags {
|
||||||
|
type Native = i32;
|
||||||
|
|
||||||
|
fn to_native(self) -> Self::Native {
|
||||||
|
self.bits() as i32
|
||||||
|
}
|
||||||
|
fn from_native(n: Self::Native) -> Self {
|
||||||
|
Self::from_bits_truncate(n as u16)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_from_store(&self, _store: &impl wasmer::AsStoreRef) -> bool {
|
||||||
|
// TODO: find correct implementation
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq for OptionCid {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.tag == other.tag && self.cid == other.cid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Eq for OptionCid {}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub enum PrestatEnum {
|
||||||
|
Dir { pr_name_len: u32 },
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PrestatEnum {
|
||||||
|
pub fn untagged(self) -> PrestatU {
|
||||||
|
match self {
|
||||||
|
PrestatEnum::Dir { pr_name_len } => PrestatU {
|
||||||
|
dir: PrestatUDir { pr_name_len },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Prestat {
|
||||||
|
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||||
|
pub fn tagged(&self) -> Option<PrestatEnum> {
|
||||||
|
match self.pr_type {
|
||||||
|
Preopentype::Dir => Some(PrestatEnum::Dir {
|
||||||
|
pr_name_len: self.u.dir.pr_name_len,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl wasmer::ValueType for Prestat {
|
||||||
|
fn zero_padding_bytes(&self, bytes: &mut [core::mem::MaybeUninit<u8>]) {
|
||||||
|
macro_rules! field {
|
||||||
|
($($f:tt)*) => {
|
||||||
|
&self.$($f)* as *const _ as usize - self as *const _ as usize
|
||||||
|
};
|
||||||
|
}
|
||||||
|
macro_rules! field_end {
|
||||||
|
($($f:tt)*) => {
|
||||||
|
field!($($f)*) + core::mem::size_of_val(&self.$($f)*)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
macro_rules! zero {
|
||||||
|
($start:expr, $end:expr) => {
|
||||||
|
for i in $start..$end {
|
||||||
|
bytes[i] = core::mem::MaybeUninit::new(0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
self.pr_type
|
||||||
|
.zero_padding_bytes(&mut bytes[field!(pr_type)..field_end!(pr_type)]);
|
||||||
|
zero!(field_end!(pr_type), field!(u));
|
||||||
|
match self.pr_type {
|
||||||
|
Preopentype::Dir => {
|
||||||
|
self.u
|
||||||
|
.dir
|
||||||
|
.zero_padding_bytes(&mut bytes[field!(u.dir)..field_end!(u.dir)]);
|
||||||
|
zero!(field_end!(u.dir), field_end!(u));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zero!(field_end!(u), core::mem::size_of_val(self));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SubscriptionEnum {
|
||||||
|
pub fn raw_tag(&self) -> Eventtype {
|
||||||
|
match self {
|
||||||
|
SubscriptionEnum::Clock(_) => Eventtype::Clock,
|
||||||
|
SubscriptionEnum::Read(_) => Eventtype::FdRead,
|
||||||
|
SubscriptionEnum::Write(_) => Eventtype::FdWrite,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
4
lib/wasi-types/src/wasi/mod.rs
Normal file
4
lib/wasi-types/src/wasi/mod.rs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
pub(crate) mod extra;
|
||||||
|
pub(crate) mod extra_manual;
|
||||||
|
pub use extra::*;
|
||||||
|
pub use extra_manual::*;
|
||||||
1
lib/wasi-types/wasi-types-generator-extra/.gitignore
vendored
Normal file
1
lib/wasi-types/wasi-types-generator-extra/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
target/
|
||||||
14
lib/wasi-types/wasi-types-generator-extra/Cargo.toml
Normal file
14
lib/wasi-types/wasi-types-generator-extra/Cargo.toml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[package]
|
||||||
|
name = "wasi-types-generator-extra"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
license = "MIT"
|
||||||
|
description = "Generator for wasi-types"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
convert_case = "0.5.0"
|
||||||
|
|
||||||
|
[dependencies.wit-parser]
|
||||||
|
default-features = false
|
||||||
|
package = "wasmer-wit-parser"
|
||||||
|
version = "0.1.1"
|
||||||
152
lib/wasi-types/wasi-types-generator-extra/src/main.rs
Normal file
152
lib/wasi-types/wasi-types-generator-extra/src/main.rs
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
//! This generator is run when regenerate.sh is executed and fixes a couple
|
||||||
|
//! of issues that wit-bindgen currently doesn't support.
|
||||||
|
//!
|
||||||
|
//! Eventually this functionality should be upstreamed into wit-bindgen,
|
||||||
|
//! see issue [#3177](https://github.com/wasmerio/wasmer/issues/3177).
|
||||||
|
|
||||||
|
use convert_case::{Case, Casing};
|
||||||
|
use wit_parser::TypeDefKind;
|
||||||
|
|
||||||
|
const WIT_1: &str = include_str!("../../wit-clean/output.wit");
|
||||||
|
const BINDINGS_RS: &str = include_str!("../../src/wasi/bindings.rs");
|
||||||
|
|
||||||
|
fn replace_in_string(s: &str, id: &str, ty: &str) -> String {
|
||||||
|
let parts = s.split(&format!("impl {id} {{")).collect::<Vec<_>>();
|
||||||
|
if parts.len() == 1 {
|
||||||
|
return s.to_string();
|
||||||
|
}
|
||||||
|
let replaced = parts[1].replacen(
|
||||||
|
"from_bits_preserve(bits: u8)",
|
||||||
|
&format!("from_bits_preserve(bits: {ty})"),
|
||||||
|
1,
|
||||||
|
);
|
||||||
|
format!("{}impl {id} {{ {replaced}", parts[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut bindings_rs = BINDINGS_RS
|
||||||
|
.replace("#[allow(clippy::all)]", "")
|
||||||
|
.replace("pub mod output {", "")
|
||||||
|
.replace("mod output {", "")
|
||||||
|
.replace("pub struct Rights: u8 {", "pub struct Rights: u64 {")
|
||||||
|
.replace("pub struct Lookup: u8 {", "pub struct Lookup: u32 {")
|
||||||
|
.replace("pub struct Oflags: u8 {", "pub struct Oflags: u16 {")
|
||||||
|
.replace(
|
||||||
|
"pub struct Subclockflags: u8 {",
|
||||||
|
"pub struct Subclockflags: u16 {",
|
||||||
|
)
|
||||||
|
.replace(
|
||||||
|
"pub struct Eventrwflags: u8 {",
|
||||||
|
"pub struct Eventrwflags: u16 {",
|
||||||
|
)
|
||||||
|
.replace("pub struct Fstflags: u8 {", "pub struct Fstflags: u16 {")
|
||||||
|
.replace("pub struct Fdflags: u8 {", "pub struct Fdflags: u16 {");
|
||||||
|
|
||||||
|
bindings_rs = replace_in_string(&bindings_rs, "Oflags", "u16");
|
||||||
|
bindings_rs = replace_in_string(&bindings_rs, "Subclockflags", "u16");
|
||||||
|
bindings_rs = replace_in_string(&bindings_rs, "Eventrwflags", "u16");
|
||||||
|
bindings_rs = replace_in_string(&bindings_rs, "Fstflags", "u16");
|
||||||
|
bindings_rs = replace_in_string(&bindings_rs, "Fdflags", "u16");
|
||||||
|
bindings_rs = replace_in_string(&bindings_rs, "Lookup", "u32");
|
||||||
|
bindings_rs = replace_in_string(&bindings_rs, "Rights", "u64");
|
||||||
|
|
||||||
|
let mut bindings_rs = bindings_rs.lines().collect::<Vec<_>>();
|
||||||
|
bindings_rs.pop();
|
||||||
|
let bindings_rs = bindings_rs.join("\n");
|
||||||
|
|
||||||
|
let target_path = env!("CARGO_MANIFEST_DIR");
|
||||||
|
let path = std::path::Path::new(&target_path)
|
||||||
|
.parent()
|
||||||
|
.unwrap()
|
||||||
|
.join("src")
|
||||||
|
.join("wasi")
|
||||||
|
.join("extra.rs");
|
||||||
|
let result = wit_parser::Interface::parse("output.wit", WIT_1).unwrap();
|
||||||
|
let mut contents = format!(
|
||||||
|
"
|
||||||
|
use std::mem::MaybeUninit;
|
||||||
|
use wasmer::ValueType;
|
||||||
|
|
||||||
|
{bindings_rs}
|
||||||
|
|
||||||
|
"
|
||||||
|
)
|
||||||
|
.replace(" ", "");
|
||||||
|
|
||||||
|
println!("output to {}", path.display());
|
||||||
|
|
||||||
|
let excluded_from_impl_valuetype = ["Prestat"];
|
||||||
|
|
||||||
|
for (_, i) in result.types.iter() {
|
||||||
|
match i.kind {
|
||||||
|
| TypeDefKind::Record(_)
|
||||||
|
| TypeDefKind::Flags(_)
|
||||||
|
| TypeDefKind::Tuple(_)
|
||||||
|
| TypeDefKind::Variant(_)
|
||||||
|
| TypeDefKind::Enum(_)
|
||||||
|
| TypeDefKind::Option(_)
|
||||||
|
| TypeDefKind::Expected(_)
|
||||||
|
| TypeDefKind::Union(_)
|
||||||
|
| TypeDefKind::List(_)
|
||||||
|
| TypeDefKind::Future(_)
|
||||||
|
| TypeDefKind::Stream(_)
|
||||||
|
// | TypeDefKind::Type(_)
|
||||||
|
=> {
|
||||||
|
let name = i.name.clone().unwrap_or_default().to_case(Case::Pascal);
|
||||||
|
if excluded_from_impl_valuetype.iter().any(|s| *s == name.as_str()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
contents.push_str(&format!("
|
||||||
|
// TODO: if necessary, must be implemented in wit-bindgen
|
||||||
|
unsafe impl ValueType for {name} {{
|
||||||
|
#[inline]
|
||||||
|
fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>]) {{ }}
|
||||||
|
}}
|
||||||
|
|
||||||
|
").replace(" ", ""))
|
||||||
|
},
|
||||||
|
_ => { }
|
||||||
|
}
|
||||||
|
|
||||||
|
let name = i.name.clone().unwrap_or_default().to_case(Case::Pascal);
|
||||||
|
|
||||||
|
if let wit_parser::TypeDefKind::Enum(e) = &i.kind {
|
||||||
|
contents.push_str(
|
||||||
|
&format!(
|
||||||
|
"
|
||||||
|
unsafe impl wasmer::FromToNativeWasmType for {name} {{
|
||||||
|
type Native = i32;
|
||||||
|
|
||||||
|
fn to_native(self) -> Self::Native {{
|
||||||
|
self as i32
|
||||||
|
}}
|
||||||
|
|
||||||
|
fn from_native(n: Self::Native) -> Self {{
|
||||||
|
match n {{\n"
|
||||||
|
)
|
||||||
|
.replace(" ", ""),
|
||||||
|
);
|
||||||
|
|
||||||
|
for (i, case) in e.cases.iter().enumerate() {
|
||||||
|
contents.push_str(&format!(
|
||||||
|
" {i} => Self::{},\n",
|
||||||
|
case.name.to_case(Case::Pascal)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
contents.push_str(
|
||||||
|
&format!(
|
||||||
|
"
|
||||||
|
q => todo!(\"could not serialize number {{q}} to enum {name}\"),
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
|
||||||
|
fn is_from_store(&self, _store: &impl wasmer::AsStoreRef) -> bool {{ false }}
|
||||||
|
}}
|
||||||
|
"
|
||||||
|
)
|
||||||
|
.replace(" ", ""),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::fs::write(path, contents).unwrap();
|
||||||
|
}
|
||||||
1750
lib/wasi-types/wit-clean/output.wit
Normal file
1750
lib/wasi-types/wit-clean/output.wit
Normal file
File diff suppressed because it is too large
Load Diff
1239
lib/wasi-types/wit-clean/typenames.wit
Normal file
1239
lib/wasi-types/wit-clean/typenames.wit
Normal file
File diff suppressed because it is too large
Load Diff
512
lib/wasi-types/wit-clean/wasi_unstable.wit
Normal file
512
lib/wasi-types/wit-clean/wasi_unstable.wit
Normal file
@@ -0,0 +1,512 @@
|
|||||||
|
// WASI Preview. This is an evolution of the API that WASI initially
|
||||||
|
// launched with.
|
||||||
|
//
|
||||||
|
// Some content here is derived from [CloudABI](https://github.com/NuxiNL/cloudabi).
|
||||||
|
|
||||||
|
/// This API predated the convention of naming modules with a `wasi_unstable_`
|
||||||
|
/// prefix and a version number. It is preserved here for compatibility, but
|
||||||
|
/// we shouldn't follow this pattern in new APIs.
|
||||||
|
/*
|
||||||
|
(module $wasi_unstable
|
||||||
|
/// Linear memory to be accessed by WASI functions that need it.
|
||||||
|
(import "memory" (memory))
|
||||||
|
|
||||||
|
/// Read command-line argument data.
|
||||||
|
/// The size of the array should match that returned by `args_sizes_get`.
|
||||||
|
/// Each argument is expected to be `\0` terminated.
|
||||||
|
(@interface func (export "args_get")
|
||||||
|
(param $argv (@witx pointer (@witx pointer u8)))
|
||||||
|
(param $argv_buf (@witx pointer u8))
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Return command-line argument data sizes.
|
||||||
|
(@interface func (export "args_sizes_get")
|
||||||
|
/// Returns the number of arguments and the size of the argument string
|
||||||
|
/// data, or an error.
|
||||||
|
(result $error (expected (tuple $size $size) (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Read environment variable data.
|
||||||
|
/// The sizes of the buffers should match that returned by `environ_sizes_get`.
|
||||||
|
/// Key/value pairs are expected to be joined with `=`s, and terminated with `\0`s.
|
||||||
|
(@interface func (export "environ_get")
|
||||||
|
(param $environ (@witx pointer (@witx pointer u8)))
|
||||||
|
(param $environ_buf (@witx pointer u8))
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Return environment variable data sizes.
|
||||||
|
(@interface func (export "environ_sizes_get")
|
||||||
|
/// Returns the number of environment variable arguments and the size of the
|
||||||
|
/// environment variable data.
|
||||||
|
(result $error (expected (tuple $size $size) (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Return the resolution of a clock.
|
||||||
|
/// Implementations are required to provide a non-zero value for supported clocks. For unsupported clocks, return
|
||||||
|
/// `errno::inval`.
|
||||||
|
/// Note: This is similar to `clock_getres` in POSIX.
|
||||||
|
(@interface func (export "clock_res_get")
|
||||||
|
/// The clock for which to return the resolution.
|
||||||
|
(param $id $clockid)
|
||||||
|
/// The resolution of the clock, or an error if one happened.
|
||||||
|
(result $error (expected $timestamp (error $errno)))
|
||||||
|
)
|
||||||
|
/// Return the time value of a clock.
|
||||||
|
/// Note: This is similar to `clock_gettime` in POSIX.
|
||||||
|
(@interface func (export "clock_time_get")
|
||||||
|
/// The clock for which to return the time.
|
||||||
|
(param $id $clockid)
|
||||||
|
/// The maximum lag (exclusive) that the returned time value may have, compared to its actual value.
|
||||||
|
(param $precision $timestamp)
|
||||||
|
/// The time value of the clock.
|
||||||
|
(result $error (expected $timestamp (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Provide file advisory information on a file descriptor.
|
||||||
|
/// Note: This is similar to `posix_fadvise` in POSIX.
|
||||||
|
(@interface func (export "fd_advise")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// The offset within the file to which the advisory applies.
|
||||||
|
(param $offset $filesize)
|
||||||
|
/// The length of the region to which the advisory applies.
|
||||||
|
(param $len $filesize)
|
||||||
|
/// The advice.
|
||||||
|
(param $advice $advice)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Force the allocation of space in a file.
|
||||||
|
/// Note: This is similar to `posix_fallocate` in POSIX.
|
||||||
|
(@interface func (export "fd_allocate")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// The offset at which to start the allocation.
|
||||||
|
(param $offset $filesize)
|
||||||
|
/// The length of the area that is allocated.
|
||||||
|
(param $len $filesize)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Close a file descriptor.
|
||||||
|
/// Note: This is similar to `close` in POSIX.
|
||||||
|
(@interface func (export "fd_close")
|
||||||
|
(param $fd $fd)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Synchronize the data of a file to disk.
|
||||||
|
/// Note: This is similar to `fdatasync` in POSIX.
|
||||||
|
(@interface func (export "fd_datasync")
|
||||||
|
(param $fd $fd)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Get the attributes of a file descriptor.
|
||||||
|
/// Note: This returns similar flags to `fsync(fd, F_GETFL)` in POSIX, as well as additional fields.
|
||||||
|
(@interface func (export "fd_fdstat_get")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// The buffer where the file descriptor's attributes are stored.
|
||||||
|
(result $error (expected $fdstat (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Adjust the flags associated with a file descriptor.
|
||||||
|
/// Note: This is similar to `fcntl(fd, F_SETFL, flags)` in POSIX.
|
||||||
|
(@interface func (export "fd_fdstat_set_flags")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// The desired values of the file descriptor flags.
|
||||||
|
(param $flags $fdflags)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Adjust the rights associated with a file descriptor.
|
||||||
|
/// This can only be used to remove rights, and returns `errno::notcapable` if called in a way that would attempt to add rights
|
||||||
|
(@interface func (export "fd_fdstat_set_rights")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// The desired rights of the file descriptor.
|
||||||
|
(param $fs_rights_base $rights)
|
||||||
|
(param $fs_rights_inheriting $rights)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Return the attributes of an open file.
|
||||||
|
(@interface func (export "fd_filestat_get")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// The buffer where the file's attributes are stored.
|
||||||
|
(result $error (expected $filestat (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Adjust the size of an open file. If this increases the file's size, the extra bytes are filled with zeros.
|
||||||
|
/// Note: This is similar to `ftruncate` in POSIX.
|
||||||
|
(@interface func (export "fd_filestat_set_size")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// The desired file size.
|
||||||
|
(param $size $filesize)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Adjust the timestamps of an open file or directory.
|
||||||
|
/// Note: This is similar to `futimens` in POSIX.
|
||||||
|
(@interface func (export "fd_filestat_set_times")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// The desired values of the data access timestamp.
|
||||||
|
(param $atim $timestamp)
|
||||||
|
/// The desired values of the data modification timestamp.
|
||||||
|
(param $mtim $timestamp)
|
||||||
|
/// A bitmask indicating which timestamps to adjust.
|
||||||
|
(param $fst_flags $fstflags)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Read from a file descriptor, without using and updating the file descriptor's offset.
|
||||||
|
/// Note: This is similar to `preadv` in POSIX.
|
||||||
|
(@interface func (export "fd_pread")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// List of scatter/gather vectors in which to store data.
|
||||||
|
(param $iovs $iovec_array)
|
||||||
|
/// The offset within the file at which to read.
|
||||||
|
(param $offset $filesize)
|
||||||
|
/// The number of bytes read.
|
||||||
|
(result $error (expected $size (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Return a description of the given preopened file descriptor.
|
||||||
|
(@interface func (export "fd_prestat_get")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// The buffer where the description is stored.
|
||||||
|
(result $error (expected $prestat (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Return a description of the given preopened file descriptor.
|
||||||
|
(@interface func (export "fd_prestat_dir_name")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// A buffer into which to write the preopened directory name.
|
||||||
|
(param $path (@witx pointer u8))
|
||||||
|
(param $path_len $size)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Write to a file descriptor, without using and updating the file descriptor's offset.
|
||||||
|
/// Note: This is similar to `pwritev` in POSIX.
|
||||||
|
(@interface func (export "fd_pwrite")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// List of scatter/gather vectors from which to retrieve data.
|
||||||
|
(param $iovs $ciovec_array)
|
||||||
|
/// The offset within the file at which to write.
|
||||||
|
(param $offset $filesize)
|
||||||
|
/// The number of bytes written.
|
||||||
|
(result $error (expected $size (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Read from a file descriptor.
|
||||||
|
/// Note: This is similar to `readv` in POSIX.
|
||||||
|
(@interface func (export "fd_read")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// List of scatter/gather vectors to which to store data.
|
||||||
|
(param $iovs $iovec_array)
|
||||||
|
/// The number of bytes read.
|
||||||
|
(result $error (expected $size (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Read directory entries from a directory.
|
||||||
|
/// When successful, the contents of the output buffer consist of a sequence of
|
||||||
|
/// directory entries. Each directory entry consists of a `dirent` object,
|
||||||
|
/// followed by `dirent::d_namlen` bytes holding the name of the directory
|
||||||
|
/// entry.
|
||||||
|
///
|
||||||
|
/// This function fills the output buffer as much as possible, potentially
|
||||||
|
/// truncating the last directory entry. This allows the caller to grow its
|
||||||
|
/// read buffer size in case it's too small to fit a single large directory
|
||||||
|
/// entry, or skip the oversized directory entry.
|
||||||
|
(@interface func (export "fd_readdir")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// The buffer where directory entries are stored
|
||||||
|
(param $buf (@witx pointer u8))
|
||||||
|
(param $buf_len $size)
|
||||||
|
/// The location within the directory to start reading
|
||||||
|
(param $cookie $dircookie)
|
||||||
|
/// The number of bytes stored in the read buffer. If less than the size of the read buffer, the end of the directory has been reached.
|
||||||
|
(result $error (expected $size (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Atomically replace a file descriptor by renumbering another file descriptor.
|
||||||
|
//
|
||||||
|
/// Due to the strong focus on thread safety, this environment does not provide
|
||||||
|
/// a mechanism to duplicate or renumber a file descriptor to an arbitrary
|
||||||
|
/// number, like `dup2()`. This would be prone to race conditions, as an actual
|
||||||
|
/// file descriptor with the same number could be allocated by a different
|
||||||
|
/// thread at the same time.
|
||||||
|
//
|
||||||
|
/// This function provides a way to atomically renumber file descriptors, which
|
||||||
|
/// would disappear if `dup2()` were to be removed entirely.
|
||||||
|
(@interface func (export "fd_renumber")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// The file descriptor to overwrite.
|
||||||
|
(param $to $fd)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Move the offset of a file descriptor.
|
||||||
|
/// Note: This is similar to `lseek` in POSIX.
|
||||||
|
(@interface func (export "fd_seek")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// The number of bytes to move.
|
||||||
|
(param $offset $filedelta)
|
||||||
|
/// The base from which the offset is relative.
|
||||||
|
(param $whence $whence)
|
||||||
|
/// The new offset of the file descriptor, relative to the start of the file.
|
||||||
|
(result $error (expected $filesize (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Synchronize the data and metadata of a file to disk.
|
||||||
|
/// Note: This is similar to `fsync` in POSIX.
|
||||||
|
(@interface func (export "fd_sync")
|
||||||
|
(param $fd $fd)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Return the current offset of a file descriptor.
|
||||||
|
/// Note: This is similar to `lseek(fd, 0, SEEK_CUR)` in POSIX.
|
||||||
|
(@interface func (export "fd_tell")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// The current offset of the file descriptor, relative to the start of the file.
|
||||||
|
(result $error (expected $filesize (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Write to a file descriptor.
|
||||||
|
/// Note: This is similar to `writev` in POSIX.
|
||||||
|
(@interface func (export "fd_write")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// List of scatter/gather vectors from which to retrieve data.
|
||||||
|
(param $iovs $ciovec_array)
|
||||||
|
(result $error (expected $size (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Create a directory.
|
||||||
|
/// Note: This is similar to `mkdirat` in POSIX.
|
||||||
|
(@interface func (export "path_create_directory")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// The path at which to create the directory.
|
||||||
|
(param $path string)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Return the attributes of a file or directory.
|
||||||
|
/// Note: This is similar to `stat` in POSIX.
|
||||||
|
(@interface func (export "path_filestat_get")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// Flags determining the method of how the path is resolved.
|
||||||
|
(param $flags $lookupflags)
|
||||||
|
/// The path of the file or directory to inspect.
|
||||||
|
(param $path string)
|
||||||
|
/// The buffer where the file's attributes are stored.
|
||||||
|
(result $error (expected $filestat (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Adjust the timestamps of a file or directory.
|
||||||
|
/// Note: This is similar to `utimensat` in POSIX.
|
||||||
|
(@interface func (export "path_filestat_set_times")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// Flags determining the method of how the path is resolved.
|
||||||
|
(param $flags $lookupflags)
|
||||||
|
/// The path of the file or directory to operate on.
|
||||||
|
(param $path string)
|
||||||
|
/// The desired values of the data access timestamp.
|
||||||
|
(param $atim $timestamp)
|
||||||
|
/// The desired values of the data modification timestamp.
|
||||||
|
(param $mtim $timestamp)
|
||||||
|
/// A bitmask indicating which timestamps to adjust.
|
||||||
|
(param $fst_flags $fstflags)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Create a hard link.
|
||||||
|
/// Note: This is similar to `linkat` in POSIX.
|
||||||
|
(@interface func (export "path_link")
|
||||||
|
(param $old_fd $fd)
|
||||||
|
/// Flags determining the method of how the path is resolved.
|
||||||
|
(param $old_flags $lookupflags)
|
||||||
|
/// The source path from which to link.
|
||||||
|
(param $old_path string)
|
||||||
|
/// The working directory at which the resolution of the new path starts.
|
||||||
|
(param $new_fd $fd)
|
||||||
|
/// The destination path at which to create the hard link.
|
||||||
|
(param $new_path string)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Open a file or directory.
|
||||||
|
//
|
||||||
|
/// The returned file descriptor is not guaranteed to be the lowest-numbered
|
||||||
|
/// file descriptor not currently open; it is randomized to prevent
|
||||||
|
/// applications from depending on making assumptions about indexes, since this
|
||||||
|
/// is error-prone in multi-threaded contexts. The returned file descriptor is
|
||||||
|
/// guaranteed to be less than 2**31.
|
||||||
|
//
|
||||||
|
/// Note: This is similar to `openat` in POSIX.
|
||||||
|
(@interface func (export "path_open")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// Flags determining the method of how the path is resolved.
|
||||||
|
(param $dirflags $lookupflags)
|
||||||
|
/// The relative path of the file or directory to open, relative to the
|
||||||
|
/// `path_open::fd` directory.
|
||||||
|
(param $path string)
|
||||||
|
/// The method by which to open the file.
|
||||||
|
(param $oflags $oflags)
|
||||||
|
/// The initial rights of the newly created file descriptor. The
|
||||||
|
/// implementation is allowed to return a file descriptor with fewer rights
|
||||||
|
/// than specified, if and only if those rights do not apply to the type of
|
||||||
|
/// file being opened.
|
||||||
|
//
|
||||||
|
/// The *base* rights are rights that will apply to operations using the file
|
||||||
|
/// descriptor itself, while the *inheriting* rights are rights that apply to
|
||||||
|
/// file descriptors derived from it.
|
||||||
|
(param $fs_rights_base $rights)
|
||||||
|
(param $fs_rights_inheriting $rights)
|
||||||
|
(param $fdflags $fdflags)
|
||||||
|
/// The file descriptor of the file that has been opened.
|
||||||
|
(result $error (expected $fd (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Read the contents of a symbolic link.
|
||||||
|
/// Note: This is similar to `readlinkat` in POSIX.
|
||||||
|
(@interface func (export "path_readlink")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// The path of the symbolic link from which to read.
|
||||||
|
(param $path string)
|
||||||
|
/// The buffer to which to write the contents of the symbolic link.
|
||||||
|
(param $buf (@witx pointer u8))
|
||||||
|
(param $buf_len $size)
|
||||||
|
/// The number of bytes placed in the buffer.
|
||||||
|
(result $error (expected $size (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Remove a directory.
|
||||||
|
/// Return `errno::notempty` if the directory is not empty.
|
||||||
|
/// Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX.
|
||||||
|
(@interface func (export "path_remove_directory")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// The path to a directory to remove.
|
||||||
|
(param $path string)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Rename a file or directory.
|
||||||
|
/// Note: This is similar to `renameat` in POSIX.
|
||||||
|
(@interface func (export "path_rename")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// The source path of the file or directory to rename.
|
||||||
|
(param $old_path string)
|
||||||
|
/// The working directory at which the resolution of the new path starts.
|
||||||
|
(param $new_fd $fd)
|
||||||
|
/// The destination path to which to rename the file or directory.
|
||||||
|
(param $new_path string)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Create a symbolic link.
|
||||||
|
/// Note: This is similar to `symlinkat` in POSIX.
|
||||||
|
(@interface func (export "path_symlink")
|
||||||
|
/// The contents of the symbolic link.
|
||||||
|
(param $old_path string)
|
||||||
|
(param $fd $fd)
|
||||||
|
/// The destination path at which to create the symbolic link.
|
||||||
|
(param $new_path string)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
/// Unlink a file.
|
||||||
|
/// Return `errno::isdir` if the path refers to a directory.
|
||||||
|
/// Note: This is similar to `unlinkat(fd, path, 0)` in POSIX.
|
||||||
|
(@interface func (export "path_unlink_file")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// The path to a file to unlink.
|
||||||
|
(param $path string)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Concurrently poll for the occurrence of a set of events.
|
||||||
|
(@interface func (export "poll_oneoff")
|
||||||
|
/// The events to which to subscribe.
|
||||||
|
(param $in (@witx const_pointer $subscription))
|
||||||
|
/// The events that have occurred.
|
||||||
|
(param $out (@witx pointer $event))
|
||||||
|
/// Both the number of subscriptions and events.
|
||||||
|
(param $nsubscriptions $size)
|
||||||
|
/// The number of events stored.
|
||||||
|
(result $error (expected $size (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Terminate the process normally. An exit code of 0 indicates successful
|
||||||
|
/// termination of the program. The meanings of other values is dependent on
|
||||||
|
/// the environment.
|
||||||
|
(@interface func (export "proc_exit")
|
||||||
|
/// The exit code returned by the process.
|
||||||
|
(param $rval $exitcode)
|
||||||
|
(@witx noreturn)
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Send a signal to the process of the calling thread.
|
||||||
|
/// Note: This is similar to `raise` in POSIX.
|
||||||
|
(@interface func (export "proc_raise")
|
||||||
|
/// The signal condition to trigger.
|
||||||
|
(param $sig $signal)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Temporarily yield execution of the calling thread.
|
||||||
|
/// Note: This is similar to `sched_yield` in POSIX.
|
||||||
|
(@interface func (export "sched_yield")
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Write high-quality random data into a buffer.
|
||||||
|
/// This function blocks when the implementation is unable to immediately
|
||||||
|
/// provide sufficient high-quality random data.
|
||||||
|
/// This function may execute slowly, so when large mounts of random data are
|
||||||
|
/// required, it's advisable to use this function to seed a pseudo-random
|
||||||
|
/// number generator, rather than to provide the random data directly.
|
||||||
|
(@interface func (export "random_get")
|
||||||
|
/// The buffer to fill with random data.
|
||||||
|
(param $buf (@witx pointer u8))
|
||||||
|
(param $buf_len $size)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Receive a message from a socket.
|
||||||
|
/// Note: This is similar to `recv` in POSIX, though it also supports reading
|
||||||
|
/// the data into multiple buffers in the manner of `readv`.
|
||||||
|
(@interface func (export "sock_recv")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// List of scatter/gather vectors to which to store data.
|
||||||
|
(param $ri_data $iovec_array)
|
||||||
|
/// Message flags.
|
||||||
|
(param $ri_flags $riflags)
|
||||||
|
/// Number of bytes stored in ri_data and message flags.
|
||||||
|
(result $error (expected (tuple $size $roflags) (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Send a message on a socket.
|
||||||
|
/// Note: This is similar to `send` in POSIX, though it also supports writing
|
||||||
|
/// the data from multiple buffers in the manner of `writev`.
|
||||||
|
(@interface func (export "sock_send")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// List of scatter/gather vectors to which to retrieve data
|
||||||
|
(param $si_data $ciovec_array)
|
||||||
|
/// Message flags.
|
||||||
|
(param $si_flags $siflags)
|
||||||
|
/// Number of bytes transmitted.
|
||||||
|
(result $error (expected $size (error $errno)))
|
||||||
|
)
|
||||||
|
|
||||||
|
/// Shut down socket send and receive channels.
|
||||||
|
/// Note: This is similar to `shutdown` in POSIX.
|
||||||
|
(@interface func (export "sock_shutdown")
|
||||||
|
(param $fd $fd)
|
||||||
|
/// Which channels on the socket to shut down.
|
||||||
|
(param $how $sdflags)
|
||||||
|
(result $error (expected (error $errno)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
*/
|
||||||
@@ -46,11 +46,11 @@ tracing-wasm = "0.2"
|
|||||||
default = ["sys-default"]
|
default = ["sys-default"]
|
||||||
wasix = []
|
wasix = []
|
||||||
|
|
||||||
sys = ["wasmer/sys", "wasix"]
|
sys = ["wasmer/sys", "wasix", "wasmer-wasi-types/sys"]
|
||||||
sys-default = ["wasmer/wat", "wasmer/compiler", "sys", "logging", "host-fs", "sys-poll", "host-vnet" ]
|
sys-default = ["wasmer/wat", "wasmer/compiler", "sys", "logging", "host-fs", "sys-poll", "host-vnet" ]
|
||||||
sys-poll = []
|
sys-poll = []
|
||||||
|
|
||||||
js = ["wasmer/js", "mem-fs", "wasmer-vfs/no-time", "getrandom/js", "chrono"]
|
js = ["wasmer/js", "mem-fs", "wasmer-vfs/no-time", "getrandom/js", "chrono", "wasmer-wasi-types/js"]
|
||||||
js-default = ["js", "wasmer/js-default"]
|
js-default = ["js", "wasmer/js-default"]
|
||||||
test-js = ["js", "wasmer/js-default", "wasmer/wat"]
|
test-js = ["js", "wasmer/js-default", "wasmer/wat"]
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ pub use wasmer_vfs::FsError as WasiFsError;
|
|||||||
pub use wasmer_vfs::VirtualFile as WasiFile;
|
pub use wasmer_vfs::VirtualFile as WasiFile;
|
||||||
pub use wasmer_vfs::{FsError, VirtualFile};
|
pub use wasmer_vfs::{FsError, VirtualFile};
|
||||||
pub use wasmer_vnet::{UnsupportedVirtualNetworking, VirtualNetworking};
|
pub use wasmer_vnet::{UnsupportedVirtualNetworking, VirtualNetworking};
|
||||||
use wasmer_wasi_types::__WASI_CLOCK_MONOTONIC;
|
|
||||||
|
|
||||||
use derivative::*;
|
use derivative::*;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
@@ -68,6 +67,7 @@ use wasmer::{
|
|||||||
Imports, Instance, Memory, Memory32, MemoryAccessError, MemorySize, MemoryView, Module,
|
Imports, Instance, Memory, Memory32, MemoryAccessError, MemorySize, MemoryView, Module,
|
||||||
TypedFunction,
|
TypedFunction,
|
||||||
};
|
};
|
||||||
|
use wasmer_wasi_types::wasi::{BusErrno, Errno, Snapshot0Clockid};
|
||||||
|
|
||||||
pub use runtime::{
|
pub use runtime::{
|
||||||
PluggableRuntimeImplementation, WasiRuntimeImplementation, WasiThreadError, WasiTtyState,
|
PluggableRuntimeImplementation, WasiRuntimeImplementation, WasiThreadError, WasiTtyState,
|
||||||
@@ -321,10 +321,12 @@ impl WasiEnv {
|
|||||||
// Sleeps for a period of time
|
// Sleeps for a period of time
|
||||||
pub fn sleep(&self, duration: Duration) -> Result<(), WasiError> {
|
pub fn sleep(&self, duration: Duration) -> Result<(), WasiError> {
|
||||||
let duration = duration.as_nanos();
|
let duration = duration.as_nanos();
|
||||||
let start = platform_clock_time_get(__WASI_CLOCK_MONOTONIC, 1_000_000).unwrap() as u128;
|
let start =
|
||||||
|
platform_clock_time_get(Snapshot0Clockid::Monotonic, 1_000_000).unwrap() as u128;
|
||||||
self.yield_now()?;
|
self.yield_now()?;
|
||||||
loop {
|
loop {
|
||||||
let now = platform_clock_time_get(__WASI_CLOCK_MONOTONIC, 1_000_000).unwrap() as u128;
|
let now =
|
||||||
|
platform_clock_time_get(Snapshot0Clockid::Monotonic, 1_000_000).unwrap() as u128;
|
||||||
let delta = match now.checked_sub(start) {
|
let delta = match now.checked_sub(start) {
|
||||||
Some(a) => a,
|
Some(a) => a,
|
||||||
None => {
|
None => {
|
||||||
@@ -809,20 +811,20 @@ fn generate_import_object_wasix64_v1(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mem_error_to_wasi(err: MemoryAccessError) -> types::__wasi_errno_t {
|
fn mem_error_to_wasi(err: MemoryAccessError) -> Errno {
|
||||||
match err {
|
match err {
|
||||||
MemoryAccessError::HeapOutOfBounds => types::__WASI_EFAULT,
|
MemoryAccessError::HeapOutOfBounds => Errno::Fault,
|
||||||
MemoryAccessError::Overflow => types::__WASI_EOVERFLOW,
|
MemoryAccessError::Overflow => Errno::Overflow,
|
||||||
MemoryAccessError::NonUtf8String => types::__WASI_EINVAL,
|
MemoryAccessError::NonUtf8String => Errno::Inval,
|
||||||
_ => types::__WASI_EINVAL,
|
_ => Errno::Inval,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mem_error_to_bus(err: MemoryAccessError) -> types::__bus_errno_t {
|
fn mem_error_to_bus(err: MemoryAccessError) -> BusErrno {
|
||||||
match err {
|
match err {
|
||||||
MemoryAccessError::HeapOutOfBounds => types::__BUS_EMEMVIOLATION,
|
MemoryAccessError::HeapOutOfBounds => BusErrno::Memviolation,
|
||||||
MemoryAccessError::Overflow => types::__BUS_EMEMVIOLATION,
|
MemoryAccessError::Overflow => BusErrno::Memviolation,
|
||||||
MemoryAccessError::NonUtf8String => types::__BUS_EBADREQUEST,
|
MemoryAccessError::NonUtf8String => BusErrno::Badrequest,
|
||||||
_ => types::__BUS_EUNKNOWN,
|
_ => BusErrno::Unknown,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
/// succeeded or returns the error value.
|
/// succeeded or returns the error value.
|
||||||
macro_rules! wasi_try {
|
macro_rules! wasi_try {
|
||||||
($expr:expr) => {{
|
($expr:expr) => {{
|
||||||
let res: Result<_, crate::syscalls::types::__wasi_errno_t> = $expr;
|
let res: Result<_, crate::syscalls::types::wasi::Errno> = $expr;
|
||||||
match res {
|
match res {
|
||||||
Ok(val) => {
|
Ok(val) => {
|
||||||
tracing::trace!("wasi::wasi_try::val: {:?}", val);
|
tracing::trace!("wasi::wasi_try::val: {:?}", val);
|
||||||
@@ -22,7 +22,7 @@ macro_rules! wasi_try {
|
|||||||
/// succeeded or returns the error value. Results are wrapped in an Ok
|
/// succeeded or returns the error value. Results are wrapped in an Ok
|
||||||
macro_rules! wasi_try_ok {
|
macro_rules! wasi_try_ok {
|
||||||
($expr:expr) => {{
|
($expr:expr) => {{
|
||||||
let res: Result<_, crate::syscalls::types::__wasi_errno_t> = $expr;
|
let res: Result<_, crate::syscalls::types::wasi::Errno> = $expr;
|
||||||
match res {
|
match res {
|
||||||
Ok(val) => {
|
Ok(val) => {
|
||||||
tracing::trace!("wasi::wasi_try_ok::val: {:?}", val);
|
tracing::trace!("wasi::wasi_try_ok::val: {:?}", val);
|
||||||
@@ -36,14 +36,14 @@ macro_rules! wasi_try_ok {
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
($expr:expr, $thread:expr) => {{
|
($expr:expr, $thread:expr) => {{
|
||||||
let res: Result<_, crate::syscalls::types::__wasi_errno_t> = $expr;
|
let res: Result<_, crate::syscalls::types::wasi::Errno> = $expr;
|
||||||
match res {
|
match res {
|
||||||
Ok(val) => {
|
Ok(val) => {
|
||||||
tracing::trace!("wasi::wasi_try_ok::val: {:?}", val);
|
tracing::trace!("wasi::wasi_try_ok::val: {:?}", val);
|
||||||
val
|
val
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
if err == __WASI_EINTR {
|
if err == crate::syscalls::types::wasi::Errno::Intr {
|
||||||
$thread.yield_now()?;
|
$thread.yield_now()?;
|
||||||
}
|
}
|
||||||
tracing::debug!("wasi::wasi_try_ok::err: {:?}", err);
|
tracing::debug!("wasi::wasi_try_ok::err: {:?}", err);
|
||||||
@@ -57,7 +57,7 @@ macro_rules! wasi_try_ok {
|
|||||||
/// succeeded or returns the error value.
|
/// succeeded or returns the error value.
|
||||||
macro_rules! wasi_try_bus {
|
macro_rules! wasi_try_bus {
|
||||||
($expr:expr) => {{
|
($expr:expr) => {{
|
||||||
let res: Result<_, crate::syscalls::types::__bus_errno_t> = $expr;
|
let res: Result<_, crate::syscalls::types::wasi::BusErrno> = $expr;
|
||||||
match res {
|
match res {
|
||||||
Ok(val) => {
|
Ok(val) => {
|
||||||
tracing::trace!("wasi::wasi_try_bus::val: {:?}", val);
|
tracing::trace!("wasi::wasi_try_bus::val: {:?}", val);
|
||||||
@@ -71,21 +71,21 @@ macro_rules! wasi_try_bus {
|
|||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Like `wasi_try` but converts a `MemoryAccessError` to a __wasi_errno_t`.
|
/// Like `wasi_try` but converts a `MemoryAccessError` to a `wasi::Errno`.
|
||||||
macro_rules! wasi_try_mem {
|
macro_rules! wasi_try_mem {
|
||||||
($expr:expr) => {{
|
($expr:expr) => {{
|
||||||
wasi_try!($expr.map_err($crate::mem_error_to_wasi))
|
wasi_try!($expr.map_err($crate::mem_error_to_wasi))
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Like `wasi_try` but converts a `MemoryAccessError` to a __bus_errno_t`.
|
/// Like `wasi_try` but converts a `MemoryAccessError` to a `wasi::BusErrno`.
|
||||||
macro_rules! wasi_try_mem_bus {
|
macro_rules! wasi_try_mem_bus {
|
||||||
($expr:expr) => {{
|
($expr:expr) => {{
|
||||||
wasi_try_bus!($expr.map_err($crate::mem_error_to_bus))
|
wasi_try_bus!($expr.map_err($crate::mem_error_to_bus))
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Like `wasi_try` but converts a `MemoryAccessError` to a __wasi_errno_t`.
|
/// Like `wasi_try` but converts a `MemoryAccessError` to a `wasi::Errno`.
|
||||||
macro_rules! wasi_try_mem_ok {
|
macro_rules! wasi_try_mem_ok {
|
||||||
($expr:expr) => {{
|
($expr:expr) => {{
|
||||||
wasi_try_ok!($expr.map_err($crate::mem_error_to_wasi))
|
wasi_try_ok!($expr.map_err($crate::mem_error_to_wasi))
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ use std::sync::atomic::{AtomicU32, Ordering};
|
|||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use wasmer_vbus::{UnsupportedVirtualBus, VirtualBus};
|
use wasmer_vbus::{UnsupportedVirtualBus, VirtualBus};
|
||||||
use wasmer_vnet::VirtualNetworking;
|
use wasmer_vnet::VirtualNetworking;
|
||||||
|
use wasmer_wasi_types::wasi::Errno;
|
||||||
|
|
||||||
use super::types::*;
|
|
||||||
use super::WasiError;
|
use super::WasiError;
|
||||||
use super::WasiThreadId;
|
use super::WasiThreadId;
|
||||||
|
|
||||||
@@ -17,11 +17,11 @@ pub enum WasiThreadError {
|
|||||||
MethodNotFound,
|
MethodNotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<WasiThreadError> for __wasi_errno_t {
|
impl From<WasiThreadError> for Errno {
|
||||||
fn from(a: WasiThreadError) -> __wasi_errno_t {
|
fn from(a: WasiThreadError) -> Errno {
|
||||||
match a {
|
match a {
|
||||||
WasiThreadError::Unsupported => __WASI_ENOTSUP,
|
WasiThreadError::Unsupported => Errno::Notsup,
|
||||||
WasiThreadError::MethodNotFound => __WASI_EINVAL,
|
WasiThreadError::MethodNotFound => Errno::Inval,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ pub(crate) struct WasiStateFileGuard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl WasiStateFileGuard {
|
impl WasiStateFileGuard {
|
||||||
pub fn new(state: &WasiState, fd: __wasi_fd_t) -> Result<Option<Self>, FsError> {
|
pub fn new(state: &WasiState, fd: wasi::Fd) -> Result<Option<Self>, FsError> {
|
||||||
let inodes = state.inodes.read().unwrap();
|
let inodes = state.inodes.read().unwrap();
|
||||||
let fd_map = state.fs.fd_map.read().unwrap();
|
let fd_map = state.fs.fd_map.read().unwrap();
|
||||||
if let Some(fd) = fd_map.get(&fd) {
|
if let Some(fd) = fd_map.get(&fd) {
|
||||||
|
|||||||
@@ -52,26 +52,42 @@ use std::{
|
|||||||
};
|
};
|
||||||
use tracing::{debug, trace};
|
use tracing::{debug, trace};
|
||||||
use wasmer_vbus::BusSpawnedProcess;
|
use wasmer_vbus::BusSpawnedProcess;
|
||||||
|
use wasmer_wasi_types::wasi::{
|
||||||
|
Errno, Fd as WasiFd, Fdflags, Fdstat, Filesize, Filestat, Filetype, Preopentype, Rights,
|
||||||
|
};
|
||||||
|
use wasmer_wasi_types::wasi::{Prestat, PrestatEnum};
|
||||||
|
|
||||||
use wasmer_vfs::{FileSystem, FsError, OpenOptions, VirtualFile};
|
use wasmer_vfs::{FileSystem, FsError, OpenOptions, VirtualFile};
|
||||||
|
|
||||||
/// the fd value of the virtual root
|
/// the fd value of the virtual root
|
||||||
pub const VIRTUAL_ROOT_FD: __wasi_fd_t = 3;
|
pub const VIRTUAL_ROOT_FD: WasiFd = 3;
|
||||||
/// all the rights enabled
|
/// all the rights enabled
|
||||||
pub const ALL_RIGHTS: __wasi_rights_t = 0x1FFF_FFFF;
|
pub const ALL_RIGHTS: Rights = Rights::all();
|
||||||
const STDIN_DEFAULT_RIGHTS: __wasi_rights_t = __WASI_RIGHT_FD_DATASYNC
|
const STDIN_DEFAULT_RIGHTS: Rights = {
|
||||||
| __WASI_RIGHT_FD_READ
|
// This might seem a bit overenineered, but it's the only way I
|
||||||
| __WASI_RIGHT_FD_SYNC
|
// discovered for getting the values in a const environment
|
||||||
| __WASI_RIGHT_FD_ADVISE
|
Rights::from_bits_truncate(
|
||||||
| __WASI_RIGHT_FD_FILESTAT_GET
|
Rights::FD_DATASYNC.bits()
|
||||||
| __WASI_RIGHT_POLL_FD_READWRITE;
|
| Rights::FD_READ.bits()
|
||||||
const STDOUT_DEFAULT_RIGHTS: __wasi_rights_t = __WASI_RIGHT_FD_DATASYNC
|
| Rights::FD_SYNC.bits()
|
||||||
| __WASI_RIGHT_FD_WRITE
|
| Rights::FD_ADVISE.bits()
|
||||||
| __WASI_RIGHT_FD_SYNC
|
| Rights::FD_FILESTAT_GET.bits()
|
||||||
| __WASI_RIGHT_FD_ADVISE
|
| Rights::POLL_FD_READWRITE.bits(),
|
||||||
| __WASI_RIGHT_FD_FILESTAT_GET
|
)
|
||||||
| __WASI_RIGHT_POLL_FD_READWRITE;
|
};
|
||||||
const STDERR_DEFAULT_RIGHTS: __wasi_rights_t = STDOUT_DEFAULT_RIGHTS;
|
const STDOUT_DEFAULT_RIGHTS: Rights = {
|
||||||
|
// This might seem a bit overenineered, but it's the only way I
|
||||||
|
// discovered for getting the values in a const environment
|
||||||
|
Rights::from_bits_truncate(
|
||||||
|
Rights::FD_DATASYNC.bits()
|
||||||
|
| Rights::FD_SYNC.bits()
|
||||||
|
| Rights::FD_WRITE.bits()
|
||||||
|
| Rights::FD_ADVISE.bits()
|
||||||
|
| Rights::FD_FILESTAT_GET.bits()
|
||||||
|
| Rights::POLL_FD_READWRITE.bits(),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
const STDERR_DEFAULT_RIGHTS: Rights = STDOUT_DEFAULT_RIGHTS;
|
||||||
|
|
||||||
/// A completely aribtrary "big enough" number used as the upper limit for
|
/// A completely aribtrary "big enough" number used as the upper limit for
|
||||||
/// the number of symlinks that can be traversed when resolving a path
|
/// the number of symlinks that can be traversed when resolving a path
|
||||||
@@ -81,7 +97,7 @@ pub const MAX_SYMLINKS: u32 = 128;
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct InodeVal {
|
pub struct InodeVal {
|
||||||
pub stat: RwLock<__wasi_filestat_t>,
|
pub stat: RwLock<Filestat>,
|
||||||
pub is_preopened: bool,
|
pub is_preopened: bool,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub kind: RwLock<Kind>,
|
pub kind: RwLock<Kind>,
|
||||||
@@ -149,7 +165,7 @@ pub enum Kind {
|
|||||||
/// - There is always a closer pre-opened dir to the symlink file (by definition of the root being a collection of preopened dirs)
|
/// - There is always a closer pre-opened dir to the symlink file (by definition of the root being a collection of preopened dirs)
|
||||||
Symlink {
|
Symlink {
|
||||||
/// The preopened dir that this symlink file is relative to (via `path_to_symlink`)
|
/// The preopened dir that this symlink file is relative to (via `path_to_symlink`)
|
||||||
base_po_dir: __wasi_fd_t,
|
base_po_dir: WasiFd,
|
||||||
/// The path to the symlink from the `base_po_dir`
|
/// The path to the symlink from the `base_po_dir`
|
||||||
path_to_symlink: PathBuf,
|
path_to_symlink: PathBuf,
|
||||||
/// the value of the symlink as a relative path
|
/// the value of the symlink as a relative path
|
||||||
@@ -172,9 +188,9 @@ pub enum Kind {
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Fd {
|
pub struct Fd {
|
||||||
pub rights: __wasi_rights_t,
|
pub rights: Rights,
|
||||||
pub rights_inheriting: __wasi_rights_t,
|
pub rights_inheriting: Rights,
|
||||||
pub flags: __wasi_fdflags_t,
|
pub flags: Fdflags,
|
||||||
pub offset: u64,
|
pub offset: u64,
|
||||||
/// Flags that determine how the [`Fd`] can be used.
|
/// Flags that determine how the [`Fd`] can be used.
|
||||||
///
|
///
|
||||||
@@ -212,14 +228,11 @@ pub struct WasiInodes {
|
|||||||
|
|
||||||
impl WasiInodes {
|
impl WasiInodes {
|
||||||
/// gets either a normal inode or an orphaned inode
|
/// gets either a normal inode or an orphaned inode
|
||||||
pub fn get_inodeval(
|
pub fn get_inodeval(&self, inode: generational_arena::Index) -> Result<&InodeVal, Errno> {
|
||||||
&self,
|
|
||||||
inode: generational_arena::Index,
|
|
||||||
) -> Result<&InodeVal, __wasi_errno_t> {
|
|
||||||
if let Some(iv) = self.arena.get(inode) {
|
if let Some(iv) = self.arena.get(inode) {
|
||||||
Ok(iv)
|
Ok(iv)
|
||||||
} else {
|
} else {
|
||||||
self.orphan_fds.get(&inode).ok_or(__WASI_EBADF)
|
self.orphan_fds.get(&inode).ok_or(Errno::Badf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,11 +240,11 @@ impl WasiInodes {
|
|||||||
pub fn get_inodeval_mut(
|
pub fn get_inodeval_mut(
|
||||||
&mut self,
|
&mut self,
|
||||||
inode: generational_arena::Index,
|
inode: generational_arena::Index,
|
||||||
) -> Result<&mut InodeVal, __wasi_errno_t> {
|
) -> Result<&mut InodeVal, Errno> {
|
||||||
if let Some(iv) = self.arena.get_mut(inode) {
|
if let Some(iv) = self.arena.get_mut(inode) {
|
||||||
Ok(iv)
|
Ok(iv)
|
||||||
} else {
|
} else {
|
||||||
self.orphan_fds.get_mut(&inode).ok_or(__WASI_EBADF)
|
self.orphan_fds.get_mut(&inode).ok_or(Errno::Badf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,7 +298,7 @@ impl WasiInodes {
|
|||||||
fn std_dev_get<'a>(
|
fn std_dev_get<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
fd_map: &RwLock<HashMap<u32, Fd>>,
|
fd_map: &RwLock<HashMap<u32, Fd>>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
) -> Result<InodeValFileReadGuard<'a>, FsError> {
|
) -> Result<InodeValFileReadGuard<'a>, FsError> {
|
||||||
if let Some(fd) = fd_map.read().unwrap().get(&fd) {
|
if let Some(fd) = fd_map.read().unwrap().get(&fd) {
|
||||||
let guard = self.arena[fd.inode].read();
|
let guard = self.arena[fd.inode].read();
|
||||||
@@ -305,7 +318,7 @@ impl WasiInodes {
|
|||||||
fn std_dev_get_mut<'a>(
|
fn std_dev_get_mut<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
fd_map: &RwLock<HashMap<u32, Fd>>,
|
fd_map: &RwLock<HashMap<u32, Fd>>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
) -> Result<InodeValFileWriteGuard<'a>, FsError> {
|
) -> Result<InodeValFileWriteGuard<'a>, FsError> {
|
||||||
if let Some(fd) = fd_map.read().unwrap().get(&fd) {
|
if let Some(fd) = fd_map.read().unwrap().get(&fd) {
|
||||||
let guard = self.arena[fd.inode].write();
|
let guard = self.arena[fd.inode].write();
|
||||||
@@ -404,19 +417,19 @@ impl WasiFs {
|
|||||||
path: PathBuf::from(preopen_name),
|
path: PathBuf::from(preopen_name),
|
||||||
entries: Default::default(),
|
entries: Default::default(),
|
||||||
};
|
};
|
||||||
let rights = __WASI_RIGHT_FD_ADVISE
|
let rights = Rights::FD_ADVISE
|
||||||
| __WASI_RIGHT_FD_TELL
|
| Rights::FD_TELL
|
||||||
| __WASI_RIGHT_FD_SEEK
|
| Rights::FD_SEEK
|
||||||
| __WASI_RIGHT_FD_READ
|
| Rights::FD_READ
|
||||||
| __WASI_RIGHT_PATH_OPEN
|
| Rights::PATH_OPEN
|
||||||
| __WASI_RIGHT_FD_READDIR
|
| Rights::FD_READDIR
|
||||||
| __WASI_RIGHT_PATH_READLINK
|
| Rights::PATH_READLINK
|
||||||
| __WASI_RIGHT_PATH_FILESTAT_GET
|
| Rights::PATH_FILESTAT_GET
|
||||||
| __WASI_RIGHT_FD_FILESTAT_GET
|
| Rights::FD_FILESTAT_GET
|
||||||
| __WASI_RIGHT_PATH_LINK_SOURCE
|
| Rights::PATH_LINK_SOURCE
|
||||||
| __WASI_RIGHT_PATH_RENAME_SOURCE
|
| Rights::PATH_RENAME_SOURCE
|
||||||
| __WASI_RIGHT_POLL_FD_READWRITE
|
| Rights::POLL_FD_READWRITE
|
||||||
| __WASI_RIGHT_SOCK_SHUTDOWN;
|
| Rights::SOCK_SHUTDOWN;
|
||||||
let inode = wasi_fs
|
let inode = wasi_fs
|
||||||
.create_inode(inodes, kind, true, preopen_name.clone())
|
.create_inode(inodes, kind, true, preopen_name.clone())
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
@@ -427,7 +440,7 @@ impl WasiFs {
|
|||||||
})?;
|
})?;
|
||||||
let fd_flags = Fd::READ;
|
let fd_flags = Fd::READ;
|
||||||
let fd = wasi_fs
|
let fd = wasi_fs
|
||||||
.create_fd(rights, rights, 0, fd_flags, inode)
|
.create_fd(rights, rights, Fdflags::empty(), fd_flags, inode)
|
||||||
.map_err(|e| format!("Could not open fd for file {:?}: {}", preopen_name, e))?;
|
.map_err(|e| format!("Could not open fd for file {:?}: {}", preopen_name, e))?;
|
||||||
{
|
{
|
||||||
let mut guard = inodes.arena[root_inode].write();
|
let mut guard = inodes.arena[root_inode].write();
|
||||||
@@ -478,44 +491,43 @@ impl WasiFs {
|
|||||||
|
|
||||||
let rights = {
|
let rights = {
|
||||||
// TODO: review tell' and fd_readwrite
|
// TODO: review tell' and fd_readwrite
|
||||||
let mut rights =
|
let mut rights = Rights::FD_ADVISE | Rights::FD_TELL | Rights::FD_SEEK;
|
||||||
__WASI_RIGHT_FD_ADVISE | __WASI_RIGHT_FD_TELL | __WASI_RIGHT_FD_SEEK;
|
|
||||||
if *read {
|
if *read {
|
||||||
rights |= __WASI_RIGHT_FD_READ
|
rights |= Rights::FD_READ
|
||||||
| __WASI_RIGHT_PATH_OPEN
|
| Rights::PATH_OPEN
|
||||||
| __WASI_RIGHT_FD_READDIR
|
| Rights::FD_READDIR
|
||||||
| __WASI_RIGHT_PATH_READLINK
|
| Rights::PATH_READLINK
|
||||||
| __WASI_RIGHT_PATH_FILESTAT_GET
|
| Rights::PATH_FILESTAT_GET
|
||||||
| __WASI_RIGHT_FD_FILESTAT_GET
|
| Rights::FD_FILESTAT_GET
|
||||||
| __WASI_RIGHT_PATH_LINK_SOURCE
|
| Rights::PATH_LINK_SOURCE
|
||||||
| __WASI_RIGHT_PATH_RENAME_SOURCE
|
| Rights::PATH_RENAME_SOURCE
|
||||||
| __WASI_RIGHT_POLL_FD_READWRITE
|
| Rights::POLL_FD_READWRITE
|
||||||
| __WASI_RIGHT_SOCK_SHUTDOWN;
|
| Rights::SOCK_SHUTDOWN;
|
||||||
}
|
}
|
||||||
if *write {
|
if *write {
|
||||||
rights |= __WASI_RIGHT_FD_DATASYNC
|
rights |= Rights::FD_DATASYNC
|
||||||
| __WASI_RIGHT_FD_FDSTAT_SET_FLAGS
|
| Rights::FD_FDSTAT_SET_FLAGS
|
||||||
| __WASI_RIGHT_FD_WRITE
|
| Rights::FD_WRITE
|
||||||
| __WASI_RIGHT_FD_SYNC
|
| Rights::FD_SYNC
|
||||||
| __WASI_RIGHT_FD_ALLOCATE
|
| Rights::FD_ALLOCATE
|
||||||
| __WASI_RIGHT_PATH_OPEN
|
| Rights::PATH_OPEN
|
||||||
| __WASI_RIGHT_PATH_RENAME_TARGET
|
| Rights::PATH_RENAME_TARGET
|
||||||
| __WASI_RIGHT_PATH_FILESTAT_SET_SIZE
|
| Rights::PATH_FILESTAT_SET_SIZE
|
||||||
| __WASI_RIGHT_PATH_FILESTAT_SET_TIMES
|
| Rights::PATH_FILESTAT_SET_TIMES
|
||||||
| __WASI_RIGHT_FD_FILESTAT_SET_SIZE
|
| Rights::FD_FILESTAT_SET_SIZE
|
||||||
| __WASI_RIGHT_FD_FILESTAT_SET_TIMES
|
| Rights::FD_FILESTAT_SET_TIMES
|
||||||
| __WASI_RIGHT_PATH_REMOVE_DIRECTORY
|
| Rights::PATH_REMOVE_DIRECTORY
|
||||||
| __WASI_RIGHT_PATH_UNLINK_FILE
|
| Rights::PATH_UNLINK_FILE
|
||||||
| __WASI_RIGHT_POLL_FD_READWRITE
|
| Rights::POLL_FD_READWRITE
|
||||||
| __WASI_RIGHT_SOCK_SHUTDOWN;
|
| Rights::SOCK_SHUTDOWN;
|
||||||
}
|
}
|
||||||
if *create {
|
if *create {
|
||||||
rights |= __WASI_RIGHT_PATH_CREATE_DIRECTORY
|
rights |= Rights::PATH_CREATE_DIRECTORY
|
||||||
| __WASI_RIGHT_PATH_CREATE_FILE
|
| Rights::PATH_CREATE_FILE
|
||||||
| __WASI_RIGHT_PATH_LINK_TARGET
|
| Rights::PATH_LINK_TARGET
|
||||||
| __WASI_RIGHT_PATH_OPEN
|
| Rights::PATH_OPEN
|
||||||
| __WASI_RIGHT_PATH_RENAME_TARGET
|
| Rights::PATH_RENAME_TARGET
|
||||||
| __WASI_RIGHT_PATH_SYMLINK;
|
| Rights::PATH_SYMLINK;
|
||||||
}
|
}
|
||||||
|
|
||||||
rights
|
rights
|
||||||
@@ -546,7 +558,7 @@ impl WasiFs {
|
|||||||
fd_flags
|
fd_flags
|
||||||
};
|
};
|
||||||
let fd = wasi_fs
|
let fd = wasi_fs
|
||||||
.create_fd(rights, rights, 0, fd_flags, inode)
|
.create_fd(rights, rights, Fdflags::empty(), fd_flags, inode)
|
||||||
.map_err(|e| format!("Could not open fd for file {:?}: {}", path, e))?;
|
.map_err(|e| format!("Could not open fd for file {:?}: {}", path, e))?;
|
||||||
{
|
{
|
||||||
let mut guard = inodes.arena[root_inode].write();
|
let mut guard = inodes.arena[root_inode].write();
|
||||||
@@ -596,23 +608,25 @@ impl WasiFs {
|
|||||||
// TODO: make this a list of positive rigths instead of negative ones
|
// TODO: make this a list of positive rigths instead of negative ones
|
||||||
// root gets all right for now
|
// root gets all right for now
|
||||||
let root_rights = all_rights
|
let root_rights = all_rights
|
||||||
/*& (!__WASI_RIGHT_FD_WRITE)
|
/*
|
||||||
& (!__WASI_RIGHT_FD_ALLOCATE)
|
& (!Rights::FD_WRITE)
|
||||||
& (!__WASI_RIGHT_PATH_CREATE_DIRECTORY)
|
& (!Rights::FD_ALLOCATE)
|
||||||
& (!__WASI_RIGHT_PATH_CREATE_FILE)
|
& (!Rights::PATH_CREATE_DIRECTORY)
|
||||||
& (!__WASI_RIGHT_PATH_LINK_SOURCE)
|
& (!Rights::PATH_CREATE_FILE)
|
||||||
& (!__WASI_RIGHT_PATH_RENAME_SOURCE)
|
& (!Rights::PATH_LINK_SOURCE)
|
||||||
& (!__WASI_RIGHT_PATH_RENAME_TARGET)
|
& (!Rights::PATH_RENAME_SOURCE)
|
||||||
& (!__WASI_RIGHT_PATH_FILESTAT_SET_SIZE)
|
& (!Rights::PATH_RENAME_TARGET)
|
||||||
& (!__WASI_RIGHT_PATH_FILESTAT_SET_TIMES)
|
& (!Rights::PATH_FILESTAT_SET_SIZE)
|
||||||
& (!__WASI_RIGHT_FD_FILESTAT_SET_SIZE)
|
& (!Rights::PATH_FILESTAT_SET_TIMES)
|
||||||
& (!__WASI_RIGHT_FD_FILESTAT_SET_TIMES)
|
& (!Rights::FD_FILESTAT_SET_SIZE)
|
||||||
& (!__WASI_RIGHT_PATH_SYMLINK)
|
& (!Rights::FD_FILESTAT_SET_TIMES)
|
||||||
& (!__WASI_RIGHT_PATH_UNLINK_FILE)
|
& (!Rights::PATH_SYMLINK)
|
||||||
& (!__WASI_RIGHT_PATH_REMOVE_DIRECTORY)*/;
|
& (!Rights::PATH_UNLINK_FILE)
|
||||||
|
& (!Rights::PATH_REMOVE_DIRECTORY)
|
||||||
|
*/;
|
||||||
let inode = wasi_fs.create_virtual_root(inodes);
|
let inode = wasi_fs.create_virtual_root(inodes);
|
||||||
let fd = wasi_fs
|
let fd = wasi_fs
|
||||||
.create_fd(root_rights, root_rights, 0, Fd::READ, inode)
|
.create_fd(root_rights, root_rights, Fdflags::empty(), Fd::READ, inode)
|
||||||
.map_err(|e| format!("Could not create root fd: {}", e))?;
|
.map_err(|e| format!("Could not create root fd: {}", e))?;
|
||||||
wasi_fs.preopen_fds.write().unwrap().push(fd);
|
wasi_fs.preopen_fds.write().unwrap().push(fd);
|
||||||
inode
|
inode
|
||||||
@@ -639,12 +653,12 @@ impl WasiFs {
|
|||||||
pub unsafe fn open_dir_all(
|
pub unsafe fn open_dir_all(
|
||||||
&mut self,
|
&mut self,
|
||||||
inodes: &mut WasiInodes,
|
inodes: &mut WasiInodes,
|
||||||
base: __wasi_fd_t,
|
base: WasiFd,
|
||||||
name: String,
|
name: String,
|
||||||
rights: __wasi_rights_t,
|
rights: Rights,
|
||||||
rights_inheriting: __wasi_rights_t,
|
rights_inheriting: Rights,
|
||||||
flags: __wasi_fdflags_t,
|
flags: Fdflags,
|
||||||
) -> Result<__wasi_fd_t, FsError> {
|
) -> Result<WasiFd, FsError> {
|
||||||
// TODO: check permissions here? probably not, but this should be
|
// TODO: check permissions here? probably not, but this should be
|
||||||
// an explicit choice, so justify it in a comment when we remove this one
|
// an explicit choice, so justify it in a comment when we remove this one
|
||||||
let mut cur_inode = self.get_fd_inode(base).map_err(fs_error_from_wasi_err)?;
|
let mut cur_inode = self.get_fd_inode(base).map_err(fs_error_from_wasi_err)?;
|
||||||
@@ -714,14 +728,14 @@ impl WasiFs {
|
|||||||
pub fn open_file_at(
|
pub fn open_file_at(
|
||||||
&mut self,
|
&mut self,
|
||||||
inodes: &mut WasiInodes,
|
inodes: &mut WasiInodes,
|
||||||
base: __wasi_fd_t,
|
base: WasiFd,
|
||||||
file: Box<dyn VirtualFile + Send + Sync + 'static>,
|
file: Box<dyn VirtualFile + Send + Sync + 'static>,
|
||||||
open_flags: u16,
|
open_flags: u16,
|
||||||
name: String,
|
name: String,
|
||||||
rights: __wasi_rights_t,
|
rights: Rights,
|
||||||
rights_inheriting: __wasi_rights_t,
|
rights_inheriting: Rights,
|
||||||
flags: __wasi_fdflags_t,
|
flags: Fdflags,
|
||||||
) -> Result<__wasi_fd_t, FsError> {
|
) -> Result<WasiFd, FsError> {
|
||||||
// TODO: check permissions here? probably not, but this should be
|
// TODO: check permissions here? probably not, but this should be
|
||||||
// an explicit choice, so justify it in a comment when we remove this one
|
// an explicit choice, so justify it in a comment when we remove this one
|
||||||
let base_inode = self.get_fd_inode(base).map_err(fs_error_from_wasi_err)?;
|
let base_inode = self.get_fd_inode(base).map_err(fs_error_from_wasi_err)?;
|
||||||
@@ -774,7 +788,7 @@ impl WasiFs {
|
|||||||
pub fn swap_file(
|
pub fn swap_file(
|
||||||
&self,
|
&self,
|
||||||
inodes: &WasiInodes,
|
inodes: &WasiInodes,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
file: Box<dyn VirtualFile + Send + Sync + 'static>,
|
file: Box<dyn VirtualFile + Send + Sync + 'static>,
|
||||||
) -> Result<Option<Box<dyn VirtualFile + Send + Sync + 'static>>, FsError> {
|
) -> Result<Option<Box<dyn VirtualFile + Send + Sync + 'static>>, FsError> {
|
||||||
let mut ret = Some(file);
|
let mut ret = Some(file);
|
||||||
@@ -811,8 +825,8 @@ impl WasiFs {
|
|||||||
pub(crate) fn filestat_resync_size(
|
pub(crate) fn filestat_resync_size(
|
||||||
&self,
|
&self,
|
||||||
inodes: &WasiInodes,
|
inodes: &WasiInodes,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
) -> Result<__wasi_filesize_t, __wasi_errno_t> {
|
) -> Result<Filesize, Errno> {
|
||||||
let inode = self.get_fd_inode(fd)?;
|
let inode = self.get_fd_inode(fd)?;
|
||||||
let mut guard = inodes.arena[inode].write();
|
let mut guard = inodes.arena[inode].write();
|
||||||
let deref_mut = guard.deref_mut();
|
let deref_mut = guard.deref_mut();
|
||||||
@@ -823,13 +837,13 @@ impl WasiFs {
|
|||||||
drop(guard);
|
drop(guard);
|
||||||
|
|
||||||
inodes.arena[inode].stat.write().unwrap().st_size = new_size;
|
inodes.arena[inode].stat.write().unwrap().st_size = new_size;
|
||||||
Ok(new_size as __wasi_filesize_t)
|
Ok(new_size as Filesize)
|
||||||
} else {
|
} else {
|
||||||
Err(__WASI_EBADF)
|
Err(Errno::Badf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Kind::Dir { .. } | Kind::Root { .. } => Err(__WASI_EISDIR),
|
Kind::Dir { .. } | Kind::Root { .. } => Err(Errno::Isdir),
|
||||||
_ => Err(__WASI_EINVAL),
|
_ => Err(Errno::Inval),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -843,17 +857,17 @@ impl WasiFs {
|
|||||||
pub fn get_current_dir(
|
pub fn get_current_dir(
|
||||||
&self,
|
&self,
|
||||||
inodes: &mut WasiInodes,
|
inodes: &mut WasiInodes,
|
||||||
base: __wasi_fd_t,
|
base: WasiFd,
|
||||||
) -> Result<(Inode, String), __wasi_errno_t> {
|
) -> Result<(Inode, String), Errno> {
|
||||||
self.get_current_dir_inner(inodes, base, 0)
|
self.get_current_dir_inner(inodes, base, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_current_dir_inner(
|
pub(crate) fn get_current_dir_inner(
|
||||||
&self,
|
&self,
|
||||||
inodes: &mut WasiInodes,
|
inodes: &mut WasiInodes,
|
||||||
base: __wasi_fd_t,
|
base: WasiFd,
|
||||||
symlink_count: u32,
|
symlink_count: u32,
|
||||||
) -> Result<(Inode, String), __wasi_errno_t> {
|
) -> Result<(Inode, String), Errno> {
|
||||||
let current_dir = {
|
let current_dir = {
|
||||||
let guard = self.current_dir.lock().unwrap();
|
let guard = self.current_dir.lock().unwrap();
|
||||||
guard.clone()
|
guard.clone()
|
||||||
@@ -889,9 +903,9 @@ impl WasiFs {
|
|||||||
path: &str,
|
path: &str,
|
||||||
mut symlink_count: u32,
|
mut symlink_count: u32,
|
||||||
follow_symlinks: bool,
|
follow_symlinks: bool,
|
||||||
) -> Result<Inode, __wasi_errno_t> {
|
) -> Result<Inode, Errno> {
|
||||||
if symlink_count > MAX_SYMLINKS {
|
if symlink_count > MAX_SYMLINKS {
|
||||||
return Err(__WASI_EMLINK);
|
return Err(Errno::Mlink);
|
||||||
}
|
}
|
||||||
|
|
||||||
let path: &Path = Path::new(path);
|
let path: &Path = Path::new(path);
|
||||||
@@ -920,7 +934,7 @@ impl WasiFs {
|
|||||||
cur_inode = *p;
|
cur_inode = *p;
|
||||||
continue 'path_iter;
|
continue 'path_iter;
|
||||||
} else {
|
} else {
|
||||||
return Err(__WASI_EACCES);
|
return Err(Errno::Access);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"." => continue 'path_iter,
|
"." => continue 'path_iter,
|
||||||
@@ -942,7 +956,7 @@ impl WasiFs {
|
|||||||
.fs_backing
|
.fs_backing
|
||||||
.symlink_metadata(&file)
|
.symlink_metadata(&file)
|
||||||
.ok()
|
.ok()
|
||||||
.ok_or(__WASI_ENOENT)?;
|
.ok_or(Errno::Noent)?;
|
||||||
let file_type = metadata.file_type();
|
let file_type = metadata.file_type();
|
||||||
// we want to insert newly opened dirs and files, but not transient symlinks
|
// we want to insert newly opened dirs and files, but not transient symlinks
|
||||||
// TODO: explain why (think about this deeply when well rested)
|
// TODO: explain why (think about this deeply when well rested)
|
||||||
@@ -985,18 +999,17 @@ impl WasiFs {
|
|||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
{
|
{
|
||||||
//use std::os::unix::fs::FileTypeExt;
|
//use std::os::unix::fs::FileTypeExt;
|
||||||
let file_type: __wasi_filetype_t = if file_type.is_char_device()
|
let file_type: Filetype = if file_type.is_char_device() {
|
||||||
{
|
Filetype::CharacterDevice
|
||||||
__WASI_FILETYPE_CHARACTER_DEVICE
|
|
||||||
} else if file_type.is_block_device() {
|
} else if file_type.is_block_device() {
|
||||||
__WASI_FILETYPE_BLOCK_DEVICE
|
Filetype::BlockDevice
|
||||||
} else if file_type.is_fifo() {
|
} else if file_type.is_fifo() {
|
||||||
// FIFO doesn't seem to fit any other type, so unknown
|
// FIFO doesn't seem to fit any other type, so unknown
|
||||||
__WASI_FILETYPE_UNKNOWN
|
Filetype::Unknown
|
||||||
} else if file_type.is_socket() {
|
} else if file_type.is_socket() {
|
||||||
// TODO: how do we know if it's a `__WASI_FILETYPE_SOCKET_STREAM` or
|
// TODO: how do we know if it's a `SocketStream` or
|
||||||
// a `__WASI_FILETYPE_SOCKET_DGRAM`?
|
// a `SocketDgram`?
|
||||||
__WASI_FILETYPE_SOCKET_STREAM
|
Filetype::SocketStream
|
||||||
} else {
|
} else {
|
||||||
unimplemented!("state::get_inode_at_path unknown file type: not file, directory, symlink, char device, block device, fifo, or socket");
|
unimplemented!("state::get_inode_at_path unknown file type: not file, directory, symlink, char device, block device, fifo, or socket");
|
||||||
};
|
};
|
||||||
@@ -1012,9 +1025,9 @@ impl WasiFs {
|
|||||||
kind,
|
kind,
|
||||||
false,
|
false,
|
||||||
file.to_string_lossy().to_string(),
|
file.to_string_lossy().to_string(),
|
||||||
__wasi_filestat_t {
|
Filestat {
|
||||||
st_filetype: file_type,
|
st_filetype: file_type,
|
||||||
..__wasi_filestat_t::default()
|
..Filestat::default()
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1080,14 +1093,14 @@ impl WasiFs {
|
|||||||
{
|
{
|
||||||
cur_inode = *entry;
|
cur_inode = *entry;
|
||||||
} else {
|
} else {
|
||||||
return Err(__WASI_ENOENT);
|
return Err(Errno::Noent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Kind::File { .. }
|
Kind::File { .. }
|
||||||
| Kind::Socket { .. }
|
| Kind::Socket { .. }
|
||||||
| Kind::Pipe { .. }
|
| Kind::Pipe { .. }
|
||||||
| Kind::EventNotifications { .. } => {
|
| Kind::EventNotifications { .. } => {
|
||||||
return Err(__WASI_ENOTDIR);
|
return Err(Errno::Notdir);
|
||||||
}
|
}
|
||||||
Kind::Symlink {
|
Kind::Symlink {
|
||||||
base_po_dir,
|
base_po_dir,
|
||||||
@@ -1151,11 +1164,11 @@ impl WasiFs {
|
|||||||
&self,
|
&self,
|
||||||
inodes: &WasiInodes,
|
inodes: &WasiInodes,
|
||||||
path: &'path Path,
|
path: &'path Path,
|
||||||
) -> Result<(__wasi_fd_t, &'path Path), __wasi_errno_t> {
|
) -> Result<(WasiFd, &'path Path), Errno> {
|
||||||
enum BaseFdAndRelPath<'a> {
|
enum BaseFdAndRelPath<'a> {
|
||||||
None,
|
None,
|
||||||
BestMatch {
|
BestMatch {
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
rel_path: &'a Path,
|
rel_path: &'a Path,
|
||||||
max_seen: usize,
|
max_seen: usize,
|
||||||
},
|
},
|
||||||
@@ -1199,7 +1212,7 @@ impl WasiFs {
|
|||||||
}
|
}
|
||||||
match res {
|
match res {
|
||||||
// this error may not make sense depending on where it's called
|
// this error may not make sense depending on where it's called
|
||||||
BaseFdAndRelPath::None => Err(__WASI_EINVAL),
|
BaseFdAndRelPath::None => Err(Errno::Inval),
|
||||||
BaseFdAndRelPath::BestMatch { fd, rel_path, .. } => Ok((fd, rel_path)),
|
BaseFdAndRelPath::BestMatch { fd, rel_path, .. } => Ok((fd, rel_path)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1209,9 +1222,9 @@ impl WasiFs {
|
|||||||
pub(crate) fn path_depth_from_fd(
|
pub(crate) fn path_depth_from_fd(
|
||||||
&self,
|
&self,
|
||||||
inodes: &WasiInodes,
|
inodes: &WasiInodes,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
inode: Inode,
|
inode: Inode,
|
||||||
) -> Result<usize, __wasi_errno_t> {
|
) -> Result<usize, Errno> {
|
||||||
let mut counter = 0;
|
let mut counter = 0;
|
||||||
let base_inode = self.get_fd_inode(fd)?;
|
let base_inode = self.get_fd_inode(fd)?;
|
||||||
let mut cur_inode = inode;
|
let mut cur_inode = inode;
|
||||||
@@ -1226,7 +1239,7 @@ impl WasiFs {
|
|||||||
cur_inode = *p;
|
cur_inode = *p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => return Err(__WASI_EINVAL),
|
_ => return Err(Errno::Inval),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1242,10 +1255,10 @@ impl WasiFs {
|
|||||||
pub(crate) fn get_inode_at_path(
|
pub(crate) fn get_inode_at_path(
|
||||||
&self,
|
&self,
|
||||||
inodes: &mut WasiInodes,
|
inodes: &mut WasiInodes,
|
||||||
base: __wasi_fd_t,
|
base: WasiFd,
|
||||||
path: &str,
|
path: &str,
|
||||||
follow_symlinks: bool,
|
follow_symlinks: bool,
|
||||||
) -> Result<Inode, __wasi_errno_t> {
|
) -> Result<Inode, Errno> {
|
||||||
let start_inode = if !path.starts_with('/') && self.is_wasix.load(Ordering::Acquire) {
|
let start_inode = if !path.starts_with('/') && self.is_wasix.load(Ordering::Acquire) {
|
||||||
let (cur_inode, _) = self.get_current_dir(inodes, base)?;
|
let (cur_inode, _) = self.get_current_dir(inodes, base)?;
|
||||||
cur_inode
|
cur_inode
|
||||||
@@ -1261,15 +1274,15 @@ impl WasiFs {
|
|||||||
pub(crate) fn get_parent_inode_at_path(
|
pub(crate) fn get_parent_inode_at_path(
|
||||||
&self,
|
&self,
|
||||||
inodes: &mut WasiInodes,
|
inodes: &mut WasiInodes,
|
||||||
base: __wasi_fd_t,
|
base: WasiFd,
|
||||||
path: &Path,
|
path: &Path,
|
||||||
follow_symlinks: bool,
|
follow_symlinks: bool,
|
||||||
) -> Result<(Inode, String), __wasi_errno_t> {
|
) -> Result<(Inode, String), Errno> {
|
||||||
let mut parent_dir = std::path::PathBuf::new();
|
let mut parent_dir = std::path::PathBuf::new();
|
||||||
let mut components = path.components().rev();
|
let mut components = path.components().rev();
|
||||||
let new_entity_name = components
|
let new_entity_name = components
|
||||||
.next()
|
.next()
|
||||||
.ok_or(__WASI_EINVAL)?
|
.ok_or(Errno::Inval)?
|
||||||
.as_os_str()
|
.as_os_str()
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.to_string();
|
.to_string();
|
||||||
@@ -1280,70 +1293,59 @@ impl WasiFs {
|
|||||||
.map(|v| (v, new_entity_name))
|
.map(|v| (v, new_entity_name))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_fd(&self, fd: __wasi_fd_t) -> Result<Fd, __wasi_errno_t> {
|
pub fn get_fd(&self, fd: WasiFd) -> Result<Fd, Errno> {
|
||||||
self.fd_map
|
self.fd_map
|
||||||
.read()
|
.read()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.get(&fd)
|
.get(&fd)
|
||||||
.ok_or(__WASI_EBADF)
|
.ok_or(Errno::Badf)
|
||||||
.map(|a| a.clone())
|
.map(|a| a.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_fd_inode(
|
pub fn get_fd_inode(&self, fd: WasiFd) -> Result<generational_arena::Index, Errno> {
|
||||||
&self,
|
|
||||||
fd: __wasi_fd_t,
|
|
||||||
) -> Result<generational_arena::Index, __wasi_errno_t> {
|
|
||||||
self.fd_map
|
self.fd_map
|
||||||
.read()
|
.read()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.get(&fd)
|
.get(&fd)
|
||||||
.ok_or(__WASI_EBADF)
|
.ok_or(Errno::Badf)
|
||||||
.map(|a| a.inode)
|
.map(|a| a.inode)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn filestat_fd(
|
pub fn filestat_fd(&self, inodes: &WasiInodes, fd: WasiFd) -> Result<Filestat, Errno> {
|
||||||
&self,
|
|
||||||
inodes: &WasiInodes,
|
|
||||||
fd: __wasi_fd_t,
|
|
||||||
) -> Result<__wasi_filestat_t, __wasi_errno_t> {
|
|
||||||
let inode = self.get_fd_inode(fd)?;
|
let inode = self.get_fd_inode(fd)?;
|
||||||
Ok(*inodes.arena[inode].stat.read().unwrap().deref())
|
Ok(*inodes.arena[inode].stat.read().unwrap().deref())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fdstat(
|
pub fn fdstat(&self, inodes: &WasiInodes, fd: WasiFd) -> Result<Fdstat, Errno> {
|
||||||
&self,
|
|
||||||
inodes: &WasiInodes,
|
|
||||||
fd: __wasi_fd_t,
|
|
||||||
) -> Result<__wasi_fdstat_t, __wasi_errno_t> {
|
|
||||||
match fd {
|
match fd {
|
||||||
__WASI_STDIN_FILENO => {
|
__WASI_STDIN_FILENO => {
|
||||||
return Ok(__wasi_fdstat_t {
|
return Ok(Fdstat {
|
||||||
fs_filetype: __WASI_FILETYPE_CHARACTER_DEVICE,
|
fs_filetype: Filetype::CharacterDevice,
|
||||||
fs_flags: 0,
|
fs_flags: Fdflags::empty(),
|
||||||
fs_rights_base: STDIN_DEFAULT_RIGHTS,
|
fs_rights_base: STDIN_DEFAULT_RIGHTS,
|
||||||
fs_rights_inheriting: 0,
|
fs_rights_inheriting: Rights::empty(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
__WASI_STDOUT_FILENO => {
|
__WASI_STDOUT_FILENO => {
|
||||||
return Ok(__wasi_fdstat_t {
|
return Ok(Fdstat {
|
||||||
fs_filetype: __WASI_FILETYPE_CHARACTER_DEVICE,
|
fs_filetype: Filetype::CharacterDevice,
|
||||||
fs_flags: __WASI_FDFLAG_APPEND,
|
fs_flags: Fdflags::APPEND,
|
||||||
fs_rights_base: STDOUT_DEFAULT_RIGHTS,
|
fs_rights_base: STDOUT_DEFAULT_RIGHTS,
|
||||||
fs_rights_inheriting: 0,
|
fs_rights_inheriting: Rights::empty(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
__WASI_STDERR_FILENO => {
|
__WASI_STDERR_FILENO => {
|
||||||
return Ok(__wasi_fdstat_t {
|
return Ok(Fdstat {
|
||||||
fs_filetype: __WASI_FILETYPE_CHARACTER_DEVICE,
|
fs_filetype: Filetype::CharacterDevice,
|
||||||
fs_flags: __WASI_FDFLAG_APPEND,
|
fs_flags: Fdflags::APPEND,
|
||||||
fs_rights_base: STDERR_DEFAULT_RIGHTS,
|
fs_rights_base: STDERR_DEFAULT_RIGHTS,
|
||||||
fs_rights_inheriting: 0,
|
fs_rights_inheriting: Rights::empty(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
VIRTUAL_ROOT_FD => {
|
VIRTUAL_ROOT_FD => {
|
||||||
return Ok(__wasi_fdstat_t {
|
return Ok(Fdstat {
|
||||||
fs_filetype: __WASI_FILETYPE_DIRECTORY,
|
fs_filetype: Filetype::Directory,
|
||||||
fs_flags: 0,
|
fs_flags: Fdflags::empty(),
|
||||||
// TODO: fix this
|
// TODO: fix this
|
||||||
fs_rights_base: ALL_RIGHTS,
|
fs_rights_base: ALL_RIGHTS,
|
||||||
fs_rights_inheriting: ALL_RIGHTS,
|
fs_rights_inheriting: ALL_RIGHTS,
|
||||||
@@ -1356,12 +1358,12 @@ impl WasiFs {
|
|||||||
|
|
||||||
let guard = inodes.arena[fd.inode].read();
|
let guard = inodes.arena[fd.inode].read();
|
||||||
let deref = guard.deref();
|
let deref = guard.deref();
|
||||||
Ok(__wasi_fdstat_t {
|
Ok(Fdstat {
|
||||||
fs_filetype: match deref {
|
fs_filetype: match deref {
|
||||||
Kind::File { .. } => __WASI_FILETYPE_REGULAR_FILE,
|
Kind::File { .. } => Filetype::RegularFile,
|
||||||
Kind::Dir { .. } => __WASI_FILETYPE_DIRECTORY,
|
Kind::Dir { .. } => Filetype::Directory,
|
||||||
Kind::Symlink { .. } => __WASI_FILETYPE_SYMBOLIC_LINK,
|
Kind::Symlink { .. } => Filetype::SymbolicLink,
|
||||||
_ => __WASI_FILETYPE_UNKNOWN,
|
_ => Filetype::Unknown,
|
||||||
},
|
},
|
||||||
fs_flags: fd.flags,
|
fs_flags: fd.flags,
|
||||||
fs_rights_base: fd.rights,
|
fs_rights_base: fd.rights,
|
||||||
@@ -1369,11 +1371,7 @@ impl WasiFs {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn prestat_fd(
|
pub fn prestat_fd(&self, inodes: &WasiInodes, fd: WasiFd) -> Result<Prestat, Errno> {
|
||||||
&self,
|
|
||||||
inodes: &WasiInodes,
|
|
||||||
fd: __wasi_fd_t,
|
|
||||||
) -> Result<__wasi_prestat_t, __wasi_errno_t> {
|
|
||||||
let inode = self.get_fd_inode(fd)?;
|
let inode = self.get_fd_inode(fd)?;
|
||||||
trace!("in prestat_fd {:?}", self.get_fd(fd)?);
|
trace!("in prestat_fd {:?}", self.get_fd(fd)?);
|
||||||
|
|
||||||
@@ -1382,13 +1380,13 @@ impl WasiFs {
|
|||||||
if inode_val.is_preopened {
|
if inode_val.is_preopened {
|
||||||
Ok(self.prestat_fd_inner(inode_val))
|
Ok(self.prestat_fd_inner(inode_val))
|
||||||
} else {
|
} else {
|
||||||
Err(__WASI_EBADF)
|
Err(Errno::Badf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn prestat_fd_inner(&self, inode_val: &InodeVal) -> __wasi_prestat_t {
|
pub(crate) fn prestat_fd_inner(&self, inode_val: &InodeVal) -> Prestat {
|
||||||
__wasi_prestat_t {
|
Prestat {
|
||||||
pr_type: __WASI_PREOPENTYPE_DIR,
|
pr_type: Preopentype::Dir,
|
||||||
u: PrestatEnum::Dir {
|
u: PrestatEnum::Dir {
|
||||||
// REVIEW:
|
// REVIEW:
|
||||||
pr_name_len: inode_val.name.len() as u32 + 1,
|
pr_name_len: inode_val.name.len() as u32 + 1,
|
||||||
@@ -1397,7 +1395,7 @@ impl WasiFs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn flush(&self, inodes: &WasiInodes, fd: __wasi_fd_t) -> Result<(), __wasi_errno_t> {
|
pub fn flush(&self, inodes: &WasiInodes, fd: WasiFd) -> Result<(), Errno> {
|
||||||
match fd {
|
match fd {
|
||||||
__WASI_STDIN_FILENO => (),
|
__WASI_STDIN_FILENO => (),
|
||||||
__WASI_STDOUT_FILENO => inodes
|
__WASI_STDOUT_FILENO => inodes
|
||||||
@@ -1405,17 +1403,17 @@ impl WasiFs {
|
|||||||
.map_err(fs_error_into_wasi_err)?
|
.map_err(fs_error_into_wasi_err)?
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.map(|f| f.flush().map_err(map_io_err))
|
.map(|f| f.flush().map_err(map_io_err))
|
||||||
.unwrap_or_else(|| Err(__WASI_EIO))?,
|
.unwrap_or_else(|| Err(Errno::Io))?,
|
||||||
__WASI_STDERR_FILENO => inodes
|
__WASI_STDERR_FILENO => inodes
|
||||||
.stderr_mut(&self.fd_map)
|
.stderr_mut(&self.fd_map)
|
||||||
.map_err(fs_error_into_wasi_err)?
|
.map_err(fs_error_into_wasi_err)?
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.and_then(|f| f.flush().ok())
|
.and_then(|f| f.flush().ok())
|
||||||
.ok_or(__WASI_EIO)?,
|
.ok_or(Errno::Io)?,
|
||||||
_ => {
|
_ => {
|
||||||
let fd = self.get_fd(fd)?;
|
let fd = self.get_fd(fd)?;
|
||||||
if fd.rights & __WASI_RIGHT_FD_DATASYNC == 0 {
|
if !fd.rights.contains(Rights::FD_DATASYNC) {
|
||||||
return Err(__WASI_EACCES);
|
return Err(Errno::Access);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut guard = inodes.arena[fd.inode].write();
|
let mut guard = inodes.arena[fd.inode].write();
|
||||||
@@ -1423,12 +1421,12 @@ impl WasiFs {
|
|||||||
match deref_mut {
|
match deref_mut {
|
||||||
Kind::File {
|
Kind::File {
|
||||||
handle: Some(file), ..
|
handle: Some(file), ..
|
||||||
} => file.flush().map_err(|_| __WASI_EIO)?,
|
} => file.flush().map_err(|_| Errno::Io)?,
|
||||||
// TODO: verify this behavior
|
// TODO: verify this behavior
|
||||||
Kind::Dir { .. } => return Err(__WASI_EISDIR),
|
Kind::Dir { .. } => return Err(Errno::Isdir),
|
||||||
Kind::Symlink { .. } => unimplemented!("WasiFs::flush Kind::Symlink"),
|
Kind::Symlink { .. } => unimplemented!("WasiFs::flush Kind::Symlink"),
|
||||||
Kind::Buffer { .. } => (),
|
Kind::Buffer { .. } => (),
|
||||||
_ => return Err(__WASI_EIO),
|
_ => return Err(Errno::Io),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1442,7 +1440,7 @@ impl WasiFs {
|
|||||||
kind: Kind,
|
kind: Kind,
|
||||||
is_preopened: bool,
|
is_preopened: bool,
|
||||||
name: String,
|
name: String,
|
||||||
) -> Result<Inode, __wasi_errno_t> {
|
) -> Result<Inode, Errno> {
|
||||||
let stat = self.get_stat_for_kind(inodes, &kind)?;
|
let stat = self.get_stat_for_kind(inodes, &kind)?;
|
||||||
Ok(self.create_inode_with_stat(inodes, kind, is_preopened, name, stat))
|
Ok(self.create_inode_with_stat(inodes, kind, is_preopened, name, stat))
|
||||||
}
|
}
|
||||||
@@ -1455,7 +1453,7 @@ impl WasiFs {
|
|||||||
is_preopened: bool,
|
is_preopened: bool,
|
||||||
name: String,
|
name: String,
|
||||||
) -> Inode {
|
) -> Inode {
|
||||||
let stat = __wasi_filestat_t::default();
|
let stat = Filestat::default();
|
||||||
self.create_inode_with_stat(inodes, kind, is_preopened, name, stat)
|
self.create_inode_with_stat(inodes, kind, is_preopened, name, stat)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1466,7 +1464,7 @@ impl WasiFs {
|
|||||||
kind: Kind,
|
kind: Kind,
|
||||||
is_preopened: bool,
|
is_preopened: bool,
|
||||||
name: String,
|
name: String,
|
||||||
mut stat: __wasi_filestat_t,
|
mut stat: Filestat,
|
||||||
) -> Inode {
|
) -> Inode {
|
||||||
stat.st_ino = self.get_next_inode_index();
|
stat.st_ino = self.get_next_inode_index();
|
||||||
|
|
||||||
@@ -1480,12 +1478,12 @@ impl WasiFs {
|
|||||||
|
|
||||||
pub fn create_fd(
|
pub fn create_fd(
|
||||||
&self,
|
&self,
|
||||||
rights: __wasi_rights_t,
|
rights: Rights,
|
||||||
rights_inheriting: __wasi_rights_t,
|
rights_inheriting: Rights,
|
||||||
flags: __wasi_fdflags_t,
|
flags: Fdflags,
|
||||||
open_flags: u16,
|
open_flags: u16,
|
||||||
inode: Inode,
|
inode: Inode,
|
||||||
) -> Result<__wasi_fd_t, __wasi_errno_t> {
|
) -> Result<WasiFd, Errno> {
|
||||||
let idx = self.next_fd.fetch_add(1, Ordering::AcqRel);
|
let idx = self.next_fd.fetch_add(1, Ordering::AcqRel);
|
||||||
self.fd_map.write().unwrap().insert(
|
self.fd_map.write().unwrap().insert(
|
||||||
idx,
|
idx,
|
||||||
@@ -1501,7 +1499,7 @@ impl WasiFs {
|
|||||||
Ok(idx)
|
Ok(idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clone_fd(&self, fd: __wasi_fd_t) -> Result<__wasi_fd_t, __wasi_errno_t> {
|
pub fn clone_fd(&self, fd: WasiFd) -> Result<WasiFd, Errno> {
|
||||||
let fd = self.get_fd(fd)?;
|
let fd = self.get_fd(fd)?;
|
||||||
let idx = self.next_fd.fetch_add(1, Ordering::AcqRel);
|
let idx = self.next_fd.fetch_add(1, Ordering::AcqRel);
|
||||||
self.fd_map.write().unwrap().insert(
|
self.fd_map.write().unwrap().insert(
|
||||||
@@ -1531,10 +1529,10 @@ impl WasiFs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn create_virtual_root(&self, inodes: &mut WasiInodes) -> Inode {
|
fn create_virtual_root(&self, inodes: &mut WasiInodes) -> Inode {
|
||||||
let stat = __wasi_filestat_t {
|
let stat = Filestat {
|
||||||
st_filetype: __WASI_FILETYPE_DIRECTORY,
|
st_filetype: Filetype::Directory,
|
||||||
st_ino: self.get_next_inode_index(),
|
st_ino: self.get_next_inode_index(),
|
||||||
..__wasi_filestat_t::default()
|
..Filestat::default()
|
||||||
};
|
};
|
||||||
let root_kind = Kind::Root {
|
let root_kind = Kind::Root {
|
||||||
entries: HashMap::new(),
|
entries: HashMap::new(),
|
||||||
@@ -1555,7 +1553,7 @@ impl WasiFs {
|
|||||||
"stdout",
|
"stdout",
|
||||||
__WASI_STDOUT_FILENO,
|
__WASI_STDOUT_FILENO,
|
||||||
STDOUT_DEFAULT_RIGHTS,
|
STDOUT_DEFAULT_RIGHTS,
|
||||||
__WASI_FDFLAG_APPEND,
|
Fdflags::APPEND,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
fn create_stdin(&self, inodes: &mut WasiInodes) {
|
fn create_stdin(&self, inodes: &mut WasiInodes) {
|
||||||
@@ -1565,7 +1563,7 @@ impl WasiFs {
|
|||||||
"stdin",
|
"stdin",
|
||||||
__WASI_STDIN_FILENO,
|
__WASI_STDIN_FILENO,
|
||||||
STDIN_DEFAULT_RIGHTS,
|
STDIN_DEFAULT_RIGHTS,
|
||||||
0,
|
Fdflags::empty(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
fn create_stderr(&self, inodes: &mut WasiInodes) {
|
fn create_stderr(&self, inodes: &mut WasiInodes) {
|
||||||
@@ -1575,7 +1573,7 @@ impl WasiFs {
|
|||||||
"stderr",
|
"stderr",
|
||||||
__WASI_STDERR_FILENO,
|
__WASI_STDERR_FILENO,
|
||||||
STDERR_DEFAULT_RIGHTS,
|
STDERR_DEFAULT_RIGHTS,
|
||||||
__WASI_FDFLAG_APPEND,
|
Fdflags::APPEND,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1584,14 +1582,14 @@ impl WasiFs {
|
|||||||
inodes: &mut WasiInodes,
|
inodes: &mut WasiInodes,
|
||||||
handle: Box<dyn VirtualFile + Send + Sync + 'static>,
|
handle: Box<dyn VirtualFile + Send + Sync + 'static>,
|
||||||
name: &'static str,
|
name: &'static str,
|
||||||
raw_fd: __wasi_fd_t,
|
raw_fd: WasiFd,
|
||||||
rights: __wasi_rights_t,
|
rights: Rights,
|
||||||
fd_flags: __wasi_fdflags_t,
|
fd_flags: Fdflags,
|
||||||
) {
|
) {
|
||||||
let stat = __wasi_filestat_t {
|
let stat = Filestat {
|
||||||
st_filetype: __WASI_FILETYPE_CHARACTER_DEVICE,
|
st_filetype: Filetype::CharacterDevice,
|
||||||
st_ino: self.get_next_inode_index(),
|
st_ino: self.get_next_inode_index(),
|
||||||
..__wasi_filestat_t::default()
|
..Filestat::default()
|
||||||
};
|
};
|
||||||
let kind = Kind::File {
|
let kind = Kind::File {
|
||||||
fd: Some(raw_fd),
|
fd: Some(raw_fd),
|
||||||
@@ -1610,7 +1608,7 @@ impl WasiFs {
|
|||||||
raw_fd,
|
raw_fd,
|
||||||
Fd {
|
Fd {
|
||||||
rights,
|
rights,
|
||||||
rights_inheriting: 0,
|
rights_inheriting: Rights::empty(),
|
||||||
flags: fd_flags,
|
flags: fd_flags,
|
||||||
// since we're not calling open on this, we don't need open flags
|
// since we're not calling open on this, we don't need open flags
|
||||||
open_flags: 0,
|
open_flags: 0,
|
||||||
@@ -1620,22 +1618,18 @@ impl WasiFs {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_stat_for_kind(
|
pub fn get_stat_for_kind(&self, inodes: &WasiInodes, kind: &Kind) -> Result<Filestat, Errno> {
|
||||||
&self,
|
|
||||||
inodes: &WasiInodes,
|
|
||||||
kind: &Kind,
|
|
||||||
) -> Result<__wasi_filestat_t, __wasi_errno_t> {
|
|
||||||
let md = match kind {
|
let md = match kind {
|
||||||
Kind::File { handle, path, .. } => match handle {
|
Kind::File { handle, path, .. } => match handle {
|
||||||
Some(wf) => {
|
Some(wf) => {
|
||||||
return Ok(__wasi_filestat_t {
|
return Ok(Filestat {
|
||||||
st_filetype: __WASI_FILETYPE_REGULAR_FILE,
|
st_filetype: Filetype::RegularFile,
|
||||||
st_size: wf.size(),
|
st_size: wf.size(),
|
||||||
st_atim: wf.last_accessed(),
|
st_atim: wf.last_accessed(),
|
||||||
st_mtim: wf.last_modified(),
|
st_mtim: wf.last_modified(),
|
||||||
st_ctim: wf.created_time(),
|
st_ctim: wf.created_time(),
|
||||||
|
|
||||||
..__wasi_filestat_t::default()
|
..Filestat::default()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
None => self
|
None => self
|
||||||
@@ -1675,24 +1669,20 @@ impl WasiFs {
|
|||||||
_ => unreachable!("Symlink pointing to something that's not a directory as its base preopened directory"),
|
_ => unreachable!("Symlink pointing to something that's not a directory as its base preopened directory"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => return Err(__WASI_EIO),
|
_ => return Err(Errno::Io),
|
||||||
};
|
};
|
||||||
Ok(__wasi_filestat_t {
|
Ok(Filestat {
|
||||||
st_filetype: virtual_file_type_to_wasi_file_type(md.file_type()),
|
st_filetype: virtual_file_type_to_wasi_file_type(md.file_type()),
|
||||||
st_size: md.len(),
|
st_size: md.len(),
|
||||||
st_atim: md.accessed(),
|
st_atim: md.accessed(),
|
||||||
st_mtim: md.modified(),
|
st_mtim: md.modified(),
|
||||||
st_ctim: md.created(),
|
st_ctim: md.created(),
|
||||||
..__wasi_filestat_t::default()
|
..Filestat::default()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Closes an open FD, handling all details such as FD being preopen
|
/// Closes an open FD, handling all details such as FD being preopen
|
||||||
pub(crate) fn close_fd(
|
pub(crate) fn close_fd(&self, inodes: &WasiInodes, fd: WasiFd) -> Result<(), Errno> {
|
||||||
&self,
|
|
||||||
inodes: &WasiInodes,
|
|
||||||
fd: __wasi_fd_t,
|
|
||||||
) -> Result<(), __wasi_errno_t> {
|
|
||||||
let inode = self.get_fd_inode(fd)?;
|
let inode = self.get_fd_inode(fd)?;
|
||||||
let inodeval = inodes.get_inodeval(inode)?;
|
let inodeval = inodes.get_inodeval(inode)?;
|
||||||
let is_preopened = inodeval.is_preopened;
|
let is_preopened = inodeval.is_preopened;
|
||||||
@@ -1715,7 +1705,7 @@ impl WasiFs {
|
|||||||
debug!("Closing dir {:?}", &path);
|
debug!("Closing dir {:?}", &path);
|
||||||
let key = path
|
let key = path
|
||||||
.file_name()
|
.file_name()
|
||||||
.ok_or(__WASI_EINVAL)?
|
.ok_or(Errno::Inval)?
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.to_string();
|
.to_string();
|
||||||
if let Some(p) = *parent {
|
if let Some(p) = *parent {
|
||||||
@@ -1753,12 +1743,12 @@ impl WasiFs {
|
|||||||
} else {
|
} else {
|
||||||
// this shouldn't be possible anymore due to Root
|
// this shouldn't be possible anymore due to Root
|
||||||
debug!("HIT UNREACHABLE CODE! Non-root directory does not have a parent");
|
debug!("HIT UNREACHABLE CODE! Non-root directory does not have a parent");
|
||||||
return Err(__WASI_EINVAL);
|
return Err(Errno::Inval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Kind::EventNotifications { .. } => {}
|
Kind::EventNotifications { .. } => {}
|
||||||
Kind::Root { .. } => return Err(__WASI_EACCES),
|
Kind::Root { .. } => return Err(Errno::Access),
|
||||||
Kind::Symlink { .. } | Kind::Buffer { .. } => return Err(__WASI_EINVAL),
|
Kind::Symlink { .. } | Kind::Buffer { .. } => return Err(Errno::Inval),
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1770,21 +1760,21 @@ impl WasiState {
|
|||||||
pub(crate) fn fs_read_dir<P: AsRef<Path>>(
|
pub(crate) fn fs_read_dir<P: AsRef<Path>>(
|
||||||
&self,
|
&self,
|
||||||
path: P,
|
path: P,
|
||||||
) -> Result<wasmer_vfs::ReadDir, __wasi_errno_t> {
|
) -> Result<wasmer_vfs::ReadDir, Errno> {
|
||||||
self.fs
|
self.fs
|
||||||
.fs_backing
|
.fs_backing
|
||||||
.read_dir(path.as_ref())
|
.read_dir(path.as_ref())
|
||||||
.map_err(fs_error_into_wasi_err)
|
.map_err(fs_error_into_wasi_err)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fs_create_dir<P: AsRef<Path>>(&self, path: P) -> Result<(), __wasi_errno_t> {
|
pub(crate) fn fs_create_dir<P: AsRef<Path>>(&self, path: P) -> Result<(), Errno> {
|
||||||
self.fs
|
self.fs
|
||||||
.fs_backing
|
.fs_backing
|
||||||
.create_dir(path.as_ref())
|
.create_dir(path.as_ref())
|
||||||
.map_err(fs_error_into_wasi_err)
|
.map_err(fs_error_into_wasi_err)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fs_remove_dir<P: AsRef<Path>>(&self, path: P) -> Result<(), __wasi_errno_t> {
|
pub(crate) fn fs_remove_dir<P: AsRef<Path>>(&self, path: P) -> Result<(), Errno> {
|
||||||
self.fs
|
self.fs
|
||||||
.fs_backing
|
.fs_backing
|
||||||
.remove_dir(path.as_ref())
|
.remove_dir(path.as_ref())
|
||||||
@@ -1795,14 +1785,14 @@ impl WasiState {
|
|||||||
&self,
|
&self,
|
||||||
from: P,
|
from: P,
|
||||||
to: Q,
|
to: Q,
|
||||||
) -> Result<(), __wasi_errno_t> {
|
) -> Result<(), Errno> {
|
||||||
self.fs
|
self.fs
|
||||||
.fs_backing
|
.fs_backing
|
||||||
.rename(from.as_ref(), to.as_ref())
|
.rename(from.as_ref(), to.as_ref())
|
||||||
.map_err(fs_error_into_wasi_err)
|
.map_err(fs_error_into_wasi_err)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fs_remove_file<P: AsRef<Path>>(&self, path: P) -> Result<(), __wasi_errno_t> {
|
pub(crate) fn fs_remove_file<P: AsRef<Path>>(&self, path: P) -> Result<(), Errno> {
|
||||||
self.fs
|
self.fs
|
||||||
.fs_backing
|
.fs_backing
|
||||||
.remove_file(path.as_ref())
|
.remove_file(path.as_ref())
|
||||||
@@ -1938,7 +1928,7 @@ impl WasiState {
|
|||||||
/// Expects one of `__WASI_STDIN_FILENO`, `__WASI_STDOUT_FILENO`, `__WASI_STDERR_FILENO`.
|
/// Expects one of `__WASI_STDIN_FILENO`, `__WASI_STDOUT_FILENO`, `__WASI_STDERR_FILENO`.
|
||||||
fn std_dev_get(
|
fn std_dev_get(
|
||||||
&self,
|
&self,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
) -> Result<Option<Box<dyn VirtualFile + Send + Sync + 'static>>, FsError> {
|
) -> Result<Option<Box<dyn VirtualFile + Send + Sync + 'static>>, FsError> {
|
||||||
let ret = WasiStateFileGuard::new(self, fd)?.map(|a| {
|
let ret = WasiStateFileGuard::new(self, fd)?.map(|a| {
|
||||||
let ret = Box::new(a);
|
let ret = Box::new(a);
|
||||||
@@ -1949,15 +1939,15 @@ impl WasiState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn virtual_file_type_to_wasi_file_type(file_type: wasmer_vfs::FileType) -> __wasi_filetype_t {
|
pub fn virtual_file_type_to_wasi_file_type(file_type: wasmer_vfs::FileType) -> Filetype {
|
||||||
// TODO: handle other file types
|
// TODO: handle other file types
|
||||||
if file_type.is_dir() {
|
if file_type.is_dir() {
|
||||||
__WASI_FILETYPE_DIRECTORY
|
Filetype::Directory
|
||||||
} else if file_type.is_file() {
|
} else if file_type.is_file() {
|
||||||
__WASI_FILETYPE_REGULAR_FILE
|
Filetype::RegularFile
|
||||||
} else if file_type.is_symlink() {
|
} else if file_type.is_symlink() {
|
||||||
__WASI_FILETYPE_SYMBOLIC_LINK
|
Filetype::SymbolicLink
|
||||||
} else {
|
} else {
|
||||||
__WASI_FILETYPE_UNKNOWN
|
Filetype::Unknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use std::sync::mpsc;
|
|||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use wasmer::WasmSlice;
|
use wasmer::WasmSlice;
|
||||||
use wasmer::{MemorySize, MemoryView};
|
use wasmer::{MemorySize, MemoryView};
|
||||||
|
use wasmer_wasi_types::wasi::Errno;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct WasiPipe {
|
pub struct WasiPipe {
|
||||||
@@ -43,7 +44,7 @@ impl WasiPipe {
|
|||||||
&mut self,
|
&mut self,
|
||||||
memory: &MemoryView,
|
memory: &MemoryView,
|
||||||
iov: WasmSlice<__wasi_iovec_t<M>>,
|
iov: WasmSlice<__wasi_iovec_t<M>>,
|
||||||
) -> Result<usize, __wasi_errno_t> {
|
) -> Result<usize, Errno> {
|
||||||
loop {
|
loop {
|
||||||
if let Some(buf) = self.read_buffer.as_mut() {
|
if let Some(buf) = self.read_buffer.as_mut() {
|
||||||
let buf_len = buf.len();
|
let buf_len = buf.len();
|
||||||
@@ -55,7 +56,7 @@ impl WasiPipe {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let rx = self.rx.lock().unwrap();
|
let rx = self.rx.lock().unwrap();
|
||||||
let data = rx.recv().map_err(|_| __WASI_EIO)?;
|
let data = rx.recv().map_err(|_| Errno::Io)?;
|
||||||
self.read_buffer.replace(Bytes::from(data));
|
self.read_buffer.replace(Bytes::from(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,17 +65,17 @@ impl WasiPipe {
|
|||||||
&mut self,
|
&mut self,
|
||||||
memory: &MemoryView,
|
memory: &MemoryView,
|
||||||
iov: WasmSlice<__wasi_ciovec_t<M>>,
|
iov: WasmSlice<__wasi_ciovec_t<M>>,
|
||||||
) -> Result<usize, __wasi_errno_t> {
|
) -> Result<usize, Errno> {
|
||||||
let buf_len: M::Offset = iov
|
let buf_len: M::Offset = iov
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|a| a.read().ok())
|
.filter_map(|a| a.read().ok())
|
||||||
.map(|a| a.buf_len)
|
.map(|a| a.buf_len)
|
||||||
.sum();
|
.sum();
|
||||||
let buf_len: usize = buf_len.try_into().map_err(|_| __WASI_EINVAL)?;
|
let buf_len: usize = buf_len.try_into().map_err(|_| Errno::Inval)?;
|
||||||
let mut buf = Vec::with_capacity(buf_len);
|
let mut buf = Vec::with_capacity(buf_len);
|
||||||
write_bytes(&mut buf, memory, iov)?;
|
write_bytes(&mut buf, memory, iov)?;
|
||||||
let tx = self.tx.lock().unwrap();
|
let tx = self.tx.lock().unwrap();
|
||||||
tx.send(buf).map_err(|_| __WASI_EIO)?;
|
tx.send(buf).map_err(|_| Errno::Io)?;
|
||||||
Ok(buf_len)
|
Ok(buf_len)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,4 @@
|
|||||||
/// types for use in the WASI filesystem
|
/// types for use in the WASI filesystem
|
||||||
use crate::syscalls::types::*;
|
|
||||||
#[cfg(feature = "enable-serde")]
|
#[cfg(feature = "enable-serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
#[cfg(all(unix, feature = "sys-poll"))]
|
#[cfg(all(unix, feature = "sys-poll"))]
|
||||||
@@ -11,6 +10,7 @@ use std::{
|
|||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use wasmer_vbus::BusError;
|
use wasmer_vbus::BusError;
|
||||||
|
use wasmer_wasi_types::wasi::{BusErrno, Errno};
|
||||||
|
|
||||||
#[cfg(feature = "host-fs")]
|
#[cfg(feature = "host-fs")]
|
||||||
pub use wasmer_vfs::host_fs::{Stderr, Stdin, Stdout};
|
pub use wasmer_vfs::host_fs::{Stderr, Stdin, Stdout};
|
||||||
@@ -20,135 +20,136 @@ pub use wasmer_vfs::mem_fs::{Stderr, Stdin, Stdout};
|
|||||||
use wasmer_vfs::{FsError, VirtualFile};
|
use wasmer_vfs::{FsError, VirtualFile};
|
||||||
use wasmer_vnet::NetworkError;
|
use wasmer_vnet::NetworkError;
|
||||||
|
|
||||||
pub fn fs_error_from_wasi_err(err: __wasi_errno_t) -> FsError {
|
pub fn fs_error_from_wasi_err(err: Errno) -> FsError {
|
||||||
match err {
|
match err {
|
||||||
__WASI_EBADF => FsError::InvalidFd,
|
Errno::Badf => FsError::InvalidFd,
|
||||||
__WASI_EEXIST => FsError::AlreadyExists,
|
Errno::Exist => FsError::AlreadyExists,
|
||||||
__WASI_EIO => FsError::IOError,
|
Errno::Io => FsError::IOError,
|
||||||
__WASI_EADDRINUSE => FsError::AddressInUse,
|
Errno::Addrinuse => FsError::AddressInUse,
|
||||||
__WASI_EADDRNOTAVAIL => FsError::AddressNotAvailable,
|
Errno::Addrnotavail => FsError::AddressNotAvailable,
|
||||||
__WASI_EPIPE => FsError::BrokenPipe,
|
Errno::Pipe => FsError::BrokenPipe,
|
||||||
__WASI_ECONNABORTED => FsError::ConnectionAborted,
|
Errno::Connaborted => FsError::ConnectionAborted,
|
||||||
__WASI_ECONNREFUSED => FsError::ConnectionRefused,
|
Errno::Connrefused => FsError::ConnectionRefused,
|
||||||
__WASI_ECONNRESET => FsError::ConnectionReset,
|
Errno::Connreset => FsError::ConnectionReset,
|
||||||
__WASI_EINTR => FsError::Interrupted,
|
Errno::Intr => FsError::Interrupted,
|
||||||
__WASI_EINVAL => FsError::InvalidInput,
|
Errno::Inval => FsError::InvalidInput,
|
||||||
__WASI_ENOTCONN => FsError::NotConnected,
|
Errno::Notconn => FsError::NotConnected,
|
||||||
__WASI_ENODEV => FsError::NoDevice,
|
Errno::Nodev => FsError::NoDevice,
|
||||||
__WASI_ENOENT => FsError::EntityNotFound,
|
Errno::Noent => FsError::EntityNotFound,
|
||||||
__WASI_EPERM => FsError::PermissionDenied,
|
Errno::Perm => FsError::PermissionDenied,
|
||||||
__WASI_ETIMEDOUT => FsError::TimedOut,
|
Errno::Timedout => FsError::TimedOut,
|
||||||
__WASI_EPROTO => FsError::UnexpectedEof,
|
Errno::Proto => FsError::UnexpectedEof,
|
||||||
__WASI_EAGAIN => FsError::WouldBlock,
|
Errno::Again => FsError::WouldBlock,
|
||||||
__WASI_ENOSPC => FsError::WriteZero,
|
Errno::Nospc => FsError::WriteZero,
|
||||||
__WASI_ENOTEMPTY => FsError::DirectoryNotEmpty,
|
Errno::Notempty => FsError::DirectoryNotEmpty,
|
||||||
_ => FsError::UnknownError,
|
_ => FsError::UnknownError,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fs_error_into_wasi_err(fs_error: FsError) -> __wasi_errno_t {
|
pub fn fs_error_into_wasi_err(fs_error: FsError) -> Errno {
|
||||||
match fs_error {
|
match fs_error {
|
||||||
FsError::AlreadyExists => __WASI_EEXIST,
|
FsError::AlreadyExists => Errno::Exist,
|
||||||
FsError::AddressInUse => __WASI_EADDRINUSE,
|
FsError::AddressInUse => Errno::Addrinuse,
|
||||||
FsError::AddressNotAvailable => __WASI_EADDRNOTAVAIL,
|
FsError::AddressNotAvailable => Errno::Addrnotavail,
|
||||||
FsError::BaseNotDirectory => __WASI_ENOTDIR,
|
FsError::BaseNotDirectory => Errno::Notdir,
|
||||||
FsError::BrokenPipe => __WASI_EPIPE,
|
FsError::BrokenPipe => Errno::Pipe,
|
||||||
FsError::ConnectionAborted => __WASI_ECONNABORTED,
|
FsError::ConnectionAborted => Errno::Connaborted,
|
||||||
FsError::ConnectionRefused => __WASI_ECONNREFUSED,
|
FsError::ConnectionRefused => Errno::Connrefused,
|
||||||
FsError::ConnectionReset => __WASI_ECONNRESET,
|
FsError::ConnectionReset => Errno::Connreset,
|
||||||
FsError::Interrupted => __WASI_EINTR,
|
FsError::Interrupted => Errno::Intr,
|
||||||
FsError::InvalidData => __WASI_EIO,
|
FsError::InvalidData => Errno::Io,
|
||||||
FsError::InvalidFd => __WASI_EBADF,
|
FsError::InvalidFd => Errno::Badf,
|
||||||
FsError::InvalidInput => __WASI_EINVAL,
|
FsError::InvalidInput => Errno::Inval,
|
||||||
FsError::IOError => __WASI_EIO,
|
FsError::IOError => Errno::Io,
|
||||||
FsError::NoDevice => __WASI_ENODEV,
|
FsError::NoDevice => Errno::Nodev,
|
||||||
FsError::NotAFile => __WASI_EINVAL,
|
FsError::NotAFile => Errno::Inval,
|
||||||
FsError::NotConnected => __WASI_ENOTCONN,
|
FsError::NotConnected => Errno::Notconn,
|
||||||
FsError::EntityNotFound => __WASI_ENOENT,
|
FsError::EntityNotFound => Errno::Noent,
|
||||||
FsError::PermissionDenied => __WASI_EPERM,
|
FsError::PermissionDenied => Errno::Perm,
|
||||||
FsError::TimedOut => __WASI_ETIMEDOUT,
|
FsError::TimedOut => Errno::Timedout,
|
||||||
FsError::UnexpectedEof => __WASI_EPROTO,
|
FsError::UnexpectedEof => Errno::Proto,
|
||||||
FsError::WouldBlock => __WASI_EAGAIN,
|
FsError::WouldBlock => Errno::Again,
|
||||||
FsError::WriteZero => __WASI_ENOSPC,
|
FsError::WriteZero => Errno::Nospc,
|
||||||
FsError::DirectoryNotEmpty => __WASI_ENOTEMPTY,
|
FsError::DirectoryNotEmpty => Errno::Notempty,
|
||||||
FsError::Lock | FsError::UnknownError => __WASI_EIO,
|
FsError::Lock | FsError::UnknownError => Errno::Io,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn net_error_into_wasi_err(net_error: NetworkError) -> __wasi_errno_t {
|
pub fn net_error_into_wasi_err(net_error: NetworkError) -> Errno {
|
||||||
match net_error {
|
match net_error {
|
||||||
NetworkError::InvalidFd => __WASI_EBADF,
|
NetworkError::InvalidFd => Errno::Badf,
|
||||||
NetworkError::AlreadyExists => __WASI_EEXIST,
|
NetworkError::AlreadyExists => Errno::Exist,
|
||||||
NetworkError::Lock => __WASI_EIO,
|
NetworkError::Lock => Errno::Io,
|
||||||
NetworkError::IOError => __WASI_EIO,
|
NetworkError::IOError => Errno::Io,
|
||||||
NetworkError::AddressInUse => __WASI_EADDRINUSE,
|
NetworkError::AddressInUse => Errno::Addrinuse,
|
||||||
NetworkError::AddressNotAvailable => __WASI_EADDRNOTAVAIL,
|
NetworkError::AddressNotAvailable => Errno::Addrnotavail,
|
||||||
NetworkError::BrokenPipe => __WASI_EPIPE,
|
NetworkError::BrokenPipe => Errno::Pipe,
|
||||||
NetworkError::ConnectionAborted => __WASI_ECONNABORTED,
|
NetworkError::ConnectionAborted => Errno::Connaborted,
|
||||||
NetworkError::ConnectionRefused => __WASI_ECONNREFUSED,
|
NetworkError::ConnectionRefused => Errno::Connrefused,
|
||||||
NetworkError::ConnectionReset => __WASI_ECONNRESET,
|
NetworkError::ConnectionReset => Errno::Connreset,
|
||||||
NetworkError::Interrupted => __WASI_EINTR,
|
NetworkError::Interrupted => Errno::Intr,
|
||||||
NetworkError::InvalidData => __WASI_EIO,
|
NetworkError::InvalidData => Errno::Io,
|
||||||
NetworkError::InvalidInput => __WASI_EINVAL,
|
NetworkError::InvalidInput => Errno::Inval,
|
||||||
NetworkError::NotConnected => __WASI_ENOTCONN,
|
NetworkError::NotConnected => Errno::Notconn,
|
||||||
NetworkError::NoDevice => __WASI_ENODEV,
|
NetworkError::NoDevice => Errno::Nodev,
|
||||||
NetworkError::PermissionDenied => __WASI_EPERM,
|
NetworkError::PermissionDenied => Errno::Perm,
|
||||||
NetworkError::TimedOut => __WASI_ETIMEDOUT,
|
NetworkError::TimedOut => Errno::Timedout,
|
||||||
NetworkError::UnexpectedEof => __WASI_EPROTO,
|
NetworkError::UnexpectedEof => Errno::Proto,
|
||||||
NetworkError::WouldBlock => __WASI_EAGAIN,
|
NetworkError::WouldBlock => Errno::Again,
|
||||||
NetworkError::WriteZero => __WASI_ENOSPC,
|
NetworkError::WriteZero => Errno::Nospc,
|
||||||
NetworkError::Unsupported => __WASI_ENOTSUP,
|
NetworkError::Unsupported => Errno::Notsup,
|
||||||
NetworkError::UnknownError => __WASI_EIO,
|
NetworkError::UnknownError => Errno::Io,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bus_error_into_wasi_err(bus_error: BusError) -> __bus_errno_t {
|
pub fn bus_error_into_wasi_err(bus_error: BusError) -> BusErrno {
|
||||||
use BusError::*;
|
use BusError::*;
|
||||||
match bus_error {
|
match bus_error {
|
||||||
Serialization => __BUS_ESER,
|
Serialization => BusErrno::Ser,
|
||||||
Deserialization => __BUS_EDES,
|
Deserialization => BusErrno::Des,
|
||||||
InvalidWapm => __BUS_EWAPM,
|
InvalidWapm => BusErrno::Wapm,
|
||||||
FetchFailed => __BUS_EFETCH,
|
FetchFailed => BusErrno::Fetch,
|
||||||
CompileError => __BUS_ECOMPILE,
|
CompileError => BusErrno::Compile,
|
||||||
InvalidABI => __BUS_EABI,
|
InvalidABI => BusErrno::Abi,
|
||||||
Aborted => __BUS_EABORTED,
|
Aborted => BusErrno::Aborted,
|
||||||
BadHandle => __BUS_EBADHANDLE,
|
BadHandle => BusErrno::Badhandle,
|
||||||
InvalidTopic => __BUS_ETOPIC,
|
InvalidTopic => BusErrno::Topic,
|
||||||
BadCallback => __BUS_EBADCB,
|
BadCallback => BusErrno::Badcb,
|
||||||
Unsupported => __BUS_EUNSUPPORTED,
|
Unsupported => BusErrno::Unsupported,
|
||||||
BadRequest => __BUS_EBADREQUEST,
|
BadRequest => BusErrno::Badrequest,
|
||||||
AccessDenied => __BUS_EDENIED,
|
AccessDenied => BusErrno::Denied,
|
||||||
InternalError => __BUS_EINTERNAL,
|
InternalError => BusErrno::Internal,
|
||||||
MemoryAllocationFailed => __BUS_EALLOC,
|
MemoryAllocationFailed => BusErrno::Alloc,
|
||||||
InvokeFailed => __BUS_EINVOKE,
|
InvokeFailed => BusErrno::Invoke,
|
||||||
AlreadyConsumed => __BUS_ECONSUMED,
|
AlreadyConsumed => BusErrno::Consumed,
|
||||||
MemoryAccessViolation => __BUS_EMEMVIOLATION,
|
MemoryAccessViolation => BusErrno::Memviolation,
|
||||||
UnknownError => __BUS_EUNKNOWN,
|
UnknownError => BusErrno::Unknown,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wasi_error_into_bus_err(bus_error: __bus_errno_t) -> BusError {
|
pub fn wasi_error_into_bus_err(bus_error: BusErrno) -> BusError {
|
||||||
use BusError::*;
|
use BusError::*;
|
||||||
match bus_error {
|
match bus_error {
|
||||||
__BUS_ESER => Serialization,
|
BusErrno::Success => UnknownError,
|
||||||
__BUS_EDES => Deserialization,
|
BusErrno::Ser => Serialization,
|
||||||
__BUS_EWAPM => InvalidWapm,
|
BusErrno::Des => Deserialization,
|
||||||
__BUS_EFETCH => FetchFailed,
|
BusErrno::Wapm => InvalidWapm,
|
||||||
__BUS_ECOMPILE => CompileError,
|
BusErrno::Fetch => FetchFailed,
|
||||||
__BUS_EABI => InvalidABI,
|
BusErrno::Compile => CompileError,
|
||||||
__BUS_EABORTED => Aborted,
|
BusErrno::Abi => InvalidABI,
|
||||||
__BUS_EBADHANDLE => BadHandle,
|
BusErrno::Aborted => Aborted,
|
||||||
__BUS_ETOPIC => InvalidTopic,
|
BusErrno::Badhandle => BadHandle,
|
||||||
__BUS_EBADCB => BadCallback,
|
BusErrno::Topic => InvalidTopic,
|
||||||
__BUS_EUNSUPPORTED => Unsupported,
|
BusErrno::Badcb => BadCallback,
|
||||||
__BUS_EBADREQUEST => BadRequest,
|
BusErrno::Unsupported => Unsupported,
|
||||||
__BUS_EDENIED => AccessDenied,
|
BusErrno::Badrequest => BadRequest,
|
||||||
__BUS_EINTERNAL => InternalError,
|
BusErrno::Denied => AccessDenied,
|
||||||
__BUS_EALLOC => MemoryAllocationFailed,
|
BusErrno::Internal => InternalError,
|
||||||
__BUS_EINVOKE => InvokeFailed,
|
BusErrno::Alloc => MemoryAllocationFailed,
|
||||||
__BUS_ECONSUMED => AlreadyConsumed,
|
BusErrno::Invoke => InvokeFailed,
|
||||||
__BUS_EMEMVIOLATION => MemoryAccessViolation,
|
BusErrno::Consumed => AlreadyConsumed,
|
||||||
/*__BUS_EUNKNOWN |*/ _ => UnknownError,
|
BusErrno::Memviolation => MemoryAccessViolation,
|
||||||
|
BusErrno::Unknown => UnknownError,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -452,8 +453,8 @@ impl VirtualFile for Pipe {
|
|||||||
/*
|
/*
|
||||||
TODO: Think about using this
|
TODO: Think about using this
|
||||||
trait WasiFdBacking: std::fmt::Debug {
|
trait WasiFdBacking: std::fmt::Debug {
|
||||||
fn get_stat(&self) -> &__wasi_filestat_t;
|
fn get_stat(&self) -> &Filestat;
|
||||||
fn get_stat_mut(&mut self) -> &mut __wasi_filestat_t;
|
fn get_stat_mut(&mut self) -> &mut Filestat;
|
||||||
fn is_preopened(&self) -> bool;
|
fn is_preopened(&self) -> bool;
|
||||||
fn get_name(&self) -> &str;
|
fn get_name(&self) -> &str;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
use crate::syscalls;
|
use crate::syscalls;
|
||||||
use crate::syscalls::types::{self, snapshot0};
|
use crate::syscalls::types;
|
||||||
use crate::{mem_error_to_wasi, Memory32, MemorySize, WasiEnv, WasiError, WasiThread};
|
use crate::{mem_error_to_wasi, Memory32, MemorySize, WasiEnv, WasiError, WasiThread};
|
||||||
use wasmer::{AsStoreMut, FunctionEnvMut, WasmPtr};
|
use wasmer::{AsStoreMut, FunctionEnvMut, WasmPtr};
|
||||||
|
use wasmer_wasi_types::wasi::{
|
||||||
|
Errno, Event, Fd, Filesize, Filestat, Filetype, Snapshot0Filestat, Snapshot0Subscription,
|
||||||
|
Snapshot0Whence, Subscription, Whence,
|
||||||
|
};
|
||||||
|
|
||||||
/// Wrapper around `syscalls::fd_filestat_get` with extra logic to handle the size
|
/// Wrapper around `syscalls::fd_filestat_get` with extra logic to handle the size
|
||||||
/// difference of `wasi_filestat_t`
|
/// difference of `wasi_filestat_t`
|
||||||
@@ -11,19 +15,20 @@ use wasmer::{AsStoreMut, FunctionEnvMut, WasmPtr};
|
|||||||
/// that syscall, then it may break.
|
/// that syscall, then it may break.
|
||||||
pub fn fd_filestat_get(
|
pub fn fd_filestat_get(
|
||||||
mut ctx: FunctionEnvMut<WasiEnv>,
|
mut ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: types::__wasi_fd_t,
|
fd: Fd,
|
||||||
buf: WasmPtr<snapshot0::__wasi_filestat_t, Memory32>,
|
buf: WasmPtr<Snapshot0Filestat, Memory32>,
|
||||||
) -> types::__wasi_errno_t {
|
) -> Errno {
|
||||||
let env = ctx.data();
|
let env = ctx.data();
|
||||||
let memory = env.memory_view(&ctx);
|
let memory = env.memory_view(&ctx);
|
||||||
|
// TODO: understand what's happening inside this function, then do the correct thing
|
||||||
|
|
||||||
// transmute the WasmPtr<T1> into a WasmPtr<T2> where T2 > T1, this will read extra memory.
|
// transmute the WasmPtr<T1> into a WasmPtr<T2> where T2 > T1, this will read extra memory.
|
||||||
// The edge case of this cenv.mausing an OOB is not handled, if the new field is OOB, then the entire
|
// The edge case of this cenv.mausing an OOB is not handled, if the new field is OOB, then the entire
|
||||||
// memory access will fail.
|
// memory access will fail.
|
||||||
let new_buf: WasmPtr<types::__wasi_filestat_t, Memory32> = buf.cast();
|
let new_buf: WasmPtr<Filestat, Memory32> = buf.cast();
|
||||||
|
|
||||||
// Copy the data including the extra data
|
// Copy the data including the extra data
|
||||||
let new_filestat_setup: types::__wasi_filestat_t = wasi_try_mem!(new_buf.read(&memory));
|
let new_filestat_setup: Filestat = wasi_try_mem!(new_buf.read(&memory));
|
||||||
|
|
||||||
// Set up complete, make the call with the pointer that will write to the
|
// Set up complete, make the call with the pointer that will write to the
|
||||||
// struct and some unrelated memory after the struct.
|
// struct and some unrelated memory after the struct.
|
||||||
@@ -36,7 +41,7 @@ pub fn fd_filestat_get(
|
|||||||
// get the values written to memory
|
// get the values written to memory
|
||||||
let new_filestat = wasi_try_mem!(new_buf.deref(&memory).read());
|
let new_filestat = wasi_try_mem!(new_buf.deref(&memory).read());
|
||||||
// translate the new struct into the old struct in host memory
|
// translate the new struct into the old struct in host memory
|
||||||
let old_stat = snapshot0::__wasi_filestat_t {
|
let old_stat = Snapshot0Filestat {
|
||||||
st_dev: new_filestat.st_dev,
|
st_dev: new_filestat.st_dev,
|
||||||
st_ino: new_filestat.st_ino,
|
st_ino: new_filestat.st_ino,
|
||||||
st_filetype: new_filestat.st_filetype,
|
st_filetype: new_filestat.st_filetype,
|
||||||
@@ -62,18 +67,20 @@ pub fn fd_filestat_get(
|
|||||||
/// difference of `wasi_filestat_t`
|
/// difference of `wasi_filestat_t`
|
||||||
pub fn path_filestat_get(
|
pub fn path_filestat_get(
|
||||||
mut ctx: FunctionEnvMut<WasiEnv>,
|
mut ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: types::__wasi_fd_t,
|
fd: Fd,
|
||||||
flags: types::__wasi_lookupflags_t,
|
flags: types::LookupFlags,
|
||||||
path: WasmPtr<u8, Memory32>,
|
path: WasmPtr<u8, Memory32>,
|
||||||
path_len: u32,
|
path_len: u32,
|
||||||
buf: WasmPtr<snapshot0::__wasi_filestat_t, Memory32>,
|
buf: WasmPtr<Snapshot0Filestat, Memory32>,
|
||||||
) -> types::__wasi_errno_t {
|
) -> Errno {
|
||||||
|
// TODO: understand what's happening inside this function, then do the correct thing
|
||||||
|
|
||||||
// see `fd_filestat_get` in this file for an explanation of this strange behavior
|
// see `fd_filestat_get` in this file for an explanation of this strange behavior
|
||||||
let env = ctx.data();
|
let env = ctx.data();
|
||||||
let memory = env.memory_view(&ctx);
|
let memory = env.memory_view(&ctx);
|
||||||
|
|
||||||
let new_buf: WasmPtr<types::__wasi_filestat_t, Memory32> = buf.cast();
|
let new_buf: WasmPtr<Filestat, Memory32> = buf.cast();
|
||||||
let new_filestat_setup: types::__wasi_filestat_t = wasi_try_mem!(new_buf.read(&memory));
|
let new_filestat_setup: Filestat = wasi_try_mem!(new_buf.read(&memory));
|
||||||
|
|
||||||
let result =
|
let result =
|
||||||
syscalls::path_filestat_get::<Memory32>(ctx.as_mut(), fd, flags, path, path_len, new_buf);
|
syscalls::path_filestat_get::<Memory32>(ctx.as_mut(), fd, flags, path, path_len, new_buf);
|
||||||
@@ -82,7 +89,7 @@ pub fn path_filestat_get(
|
|||||||
let env = ctx.data();
|
let env = ctx.data();
|
||||||
let memory = env.memory_view(&ctx);
|
let memory = env.memory_view(&ctx);
|
||||||
let new_filestat = wasi_try_mem!(new_buf.deref(&memory).read());
|
let new_filestat = wasi_try_mem!(new_buf.deref(&memory).read());
|
||||||
let old_stat = snapshot0::__wasi_filestat_t {
|
let old_stat = Snapshot0Filestat {
|
||||||
st_dev: new_filestat.st_dev,
|
st_dev: new_filestat.st_dev,
|
||||||
st_ino: new_filestat.st_ino,
|
st_ino: new_filestat.st_ino,
|
||||||
st_filetype: new_filestat.st_filetype,
|
st_filetype: new_filestat.st_filetype,
|
||||||
@@ -100,20 +107,18 @@ pub fn path_filestat_get(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Wrapper around `syscalls::fd_seek` with extra logic to remap the values
|
/// Wrapper around `syscalls::fd_seek` with extra logic to remap the values
|
||||||
/// of `__wasi_whence_t`
|
/// of `Whence`
|
||||||
pub fn fd_seek(
|
pub fn fd_seek(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: types::__wasi_fd_t,
|
fd: Fd,
|
||||||
offset: types::__wasi_filedelta_t,
|
offset: types::FileDelta,
|
||||||
whence: snapshot0::__wasi_whence_t,
|
whence: Snapshot0Whence,
|
||||||
newoffset: WasmPtr<types::__wasi_filesize_t, Memory32>,
|
newoffset: WasmPtr<Filesize, Memory32>,
|
||||||
) -> Result<types::__wasi_errno_t, WasiError> {
|
) -> Result<Errno, WasiError> {
|
||||||
let new_whence = match whence {
|
let new_whence = match whence {
|
||||||
snapshot0::__WASI_WHENCE_CUR => types::__WASI_WHENCE_CUR,
|
Snapshot0Whence::Cur => Whence::Cur,
|
||||||
snapshot0::__WASI_WHENCE_END => types::__WASI_WHENCE_END,
|
Snapshot0Whence::End => Whence::End,
|
||||||
snapshot0::__WASI_WHENCE_SET => types::__WASI_WHENCE_SET,
|
Snapshot0Whence::Set => Whence::Set,
|
||||||
// if it's invalid, let the new fd_seek handle it
|
|
||||||
_ => whence,
|
|
||||||
};
|
};
|
||||||
syscalls::fd_seek::<Memory32>(ctx, fd, offset, new_whence, newoffset)
|
syscalls::fd_seek::<Memory32>(ctx, fd, offset, new_whence, newoffset)
|
||||||
}
|
}
|
||||||
@@ -122,11 +127,12 @@ pub fn fd_seek(
|
|||||||
/// userdata field back
|
/// userdata field back
|
||||||
pub fn poll_oneoff(
|
pub fn poll_oneoff(
|
||||||
mut ctx: FunctionEnvMut<WasiEnv>,
|
mut ctx: FunctionEnvMut<WasiEnv>,
|
||||||
in_: WasmPtr<snapshot0::__wasi_subscription_t, Memory32>,
|
in_: WasmPtr<Snapshot0Subscription, Memory32>,
|
||||||
out_: WasmPtr<types::__wasi_event_t, Memory32>,
|
out_: WasmPtr<Event, Memory32>,
|
||||||
nsubscriptions: u32,
|
nsubscriptions: u32,
|
||||||
nevents: WasmPtr<u32, Memory32>,
|
nevents: WasmPtr<u32, Memory32>,
|
||||||
) -> Result<types::__wasi_errno_t, WasiError> {
|
) -> Result<Errno, WasiError> {
|
||||||
|
// TODO: verify that the assumptions in the comment here still applyd
|
||||||
// in this case the new type is smaller than the old type, so it all fits into memory,
|
// in this case the new type is smaller than the old type, so it all fits into memory,
|
||||||
// we just need to readjust and copy it
|
// we just need to readjust and copy it
|
||||||
|
|
||||||
@@ -138,31 +144,14 @@ pub fn poll_oneoff(
|
|||||||
let in_origs = wasi_try_mem_ok!(in_origs.read_to_vec());
|
let in_origs = wasi_try_mem_ok!(in_origs.read_to_vec());
|
||||||
|
|
||||||
// get a pointer to the smaller new type
|
// get a pointer to the smaller new type
|
||||||
let in_new_type_ptr: WasmPtr<types::__wasi_subscription_t, Memory32> = in_.cast();
|
let in_new_type_ptr: WasmPtr<Subscription, Memory32> = in_.cast();
|
||||||
|
|
||||||
for (in_sub_new, orig) in
|
for (in_sub_new, orig) in
|
||||||
wasi_try_mem_ok!(in_new_type_ptr.slice(&memory, nsubscriptions_offset))
|
wasi_try_mem_ok!(in_new_type_ptr.slice(&memory, nsubscriptions_offset))
|
||||||
.iter()
|
.iter()
|
||||||
.zip(in_origs.iter())
|
.zip(in_origs.iter())
|
||||||
{
|
{
|
||||||
wasi_try_mem_ok!(in_sub_new.write(types::__wasi_subscription_t {
|
wasi_try_mem_ok!(in_sub_new.write(Subscription::from(*orig)));
|
||||||
userdata: orig.userdata,
|
|
||||||
type_: orig.type_,
|
|
||||||
u: if orig.type_ == types::__WASI_EVENTTYPE_CLOCK {
|
|
||||||
types::__wasi_subscription_u {
|
|
||||||
clock: types::__wasi_subscription_clock_t {
|
|
||||||
clock_id: unsafe { orig.u.clock.clock_id },
|
|
||||||
timeout: unsafe { orig.u.clock.timeout },
|
|
||||||
precision: unsafe { orig.u.clock.precision },
|
|
||||||
flags: unsafe { orig.u.clock.flags },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
types::__wasi_subscription_u {
|
|
||||||
fd_readwrite: unsafe { orig.u.fd_readwrite },
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// make the call
|
// make the call
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -5,17 +5,18 @@ use libc::{
|
|||||||
};
|
};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use wasmer::WasmRef;
|
use wasmer::WasmRef;
|
||||||
|
use wasmer_wasi_types::wasi::{Errno, Snapshot0Clockid, Timestamp};
|
||||||
|
|
||||||
pub fn platform_clock_res_get(
|
pub fn platform_clock_res_get(
|
||||||
clock_id: __wasi_clockid_t,
|
clock_id: Snapshot0Clockid,
|
||||||
resolution: WasmRef<__wasi_timestamp_t>,
|
resolution: WasmRef<Timestamp>,
|
||||||
) -> Result<i64, __wasi_errno_t> {
|
) -> Result<i64, Errno> {
|
||||||
let unix_clock_id = match clock_id {
|
let unix_clock_id = match clock_id {
|
||||||
__WASI_CLOCK_MONOTONIC => CLOCK_MONOTONIC,
|
Snapshot0Clockid::Monotonic => CLOCK_MONOTONIC,
|
||||||
__WASI_CLOCK_PROCESS_CPUTIME_ID => CLOCK_PROCESS_CPUTIME_ID,
|
Snapshot0Clockid::ProcessCputimeId => CLOCK_PROCESS_CPUTIME_ID,
|
||||||
__WASI_CLOCK_REALTIME => CLOCK_REALTIME,
|
Snapshot0Clockid::Realtime => CLOCK_REALTIME,
|
||||||
__WASI_CLOCK_THREAD_CPUTIME_ID => CLOCK_THREAD_CPUTIME_ID,
|
Snapshot0Clockid::ThreadCputimeId => CLOCK_THREAD_CPUTIME_ID,
|
||||||
_ => return Err(__WASI_EINVAL),
|
_ => return Err(Errno::Inval),
|
||||||
};
|
};
|
||||||
|
|
||||||
let (output, timespec_out) = unsafe {
|
let (output, timespec_out) = unsafe {
|
||||||
@@ -31,15 +32,15 @@ pub fn platform_clock_res_get(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn platform_clock_time_get(
|
pub fn platform_clock_time_get(
|
||||||
clock_id: __wasi_clockid_t,
|
clock_id: Snapshot0Clockid,
|
||||||
precision: __wasi_timestamp_t,
|
precision: Timestamp,
|
||||||
) -> Result<i64, __wasi_errno_t> {
|
) -> Result<i64, Errno> {
|
||||||
let unix_clock_id = match clock_id {
|
let unix_clock_id = match clock_id {
|
||||||
__WASI_CLOCK_MONOTONIC => CLOCK_MONOTONIC,
|
Snapshot0Clockid::Monotonic => CLOCK_MONOTONIC,
|
||||||
__WASI_CLOCK_PROCESS_CPUTIME_ID => CLOCK_PROCESS_CPUTIME_ID,
|
Snapshot0Clockid::ProcessCputimeId => CLOCK_PROCESS_CPUTIME_ID,
|
||||||
__WASI_CLOCK_REALTIME => CLOCK_REALTIME,
|
Snapshot0Clockid::Realtime => CLOCK_REALTIME,
|
||||||
__WASI_CLOCK_THREAD_CPUTIME_ID => CLOCK_THREAD_CPUTIME_ID,
|
Snapshot0Clockid::ThreadCputimeId => CLOCK_THREAD_CPUTIME_ID,
|
||||||
_ => return Err(__WASI_EINVAL),
|
_ => return Err(Errno::Inval),
|
||||||
};
|
};
|
||||||
|
|
||||||
let (output, timespec_out) = unsafe {
|
let (output, timespec_out) = unsafe {
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
#![deny(dead_code)]
|
#![deny(dead_code)]
|
||||||
use crate::{WasiEnv, WasiError, WasiState, WasiThread};
|
use crate::{WasiEnv, WasiError, WasiState, WasiThread};
|
||||||
use wasmer::{StoreMut, Memory, Memory32, MemorySize, WasmPtr, WasmSlice};
|
use wasmer::{Memory, Memory32, MemorySize, StoreMut, WasmPtr, WasmSlice};
|
||||||
use wasmer_wasi_types::*;
|
use wasmer_wasi_types::{
|
||||||
|
wasi::{Errno, Event, Fd as WasiFd, Filesize, Fstflags, Fstflags, Timestamp, Whence, Clockid},
|
||||||
|
types::*,
|
||||||
|
};
|
||||||
|
|
||||||
type MemoryType = Memory32;
|
type MemoryType = Memory32;
|
||||||
type MemoryOffset = u32;
|
type MemoryOffset = u32;
|
||||||
@@ -10,7 +13,7 @@ pub(crate) fn args_get(
|
|||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
argv: WasmPtr<WasmPtr<u8, MemoryType>, MemoryType>,
|
argv: WasmPtr<WasmPtr<u8, MemoryType>, MemoryType>,
|
||||||
argv_buf: WasmPtr<u8, MemoryType>,
|
argv_buf: WasmPtr<u8, MemoryType>,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::args_get::<MemoryType>(ctx, argv, argv_buf)
|
super::args_get::<MemoryType>(ctx, argv, argv_buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,24 +21,24 @@ pub(crate) fn args_sizes_get(
|
|||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
argc: WasmPtr<MemoryOffset, MemoryType>,
|
argc: WasmPtr<MemoryOffset, MemoryType>,
|
||||||
argv_buf_size: WasmPtr<MemoryOffset, MemoryType>,
|
argv_buf_size: WasmPtr<MemoryOffset, MemoryType>,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::args_sizes_get::<MemoryType>(ctx, argc, argv_buf_size)
|
super::args_sizes_get::<MemoryType>(ctx, argc, argv_buf_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn clock_res_get(
|
pub(crate) fn clock_res_get(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
clock_id: __wasi_clockid_t,
|
clock_id: Clockid,
|
||||||
resolution: WasmPtr<__wasi_timestamp_t, MemoryType>,
|
resolution: WasmPtr<Timestamp, MemoryType>,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::clock_res_get::<MemoryType>(ctx, clock_id, resolution)
|
super::clock_res_get::<MemoryType>(ctx, clock_id, resolution)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn clock_time_get(
|
pub(crate) fn clock_time_get(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
clock_id: __wasi_clockid_t,
|
clock_id: Clockid,
|
||||||
precision: __wasi_timestamp_t,
|
precision: Timestamp,
|
||||||
time: WasmPtr<__wasi_timestamp_t, MemoryType>,
|
time: WasmPtr<Timestamp, MemoryType>,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::clock_time_get::<MemoryType>(ctx, clock_id, precision, time)
|
super::clock_time_get::<MemoryType>(ctx, clock_id, precision, time)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +46,7 @@ pub(crate) fn environ_get(
|
|||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
environ: WasmPtr<WasmPtr<u8, MemoryType>, MemoryType>,
|
environ: WasmPtr<WasmPtr<u8, MemoryType>, MemoryType>,
|
||||||
environ_buf: WasmPtr<u8, MemoryType>,
|
environ_buf: WasmPtr<u8, MemoryType>,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::environ_get::<MemoryType>(ctx, environ, environ_buf)
|
super::environ_get::<MemoryType>(ctx, environ, environ_buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,218 +54,214 @@ pub(crate) fn environ_sizes_get(
|
|||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
environ_count: WasmPtr<MemoryOffset, MemoryType>,
|
environ_count: WasmPtr<MemoryOffset, MemoryType>,
|
||||||
environ_buf_size: WasmPtr<MemoryOffset, MemoryType>,
|
environ_buf_size: WasmPtr<MemoryOffset, MemoryType>,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::environ_sizes_get::<MemoryType>(ctx, environ_count, environ_buf_size)
|
super::environ_sizes_get::<MemoryType>(ctx, environ_count, environ_buf_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_advise(
|
pub(crate) fn fd_advise(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
offset: __wasi_filesize_t,
|
offset: Filesize,
|
||||||
len: __wasi_filesize_t,
|
len: Filesize,
|
||||||
advice: __wasi_advice_t,
|
advice: __wasi_advice_t,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::fd_advise(ctx, fd, offset, len, advice)
|
super::fd_advise(ctx, fd, offset, len, advice)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_allocate(
|
pub(crate) fn fd_allocate(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
offset: __wasi_filesize_t,
|
offset: Filesize,
|
||||||
len: __wasi_filesize_t,
|
len: Filesize,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::fd_allocate(ctx, fd, offset, len)
|
super::fd_allocate(ctx, fd, offset, len)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_close(ctx: FunctionEnvMut<WasiEnv>, fd: __wasi_fd_t) -> __wasi_errno_t {
|
pub(crate) fn fd_close(ctx: FunctionEnvMut<WasiEnv>, fd: WasiFd) -> Errno {
|
||||||
super::fd_close(ctx, fd)
|
super::fd_close(ctx, fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_datasync(ctx: FunctionEnvMut<WasiEnv>, fd: __wasi_fd_t) -> __wasi_errno_t {
|
pub(crate) fn fd_datasync(ctx: FunctionEnvMut<WasiEnv>, fd: WasiFd) -> Errno {
|
||||||
super::fd_datasync(ctx, fd)
|
super::fd_datasync(ctx, fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_fdstat_get(
|
pub(crate) fn fd_fdstat_get(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
buf_ptr: WasmPtr<__wasi_fdstat_t, MemoryType>,
|
buf_ptr: WasmPtr<WasiFdstat, MemoryType>,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::fd_fdstat_get::<MemoryType>(ctx, fd, buf_ptr)
|
super::fd_fdstat_get::<MemoryType>(ctx, fd, buf_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_fdstat_set_flags(
|
pub(crate) fn fd_fdstat_set_flags(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
flags: __wasi_fdflags_t,
|
flags: WasiFdflags,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::fd_fdstat_set_flags(ctx, fd, flags)
|
super::fd_fdstat_set_flags(ctx, fd, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_fdstat_set_rights(
|
pub(crate) fn fd_fdstat_set_rights(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
fs_rights_base: __wasi_rights_t,
|
fs_rights_base: __wasi_rights_t,
|
||||||
fs_rights_inheriting: __wasi_rights_t,
|
fs_rights_inheriting: __wasi_rights_t,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::fd_fdstat_set_rights(ctx, fd, fs_rights_base, fs_rights_inheriting)
|
super::fd_fdstat_set_rights(ctx, fd, fs_rights_base, fs_rights_inheriting)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_filestat_get(
|
pub(crate) fn fd_filestat_get(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
buf: WasmPtr<__wasi_filestat_t, MemoryType>,
|
buf: WasmPtr<Filestat, MemoryType>,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::fd_filestat_get::<MemoryType>(ctx, fd, buf)
|
super::fd_filestat_get::<MemoryType>(ctx, fd, buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_filestat_set_size(
|
pub(crate) fn fd_filestat_set_size(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
st_size: __wasi_filesize_t,
|
st_size: Filesize,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::fd_filestat_set_size(ctx, fd, st_size)
|
super::fd_filestat_set_size(ctx, fd, st_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_filestat_set_times(
|
pub(crate) fn fd_filestat_set_times(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
st_atim: __wasi_timestamp_t,
|
st_atim: Timestamp,
|
||||||
st_mtim: __wasi_timestamp_t,
|
st_mtim: Timestamp,
|
||||||
fst_flags: __wasi_fstflags_t,
|
fst_flags: Fstflags,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::fd_filestat_set_times(ctx, fd, st_atim, st_mtim, fst_flags)
|
super::fd_filestat_set_times(ctx, fd, st_atim, st_mtim, fst_flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_pread(
|
pub(crate) fn fd_pread(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
iovs: WasmPtr<__wasi_iovec_t<MemoryType>, MemoryType>,
|
iovs: WasmPtr<__wasi_iovec_t<MemoryType>, MemoryType>,
|
||||||
iovs_len: MemoryOffset,
|
iovs_len: MemoryOffset,
|
||||||
offset: __wasi_filesize_t,
|
offset: Filesize,
|
||||||
nread: WasmPtr<MemoryOffset, MemoryType>,
|
nread: WasmPtr<MemoryOffset, MemoryType>,
|
||||||
) -> Result<__wasi_errno_t, WasiError> {
|
) -> Result<Errno, WasiError> {
|
||||||
super::fd_pread::<MemoryType>(ctx, fd, iovs, iovs_len, offset, nread)
|
super::fd_pread::<MemoryType>(ctx, fd, iovs, iovs_len, offset, nread)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_prestat_get(
|
pub(crate) fn fd_prestat_get(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
buf: WasmPtr<__wasi_prestat_t, MemoryType>,
|
buf: WasmPtr<Prestat, MemoryType>,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::fd_prestat_get::<MemoryType>(ctx, fd, buf)
|
super::fd_prestat_get::<MemoryType>(ctx, fd, buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_prestat_dir_name(
|
pub(crate) fn fd_prestat_dir_name(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
path: WasmPtr<u8, MemoryType>,
|
path: WasmPtr<u8, MemoryType>,
|
||||||
path_len: MemoryOffset,
|
path_len: MemoryOffset,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::fd_prestat_dir_name::<MemoryType>(ctx, fd, path, path_len)
|
super::fd_prestat_dir_name::<MemoryType>(ctx, fd, path, path_len)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_pwrite(
|
pub(crate) fn fd_pwrite(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
iovs: WasmPtr<__wasi_ciovec_t<MemoryType>, MemoryType>,
|
iovs: WasmPtr<__wasi_ciovec_t<MemoryType>, MemoryType>,
|
||||||
iovs_len: MemoryOffset,
|
iovs_len: MemoryOffset,
|
||||||
offset: __wasi_filesize_t,
|
offset: Filesize,
|
||||||
nwritten: WasmPtr<MemoryOffset, MemoryType>,
|
nwritten: WasmPtr<MemoryOffset, MemoryType>,
|
||||||
) -> Result<__wasi_errno_t, WasiError> {
|
) -> Result<Errno, WasiError> {
|
||||||
super::fd_pwrite::<MemoryType>(ctx, fd, iovs, iovs_len, offset, nwritten)
|
super::fd_pwrite::<MemoryType>(ctx, fd, iovs, iovs_len, offset, nwritten)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_read(
|
pub(crate) fn fd_read(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
iovs: WasmPtr<__wasi_iovec_t<MemoryType>, MemoryType>,
|
iovs: WasmPtr<__wasi_iovec_t<MemoryType>, MemoryType>,
|
||||||
iovs_len: MemoryOffset,
|
iovs_len: MemoryOffset,
|
||||||
nread: WasmPtr<MemoryOffset, MemoryType>,
|
nread: WasmPtr<MemoryOffset, MemoryType>,
|
||||||
) -> Result<__wasi_errno_t, WasiError> {
|
) -> Result<Errno, WasiError> {
|
||||||
super::fd_read::<MemoryType>(ctx, fd, iovs, iovs_len, nread)
|
super::fd_read::<MemoryType>(ctx, fd, iovs, iovs_len, nread)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_readdir(
|
pub(crate) fn fd_readdir(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
buf: WasmPtr<u8, MemoryType>,
|
buf: WasmPtr<u8, MemoryType>,
|
||||||
buf_len: MemoryOffset,
|
buf_len: MemoryOffset,
|
||||||
cookie: __wasi_dircookie_t,
|
cookie: __wasi_dircookie_t,
|
||||||
bufused: WasmPtr<MemoryOffset, MemoryType>,
|
bufused: WasmPtr<MemoryOffset, MemoryType>,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::fd_readdir::<MemoryType>(ctx, fd, buf, buf_len, cookie, bufused)
|
super::fd_readdir::<MemoryType>(ctx, fd, buf, buf_len, cookie, bufused)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_renumber(
|
pub(crate) fn fd_renumber(ctx: FunctionEnvMut<WasiEnv>, from: WasiFd, to: WasiFd) -> Errno {
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
|
||||||
from: __wasi_fd_t,
|
|
||||||
to: __wasi_fd_t,
|
|
||||||
) -> __wasi_errno_t {
|
|
||||||
super::fd_renumber(ctx, from, to)
|
super::fd_renumber(ctx, from, to)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_seek(
|
pub(crate) fn fd_seek(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
offset: __wasi_filedelta_t,
|
offset: FileDelta,
|
||||||
whence: __wasi_whence_t,
|
whence: Whence,
|
||||||
newoffset: WasmPtr<__wasi_filesize_t, MemoryType>,
|
newoffset: WasmPtr<Filesize, MemoryType>,
|
||||||
) -> Result<__wasi_errno_t, WasiError> {
|
) -> Result<Errno, WasiError> {
|
||||||
super::fd_seek::<MemoryType>(ctx, fd, offset, whence, newoffset)
|
super::fd_seek::<MemoryType>(ctx, fd, offset, whence, newoffset)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_sync(ctx: FunctionEnvMut<WasiEnv>, fd: __wasi_fd_t) -> __wasi_errno_t {
|
pub(crate) fn fd_sync(ctx: FunctionEnvMut<WasiEnv>, fd: WasiFd) -> Errno {
|
||||||
super::fd_sync(ctx, fd)
|
super::fd_sync(ctx, fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_tell(
|
pub(crate) fn fd_tell(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
offset: WasmPtr<__wasi_filesize_t, MemoryType>,
|
offset: WasmPtr<Filesize, MemoryType>,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::fd_tell::<MemoryType>(ctx, fd, offset)
|
super::fd_tell::<MemoryType>(ctx, fd, offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_write(
|
pub(crate) fn fd_write(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
iovs: WasmPtr<__wasi_ciovec_t<MemoryType>, MemoryType>,
|
iovs: WasmPtr<__wasi_ciovec_t<MemoryType>, MemoryType>,
|
||||||
iovs_len: MemoryOffset,
|
iovs_len: MemoryOffset,
|
||||||
nwritten: WasmPtr<MemoryOffset, MemoryType>,
|
nwritten: WasmPtr<MemoryOffset, MemoryType>,
|
||||||
) -> Result<__wasi_errno_t, WasiError> {
|
) -> Result<Errno, WasiError> {
|
||||||
super::fd_write::<MemoryType>(ctx, fd, iovs, iovs_len, nwritten)
|
super::fd_write::<MemoryType>(ctx, fd, iovs, iovs_len, nwritten)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn path_create_directory(
|
pub(crate) fn path_create_directory(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
path: WasmPtr<u8, MemoryType>,
|
path: WasmPtr<u8, MemoryType>,
|
||||||
path_len: MemoryOffset,
|
path_len: MemoryOffset,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::path_create_directory::<MemoryType>(ctx, fd, path, path_len)
|
super::path_create_directory::<MemoryType>(ctx, fd, path, path_len)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn path_filestat_get(
|
pub(crate) fn path_filestat_get(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
flags: __wasi_lookupflags_t,
|
flags: LookupFlags,
|
||||||
path: WasmPtr<u8, MemoryType>,
|
path: WasmPtr<u8, MemoryType>,
|
||||||
path_len: MemoryOffset,
|
path_len: MemoryOffset,
|
||||||
buf: WasmPtr<__wasi_filestat_t, MemoryType>,
|
buf: WasmPtr<Filestat, MemoryType>,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::path_filestat_get::<MemoryType>(ctx, fd, flags, path, path_len, buf)
|
super::path_filestat_get::<MemoryType>(ctx, fd, flags, path, path_len, buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn path_filestat_set_times(
|
pub(crate) fn path_filestat_set_times(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
flags: __wasi_lookupflags_t,
|
flags: LookupFlags,
|
||||||
path: WasmPtr<u8, MemoryType>,
|
path: WasmPtr<u8, MemoryType>,
|
||||||
path_len: MemoryOffset,
|
path_len: MemoryOffset,
|
||||||
st_atim: __wasi_timestamp_t,
|
st_atim: Timestamp,
|
||||||
st_mtim: __wasi_timestamp_t,
|
st_mtim: Timestamp,
|
||||||
fst_flags: __wasi_fstflags_t,
|
fst_flags: Fstflags,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::path_filestat_set_times::<MemoryType>(
|
super::path_filestat_set_times::<MemoryType>(
|
||||||
ctx, fd, flags, path, path_len, st_atim, st_mtim, fst_flags,
|
ctx, fd, flags, path, path_len, st_atim, st_mtim, fst_flags,
|
||||||
)
|
)
|
||||||
@@ -270,14 +269,14 @@ pub(crate) fn path_filestat_set_times(
|
|||||||
|
|
||||||
pub(crate) fn path_link(
|
pub(crate) fn path_link(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
old_fd: __wasi_fd_t,
|
old_fd: WasiFd,
|
||||||
old_flags: __wasi_lookupflags_t,
|
old_flags: LookupFlags,
|
||||||
old_path: WasmPtr<u8, MemoryType>,
|
old_path: WasmPtr<u8, MemoryType>,
|
||||||
old_path_len: MemoryOffset,
|
old_path_len: MemoryOffset,
|
||||||
new_fd: __wasi_fd_t,
|
new_fd: WasiFd,
|
||||||
new_path: WasmPtr<u8, MemoryType>,
|
new_path: WasmPtr<u8, MemoryType>,
|
||||||
new_path_len: MemoryOffset,
|
new_path_len: MemoryOffset,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::path_link::<MemoryType>(
|
super::path_link::<MemoryType>(
|
||||||
ctx,
|
ctx,
|
||||||
old_fd,
|
old_fd,
|
||||||
@@ -292,16 +291,16 @@ pub(crate) fn path_link(
|
|||||||
|
|
||||||
pub(crate) fn path_open(
|
pub(crate) fn path_open(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
dirfd: __wasi_fd_t,
|
dirfd: WasiFd,
|
||||||
dirflags: __wasi_lookupflags_t,
|
dirflags: LookupFlags,
|
||||||
path: WasmPtr<u8, MemoryType>,
|
path: WasmPtr<u8, MemoryType>,
|
||||||
path_len: MemoryOffset,
|
path_len: MemoryOffset,
|
||||||
o_flags: __wasi_oflags_t,
|
o_flags: Oflags,
|
||||||
fs_rights_base: __wasi_rights_t,
|
fs_rights_base: __wasi_rights_t,
|
||||||
fs_rights_inheriting: __wasi_rights_t,
|
fs_rights_inheriting: __wasi_rights_t,
|
||||||
fs_flags: __wasi_fdflags_t,
|
fs_flags: WasiFdflags,
|
||||||
fd: WasmPtr<__wasi_fd_t, MemoryType>,
|
fd: WasmPtr<WasiFd, MemoryType>,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::path_open::<MemoryType>(
|
super::path_open::<MemoryType>(
|
||||||
ctx,
|
ctx,
|
||||||
dirfd,
|
dirfd,
|
||||||
@@ -318,34 +317,34 @@ pub(crate) fn path_open(
|
|||||||
|
|
||||||
pub(crate) fn path_readlink(
|
pub(crate) fn path_readlink(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
dir_fd: __wasi_fd_t,
|
dir_fd: WasiFd,
|
||||||
path: WasmPtr<u8, MemoryType>,
|
path: WasmPtr<u8, MemoryType>,
|
||||||
path_len: MemoryOffset,
|
path_len: MemoryOffset,
|
||||||
buf: WasmPtr<u8, MemoryType>,
|
buf: WasmPtr<u8, MemoryType>,
|
||||||
buf_len: MemoryOffset,
|
buf_len: MemoryOffset,
|
||||||
buf_used: WasmPtr<MemoryOffset, MemoryType>,
|
buf_used: WasmPtr<MemoryOffset, MemoryType>,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::path_readlink::<MemoryType>(ctx, dir_fd, path, path_len, buf, buf_len, buf_used)
|
super::path_readlink::<MemoryType>(ctx, dir_fd, path, path_len, buf, buf_len, buf_used)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn path_remove_directory(
|
pub(crate) fn path_remove_directory(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
path: WasmPtr<u8, MemoryType>,
|
path: WasmPtr<u8, MemoryType>,
|
||||||
path_len: MemoryOffset,
|
path_len: MemoryOffset,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::path_remove_directory::<MemoryType>(ctx, fd, path, path_len)
|
super::path_remove_directory::<MemoryType>(ctx, fd, path, path_len)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn path_rename(
|
pub(crate) fn path_rename(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
old_fd: __wasi_fd_t,
|
old_fd: WasiFd,
|
||||||
old_path: WasmPtr<u8, MemoryType>,
|
old_path: WasmPtr<u8, MemoryType>,
|
||||||
old_path_len: MemoryOffset,
|
old_path_len: MemoryOffset,
|
||||||
new_fd: __wasi_fd_t,
|
new_fd: WasiFd,
|
||||||
new_path: WasmPtr<u8, MemoryType>,
|
new_path: WasmPtr<u8, MemoryType>,
|
||||||
new_path_len: MemoryOffset,
|
new_path_len: MemoryOffset,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::path_rename::<MemoryType>(
|
super::path_rename::<MemoryType>(
|
||||||
ctx,
|
ctx,
|
||||||
old_fd,
|
old_fd,
|
||||||
@@ -361,29 +360,29 @@ pub(crate) fn path_symlink(
|
|||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
old_path: WasmPtr<u8, MemoryType>,
|
old_path: WasmPtr<u8, MemoryType>,
|
||||||
old_path_len: MemoryOffset,
|
old_path_len: MemoryOffset,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
new_path: WasmPtr<u8, MemoryType>,
|
new_path: WasmPtr<u8, MemoryType>,
|
||||||
new_path_len: MemoryOffset,
|
new_path_len: MemoryOffset,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::path_symlink::<MemoryType>(ctx, old_path, old_path_len, fd, new_path, new_path_len)
|
super::path_symlink::<MemoryType>(ctx, old_path, old_path_len, fd, new_path, new_path_len)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn path_unlink_file(
|
pub(crate) fn path_unlink_file(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
fd: __wasi_fd_t,
|
fd: WasiFd,
|
||||||
path: WasmPtr<u8, MemoryType>,
|
path: WasmPtr<u8, MemoryType>,
|
||||||
path_len: MemoryOffset,
|
path_len: MemoryOffset,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::path_unlink_file::<MemoryType>(ctx, fd, path, path_len)
|
super::path_unlink_file::<MemoryType>(ctx, fd, path, path_len)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn poll_oneoff(
|
pub(crate) fn poll_oneoff(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
in_: WasmPtr<__wasi_subscription_t, MemoryType>,
|
in_: WasmPtr<__wasi_subscription_t, MemoryType>,
|
||||||
out_: WasmPtr<__wasi_event_t, MemoryType>,
|
out_: WasmPtr<Event, MemoryType>,
|
||||||
nsubscriptions: MemoryOffset,
|
nsubscriptions: MemoryOffset,
|
||||||
nevents: WasmPtr<MemoryOffset, MemoryType>,
|
nevents: WasmPtr<MemoryOffset, MemoryType>,
|
||||||
) -> Result<__wasi_errno_t, WasiError> {
|
) -> Result<Errno, WasiError> {
|
||||||
super::poll_oneoff::<MemoryType>(ctx, in_, out_, nsubscriptions, nevents)
|
super::poll_oneoff::<MemoryType>(ctx, in_, out_, nsubscriptions, nevents)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,7 +393,7 @@ pub(crate) fn proc_exit(
|
|||||||
super::proc_exit(ctx, code)
|
super::proc_exit(ctx, code)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn proc_raise(ctx: FunctionEnvMut<WasiEnv>, sig: __wasi_signal_t) -> __wasi_errno_t {
|
pub(crate) fn proc_raise(ctx: FunctionEnvMut<WasiEnv>, sig: Signal) -> Errno {
|
||||||
super::proc_raise(ctx, sig)
|
super::proc_raise(ctx, sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,23 +401,23 @@ pub(crate) fn random_get(
|
|||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
buf: WasmPtr<u8, MemoryType>,
|
buf: WasmPtr<u8, MemoryType>,
|
||||||
buf_len: MemoryOffset,
|
buf_len: MemoryOffset,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::random_get::<MemoryType>(ctx, buf, buf_len)
|
super::random_get::<MemoryType>(ctx, buf, buf_len)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn sched_yield(ctx: FunctionEnvMut<WasiEnv>) -> Result<__wasi_errno_t, WasiError> {
|
pub(crate) fn sched_yield(ctx: FunctionEnvMut<WasiEnv>) -> Result<Errno, WasiError> {
|
||||||
super::sched_yield(ctx)
|
super::sched_yield(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn sock_recv(
|
pub(crate) fn sock_recv(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
sock: __wasi_fd_t,
|
sock: WasiFd,
|
||||||
ri_data: WasmPtr<__wasi_iovec_t<MemoryType>, MemoryType>,
|
ri_data: WasmPtr<__wasi_iovec_t<MemoryType>, MemoryType>,
|
||||||
ri_data_len: MemoryOffset,
|
ri_data_len: MemoryOffset,
|
||||||
ri_flags: __wasi_riflags_t,
|
ri_flags: RiFlags,
|
||||||
ro_data_len: WasmPtr<MemoryOffset, MemoryType>,
|
ro_data_len: WasmPtr<MemoryOffset, MemoryType>,
|
||||||
ro_flags: WasmPtr<__wasi_roflags_t, MemoryType>,
|
ro_flags: WasmPtr<RoFlags, MemoryType>,
|
||||||
) -> Result<__wasi_errno_t, WasiError> {
|
) -> Result<Errno, WasiError> {
|
||||||
super::sock_recv::<MemoryType>(
|
super::sock_recv::<MemoryType>(
|
||||||
ctx,
|
ctx,
|
||||||
sock,
|
sock,
|
||||||
@@ -432,19 +431,19 @@ pub(crate) fn sock_recv(
|
|||||||
|
|
||||||
pub(crate) fn sock_send(
|
pub(crate) fn sock_send(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
sock: __wasi_fd_t,
|
sock: WasiFd,
|
||||||
si_data: WasmPtr<__wasi_ciovec_t<MemoryType>, MemoryType>,
|
si_data: WasmPtr<__wasi_ciovec_t<MemoryType>, MemoryType>,
|
||||||
si_data_len: MemoryOffset,
|
si_data_len: MemoryOffset,
|
||||||
si_flags: __wasi_siflags_t,
|
si_flags: SiFlags,
|
||||||
ret_data_len: WasmPtr<MemoryOffset, MemoryType>,
|
ret_data_len: WasmPtr<MemoryOffset, MemoryType>,
|
||||||
) -> Result<__wasi_errno_t, WasiError> {
|
) -> Result<Errno, WasiError> {
|
||||||
super::sock_send::<MemoryType>(ctx, sock, si_data, si_data_len, si_flags, ret_data_len)
|
super::sock_send::<MemoryType>(ctx, sock, si_data, si_data_len, si_flags, ret_data_len)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn sock_shutdown(
|
pub(crate) fn sock_shutdown(
|
||||||
ctx: FunctionEnvMut<WasiEnv>,
|
ctx: FunctionEnvMut<WasiEnv>,
|
||||||
sock: __wasi_fd_t,
|
sock: WasiFd,
|
||||||
how: __wasi_sdflags_t,
|
how: SdFlags,
|
||||||
) -> __wasi_errno_t {
|
) -> Errno {
|
||||||
super::sock_shutdown(ctx, sock, how)
|
super::sock_shutdown(ctx, sock, how)
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,26 +1,29 @@
|
|||||||
use crate::syscalls::types::*;
|
use crate::syscalls::types::{
|
||||||
|
wasi::{Errno, Snapshot0Clockid, Timestamp},
|
||||||
|
*,
|
||||||
|
};
|
||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use wasmer::WasmRef;
|
use wasmer::WasmRef;
|
||||||
|
|
||||||
pub fn platform_clock_res_get(
|
pub fn platform_clock_res_get(
|
||||||
clock_id: __wasi_clockid_t,
|
clock_id: Snapshot0Clockid,
|
||||||
resolution: WasmRef<__wasi_timestamp_t>,
|
resolution: WasmRef<Timestamp>,
|
||||||
) -> Result<i64, __wasi_errno_t> {
|
) -> Result<i64, Errno> {
|
||||||
let t_out = match clock_id {
|
let t_out = match clock_id {
|
||||||
__WASI_CLOCK_MONOTONIC => 10_000_000,
|
Snapshot0Clockid::Monotonic => 10_000_000,
|
||||||
__WASI_CLOCK_REALTIME => 1,
|
Snapshot0Clockid::Realtime => 1,
|
||||||
__WASI_CLOCK_PROCESS_CPUTIME_ID => 1,
|
Snapshot0Clockid::ProcessCputimeId => 1,
|
||||||
__WASI_CLOCK_THREAD_CPUTIME_ID => 1,
|
Snapshot0Clockid::ThreadCputimeId => 1,
|
||||||
_ => return Err(__WASI_EINVAL),
|
_ => return Err(Errno::Inval),
|
||||||
};
|
};
|
||||||
Ok(t_out)
|
Ok(t_out)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn platform_clock_time_get(
|
pub fn platform_clock_time_get(
|
||||||
clock_id: __wasi_clockid_t,
|
clock_id: Snapshot0Clockid,
|
||||||
precision: __wasi_timestamp_t,
|
precision: Timestamp,
|
||||||
) -> Result<i64, __wasi_errno_t> {
|
) -> Result<i64, Errno> {
|
||||||
let new_time: DateTime<Local> = Local::now();
|
let new_time: DateTime<Local> = Local::now();
|
||||||
Ok(new_time.timestamp_nanos() as i64)
|
Ok(new_time.timestamp_nanos() as i64)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,53 +1,53 @@
|
|||||||
use crate::syscalls::types::*;
|
use crate::syscalls::types::wasi::{self, Timestamp};
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
use wasmer::WasmRef;
|
use wasmer::WasmRef;
|
||||||
|
|
||||||
pub fn platform_clock_res_get(
|
pub fn platform_clock_res_get(
|
||||||
clock_id: __wasi_clockid_t,
|
clock_id: wasi::Snapshot0Clockid,
|
||||||
resolution: WasmRef<__wasi_timestamp_t>,
|
resolution: WasmRef<Timestamp>,
|
||||||
) -> Result<i64, __wasi_errno_t> {
|
) -> Result<i64, wasi::Errno> {
|
||||||
let resolution_val = match clock_id {
|
let resolution_val = match clock_id {
|
||||||
// resolution of monotonic clock at 10ms, from:
|
// resolution of monotonic clock at 10ms, from:
|
||||||
// https://docs.microsoft.com/en-us/windows/desktop/api/sysinfoapi/nf-sysinfoapi-gettickcount64
|
// https://docs.microsoft.com/en-us/windows/desktop/api/sysinfoapi/nf-sysinfoapi-gettickcount64
|
||||||
__WASI_CLOCK_MONOTONIC => 10_000_000,
|
wasi::Snapshot0Clockid::Monotonic => 10_000_000,
|
||||||
// TODO: verify or compute this
|
// TODO: verify or compute this
|
||||||
__WASI_CLOCK_REALTIME => 1,
|
wasi::Snapshot0Clockid::Realtime => 1,
|
||||||
__WASI_CLOCK_PROCESS_CPUTIME_ID => {
|
wasi::Snapshot0Clockid::ProcessCputimeId => {
|
||||||
return Err(__WASI_EINVAL);
|
return Err(wasi::Errno::Inval);
|
||||||
}
|
}
|
||||||
__WASI_CLOCK_THREAD_CPUTIME_ID => {
|
wasi::Snapshot0Clockid::ThreadCputimeId => {
|
||||||
return Err(__WASI_EINVAL);
|
return Err(wasi::Errno::Inval);
|
||||||
}
|
}
|
||||||
_ => return Err(__WASI_EINVAL),
|
_ => return Err(wasi::Errno::Inval),
|
||||||
};
|
};
|
||||||
Ok(resolution_val)
|
Ok(resolution_val)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn platform_clock_time_get(
|
pub fn platform_clock_time_get(
|
||||||
clock_id: __wasi_clockid_t,
|
clock_id: wasi::Snapshot0Clockid,
|
||||||
precision: __wasi_timestamp_t,
|
precision: Timestamp,
|
||||||
) -> Result<i64, __wasi_errno_t> {
|
) -> Result<i64, wasi::Errno> {
|
||||||
let nanos = match clock_id {
|
let nanos = match clock_id {
|
||||||
__WASI_CLOCK_MONOTONIC => {
|
wasi::Snapshot0Clockid::Monotonic => {
|
||||||
let tick_ms = unsafe { winapi::um::sysinfoapi::GetTickCount64() };
|
let tick_ms = unsafe { winapi::um::sysinfoapi::GetTickCount64() };
|
||||||
tick_ms * 1_000_000
|
tick_ms * 1_000_000
|
||||||
}
|
}
|
||||||
__WASI_CLOCK_REALTIME => {
|
wasi::Snapshot0Clockid::Realtime => {
|
||||||
let duration = std::time::SystemTime::now()
|
let duration = std::time::SystemTime::now()
|
||||||
.duration_since(std::time::UNIX_EPOCH)
|
.duration_since(std::time::UNIX_EPOCH)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
debug!("Error in wasi::platform_clock_time_get: {:?}", e);
|
debug!("Error in wasi::platform_clock_time_get: {:?}", e);
|
||||||
__WASI_EIO
|
wasi::Errno::Io
|
||||||
})?;
|
})?;
|
||||||
duration.as_nanos() as u64
|
duration.as_nanos() as u64
|
||||||
}
|
}
|
||||||
__WASI_CLOCK_PROCESS_CPUTIME_ID => {
|
wasi::Snapshot0Clockid::ProcessCputimeId => {
|
||||||
unimplemented!("wasi::platform_clock_time_get(__WASI_CLOCK_PROCESS_CPUTIME_ID, ..)")
|
unimplemented!("wasi::platform_clock_time_get(wasi::Clockid::ProcessCputimeId, ..)")
|
||||||
}
|
}
|
||||||
__WASI_CLOCK_THREAD_CPUTIME_ID => {
|
wasi::Snapshot0Clockid::ThreadCputimeId => {
|
||||||
unimplemented!("wasi::platform_clock_time_get(__WASI_CLOCK_THREAD_CPUTIME_ID, ..)")
|
unimplemented!("wasi::platform_clock_time_get(wasi::Clockid::ThreadCputimeId, ..)")
|
||||||
}
|
}
|
||||||
_ => return Err(__WASI_EINVAL),
|
_ => return Err(wasi::Errno::Inval),
|
||||||
};
|
};
|
||||||
Ok(nanos as i64)
|
Ok(nanos as i64)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use super::types::*;
|
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
use wasmer::Module;
|
use wasmer::Module;
|
||||||
|
use wasmer_wasi_types::wasi::Errno;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
/// Check if a provided module is compiled for some version of WASI.
|
/// Check if a provided module is compiled for some version of WASI.
|
||||||
@@ -22,29 +22,29 @@ pub fn is_wasix_module(module: &Module) -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn map_io_err(err: std::io::Error) -> __wasi_errno_t {
|
pub fn map_io_err(err: std::io::Error) -> Errno {
|
||||||
use std::io::ErrorKind;
|
use std::io::ErrorKind;
|
||||||
match err.kind() {
|
match err.kind() {
|
||||||
ErrorKind::NotFound => __WASI_ENOENT,
|
ErrorKind::NotFound => Errno::Noent,
|
||||||
ErrorKind::PermissionDenied => __WASI_EPERM,
|
ErrorKind::PermissionDenied => Errno::Perm,
|
||||||
ErrorKind::ConnectionRefused => __WASI_ECONNREFUSED,
|
ErrorKind::ConnectionRefused => Errno::Connrefused,
|
||||||
ErrorKind::ConnectionReset => __WASI_ECONNRESET,
|
ErrorKind::ConnectionReset => Errno::Connreset,
|
||||||
ErrorKind::ConnectionAborted => __WASI_ECONNABORTED,
|
ErrorKind::ConnectionAborted => Errno::Connaborted,
|
||||||
ErrorKind::NotConnected => __WASI_ENOTCONN,
|
ErrorKind::NotConnected => Errno::Notconn,
|
||||||
ErrorKind::AddrInUse => __WASI_EADDRINUSE,
|
ErrorKind::AddrInUse => Errno::Addrinuse,
|
||||||
ErrorKind::AddrNotAvailable => __WASI_EADDRNOTAVAIL,
|
ErrorKind::AddrNotAvailable => Errno::Addrnotavail,
|
||||||
ErrorKind::BrokenPipe => __WASI_EPIPE,
|
ErrorKind::BrokenPipe => Errno::Pipe,
|
||||||
ErrorKind::AlreadyExists => __WASI_EEXIST,
|
ErrorKind::AlreadyExists => Errno::Exist,
|
||||||
ErrorKind::WouldBlock => __WASI_EAGAIN,
|
ErrorKind::WouldBlock => Errno::Again,
|
||||||
ErrorKind::InvalidInput => __WASI_EIO,
|
ErrorKind::InvalidInput => Errno::Io,
|
||||||
ErrorKind::InvalidData => __WASI_EIO,
|
ErrorKind::InvalidData => Errno::Io,
|
||||||
ErrorKind::TimedOut => __WASI_ETIMEDOUT,
|
ErrorKind::TimedOut => Errno::Timedout,
|
||||||
ErrorKind::WriteZero => __WASI_EIO,
|
ErrorKind::WriteZero => Errno::Io,
|
||||||
ErrorKind::Interrupted => __WASI_EINTR,
|
ErrorKind::Interrupted => Errno::Intr,
|
||||||
ErrorKind::Other => __WASI_EIO,
|
ErrorKind::Other => Errno::Io,
|
||||||
ErrorKind::UnexpectedEof => __WASI_EIO,
|
ErrorKind::UnexpectedEof => Errno::Io,
|
||||||
ErrorKind::Unsupported => __WASI_ENOTSUP,
|
ErrorKind::Unsupported => Errno::Notsup,
|
||||||
_ => __WASI_EIO,
|
_ => Errno::Io,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,9 @@ use std::fs::{read_dir, File, OpenOptions, ReadDir};
|
|||||||
use std::io::{self, Read, Seek, Write};
|
use std::io::{self, Read, Seek, Write};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::{mpsc, Arc, Mutex};
|
use std::sync::{mpsc, Arc, Mutex};
|
||||||
use wasmer::FunctionEnv;
|
use wasmer::{FunctionEnv, Imports, Instance, Module, Store};
|
||||||
use wasmer::{Imports, Instance, Module, Store};
|
|
||||||
use wasmer_vfs::{host_fs, mem_fs, FileSystem};
|
use wasmer_vfs::{host_fs, mem_fs, FileSystem};
|
||||||
use wasmer_wasi::types::{__wasi_filesize_t, __wasi_timestamp_t};
|
use wasmer_wasi::types::wasi::{Filesize, Timestamp};
|
||||||
use wasmer_wasi::{
|
use wasmer_wasi::{
|
||||||
generate_import_object_from_env, get_wasi_version, FsError, Pipe, VirtualFile, WasiEnv,
|
generate_import_object_from_env, get_wasi_version, FsError, Pipe, VirtualFile, WasiEnv,
|
||||||
WasiFunctionEnv, WasiState, WasiVersion,
|
WasiFunctionEnv, WasiState, WasiVersion,
|
||||||
@@ -614,19 +613,19 @@ impl Write for OutputCapturerer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl VirtualFile for OutputCapturerer {
|
impl VirtualFile for OutputCapturerer {
|
||||||
fn last_accessed(&self) -> __wasi_timestamp_t {
|
fn last_accessed(&self) -> Timestamp {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
fn last_modified(&self) -> __wasi_timestamp_t {
|
fn last_modified(&self) -> Timestamp {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
fn created_time(&self) -> __wasi_timestamp_t {
|
fn created_time(&self) -> Timestamp {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
fn size(&self) -> u64 {
|
fn size(&self) -> u64 {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
fn set_len(&mut self, _new_size: __wasi_filesize_t) -> Result<(), FsError> {
|
fn set_len(&mut self, _new_size: Filesize) -> Result<(), FsError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn unlink(&mut self) -> Result<(), FsError> {
|
fn unlink(&mut self) -> Result<(), FsError> {
|
||||||
|
|||||||
Reference in New Issue
Block a user