Skip to content
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

Dir does not implement AsFd #2546

Open
chadaustin opened this issue Nov 22, 2024 · 2 comments
Open

Dir does not implement AsFd #2546

chadaustin opened this issue Nov 22, 2024 · 2 comments

Comments

@chadaustin
Copy link

fstatfs takes as AsFd. It used to take AsRawFd in 0.26.

That's fine, but Dir does not implement AsFd, requiring an unsafe BorrowedFd construction.

@SteveLauC
Copy link
Member

Hi, I fixed this in #2434:

nix/src/dir.rs

Lines 135 to 145 in db4ce6a

impl std::os::fd::AsFd for Dir {
fn as_fd(&self) -> std::os::fd::BorrowedFd {
let raw_fd = self.as_raw_fd();
// SAFETY:
//
// `raw_fd` should be open and valid for the lifetime of the returned
// `BorrowedFd` as it is extracted from `&self`.
unsafe { std::os::fd::BorrowedFd::borrow_raw(raw_fd) }
}
}

Though it has not been released yet.

Sigh, there are still a bunch of things to do before the 0.30.0 release, but I am too busy with my work and barely have time to push them. 😪

@chadaustin
Copy link
Author

Perfect! No hurry, just will make things a little nicer in the future. Looking forward to the release when you have time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants