Skip to content

Commit 1da615b

Browse files
committed
filesystem: Paper over fadvise harmless failure on macos
On macos and ios, fadvise is only implemented for WillNeed and dispatches via the system-interface crate to the F_RDADVISE fcntl. If you call WillNeed on an out-of-bounds offset, this fcntl returns FileTooLarge. Here we paper over this harmless error code to avoid this needless platform-dependent nonuniformity. Should fix wasmtime for WebAssembly/wasi-testsuite#178. prtest:full
1 parent 69ef9af commit 1da615b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

crates/wasi/src/filesystem.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,9 +752,17 @@ impl File {
752752
advice: system_interface::fs::Advice,
753753
) -> Result<(), ErrorCode> {
754754
use system_interface::fs::FileIoExt as _;
755-
self.run_blocking(move |f| f.advise(offset, len, advice))
756-
.await?;
757-
Ok(())
755+
match self
756+
.run_blocking(move |f| f.advise(offset, len, advice))
757+
.await
758+
{
759+
#[cfg(any(target_os = "macos", target_os = "ios"))]
760+
Err(ErrorCode::FileTooLarge) if advice == system_interface::fs::Advice::WillNeed => {
761+
Ok(())
762+
}
763+
Err(err) => Err(err.into()),
764+
Ok(()) => Ok(()),
765+
}
758766
}
759767

760768
pub(crate) async fn set_size(&self, size: u64) -> Result<(), ErrorCode> {

0 commit comments

Comments
 (0)