Skip to content

Commit 17b1a09

Browse files
committed
feat: I/O safety for 'sys/statvfs'
1 parent 7f18847 commit 17b1a09

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/sys/statvfs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! See [the man pages](https://pubs.opengroup.org/onlinepubs/9699919799/functions/fstatvfs.html)
44
//! for more details.
55
use std::mem;
6-
use std::os::unix::io::AsRawFd;
6+
use std::os::unix::io::{AsFd, AsRawFd};
77

88
use libc::{self, c_ulong};
99

@@ -146,11 +146,11 @@ pub fn statvfs<P: ?Sized + NixPath>(path: &P) -> Result<Statvfs> {
146146
}
147147

148148
/// Return a `Statvfs` object with information about `fd`
149-
pub fn fstatvfs<T: AsRawFd>(fd: &T) -> Result<Statvfs> {
149+
pub fn fstatvfs<Fd: AsFd>(fd: &Fd) -> Result<Statvfs> {
150150
unsafe {
151151
Errno::clear();
152152
let mut stat = mem::MaybeUninit::<libc::statvfs>::uninit();
153-
Errno::result(libc::fstatvfs(fd.as_raw_fd(), stat.as_mut_ptr()))
153+
Errno::result(libc::fstatvfs(fd.as_fd().as_raw_fd(), stat.as_mut_ptr()))
154154
.map(|_| Statvfs(stat.assume_init()))
155155
}
156156
}

0 commit comments

Comments
 (0)