Skip to content

Conversation

@Qelxiros
Copy link
Contributor

@Qelxiros Qelxiros commented Sep 8, 2025

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

A few notes:

  • I renamed new to open because open_dir takes &self and opens a subdirectory.
    • I also renamed open to open_file.
  • I'm not sure how to impl AsRawFd and friends because the common implementation uses PathBufs. How should I proceed here?

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.

@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
Copy link
Contributor

@ChrisDenton I'll need your help for the Windows review

@Qelxiros
Copy link
Contributor Author

@rustbot ready

@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
Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me, just a few mechanical things here. There are a couple left over from the previous review, #146341 (comment), #146341 (comment), and (newly) #146341 (comment).

View changes since this review

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

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
Copy link
Contributor

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
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
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*
@tgross35
Copy link
Contributor

For the suggestion above and a rebase,

@rustbot author

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

rustbot commented Oct 20, 2025

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

@rustbot

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Oct 20, 2025

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.

@Qelxiros
Copy link
Contributor Author

@rustbot ready

@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 Oct 20, 2025
@tgross35
Copy link
Contributor

@bors2 try

rust-bors bot added a commit that referenced this pull request Oct 20, 2025
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

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Oct 20, 2025

💔 Test for 7d804a8 failed: CI. Failed jobs:

@tgross35
Copy link
Contributor

I'm not quite sure what's failing here unfortunately. @neerajsi-msft do you have any ideas? The failure was in the test_dir_read_file test at

dir.open_file("foo.txt") failed with: The filename, directory name, or volume label syntax is incorrect. (os error 123) 

@rustbot author

@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 Oct 27, 2025
@neerajsi-msft
Copy link

I'm not quite sure what's failing here unfortunately. @neerajsi-msft do you have any ideas? The failure was in the test_dir_read_file test at

dir.open_file("foo.txt") failed with: The filename, directory name, or volume label syntax is incorrect. (os error 123) 

@rustbot author

I'll try to repro locally and take a look.

if path.is_absolute() {
return File::open(path, opts);
}
let path = to_u16s(path)?;
Copy link
Member

Choose a reason for hiding this comment

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

to_u16s produces a null-terminated path whereas kernel paths treat nulls literally rather than as a terminator (much like rust strings). I believe this is what's causing the test to fail.

Choose a reason for hiding this comment

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

Yes, I debugged this locally and Chris Denton is right. The NULL terminator is causing a problem.

@Qelxiros
Copy link
Contributor Author

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

@rust-bors
Copy link

rust-bors bot commented Oct 30, 2025

@Qelxiros: 🔑 Insufficient privileges: not in try users

@ChrisDenton
Copy link
Member

@bors2 try

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Oct 30, 2025
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
Copy link

rust-bors bot commented Oct 30, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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.

8 participants