| 1 | #!/usr/bin/perl -w | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package Linux::Mounts; | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | require Exporter; | |||||||||||||||||||||||||||
| 9 | 1 | require DynaLoader; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | our @ISA = qw(Exporter DynaLoader); | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | our $VERSION = 0.2; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 16 | 0 | my($proto, $file) = shift; | |||||||||||||||||||||||||||
| 17 | 0 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||
| 18 | 0 | my $self = { }; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | $file ||= '/proc/mounts'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$file ||= "/proc/mounts"
MC/DC0%0/1
$file ||= "/proc/mounts"
$file
Truth table0%0/2
A
A= $file
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | if (-e $file || -f $file) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e $file or -f $file
MC/DC0%0/2
-e $file or -f $file
-e $file
-f $file
Truth table0%0/3
A or B
A= -e $fileB= -f $file
| |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | if (open (MOUNTS, $file)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 0 | $self->{_private}->{num_mounts} = 0; | |||||||||||||||||||||||||||
| 25 | 0 | ▶ | while (<MOUNTS>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 0 | chomp; | |||||||||||||||||||||||||||
| 27 | 0 | my $cpt = $self->{_private}->{num_mounts}; | |||||||||||||||||||||||||||
| 28 | 0 | push(@{ $self->{_mountinfo}->[$cpt] }, split(/\s/)); | |||||||||||||||||||||||||||
| 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 | 0 | ▶ | sub num_mounts { | ||||||||||||||||||||||||||
|
Subroutine
num_mounts: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 41 | 0 | my($self) = @_; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | return $self->{_private}->{num_mounts}; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub list_mounts { | ||||||||||||||||||||||||||
|
Subroutine
list_mounts: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 47 | 0 | my($self) = @_; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | return $self->{_mountinfo}; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub show_mount { | ||||||||||||||||||||||||||
|
Subroutine
show_mount: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 53 | 0 | my($self) = @_; | |||||||||||||||||||||||||||
| 54 | 0 | my(@lst_f); | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | for (my $i = 0; $i < $self->{_private}->{num_mounts}; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | for (my $j = 0; $j < $#{ $self->{_mountinfo} }; $j++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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 | ▶ | sub stat_mount {} | ||||||||||||||||||||||||||
|
Subroutine
stat_mount: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 1 | 1; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | __END__ | ||||||||||||||||||||||||||||