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

Support getting file metadata on Windows #4067

Merged
merged 2 commits into from
Apr 9, 2025

Conversation

CraftSpider
Copy link
Contributor

@CraftSpider CraftSpider commented Dec 2, 2024

Main changes are the first two commits - one refactors handles a bit to make their usage more consistent and adds the file variant, the other actually adds the metadata shims.

This also changes miri to never return invalid handle errors, instead always treating them as an error. This behavior matches that of code running under the MSVC debugger - invalid handles are treated as exceptions in debug contexts.

Split off #4043

Copy link
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! Here are some comments for the first and last commit, I skipped the second one for now.

@CraftSpider
Copy link
Contributor Author

CraftSpider commented Dec 6, 2024

Before we get too much further on this PR, I'd like to point out 296d806 (which I just pushed) on the big PR. It's the changes needed to FileDescription methods to make them platform-agnostic enough for Windows use-cases. If they look fine, we can continue, but if you think it's a bad design then the FileDescription trait will need entirely split in two, which will change code even in this PR.

@RalfJung
Copy link
Member

RalfJung commented Dec 6, 2024

Reducing the places where we have to use global state like errno seems like an improvement. But please use Result<_, IoError> (with Miri's IoError type).

@CraftSpider
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added the S-waiting-on-review Status: Waiting for a review to complete label Dec 6, 2024
const TIME_TO_EPOCH: u64 = 31_556_926 * 369 * 10_000_000;
match time.ok() {
Some(time) => {
let duration = system_time_to_duration(&time)?;
Copy link
Member

Choose a reason for hiding this comment

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

We should probably rename this to system_time_since_unix_epoch. (Can be a future PR though.)

@RalfJung
Copy link
Member

RalfJung commented Dec 7, 2024

Okay I finally had a look at the core new file in this PR. :)
@rustbot author

@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 Dec 7, 2024
@CraftSpider
Copy link
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 Dec 9, 2024
@bors
Copy link
Contributor

bors commented Dec 12, 2024

☔ The latest upstream changes (presumably #4068) made this pull request unmergeable. Please resolve the merge conflicts.

@RalfJung
Copy link
Member

@rustbot author

@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 Dec 12, 2024
@CraftSpider
Copy link
Contributor Author

Thanks, sorry for the unnecessary ping then.

Copy link
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 for the patience!

@RalfJung
Copy link
Member

@rustbot author

@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 Mar 20, 2025
@CraftSpider
Copy link
Contributor Author

@rustbot review

@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 2, 2025
@rustbot

This comment has been minimized.

- consistent handling, invalid handles are always an abort
- Helper for reading handles that does the checking and machine stop
- Use real handle types more places
- Adds `File` and `Invalid` types of handle. File support will be added next
Copy link
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 a lot! I'm happy with the general approach and structure now, we're just finalizing comments and style. :)

@rustbot author

@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 7, 2025
@rustbot
Copy link
Collaborator

rustbot commented Apr 7, 2025

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

@CraftSpider
Copy link
Contributor Author

Thanks for the patience and help with getting this over the line! After this merges, I'll work to flesh out the shims more, make it so you can actually do useful things with files targeting Windows.

@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 7, 2025
@RalfJung
Copy link
Member

RalfJung commented Apr 8, 2025

Thank you for your patience with the sometimes slow round-trip times. :)

This looks great, thanks! Please squash the commits, then we can land this. Please use the --keep-base flag when squashing so that the force-push diff is easier to review. Then write @rustbot ready after you pushed the squashed PR.

@rustbot author

@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 8, 2025
@CraftSpider
Copy link
Contributor Author

@rustbot review

@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 9, 2025
@RalfJung RalfJung added this pull request to the merge queue Apr 9, 2025
Merged via the queue into rust-lang:master with commit c701c7d Apr 9, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Waiting for a review to complete
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants