refactor: I/O safety for modules fcntl and dir#2434
Merged
SteveLauC merged 10 commits intonix-rust:masterfrom Jun 9, 2024
Merged
refactor: I/O safety for modules fcntl and dir#2434SteveLauC merged 10 commits intonix-rust:masterfrom
SteveLauC merged 10 commits intonix-rust:masterfrom
Conversation
SteveLauC
commented
Jun 9, 2024
| since = "0.30.0", | ||
| note = "Deprecate this since it is not I/O-safe, use from_fd instead." | ||
| )] | ||
| pub unsafe fn from<F: IntoRawFd>(fd: F) -> Result<Self> { |
Member
Author
There was a problem hiding this comment.
I think this function should be removed given its IntoRawFd usage, so deprecate it in the next release and remove it in futhre versions.
Member
Author
There was a problem hiding this comment.
For all the owned file descriptors types provided by the std, they have Into<OwnedFd> implemented, so Dir::from_fd() would be a good replacement for this function.
SteveLauC
commented
Jun 9, 2024
|
|
||
| #[cfg(not(target_os = "haiku"))] | ||
| #[test] | ||
| fn ebadf() { |
Member
Author
There was a problem hiding this comment.
This test is removed because this should not happen after the adoption of I/O safety.
4004b87 to
d6d7f40
Compare
sorah
added a commit
to sorah/mairu
that referenced
this pull request
Aug 20, 2025
sorah
added a commit
to sorah/mairu
that referenced
this pull request
Aug 20, 2025
- Includes a fix for nix-rust/nix#2434 nix-rust/nix#2434
sorah
added a commit
to sorah/mairu
that referenced
this pull request
Aug 20, 2025
- Includes a fix for nix-rust/nix#2434 nix-rust/nix#2434
sorah
added a commit
to sorah/mairu
that referenced
this pull request
Aug 20, 2025
- Includes a fix for nix-rust/nix#2434 nix-rust/nix#2434
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do
This PR adds I/O safety to
fcntl.rsanddir.rs.Ref: #1750
xxat() interfaces
For those
xxat()interfaces, I didn't introduce a new trait to represent directory file descriptors, instead, I took the way how rustix implements it:AT_FDCWD: BorrowedFd<'static>xxat<Fd: AsFd>(dirfd: Fd, ...)because:
dirfd, or usingAT_FDCWDwith non-xxat()functions.Checklist:
CONTRIBUTING.md