-
Notifications
You must be signed in to change notification settings - Fork 13.4k
dirfd: preliminary unix and windows implementations #139514
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
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @workingjubilee. Use |
This comment has been minimized.
This comment has been minimized.
r? libs |
☔ The latest upstream changes (presumably #140608) made this pull request unmergeable. Please resolve the merge conflicts. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@tgross35 This has been waiting for a review for two weeks. Should I reroll another reviewer? I'm not sure what the process is here, but I don't want it to slip through the cracks. Is this PR mergeable in it's current state or is there something more I need to implement? Obviously there are more functions in the ACP, but I want to make sure I'm on the right track with what I have. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay, quite a lot of us were away for a week+. I can take an initial look at the Windows code.
This comment has been minimized.
This comment has been minimized.
All good on the delay, and thanks for the review! Those issues should be good now. As a side note to whoever does the next review, there have been a lot of changes on the unix side too since the last review. |
@tgross35 are you able to review this? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@bors2 try |
dirfd: preliminary unix and windows implementations Tracking issue: #120426 As per [this comment](#120426 (comment)), this issue needs someone to start work on an implementation, so I've implemented a couple functions for UNIX. There's a lot more work to be done here (most of the feature), so I'd love some guidance on what needs fixing in this PR and any notes on how to proceed. Thanks! try-job: `x86_64-msvc*` try-job: `test-various*` try-job: `dist-various*`
💔 Test failed
|
The default checks aren't useful for testing other platforms. @bors2 try |
@Qelxiros: 🔑 Insufficient privileges: not in try users |
@bors2 try |
dirfd: preliminary unix and windows implementations Tracking issue: #120426 As per [this comment](#120426 (comment)), this issue needs someone to start work on an implementation, so I've implemented a couple functions for UNIX. There's a lot more work to be done here (most of the feature), so I'd love some guidance on what needs fixing in this PR and any notes on how to proceed. Thanks! try-job: `x86_64-msvc*` try-job: `test-various*` try-job: `dist-various*`
💔 Test failed
|
@tgross35 I think it'll work now, if you want to try again (pun intended). |
@@ -1453,6 +1480,223 @@ impl Seek for Arc<File> { | |||
} | |||
} | |||
|
|||
impl Dir { | |||
/// Attempts to open a directory at `path` in read-only mode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we should guarantee read-only. Directories aren't entirely consistent across unixes.
They different flavors of O_EXEC
, O_SEARCH
or O_PATH
to indicate to open directories for traversal, not necessarily for readdir.
That kind of access can be sufficient for openat
for example to traverse deeper into a directory with 0o100
permissions.
Either we can try read access and fallback to traversal-only or always try traversal-only and require the use of OpenOptions::read(true)
to make that request.
Currently OpenOptions
has no way to express those O_EXEC&Co. except via platform-specifc extension traits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have tips to find which flag it is for each unix?
I think requiring OpenOptions::read(true)
is the better option. Trying for read access and then falling back would either lead to a more complex api (to communicate which method succeeded) or ambiguous results (if we don't communicate that). There might also be a TOCTOU risk, but I'm not sure of that.
Might there also be potential for confusion when refactoring from open
to open_with
? Is it worth adding a function like open_for_traversal
which uses O_EXEC
or similar when available and delegates to open
otherwise?
Finally, is this blocking? It seems more important that I finish the DirEntry api, and I suspect this is only one of several aspects that face bikeshedding before or during an FCP.
/// } | ||
/// ``` | ||
#[unstable(feature = "dirfd", issue = "120426")] | ||
pub fn open<P: AsRef<Path>>(&self, path: P) -> io::Result<File> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gives us a File
, but for traversal one might need a child-Dir
. So we'll need another method for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be in addition to create_dir()
?
Tracking issue: #120426
As per this comment, this issue needs someone to start work on an implementation, so I've implemented a couple functions for UNIX. There's a lot more work to be done here (most of the feature), so I'd love some guidance on what needs fixing in this PR and any notes on how to proceed. Thanks!
try-job:
x86_64-msvc*
try-job:
test-various*
try-job:
dist-various*