Revert fstatat on *nix and test symlinks in path_filestat calls (#1725)

* Revert fstatat on *nix and test symlinks in path_filestat calls

This commit effectively reverts too eager refactoring on my part which
resulted in incorrect `path_filestat_{get, set_times}` behaviour on
*nix hosts. In the presence of symlinks, neither of the calls would
work properly.

In order to shield ourselves from similar errors in the future, I've
augmented the `path_filestat` test cases with symlink checks as well.

* Pass appropriate flags to fstatat and utimensat

* Fix formatting

* Fix Windows build

* Expand final symlinks if follow is set on Windows

* Fix formatting

* Do not follow symlinks unless specified on Windows

* Update comments and restart CI

* Skip testing volatile atim field
This commit is contained in:
Jakub Konka
2020-05-20 21:02:24 +02:00
committed by GitHub
parent 1f620e1b46
commit 348be6f3ed
7 changed files with 202 additions and 42 deletions

View File

@@ -469,15 +469,8 @@ impl<'a> WasiSnapshotPreview1 for WasiCtx {
let required_rights = HandleRights::from_base(types::Rights::PATH_FILESTAT_GET);
let entry = self.get_entry(dirfd)?;
let (dirfd, path) = path::get(&entry, &required_rights, flags, path, false)?;
let host_filestat = dirfd
.openat(
&path,
false,
false,
types::Oflags::empty(),
types::Fdflags::empty(),
)?
.filestat_get()?;
let host_filestat =
dirfd.filestat_get_at(&path, flags.contains(&types::Lookupflags::SYMLINK_FOLLOW))?;
Ok(host_filestat)
}
@@ -493,15 +486,13 @@ impl<'a> WasiSnapshotPreview1 for WasiCtx {
let required_rights = HandleRights::from_base(types::Rights::PATH_FILESTAT_SET_TIMES);
let entry = self.get_entry(dirfd)?;
let (dirfd, path) = path::get(&entry, &required_rights, flags, path, false)?;
dirfd
.openat(
&path,
false,
false,
types::Oflags::empty(),
types::Fdflags::empty(),
)?
.filestat_set_times(atim, mtim, fst_flags)?;
dirfd.filestat_set_times_at(
&path,
atim,
mtim,
fst_flags,
flags.contains(&types::Lookupflags::SYMLINK_FOLLOW),
)?;
Ok(())
}