minimal dirfd implementation (1/4) by Qelxiros · Pull Request #146341 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation123 Commits1 Checks11 Files changed

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

[ Show hidden characters]({{ revealButtonHref }})

@Qelxiros

This is the first of four smaller PRs that will eventually be equivalent to #139514.

A few notes:

The other PRs will be based on this one, so I'll make drafts and mark them ready as their predecessors get merged. They might take a bit though; I've never done this particular thing with git before.

Tracking issue: #120426

r? @tgross35

try-job: aarch64-apple
try-job: dist-various*
try-job: test-various*
try-job: x86_64-msvc-1
try-job: x86_64-mingw*

@rustbot rustbot added O-windows

Operating system: Windows

S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-libs

Relevant to the library team, which will review and decide on the PR/issue.

labels

Sep 8, 2025

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

tgross35

@rustbot rustbot added S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

labels

Sep 10, 2025

@tgross35

Qelxiros

@Qelxiros

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

and removed S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Sep 10, 2025

tgross35

Choose a reason for hiding this comment

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

let mut handle = ptr::null_mut();
let mut io_status = c::IO_STATUS_BLOCK::PENDING;
let access = opts.get_access_mode()? | c::SYNCHRONIZE;
let options = create_options | c::FILE_SYNCHRONOUS_IO_NONALERT;

Choose a reason for hiding this comment

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

Could you add a note about why this flag is set?

Choose a reason for hiding this comment

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

I no longer remember why I chose this one, and looking at it now, I'm not sure whether we should set this one, FILE_SYNCHRONOUS_IO_ALERT, or neither. Maybe @ChrisDenton has thoughts?

Choose a reason for hiding this comment

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

Update, using neither causes an error, so I've added back FILE_SYNCHRONOUS_IO_NONALERT

Choose a reason for hiding this comment

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

Yeah, passing this flag is equivalent to not passing FILE_FLAG_OVERLAPPED to CreateFile. So if you don't pass this flag, other APIs using the handle need to follow the usual overlapped rules, otherwise they may behave improperly.

@tgross35

From the top post:

* I'm not sure how to `impl AsRawFd` and friends because the `common` implementation uses `PathBuf`s. How should I proceed here?

I think it would be fine to include the impl AsRawFd only in unix/dir so it's only implemented if we have dirfd. I'll add an unresolved question to the tracking issue.

The other PRs will be based on this one, so I'll make drafts and mark them ready as their predecessors get merged. They might take a bit though; I've never done this particular thing with git before.

That is quite alright, there is no hurry :) For reference, the --update-refs rebase flag can be pretty useful when you're working with a stack (e.g. https://andrewlock.net/working-with-stacked-branches-in-git-is-easier-with-update-refs/)

@tgross35

This comment was marked as outdated.

rust-bors bot added a commit that referenced this pull request

Sep 10, 2025

@rust-bors

minimal dirfd implementation (1/4)

try-job: aarch64-apple try-job: dist-various* try-job: test-various* try-job: x86_64-msvc* try-job: x86_64-mingw

@rust-bors

This comment has been minimized.

@rust-bors

This comment was marked as outdated.

@rust-log-analyzer

This comment was marked as outdated.

@tgross35

This comment was marked as outdated.

rust-bors bot added a commit that referenced this pull request

Sep 10, 2025

@rust-bors

minimal dirfd implementation (1/4)

try-job: aarch64-apple try-job: dist-various* try-job: test-various* try-job: x86_64-msvc* try-job: x86_64-mingw*

@Qelxiros

Looks like I need a try job to see if the error still exists.
@bors2 try

@rust-bors

@Qelxiros: 🔑 Insufficient privileges: not in try users

@ChrisDenton

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request

Oct 30, 2025

@rust-bors

minimal dirfd implementation (1/4)

try-job: aarch64-apple try-job: dist-various* try-job: test-various* try-job: x86_64-msvc-1 try-job: x86_64-mingw*

@rust-bors

☀️ Try build successful (CI)
Build commit: b34b92d (b34b92dc58537d82f2e3477bddd7c9560f59aae5, parent: 8205e6b75ec656305ac235d4726d2c7a1ddcef14)

@Qelxiros

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

and removed S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Nov 4, 2025

tgross35

@tgross35

@bors

📌 Commit 1479928 has been approved by tgross35

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

labels

Nov 19, 2025

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Nov 19, 2025

@matthiaskrgr

minimal dirfd implementation (1/4)

This is the first of four smaller PRs that will eventually be equivalent to rust-lang#139514.

A few notes:

The other PRs will be based on this one, so I'll make drafts and mark them ready as their predecessors get merged. They might take a bit though; I've never done this particular thing with git before.

Tracking issue: rust-lang#120426

try-job: aarch64-apple try-job: dist-various* try-job: test-various* try-job: x86_64-msvc-1 try-job: x86_64-mingw*

bors added a commit that referenced this pull request

Nov 19, 2025

@bors

Rollup of 7 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

@matthiaskrgr

@bors bors added S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

and removed S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

labels

Nov 19, 2025

tgross35

@bors

@rustbot

This comment has been minimized.

@Qelxiros

@rustbot

This PR was rebased onto a different main 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.

@rust-log-analyzer

The job pr-check-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors

Labels

O-windows

Operating system: Windows

S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

T-libs

Relevant to the library team, which will review and decide on the PR/issue.