|
1 | 1 | use {Errno, Result, NixPath};
|
2 | 2 | use std::os::unix::io::AsRawFd;
|
| 3 | +use libc; |
3 | 4 |
|
4 | 5 | pub mod vfs {
|
5 | 6 | #[cfg(target_pointer_width = "32")]
|
6 | 7 | pub mod hwdep {
|
7 |
| - use libc::{c_uint}; |
| 8 | + use libc::c_uint; |
8 | 9 | pub type FsType = c_uint;
|
9 |
| - pub type BlockSize = c_uint; |
10 |
| - pub type NameLen = c_uint; |
11 |
| - pub type FragmentSize = c_uint; |
12 |
| - pub type SwordType = c_uint; |
13 | 10 | }
|
14 | 11 |
|
15 | 12 | #[cfg(target_pointer_width = "64")]
|
16 | 13 | pub mod hwdep {
|
17 |
| - use libc::{c_long}; |
| 14 | + use libc::c_long; |
18 | 15 | pub type FsType = c_long;
|
19 |
| - pub type BlockSize = c_long; |
20 |
| - pub type NameLen = c_long; |
21 |
| - pub type FragmentSize = c_long; |
22 |
| - pub type SwordType = c_long; |
23 | 16 | }
|
24 | 17 |
|
25 | 18 | use sys::statfs::vfs::hwdep::*;
|
26 | 19 |
|
27 |
| - #[repr(C)] |
28 |
| - #[derive(Debug,Copy,Clone)] |
29 |
| - pub struct Statfs { |
30 |
| - pub f_type: FsType, |
31 |
| - pub f_bsize: BlockSize, |
32 |
| - pub f_blocks: u64, |
33 |
| - pub f_bfree: u64, |
34 |
| - pub f_bavail: u64, |
35 |
| - pub f_files: u64, |
36 |
| - pub f_ffree: u64, |
37 |
| - pub f_fsid: u64, |
38 |
| - pub f_namelen: NameLen, |
39 |
| - pub f_frsize: FragmentSize, |
40 |
| - pub f_spare: [SwordType; 5], |
41 |
| - } |
42 |
| - |
43 | 20 | pub const ADFS_SUPER_MAGIC : FsType = 0xadf5;
|
44 | 21 | pub const AFFS_SUPER_MAGIC : FsType = 0xADFF;
|
45 | 22 | pub const BEFS_SUPER_MAGIC : FsType = 0x42465331;
|
@@ -87,30 +64,20 @@ pub mod vfs {
|
87 | 64 | pub const _XIAFS_SUPER_MAGIC : FsType = 0x012FD16D;
|
88 | 65 | }
|
89 | 66 |
|
90 |
| -mod ffi { |
91 |
| - use libc::{c_int,c_char}; |
92 |
| - use sys::statfs::vfs; |
93 |
| - |
94 |
| - extern { |
95 |
| - pub fn statfs(path: * const c_char, buf: *mut vfs::Statfs) -> c_int; |
96 |
| - pub fn fstatfs(fd: c_int, buf: *mut vfs::Statfs) -> c_int; |
97 |
| - } |
98 |
| -} |
99 |
| - |
100 |
| -pub fn statfs<P: ?Sized + NixPath>(path: &P, stat: &mut vfs::Statfs) -> Result<()> { |
| 67 | +pub fn statfs<P: ?Sized + NixPath>(path: &P, stat: &mut libc::statfs) -> Result<()> { |
101 | 68 | unsafe {
|
102 | 69 | Errno::clear();
|
103 | 70 | let res = try!(
|
104 |
| - path.with_nix_path(|path| ffi::statfs(path.as_ptr(), stat)) |
| 71 | + path.with_nix_path(|path| libc::statfs(path.as_ptr(), stat)) |
105 | 72 | );
|
106 | 73 |
|
107 | 74 | Errno::result(res).map(drop)
|
108 | 75 | }
|
109 | 76 | }
|
110 | 77 |
|
111 |
| -pub fn fstatfs<T: AsRawFd>(fd: &T, stat: &mut vfs::Statfs) -> Result<()> { |
| 78 | +pub fn fstatfs<T: AsRawFd>(fd: &T, stat: &mut libc::statfs) -> Result<()> { |
112 | 79 | unsafe {
|
113 | 80 | Errno::clear();
|
114 |
| - Errno::result(ffi::fstatfs(fd.as_raw_fd(), stat)).map(drop) |
| 81 | + Errno::result(libc::fstatfs(fd.as_raw_fd(), stat)).map(drop) |
115 | 82 | }
|
116 | 83 | }
|
0 commit comments