From 9284c73631ced6d0d865e04eb0c8a1190433b1aa Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 9 Nov 2021 15:30:13 +0900 Subject: [PATCH 1/2] Fix error code returned by some wasi fs syscalls for a non-existent file EINVAL should not be returned when a path name doesn't exist and should return ENOENT instead according to POSIX. This change affects to: - path_filestat_get - path_filestat_set_times - path_link - path_open - path_readlink - path_remove_directory - path_unlink_file --- lib/wasi/src/state/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/wasi/src/state/mod.rs b/lib/wasi/src/state/mod.rs index fa3fdf22376..c0a72373650 100644 --- a/lib/wasi/src/state/mod.rs +++ b/lib/wasi/src/state/mod.rs @@ -766,7 +766,7 @@ impl WasiFs { .fs_backing .symlink_metadata(&file) .ok() - .ok_or(__WASI_EINVAL)?; + .ok_or(__WASI_ENOENT)?; let file_type = metadata.file_type(); // we want to insert newly opened dirs and files, but not transient symlinks // TODO: explain why (think about this deeply when well rested) @@ -894,7 +894,7 @@ impl WasiFs { { cur_inode = *entry; } else { - return Err(__WASI_EINVAL); + return Err(__WASI_ENOENT); } } Kind::File { .. } => { From ee789cd34e93bb602abd3ebd946f2989ffa8e233 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 9 Nov 2021 15:52:55 +0900 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe87ff68171..f7eadb220db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ Looking for changes that affect our C API? See the [C API Changelog](lib/c-api/C - [#2454](https://github.com/wasmerio/wasmer/issues/2454) Won't set `WASMER_CACHE_DIR` for Windows. - [#2426](https://github.com/wasmerio/wasmer/pull/2426) Fix the `wax` script generation. - [#2635](https://github.com/wasmerio/wasmer/pull/2635) Fix cross-compilation for singlepass. +- [#2672](https://github.com/wasmerio/wasmer/pull/2672) Use `ENOENT` instead of `EINVAL` in some WASI syscalls for a non-existent file ## 2.0.0 - 2021/06/16