From 4c851792ac28c6fb09828a036b7fe3d4e1707033 Mon Sep 17 00:00:00 2001 From: Shen-Ta Hsieh Date: Fri, 31 Jul 2020 08:52:59 +0000 Subject: [PATCH] Fix std::fs::File::metadata permission on WASI target Previously `std::fs::File::metadata` on wasm32-wasi would call `fd_filestat_get` to get metadata associated with fd, but that fd is opened without RIGHTS_FD_FILESTAT_GET right, so it will failed on correctly implemented WASI environment. This change instead to add the missing rights when opening an fd. --- library/std/src/sys/wasi/fs.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/std/src/sys/wasi/fs.rs b/library/std/src/sys/wasi/fs.rs index 2eed9e436a956..6782d845bb056 100644 --- a/library/std/src/sys/wasi/fs.rs +++ b/library/std/src/sys/wasi/fs.rs @@ -331,6 +331,7 @@ impl OpenOptions { // FIXME: some of these should probably be read-only or write-only... base |= wasi::RIGHTS_FD_ADVISE; base |= wasi::RIGHTS_FD_FDSTAT_SET_FLAGS; + base |= wasi::RIGHTS_FD_FILESTAT_GET; base |= wasi::RIGHTS_FD_FILESTAT_SET_TIMES; base |= wasi::RIGHTS_FD_SEEK; base |= wasi::RIGHTS_FD_SYNC;