-
Notifications
You must be signed in to change notification settings - Fork 37
Fix stat
when the last path component is a symlink to ..
.
#105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Replace `stat_via_parent` with `stat_manually` which similarly to `open_manually`. Factor the `open_manually` implemenation to allow parts to be reused.
Call `remove_dir_all` on the outermost directory, rather than the innermost one, so that it removes the whole directory.
And make more things `pub(super)` instead of `pub(crate)`.
d8d7cde
to
ae7a077
Compare
ae7a077
to
4dcf166
Compare
ongardie
added a commit
to ongardie/cap-std
that referenced
this pull request
Jun 3, 2022
Rust's standard library returns file creation times on Linux (at least with glibc), and now rust-std will too. File creation times are available on Linux via the `statx` syscall (not `fstatat`), introduced in kernel 4.11, which was released in April 2017. The Rust standard library already uses `statx` on Linux with glibc. Making cap-std support file creation times on Linux required two changes: 1. `File::metadata()` uses the standard library (which uses `statx`), but this wouldn't ever copy over the created field on Linux. Now, any time the created field is set in the std Metadata struct, it's also set in the cap-primitives Metadata, regardless of platform. 2. `stat_unchecked` is used in several places, including fetching DirEntry metadata. Before, it called `fstatat` directly. Now, it calls `statx` on Linux when available, and it falls back to `fstatat` otherwise. Fortunately, Dan Gohman (@sunfishcode) had already added a method to convert `statx` results in commit d1fa735 (PR bytecodealliance#105) in 2020. This commit also adds a new test to make sure file creation times are set in cap-std Metadata if they are set in std Metadata.
sunfishcode
added a commit
that referenced
this pull request
Jun 4, 2022
* Return file creation times on Linux (using statx) Rust's standard library returns file creation times on Linux (at least with glibc), and now rust-std will too. File creation times are available on Linux via the `statx` syscall (not `fstatat`), introduced in kernel 4.11, which was released in April 2017. The Rust standard library already uses `statx` on Linux with glibc. Making cap-std support file creation times on Linux required two changes: 1. `File::metadata()` uses the standard library (which uses `statx`), but this wouldn't ever copy over the created field on Linux. Now, any time the created field is set in the std Metadata struct, it's also set in the cap-primitives Metadata, regardless of platform. 2. `stat_unchecked` is used in several places, including fetching DirEntry metadata. Before, it called `fstatat` directly. Now, it calls `statx` on Linux when available, and it falls back to `fstatat` otherwise. Fortunately, Dan Gohman (@sunfishcode) had already added a method to convert `statx` results in commit d1fa735 (PR #105) in 2020. This commit also adds a new test to make sure file creation times are set in cap-std Metadata if they are set in std Metadata. * stat_unchecked: Add backticks to comments from PR suggestions Co-authored-by: Dan Gohman <[email protected]> * stat_unchecked: Reflow comment * stat_unchecked: Rewrite match statement for clarity * Rewrite file created times test to do exact comparisons against std * Move file created times test into fs_additional * Expand file created times test to check entire Metadata * stat_unchecked: Handle EPERM errors from statx * fs_additional: Fix non-Unix test build in metadata test I had used `cfg!(unix)` instead of `#[cfg(unix)]` in 2eca023, which doesn't conditionally compile out the Unix-specific code. Co-authored-by: Dan Gohman <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
stat_by_parent
doesn't handle this case because it drops thedirs
stack before resolving the symlink. Fixing this required a significant amount of refactoring. Fortunately, splitting upopen_manually
into smaller pieces is useful to do anyway, since it was a large and complex function.