summaryrefslogtreecommitdiff
path: root/src/sys
diff options
context:
space:
mode:
authorSteve Lau <stevelauc@outlook.com>2022-12-06 21:45:12 +0800
committerSteve Lau <stevelauc@outlook.com>2022-12-06 21:45:12 +0800
commit7058bcef55ecdab7e7df463d450fda1beff3e92b (patch)
treeb4bd812945a1f8460595186db38674f803f8d879 /src/sys
parente2257dbb971fa974cf56f00a31d739a7e583e5b8 (diff)
downloadnix-7058bcef55ecdab7e7df463d450fda1beff3e92b.zip
feat: I/O safety for 'sys/statfs'
Diffstat (limited to 'src/sys')
-rw-r--r--src/sys/statfs.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/sys/statfs.rs b/src/sys/statfs.rs
index 9be8ca66..721d45cb 100644
--- a/src/sys/statfs.rs
+++ b/src/sys/statfs.rs
@@ -5,7 +5,7 @@
use std::ffi::CStr;
use std::fmt::{self, Debug};
use std::mem;
-use std::os::unix::io::AsRawFd;
+use std::os::unix::io::{AsFd, AsRawFd};
use cfg_if::cfg_if;
@@ -740,10 +740,10 @@ pub fn statfs<P: ?Sized + NixPath>(path: &P) -> Result<Statfs> {
/// # Arguments
///
/// `fd` - File descriptor of any open file within the file system to describe
-pub fn fstatfs<T: AsRawFd>(fd: &T) -> Result<Statfs> {
+pub fn fstatfs<Fd: AsFd>(fd: &Fd) -> Result<Statfs> {
unsafe {
let mut stat = mem::MaybeUninit::<type_of_statfs>::uninit();
- Errno::result(LIBC_FSTATFS(fd.as_raw_fd(), stat.as_mut_ptr()))
+ Errno::result(LIBC_FSTATFS(fd.as_fd().as_raw_fd(), stat.as_mut_ptr()))
.map(|_| Statfs(stat.assume_init()))
}
}