From 8b9d2c5bbbb0252395d03f093bcd89b5bc782075 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Mon, 1 Feb 2021 12:42:31 -0800 Subject: [PATCH] cap-std-sync: my set_fd_flags idea didnt seem to work? --- crates/wasi-common/cap-std-sync/src/dir.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/wasi-common/cap-std-sync/src/dir.rs b/crates/wasi-common/cap-std-sync/src/dir.rs index ed78331b3f..1c75173c70 100644 --- a/crates/wasi-common/cap-std-sync/src/dir.rs +++ b/crates/wasi-common/cap-std-sync/src/dir.rs @@ -71,7 +71,16 @@ impl WasiDir for Dir { // (DSYNC, SYNC, NONBLOCK, RSYNC) // ideally OpenOptions would just support this though: // https://github.com/bytecodealliance/cap-std/issues/146 - f.set_fd_flags(to_sysif_fdflags(fdflags))?; + { + // Even worse - set_fd_flags panicks when given DSYNC, SYNC, RSYNC! + // it only supports NONBLOCK + let fdflags = if fdflags.contains(wasi_common::file::FdFlags::NONBLOCK) { + system_interface::fs::FdFlags::NONBLOCK + } else { + system_interface::fs::FdFlags::empty() + }; + f.set_fd_flags(fdflags)?; + } Ok(Box::new(File::from_cap_std(f))) }