@@ -8,119 +8,119 @@ use libc::{c_int, c_char};
8
8
target_arch = "arm" ) ) ,
9
9
) ]
10
10
pub mod quota {
11
- use libc:: c_int;
12
-
13
- pub struct QuotaCmd ( pub QuotaSubCmd , pub QuotaType ) ;
14
- pub type QuotaSubCmd = c_int ;
15
-
16
- impl QuotaCmd {
17
- pub fn as_int ( & self ) -> c_int {
18
- ( ( self . 0 << 8 ) | ( self . 1 & 0x00ff ) ) as c_int
19
- }
20
- }
21
-
22
- // linux quota version >= 2
23
- pub const Q_SYNC : QuotaSubCmd = 0x800001 ;
24
- pub const Q_QUOTAON : QuotaSubCmd = 0x800002 ;
25
- pub const Q_QUOTAOFF : QuotaSubCmd = 0x800003 ;
26
- pub const Q_GETFMT : QuotaSubCmd = 0x800004 ;
27
- pub const Q_GETINFO : QuotaSubCmd = 0x800005 ;
28
- pub const Q_SETINFO : QuotaSubCmd = 0x800006 ;
29
- pub const Q_GETQUOTA : QuotaSubCmd = 0x800007 ;
30
- pub const Q_SETQUOTA : QuotaSubCmd = 0x800008 ;
31
-
32
- pub type QuotaType = c_int ;
33
-
34
- pub const USRQUOTA : QuotaType = 0 ;
35
- pub const GRPQUOTA : QuotaType = 1 ;
36
-
37
- pub type QuotaFmt = c_int ;
38
-
39
- pub const QFMT_VFS_OLD : QuotaFmt = 1 ;
40
- pub const QFMT_VFS_V0 : QuotaFmt = 2 ;
41
- pub const QFMT_VFS_V1 : QuotaFmt = 4 ;
42
-
43
- bitflags ! (
44
- #[ derive( Default ) ]
45
- flags QuotaValidFlags : u32 {
46
- const QIF_BLIMITS = 1 ,
47
- const QIF_SPACE = 2 ,
48
- const QIF_ILIMITS = 4 ,
49
- const QIF_INODES = 8 ,
50
- const QIF_BTIME = 16 ,
51
- const QIF_ITIME = 32 ,
52
- const QIF_LIMITS = QIF_BLIMITS . bits | QIF_ILIMITS . bits,
53
- const QIF_USAGE = QIF_SPACE . bits | QIF_INODES . bits,
54
- const QIF_TIMES = QIF_BTIME . bits | QIF_ITIME . bits,
55
- const QIF_ALL = QIF_LIMITS . bits | QIF_USAGE . bits | QIF_TIMES . bits
56
- }
57
- ) ;
58
-
59
- #[ repr( C ) ]
60
- #[ derive( Default , Debug , Copy , Clone ) ]
61
- pub struct Dqblk {
62
- pub bhardlimit : u64 ,
63
- pub bsoftlimit : u64 ,
64
- pub curspace : u64 ,
65
- pub ihardlimit : u64 ,
66
- pub isoftlimit : u64 ,
67
- pub curinodes : u64 ,
68
- pub btime : u64 ,
69
- pub itime : u64 ,
70
- pub valid : QuotaValidFlags ,
71
- }
11
+ use libc:: c_int;
12
+
13
+ pub struct QuotaCmd ( pub QuotaSubCmd , pub QuotaType ) ;
14
+ pub type QuotaSubCmd = c_int ;
15
+
16
+ impl QuotaCmd {
17
+ pub fn as_int ( & self ) -> c_int {
18
+ ( ( self . 0 << 8 ) | ( self . 1 & 0x00ff ) ) as c_int
19
+ }
20
+ }
21
+
22
+ // linux quota version >= 2
23
+ pub const Q_SYNC : QuotaSubCmd = 0x800001 ;
24
+ pub const Q_QUOTAON : QuotaSubCmd = 0x800002 ;
25
+ pub const Q_QUOTAOFF : QuotaSubCmd = 0x800003 ;
26
+ pub const Q_GETFMT : QuotaSubCmd = 0x800004 ;
27
+ pub const Q_GETINFO : QuotaSubCmd = 0x800005 ;
28
+ pub const Q_SETINFO : QuotaSubCmd = 0x800006 ;
29
+ pub const Q_GETQUOTA : QuotaSubCmd = 0x800007 ;
30
+ pub const Q_SETQUOTA : QuotaSubCmd = 0x800008 ;
31
+
32
+ pub type QuotaType = c_int ;
33
+
34
+ pub const USRQUOTA : QuotaType = 0 ;
35
+ pub const GRPQUOTA : QuotaType = 1 ;
36
+
37
+ pub type QuotaFmt = c_int ;
38
+
39
+ pub const QFMT_VFS_OLD : QuotaFmt = 1 ;
40
+ pub const QFMT_VFS_V0 : QuotaFmt = 2 ;
41
+ pub const QFMT_VFS_V1 : QuotaFmt = 4 ;
42
+
43
+ bitflags ! (
44
+ #[ derive( Default ) ]
45
+ flags QuotaValidFlags : u32 {
46
+ const QIF_BLIMITS = 1 ,
47
+ const QIF_SPACE = 2 ,
48
+ const QIF_ILIMITS = 4 ,
49
+ const QIF_INODES = 8 ,
50
+ const QIF_BTIME = 16 ,
51
+ const QIF_ITIME = 32 ,
52
+ const QIF_LIMITS = QIF_BLIMITS . bits | QIF_ILIMITS . bits,
53
+ const QIF_USAGE = QIF_SPACE . bits | QIF_INODES . bits,
54
+ const QIF_TIMES = QIF_BTIME . bits | QIF_ITIME . bits,
55
+ const QIF_ALL = QIF_LIMITS . bits | QIF_USAGE . bits | QIF_TIMES . bits
56
+ }
57
+ ) ;
58
+
59
+ #[ repr( C ) ]
60
+ #[ derive( Default , Debug , Copy , Clone ) ]
61
+ pub struct Dqblk {
62
+ pub bhardlimit : u64 ,
63
+ pub bsoftlimit : u64 ,
64
+ pub curspace : u64 ,
65
+ pub ihardlimit : u64 ,
66
+ pub isoftlimit : u64 ,
67
+ pub curinodes : u64 ,
68
+ pub btime : u64 ,
69
+ pub itime : u64 ,
70
+ pub valid : QuotaValidFlags ,
71
+ }
72
72
}
73
73
74
74
mod ffi {
75
- use libc:: { c_int, c_char} ;
75
+ use libc:: { c_int, c_char} ;
76
76
77
- extern {
78
- pub fn quotactl ( cmd : c_int , special : * const c_char , id : c_int , data : * mut c_char ) -> c_int ;
79
- }
77
+ extern {
78
+ pub fn quotactl ( cmd : c_int , special : * const c_char , id : c_int , data : * mut c_char ) -> c_int ;
79
+ }
80
80
}
81
81
82
82
use std:: ptr;
83
83
84
84
fn quotactl < P : ?Sized + NixPath > ( cmd : quota:: QuotaCmd , special : Option < & P > , id : c_int , addr : * mut c_char ) -> Result < ( ) > {
85
- unsafe {
86
- Errno :: clear ( ) ;
87
- let res = try!(
88
- match special {
89
- Some ( dev) => dev. with_nix_path ( |path| ffi:: quotactl ( cmd. as_int ( ) , path. as_ptr ( ) , id, addr) ) ,
90
- None => Ok ( ffi:: quotactl ( cmd. as_int ( ) , ptr:: null ( ) , id, addr) ) ,
91
- }
92
- ) ;
93
- from_ffi ( res)
94
- }
85
+ unsafe {
86
+ Errno :: clear ( ) ;
87
+ let res = try!(
88
+ match special {
89
+ Some ( dev) => dev. with_nix_path ( |path| ffi:: quotactl ( cmd. as_int ( ) , path. as_ptr ( ) , id, addr) ) ,
90
+ None => Ok ( ffi:: quotactl ( cmd. as_int ( ) , ptr:: null ( ) , id, addr) ) ,
91
+ }
92
+ ) ;
93
+ from_ffi ( res)
94
+ }
95
95
}
96
96
97
97
pub fn quotactl_on < P : ?Sized + NixPath > ( which : quota:: QuotaType , special : & P , format : quota:: QuotaFmt , quota_file : & P ) -> Result < ( ) > {
98
- try!( quota_file. with_nix_path ( |path| {
99
- let mut path_copy = path. to_bytes_with_nul ( ) . to_owned ( ) ;
100
- let p: * mut c_char = path_copy. as_mut_ptr ( ) as * mut c_char ;
101
- quotactl ( quota:: QuotaCmd ( quota:: Q_QUOTAON , which) , Some ( special) , format as c_int , p)
102
- } ) )
98
+ try!( quota_file. with_nix_path ( |path| {
99
+ let mut path_copy = path. to_bytes_with_nul ( ) . to_owned ( ) ;
100
+ let p: * mut c_char = path_copy. as_mut_ptr ( ) as * mut c_char ;
101
+ quotactl ( quota:: QuotaCmd ( quota:: Q_QUOTAON , which) , Some ( special) , format as c_int , p)
102
+ } ) )
103
103
}
104
104
105
105
pub fn quotactl_off < P : ?Sized + NixPath > ( which : quota:: QuotaType , special : & P ) -> Result < ( ) > {
106
- quotactl ( quota:: QuotaCmd ( quota:: Q_QUOTAOFF , which) , Some ( special) , 0 , ptr:: null_mut ( ) )
106
+ quotactl ( quota:: QuotaCmd ( quota:: Q_QUOTAOFF , which) , Some ( special) , 0 , ptr:: null_mut ( ) )
107
107
}
108
108
109
109
pub fn quotactl_sync < P : ?Sized + NixPath > ( which : quota:: QuotaType , special : Option < & P > ) -> Result < ( ) > {
110
- quotactl ( quota:: QuotaCmd ( quota:: Q_SYNC , which) , special, 0 , ptr:: null_mut ( ) )
110
+ quotactl ( quota:: QuotaCmd ( quota:: Q_SYNC , which) , special, 0 , ptr:: null_mut ( ) )
111
111
}
112
112
113
113
pub fn quotactl_get < P : ?Sized + NixPath > ( which : quota:: QuotaType , special : & P , id : c_int , dqblk : & mut quota:: Dqblk ) -> Result < ( ) > {
114
- use std:: mem;
115
- unsafe {
116
- quotactl ( quota:: QuotaCmd ( quota:: Q_GETQUOTA , which) , Some ( special) , id, mem:: transmute ( dqblk) )
117
- }
114
+ use std:: mem;
115
+ unsafe {
116
+ quotactl ( quota:: QuotaCmd ( quota:: Q_GETQUOTA , which) , Some ( special) , id, mem:: transmute ( dqblk) )
117
+ }
118
118
}
119
119
120
120
pub fn quotactl_set < P : ?Sized + NixPath > ( which : quota:: QuotaType , special : & P , id : c_int , dqblk : & quota:: Dqblk ) -> Result < ( ) > {
121
- use std:: mem;
122
- let mut dqblk_copy = * dqblk;
123
- unsafe {
124
- quotactl ( quota:: QuotaCmd ( quota:: Q_SETQUOTA , which) , Some ( special) , id, mem:: transmute ( & mut dqblk_copy) )
125
- }
121
+ use std:: mem;
122
+ let mut dqblk_copy = * dqblk;
123
+ unsafe {
124
+ quotactl ( quota:: QuotaCmd ( quota:: Q_SETQUOTA , which) , Some ( special) , id, mem:: transmute ( & mut dqblk_copy) )
125
+ }
126
126
}
0 commit comments