From 04b8a34f739c6fef19be52a9ec19361c0e1a47d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 24 Mar 2017 19:33:38 +0100 Subject: [PATCH] sys/statfs: use statfs from libc --- src/sys/statfs.rs | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/src/sys/statfs.rs b/src/sys/statfs.rs index 7c61a3ab31..5edb61b52f 100644 --- a/src/sys/statfs.rs +++ b/src/sys/statfs.rs @@ -1,5 +1,6 @@ use {Errno, Result, NixPath}; use std::os::unix::io::AsRawFd; +use libc; pub mod vfs { #[cfg(target_pointer_width = "32")] @@ -24,22 +25,6 @@ pub mod vfs { use sys::statfs::vfs::hwdep::*; - #[repr(C)] - #[derive(Debug,Copy,Clone)] - pub struct Statfs { - pub f_type: FsType, - pub f_bsize: BlockSize, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_fsid: u64, - pub f_namelen: NameLen, - pub f_frsize: FragmentSize, - pub f_spare: [SwordType; 5], - } - pub const ADFS_SUPER_MAGIC : FsType = 0xadf5; pub const AFFS_SUPER_MAGIC : FsType = 0xADFF; pub const BEFS_SUPER_MAGIC : FsType = 0x42465331; @@ -87,30 +72,20 @@ pub mod vfs { pub const _XIAFS_SUPER_MAGIC : FsType = 0x012FD16D; } -mod ffi { - use libc::{c_int,c_char}; - use sys::statfs::vfs; - - extern { - pub fn statfs(path: * const c_char, buf: *mut vfs::Statfs) -> c_int; - pub fn fstatfs(fd: c_int, buf: *mut vfs::Statfs) -> c_int; - } -} - -pub fn statfs(path: &P, stat: &mut vfs::Statfs) -> Result<()> { +pub fn statfs(path: &P, stat: &mut libc::statfs) -> Result<()> { unsafe { Errno::clear(); let res = try!( - path.with_nix_path(|path| ffi::statfs(path.as_ptr(), stat)) + path.with_nix_path(|path| libc::statfs(path.as_ptr(), stat)) ); Errno::result(res).map(drop) } } -pub fn fstatfs(fd: &T, stat: &mut vfs::Statfs) -> Result<()> { +pub fn fstatfs(fd: &T, stat: &mut libc::statfs) -> Result<()> { unsafe { Errno::clear(); - Errno::result(ffi::fstatfs(fd.as_raw_fd(), stat)).map(drop) + Errno::result(libc::fstatfs(fd.as_raw_fd(), stat)).map(drop) } }