Skip to content
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

Return file creation times on Linux (using statx) #248

Merged
merged 9 commits into from
Jun 4, 2022

Commits on Jun 3, 2022

  1. 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 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.
    ongardie committed Jun 3, 2022
    Configuration menu
    Copy the full SHA
    1307013 View commit details
    Browse the repository at this point in the history
  2. stat_unchecked: Add backticks to comments from PR suggestions

    Co-authored-by: Dan Gohman <dev@sunfishcode.online>
    ongardie and sunfishcode committed Jun 3, 2022
    Configuration menu
    Copy the full SHA
    0b7dc95 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    26270cd View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    c7f65a2 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    6112c88 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    29cd8dd View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    2eca023 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    5aa6a77 View commit details
    Browse the repository at this point in the history
  9. 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.
    ongardie committed Jun 3, 2022
    Configuration menu
    Copy the full SHA
    7cee463 View commit details
    Browse the repository at this point in the history