Skip to content

Add stat and lstat shims for all Unixes#4934

Merged
RalfJung merged 2 commits intorust-lang:masterfrom
enricobolzonello:lstat-stat-support
Apr 27, 2026
Merged

Add stat and lstat shims for all Unixes#4934
RalfJung merged 2 commits intorust-lang:masterfrom
enricobolzonello:lstat-stat-support

Conversation

@enricobolzonello
Copy link
Copy Markdown
Contributor

@enricobolzonello enricobolzonello commented Apr 1, 2026

Closes #4744

Adds stat and lstat shims for Linux, following the same approach as #4714 did for fstat.

  • Add "stat" and "lstat" arms to the generic Unix foreign items handler
  • Add Os::Linux to the supported targets in fs.rs for both functions
  • Add tests for stat and lstat. The test for lstat verifies it does not follow symlinks

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 1, 2026

Thank you for contributing to Miri! A reviewer will take a look at your PR, typically within a week or two.
Please remember to not force-push to the PR branch except when you need to rebase due to a conflict or when the reviewer asks you for it.

@rustbot rustbot added the S-waiting-on-review Status: Waiting for a review to complete label Apr 1, 2026
Copy link
Copy Markdown
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the slow review.

This looks just right, thanks! However, the test could do with a bit of code deduplication.

@rustbot author

View changes since this review

Comment thread tests/pass-dep/libc/libc-fs.rs
@rustbot rustbot added S-waiting-on-author Status: Waiting for the PR author to address review comments and removed S-waiting-on-review Status: Waiting for a review to complete labels Apr 26, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 26, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 27, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@enricobolzonello
Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Waiting for a review to complete and removed S-waiting-on-author Status: Waiting for the PR author to address review comments labels Apr 27, 2026
@RalfJung RalfJung force-pushed the lstat-stat-support branch from e3e2bc4 to 7469a49 Compare April 27, 2026 13:25
Copy link
Copy Markdown
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I have one final minor nit but I'll take it from here.

View changes since this review

Comment thread tests/utils/libc.rs Outdated
}

/// Check that all common fields of a `stat` struct are initialized.
pub fn check_stat_fields(stat: &libc::stat) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You added this right in the middle of a block of functions that clearly belong together. Please be mindful of the surrounding code when deciding where to place new functions.

@RalfJung RalfJung enabled auto-merge April 27, 2026 13:26
@RalfJung RalfJung force-pushed the lstat-stat-support branch from 7469a49 to cacdc00 Compare April 27, 2026 13:27
@RalfJung RalfJung added this pull request to the merge queue Apr 27, 2026
Merged via the queue into rust-lang:master with commit 63b7e38 Apr 27, 2026
13 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Waiting for a review to complete label Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support "lstat" and "stat" on Linux (and all other Unixes)

3 participants