Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2672: Fix error code returned by some wasi fs syscalls for a non-existent file r=Amanieu a=kateinoigakukun <!-- Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test: https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests --> # Description Currently, wasmer's WASI implementation returns EINVAL when a caller gives non-existent file path as a parameter. But EINVAL should not be returned in such case 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 You can reproduce this issue by the following code ```c #include <stdio.h> #include <fcntl.h> #include <errno.h> int main(void) { int ret = open("/nonexist", O_RDONLY); if (ret < 0) { int e = errno; perror("got error"); printf("errno = %d\n", e); } printf("ret = %d\n", ret); return 0; } ``` ```console $ # expected result $ wasmtime run path_open.wasm --mapdir /::./ got error: No such file or directory errno = 44 ret = -1 $ # with the latest build of wasmer master branch $ wasmer run path_open.wasm --mapdir /::./ got error: Invalid argument errno = 28 ret = -1 ``` # Review - [x] Add a short description of the change to the CHANGELOG.md file Co-authored-by: Yuta Saito <[email protected]>
- Loading branch information