From d308c47822e1ad82c0f612f34e1f63955e3c7db9 Mon Sep 17 00:00:00 2001 From: Marcin Mielniczuk Date: Fri, 30 Aug 2019 14:57:03 +0200 Subject: [PATCH] Add a no-op implementation of fd_advise on Windows Windows apparently has no similar syscall available. --- src/sys/windows/hostcalls_impl/fs.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/sys/windows/hostcalls_impl/fs.rs b/src/sys/windows/hostcalls_impl/fs.rs index b2bbca350f..c8e1da9b24 100644 --- a/src/sys/windows/hostcalls_impl/fs.rs +++ b/src/sys/windows/hostcalls_impl/fs.rs @@ -61,12 +61,22 @@ pub(crate) fn fd_fdstat_set_flags(fd: &File, fdflags: host::__wasi_fdflags_t) -> } pub(crate) fn fd_advise( - file: &File, + _file: &File, advice: host::__wasi_advice_t, - offset: host::__wasi_filesize_t, - len: host::__wasi_filesize_t, + _offset: host::__wasi_filesize_t, + _len: host::__wasi_filesize_t, ) -> Result<()> { - unimplemented!("fd_advise") + match advice { + host::__WASI_ADVICE_DONTNEED + | host::__WASI_ADVICE_SEQUENTIAL + | host::__WASI_ADVICE_WILLNEED + | host::__WASI_ADVICE_NOREUSE + | host::__WASI_ADVICE_RANDOM + | host::__WASI_ADVICE_NORMAL => {} + _ => return Err(host::__WASI_EINVAL), + } + + Ok(()) } pub(crate) fn path_create_directory(resolved: PathGet) -> Result<()> {