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" ) ]
@@ -24,22 +25,6 @@ pub mod vfs {
24
25
25
26
use sys:: statfs:: vfs:: hwdep:: * ;
26
27
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
28
pub const ADFS_SUPER_MAGIC : FsType = 0xadf5 ;
44
29
pub const AFFS_SUPER_MAGIC : FsType = 0xADFF ;
45
30
pub const BEFS_SUPER_MAGIC : FsType = 0x42465331 ;
@@ -87,30 +72,20 @@ pub mod vfs {
87
72
pub const _XIAFS_SUPER_MAGIC : FsType = 0x012FD16D ;
88
73
}
89
74
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 < ( ) > {
75
+ pub fn statfs < P : ?Sized + NixPath > ( path : & P , stat : & mut libc:: statfs ) -> Result < ( ) > {
101
76
unsafe {
102
77
Errno :: clear ( ) ;
103
78
let res = try!(
104
- path. with_nix_path ( |path| ffi :: statfs ( path. as_ptr ( ) , stat) )
79
+ path. with_nix_path ( |path| libc :: statfs ( path. as_ptr ( ) , stat) )
105
80
) ;
106
81
107
82
Errno :: result ( res) . map ( drop)
108
83
}
109
84
}
110
85
111
- pub fn fstatfs < T : AsRawFd > ( fd : & T , stat : & mut vfs :: Statfs ) -> Result < ( ) > {
86
+ pub fn fstatfs < T : AsRawFd > ( fd : & T , stat : & mut libc :: statfs ) -> Result < ( ) > {
112
87
unsafe {
113
88
Errno :: clear ( ) ;
114
- Errno :: result ( ffi :: fstatfs ( fd. as_raw_fd ( ) , stat) ) . map ( drop)
89
+ Errno :: result ( libc :: fstatfs ( fd. as_raw_fd ( ) , stat) ) . map ( drop)
115
90
}
116
91
}
0 commit comments