about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
authorShen-Ta Hsieh <beststeve@secondstate.io>2020-07-31 08:52:59 +0000
committerShen-Ta Hsieh <beststeve@secondstate.io>2020-07-31 09:01:16 +0000
commit4c851792ac28c6fb09828a036b7fe3d4e1707033 (patch)
tree6e88d9e80f9ceecc8e3c4bdeac5e92bbf2cddf15 /library/std/src/sys
parentac91673d895a0c578ed773e1280bdde8adb87b8c (diff)
downloadrust-4c851792ac28c6fb09828a036b7fe3d4e1707033.tar.gz
rust-4c851792ac28c6fb09828a036b7fe3d4e1707033.zip
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.
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/wasi/fs.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/library/std/src/sys/wasi/fs.rs b/library/std/src/sys/wasi/fs.rs
index 2eed9e436a9..6782d845bb0 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;