Skip to content

Commit db95e26

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.
1 parent 69ef9af commit db95e26

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
@@ -751,10 +751,18 @@ impl File {
751751
len: u64,
752752
advice: system_interface::fs::Advice,
753753
) -> Result<(), ErrorCode> {
754+
use system_interface::fs::Advice;
754755
use system_interface::fs::FileIoExt as _;
755-
self.run_blocking(move |f| f.advise(offset, len, advice))
756-
.await?;
757-
Ok(())
756+
match self
757+
.run_blocking(move |f| f.advise(offset, len, advice))
758+
.await
759+
{
760+
#[cfg(any(target_os = "macos", target_os = "ios"))]
761+
Error(ErrorCode::FileTooLarge) if advice == Advice::WillNeed => 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)