diff --git a/build.rs b/build.rs index c92fea840a..dda957c59f 100644 --- a/build.rs +++ b/build.rs @@ -136,7 +136,6 @@ cfg_if::cfg_if! { "symlink_loop" => true, "clock_time_get" => true, "truncation_rights" => true, - "path_filestat" => true, _ => false, } } else { diff --git a/src/hostcalls_impl/fs.rs b/src/hostcalls_impl/fs.rs index 4f9f83c066..fb69ffb3f7 100644 --- a/src/hostcalls_impl/fs.rs +++ b/src/hostcalls_impl/fs.rs @@ -9,6 +9,7 @@ use crate::sys::{errno_from_ioerror, host_impl, hostcalls_impl}; use crate::{host, wasm32, Result}; use filetime::{set_file_handle_times, FileTime}; use log::trace; +use std::fs::File; use std::io::{self, Read, Seek, SeekFrom, Write}; use std::time::{Duration, SystemTime, UNIX_EPOCH}; @@ -766,6 +767,15 @@ pub(crate) fn fd_filestat_set_times( let st_mtim = dec_timestamp(st_mtim); let fst_flags = dec_fstflags(fst_flags); + fd_filestat_set_times_impl(fd, st_atim, st_mtim, fst_flags) +} + +pub(crate) fn fd_filestat_set_times_impl( + fd: &File, + st_atim: wasm32::__wasi_timestamp_t, + st_mtim: wasm32::__wasi_timestamp_t, + fst_flags: wasm32::__wasi_fstflags_t, +) -> Result<()> { let set_atim = fst_flags & host::__WASI_FILESTAT_SET_ATIM != 0; let set_atim_now = fst_flags & host::__WASI_FILESTAT_SET_ATIM_NOW != 0; let set_mtim = fst_flags & host::__WASI_FILESTAT_SET_MTIM != 0; diff --git a/src/sys/windows/hostcalls_impl/fs.rs b/src/sys/windows/hostcalls_impl/fs.rs index 20eb1cf471..46c145d5da 100644 --- a/src/sys/windows/hostcalls_impl/fs.rs +++ b/src/sys/windows/hostcalls_impl/fs.rs @@ -4,7 +4,7 @@ use super::fs_helpers::*; use crate::ctx::WasiCtx; use crate::fdentry::FdEntry; use crate::helpers::systemtime_to_timestamp; -use crate::hostcalls_impl::PathGet; +use crate::hostcalls_impl::{fd_filestat_set_times_impl, PathGet}; use crate::sys::fdentry_impl::determine_type_rights; use crate::sys::host_impl; use crate::sys::hostcalls_impl::fs_helpers::PathGetExt; @@ -311,7 +311,9 @@ pub(crate) fn path_filestat_get( resolved: PathGet, dirflags: host::__wasi_lookupflags_t, ) -> Result { - unimplemented!("path_filestat_get") + let path = resolved.concatenate()?; + let file = File::open(path).map_err(errno_from_ioerror)?; + fd_filestat_get_impl(&file) } pub(crate) fn path_filestat_set_times( @@ -321,7 +323,13 @@ pub(crate) fn path_filestat_set_times( mut st_mtim: host::__wasi_timestamp_t, fst_flags: host::__wasi_fstflags_t, ) -> Result<()> { - unimplemented!("path_filestat_set_times") + use winx::file::AccessMode; + let path = resolved.concatenate()?; + let file = OpenOptions::new() + .access_mode(AccessMode::FILE_WRITE_ATTRIBUTES.bits()) + .open(path) + .map_err(errno_from_ioerror)?; + fd_filestat_set_times_impl(&file, st_atim, st_mtim, fst_flags) } pub(crate) fn path_symlink(old_path: &str, resolved: PathGet) -> Result<()> { diff --git a/src/wasm32.rs b/src/wasm32.rs index b8c379afa6..1411810782 100644 --- a/src/wasm32.rs +++ b/src/wasm32.rs @@ -1505,5 +1505,4 @@ mod test { ) ); } - }