line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Quota::OO; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
116158
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
59
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
1034
|
use version;our $VERSION = qv('0.0.1'); |
|
1
|
|
|
|
|
2968
|
|
|
1
|
|
|
|
|
7
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
1884
|
use Class::Std; |
|
1
|
|
|
|
|
47551
|
|
|
1
|
|
|
|
|
8
|
|
9
|
1
|
|
|
1
|
|
1430
|
use Class::Std::Utils; |
|
1
|
|
|
|
|
1002
|
|
|
1
|
|
|
|
|
6
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
1381
|
use Quota; |
|
1
|
|
|
|
|
39453
|
|
|
1
|
|
|
|
|
25076
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
my %dev :ATTR('set' => 'dev', 'get' => 'dev', 'init_arg' => 'dev'); |
15
|
|
|
|
|
|
|
my %uid :ATTR('set' => 'uid', 'get' => 'uid', 'init_arg' => 'uid'); |
16
|
|
|
|
|
|
|
my %gid :ATTR('set' => 'gid', 'get' => 'gid', 'init_arg' => 'gid'); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my %rpc_host :ATTR('set' => 'rpc_host', 'get' => 'rpc_host', 'init_arg' => 'rpc_host'); |
19
|
|
|
|
|
|
|
my %rpc_path :ATTR('set' => 'rpc_path', 'get' => 'rpc_path', 'init_arg' => 'rpc_path'); |
20
|
|
|
|
|
|
|
my %rpc_port :ATTR('set' => 'rpc_port', 'get' => 'rpc_port', 'init_arg' => 'rpc_port'); |
21
|
|
|
|
|
|
|
my %rpc_uid :ATTR('set' => 'rpc_uid', 'get' => 'rpc_uid', 'init_arg' => 'rpc_uid'); |
22
|
|
|
|
|
|
|
my %rpc_gid :ATTR('set' => 'rpc_gid', 'get' => 'rpc_gid', 'init_arg' => 'rpc_gid'); |
23
|
|
|
|
|
|
|
my %rpc_use_tcp :ATTR('set' => 'rpc_use_tcp', 'get' => 'rpc_use_tcp', 'init_arg' => 'rpc_use_tcp'); |
24
|
|
|
|
|
|
|
my %rpc_timeout :ATTR('set' => 'rpc_timeout', 'get' => 'rpc_timeout', 'init_arg' => 'rpc_timeout'); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub BUILD { |
27
|
0
|
|
|
0
|
0
|
|
my ($self, $obj_id, $arg_ref) = @_; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$dev{$obj_id} = $self->set_dev( $arg_ref->{'dev'} ); |
30
|
0
|
|
|
|
|
|
$uid{$obj_id} = $self->set_uid( $arg_ref->{'uid'} ); |
31
|
0
|
|
|
|
|
|
$gid{$obj_id} = $self->set_gid( $arg_ref->{'gid'} ); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub set_dev { |
35
|
|
|
|
|
|
|
my ($self, $dev) = @_; |
36
|
|
|
|
|
|
|
$dev{ ident $self } = $self->getqcarg($dev); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub set_uid { |
40
|
|
|
|
|
|
|
my ($self, $uid) = @_; |
41
|
|
|
|
|
|
|
$uid{ ident $self } = $uid =~ m{^\d+$} ? $uid : $>; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub set_gid { |
45
|
|
|
|
|
|
|
my ($self, $gid) = @_; |
46
|
|
|
|
|
|
|
$gid{ ident $self } |
47
|
|
|
|
|
|
|
= $gid =~ m{^\d+$} ? $gid : ( getpwuid($uid{ ident $self }) )[3]; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
#### do rcp* ## |
51
|
|
|
|
|
|
|
#### Quota::rpcquery ## |
52
|
|
|
|
|
|
|
sub rpcquery { |
53
|
0
|
|
|
0
|
0
|
|
my ($self, $host, $path, $uid) = @_; |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
Quota::rpcquery( |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
56
|
|
|
|
|
|
|
defined $host ? $host : $rpc_host{ ident $self }, |
57
|
|
|
|
|
|
|
defined $path ? $path : $rpc_path{ ident $self }, |
58
|
|
|
|
|
|
|
defined $uid ? $uid : $rpc_uid{ ident $self }, |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
#### Quota::rpcpeer ## |
63
|
|
|
|
|
|
|
sub rpcpeer { |
64
|
0
|
|
|
0
|
0
|
|
my ($self, $port, $use_tcp, $timeout) = @_; |
65
|
|
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
|
Quota::rpcpeer( |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
67
|
|
|
|
|
|
|
defined $port ? $port : $rpc_port{ ident $self }, |
68
|
|
|
|
|
|
|
defined $use_tcp ? $use_tcp : $rpc_use_tcp{ ident $self }, |
69
|
|
|
|
|
|
|
defined $timeout ? $timeout : $rpc_timeout{ ident $self }, |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
#### Quota::rpcauth ## |
74
|
|
|
|
|
|
|
sub rpcauth { |
75
|
0
|
|
|
0
|
0
|
|
my ($self, $uid, $gid, $ host) = @_; |
76
|
|
|
|
|
|
|
|
77
|
0
|
0
|
|
|
|
|
Quota::rpcauth( |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
78
|
|
|
|
|
|
|
defined $uid ? $uid : $rpc_uid{ ident $self }, |
79
|
|
|
|
|
|
|
defined $gid ? $gid : $rpc_gid{ ident $self }, |
80
|
|
|
|
|
|
|
defined $host ? $host : $rpc_host{ ident $self }, |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub get_rpc_query { |
85
|
0
|
|
|
0
|
1
|
|
my ($self, $args_hr) = @_; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
$self->rpcpeer( |
88
|
|
|
|
|
|
|
$args_hr->{'rpc_port'}, |
89
|
|
|
|
|
|
|
$args_hr->{'rpc_use_tcp'}, |
90
|
|
|
|
|
|
|
$args_hr->{'rpc_timeout'}, |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
$self->rpcauth( |
94
|
|
|
|
|
|
|
$args_hr->{'rpc_uid'}, |
95
|
|
|
|
|
|
|
$args_hr->{'rpc_gid'}, |
96
|
|
|
|
|
|
|
$args_hr->{'rpc_host'}, |
97
|
|
|
|
|
|
|
); |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
my @rpc_results = $self->rcpquery( |
100
|
|
|
|
|
|
|
$args_hr->{'rpc_host'}, |
101
|
|
|
|
|
|
|
$args_hr->{'rpc_path'}, |
102
|
|
|
|
|
|
|
$args_hr->{'rpc_uid'}, |
103
|
|
|
|
|
|
|
); |
104
|
0
|
0
|
|
|
|
|
return wantarray ? @rpc_results : \@rpc_results; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub get_rpc_query_hash { |
109
|
0
|
|
|
0
|
1
|
|
my ($self, $args_hr) = @_; |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my $query_ar = $self->get_rpc_query( $args_hr ); |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
my $query_hr = { |
114
|
|
|
|
|
|
|
'block_current' => $query_ar->[0], |
115
|
|
|
|
|
|
|
'block_soft' => $query_ar->[1], |
116
|
|
|
|
|
|
|
'block_hard' => $query_ar->[2], |
117
|
|
|
|
|
|
|
'block_timelimit' => $query_ar->[3], |
118
|
|
|
|
|
|
|
'inode_current' => $query_ar->[4], |
119
|
|
|
|
|
|
|
'inode_soft' => $query_ar->[5], |
120
|
|
|
|
|
|
|
'inode_hard' => $query_ar->[6], |
121
|
|
|
|
|
|
|
'inode_timelimit' => $query_ar->[7], |
122
|
|
|
|
|
|
|
}; |
123
|
|
|
|
|
|
|
|
124
|
0
|
0
|
|
|
|
|
return wantarray ? %{ $query_hr } : $query_hr; |
|
0
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
#### Quota::query ## |
128
|
|
|
|
|
|
|
sub query { |
129
|
0
|
|
|
0
|
0
|
|
my($self, $dev, $id, $id_is_group) = @_; |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
my $original_dev = $dev{ ident $self }; |
132
|
0
|
|
|
|
|
|
$dev{ ident $self } = $self->getqcarg( $dev ); |
133
|
|
|
|
|
|
|
|
134
|
0
|
0
|
|
|
|
|
my @query = $id_is_group ? $self->get_gid_query($id) |
135
|
|
|
|
|
|
|
: $self->get_uid_query($id); |
136
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
$dev{ ident $self } = $original_dev; |
138
|
0
|
|
|
|
|
|
return @query; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub get_query { |
142
|
0
|
|
|
0
|
1
|
|
my($self, $id, $id_is_group) = @_; |
143
|
|
|
|
|
|
|
|
144
|
0
|
0
|
|
|
|
|
$id_is_group = 0 if !defined $id_is_group; |
145
|
|
|
|
|
|
|
|
146
|
0
|
0
|
|
|
|
|
if(!defined $id) { |
147
|
0
|
0
|
|
|
|
|
$id = $id_is_group ? $gid{ ident $self } |
148
|
|
|
|
|
|
|
: $uid{ ident $self }; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
0
|
0
|
|
|
|
|
return wantarray ? $self->query($dev{ ident $self }, $id, $id_is_group) |
152
|
|
|
|
|
|
|
: [$self->query($dev{ ident $self }, $id, $id_is_group)]; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub get_uid_query { |
156
|
0
|
|
|
0
|
1
|
|
my($self, $uid) = @_; |
157
|
0
|
|
|
|
|
|
return $self->get_query($uid, 0); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub get_gid_query { |
161
|
0
|
|
|
0
|
1
|
|
my($self, $gid) = @_; |
162
|
0
|
|
|
|
|
|
return $self->get_query($gid, 1); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub get_query_hash { |
166
|
0
|
|
|
0
|
1
|
|
my($self, $id, $id_is_group) = @_; |
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
my $query_ar = $self->get_query($id, $id_is_group); |
169
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
|
my $query_hr = { |
171
|
|
|
|
|
|
|
'block_current' => $query_ar->[0], |
172
|
|
|
|
|
|
|
'block_soft' => $query_ar->[1], |
173
|
|
|
|
|
|
|
'block_hard' => $query_ar->[2], |
174
|
|
|
|
|
|
|
'block_timelimit' => $query_ar->[3], |
175
|
|
|
|
|
|
|
'inode_current' => $query_ar->[4], |
176
|
|
|
|
|
|
|
'inode_soft' => $query_ar->[5], |
177
|
|
|
|
|
|
|
'inode_hard' => $query_ar->[6], |
178
|
|
|
|
|
|
|
'inode_timelimit' => $query_ar->[7], |
179
|
|
|
|
|
|
|
}; |
180
|
|
|
|
|
|
|
|
181
|
0
|
0
|
|
|
|
|
return wantarray ? %{ $query_hr } : $query_hr; |
|
0
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub get_uid_query_hash { |
185
|
0
|
|
|
0
|
1
|
|
my($self, $uid) = @_; |
186
|
0
|
|
|
|
|
|
return $self->get_query_hash($uid, 0); |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub get_gid_query_hash { |
190
|
0
|
|
|
0
|
1
|
|
my($self, $uid) = @_; |
191
|
0
|
|
|
|
|
|
return $self->get_query_hash($uid, 1); |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
#### Quota::setqlim ## |
195
|
|
|
|
|
|
|
sub setqlim { |
196
|
0
|
|
|
0
|
0
|
|
shift; |
197
|
0
|
|
|
|
|
|
Quota::setqlim(@_); |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub set_quota_limit { |
201
|
0
|
|
|
0
|
1
|
|
my($self, $args_hr) = @_; |
202
|
|
|
|
|
|
|
|
203
|
0
|
0
|
|
|
|
|
my $dev = !defined $args_hr->{'dev'} ? $dev{ ident $self } |
204
|
|
|
|
|
|
|
: $self->getqcarg( $args_hr->{'dev'} ); |
205
|
0
|
0
|
|
|
|
|
$args_hr->{'id'} = $uid{ ident $self } if !defined $args_hr->{'uid'}; |
206
|
0
|
|
|
|
|
|
$args_hr->{'block_soft'} = int( $args_hr->{'block_soft'} ); |
207
|
0
|
|
|
|
|
|
$args_hr->{'block_hard'} = int( $args_hr->{'block_hard'} ); |
208
|
0
|
|
|
|
|
|
$args_hr->{'inode_soft'} = int( $args_hr->{'inode_soft'} ); |
209
|
0
|
|
|
|
|
|
$args_hr->{'inode_hard'} = int( $args_hr->{'inaode_hard'} ); |
210
|
0
|
0
|
|
|
|
|
$args_hr->{'time_limit'} = 0 if !defined $args_hr->{'time_limit'}; |
211
|
0
|
0
|
|
|
|
|
$args_hr->{'id_is_gid'} = 0 if !defined $args_hr->{'id_is_gid'}; |
212
|
|
|
|
|
|
|
|
213
|
0
|
|
|
|
|
|
$self->setqlim( |
214
|
|
|
|
|
|
|
$dev, |
215
|
|
|
|
|
|
|
$args_hr->{'id'}, |
216
|
|
|
|
|
|
|
$args_hr->{'block_soft'}, |
217
|
|
|
|
|
|
|
$args_hr->{'block_hard'}, |
218
|
|
|
|
|
|
|
$args_hr->{'inode_soft'}, |
219
|
|
|
|
|
|
|
$args_hr->{'inode_hard'}, |
220
|
|
|
|
|
|
|
$args_hr->{'time_limit'}, |
221
|
|
|
|
|
|
|
$args_hr->{'id_is_gid'}, |
222
|
|
|
|
|
|
|
); |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
sub set_uid_quota_limit { |
226
|
0
|
|
|
0
|
1
|
|
my($self, $args_hr) = @_; |
227
|
0
|
|
|
|
|
|
$args_hr->{'id_is_gid'} = 0; |
228
|
0
|
|
|
|
|
|
$self->set_quota_limit($args_hr); |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
sub set_gid_quota_limit { |
232
|
0
|
|
|
0
|
1
|
|
my($self, $args_hr) = @_; |
233
|
0
|
|
|
|
|
|
$args_hr->{'id_is_gid'} = 1; |
234
|
0
|
|
|
|
|
|
$self->set_quota_limit($args_hr); |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
#### Quota::sync ## |
238
|
|
|
|
|
|
|
sub sync { |
239
|
0
|
|
|
0
|
1
|
|
my($self, $dev) = @_; |
240
|
0
|
|
0
|
|
|
|
Quots::sync( $self->getqcarg( $dev ) || $dev{ ident $self } ); |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
sub sync_all { |
244
|
0
|
|
|
0
|
1
|
|
Quota::sync(); |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
#### Quota::getqcarg ## |
248
|
|
|
|
|
|
|
sub getqcarg { |
249
|
0
|
|
|
0
|
0
|
|
shift; |
250
|
0
|
|
|
|
|
|
Quota::getqcarg(@_); |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
#### Quota::getdev ## |
254
|
|
|
|
|
|
|
sub getdev { |
255
|
0
|
|
|
0
|
0
|
|
shift; |
256
|
0
|
|
|
|
|
|
Quota::getdev(@_); |
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
#### Quota::strerr ## |
260
|
|
|
|
|
|
|
sub strerr { |
261
|
0
|
|
|
0
|
0
|
|
Quota::strerr(); |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
sub get_errstr { |
265
|
0
|
|
|
0
|
1
|
|
Quota::strerr(); |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
#### *mntent ## |
269
|
|
|
|
|
|
|
#### Quota::setmntent ## |
270
|
|
|
|
|
|
|
sub setmntent { |
271
|
0
|
|
|
0
|
0
|
|
Quota::setmntent(); |
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
#### Quota::getmntent ## |
275
|
|
|
|
|
|
|
sub getmntent { |
276
|
0
|
|
|
0
|
0
|
|
Quota::getmntent(); |
277
|
|
|
|
|
|
|
} |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
#### Quota::endmntent ## |
280
|
|
|
|
|
|
|
sub endmntent { |
281
|
0
|
|
|
0
|
0
|
|
Quota::endmntent(); |
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
sub get_mntent_hash { |
285
|
0
|
|
|
0
|
1
|
|
my($self) = @_; |
286
|
0
|
|
|
|
|
|
my $hr = {}; |
287
|
0
|
|
|
|
|
|
$self->setmntent(); |
288
|
0
|
|
|
|
|
|
while( my @ent = $self->getmntent() ){ |
289
|
0
|
|
|
|
|
|
$hr->{ $ent[0] } = { |
290
|
|
|
|
|
|
|
'path' => $ent[1], |
291
|
|
|
|
|
|
|
'type' => $ent[2], |
292
|
|
|
|
|
|
|
'opts' => $ent[3], |
293
|
|
|
|
|
|
|
}; |
294
|
|
|
|
|
|
|
} |
295
|
0
|
|
|
|
|
|
$self->endmntent(); |
296
|
|
|
|
|
|
|
|
297
|
0
|
0
|
|
|
|
|
return wantarray ? %{ $hr } : $hr; |
|
0
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
} |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
1; |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
__END__ |