-
Notifications
You must be signed in to change notification settings - Fork 672
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
refactor: I/O safety for modules fcntl and dir #2434
refactor: I/O safety for modules fcntl and dir #2434
Conversation
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> { |
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 think this function should be removed given its IntoRawFd
usage, so deprecate it in the next release and remove it in futhre versions.
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.
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.
|
||
#[cfg(not(target_os = "haiku"))] | ||
#[test] | ||
fn ebadf() { |
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 test is removed because this should not happen after the adoption of I/O safety.
4004b87
to
d6d7f40
Compare
What does this PR do
This PR adds I/O safety to
fcntl.rs
anddir.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_FDCWD
with non-xxat()
functions.Checklist:
CONTRIBUTING.md