diff --git a/src/sys/statfs.rs b/src/sys/statfs.rs index 9be8ca6667..721d45cb21 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(path: &P) -> Result { /// # Arguments /// /// `fd` - File descriptor of any open file within the file system to describe -pub fn fstatfs(fd: &T) -> Result { +pub fn fstatfs(fd: &Fd) -> Result { unsafe { let mut stat = mem::MaybeUninit::::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())) } } diff --git a/test/test_fcntl.rs b/test/test_fcntl.rs index fb2a5e2ea0..8f50f16b5a 100644 --- a/test/test_fcntl.rs +++ b/test/test_fcntl.rs @@ -383,7 +383,7 @@ mod linux_android { let tmp = NamedTempFile::new().unwrap(); let fd = tmp.as_raw_fd(); - let statfs = nix::sys::statfs::fstatfs(&tmp).unwrap(); + let statfs = nix::sys::statfs::fstatfs(tmp.as_file()).unwrap(); if statfs.filesystem_type() == nix::sys::statfs::OVERLAYFS_SUPER_MAGIC { // OverlayFS is a union file system. It returns one inode value in // stat(2), but a different one shows up in /proc/locks. So we must @@ -421,7 +421,7 @@ mod linux_android { let tmp = NamedTempFile::new().unwrap(); let fd = tmp.as_raw_fd(); - let statfs = nix::sys::statfs::fstatfs(&tmp).unwrap(); + let statfs = nix::sys::statfs::fstatfs(tmp.as_file()).unwrap(); if statfs.filesystem_type() == nix::sys::statfs::OVERLAYFS_SUPER_MAGIC { // OverlayFS is a union file system. It returns one inode value in // stat(2), but a different one shows up in /proc/locks. So we must