line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Linux::Mounts; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
23054
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
732
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter; |
9
|
|
|
|
|
|
|
require DynaLoader; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter DynaLoader); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = 0.2; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
0
|
|
|
0
|
0
|
|
my($proto, $file) = shift; |
17
|
0
|
|
0
|
|
|
|
my $class = ref($proto) || $proto; |
18
|
0
|
|
|
|
|
|
my $self = { }; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
0
|
|
|
|
$file ||= '/proc/mounts'; |
21
|
|
|
|
|
|
|
|
22
|
0
|
0
|
0
|
|
|
|
if (-e $file || -f $file) { |
23
|
0
|
0
|
|
|
|
|
if (open (MOUNTS, $file)) { |
24
|
0
|
|
|
|
|
|
$self->{_private}->{num_mounts} = 0; |
25
|
0
|
|
|
|
|
|
while () { |
26
|
0
|
|
|
|
|
|
chomp; |
27
|
0
|
|
|
|
|
|
my $cpt = $self->{_private}->{num_mounts}; |
28
|
0
|
|
|
|
|
|
push(@{ $self->{_mountinfo}->[$cpt] }, split(/\s/)); |
|
0
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$self->{_private}->{num_mounts}++; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
0
|
|
|
|
|
|
close(MOUNTS); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
bless $self, $class; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
return $self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub num_mounts { |
41
|
0
|
|
|
0
|
1
|
|
my($self) = @_; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
return $self->{_private}->{num_mounts}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub list_mounts { |
47
|
0
|
|
|
0
|
1
|
|
my($self) = @_; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return $self->{_mountinfo}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub show_mount { |
53
|
0
|
|
|
0
|
0
|
|
my($self) = @_; |
54
|
0
|
|
|
|
|
|
my(@lst_f); |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
for (my $i = 0; $i < $self->{_private}->{num_mounts}; $i++) { |
57
|
0
|
|
|
|
|
|
for (my $j = 0; $j < $#{ $self->{_mountinfo} }; $j++) { |
|
0
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
push(@lst_f, $self->{_mountinfo}->[$i][$j]); |
59
|
|
|
|
|
|
|
} |
60
|
0
|
|
|
|
|
|
write; |
61
|
0
|
|
|
|
|
|
undef(@lst_f); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
format STDOUT = |
65
|
|
|
|
|
|
|
@<<<<<<<<<<<@<<<<<<<<<<<<<<<<<@<<<<<<<<<<<@<<<<<<@<<@<<< |
66
|
|
|
|
|
|
|
$lst_f[0], $lst_f[1], $lst_f[2], $lst_f[3], $lst_f[4], $lst_f[5] |
67
|
|
|
|
|
|
|
. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
0
|
0
|
|
sub stat_mount {} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |