| 1 | package Filesys::Type::Plugin::Unix; | ||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | |||||||||||||
| 4 | 1 | our $VERSION = 0.02; | |||||||||||
| 5 | 1 | our ($df,$mounted,$err); | |||||||||||
| 6 | |||||||||||||
| 7 | 1 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||
| 8 | 1 | my $pkg = shift; | |||||||||||
| 9 | |||||||||||||
| 10 | #Check we really are on a Unix type operating system | ||||||||||||
| 11 | 1 | ▶ | return undef unless -d '/etc'; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 12 | |||||||||||||
| 13 | 1 | bless {}, $pkg; | |||||||||||
| 14 | } | ||||||||||||
| 15 | |||||||||||||
| 16 | 5 | ▶ | sub fstype { | ||||||||||
|
Subroutine
fstype: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||
| 17 | 5 | my ($self,$path) = @_; | |||||||||||
| 18 | 5 | $err = ''; | |||||||||||
| 19 | |||||||||||||
| 20 | 5 | $df = `df $path 2>/dev/null`; | |||||||||||
| 21 | 5 | ▶ | $err = 'df command failed' unless $df; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 22 | 5 | $mounted = `mount 2>/dev/null`; # Does not need root | |||||||||||
| 23 | 5 | ▶ | $err = 'mount command failed' unless $df; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 24 | 5 | ▶ | return undef if $err; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 25 | |||||||||||||
| 26 | 3 | my ($mounted_fs) = $df =~ /\d\%\s(\S+)/; | |||||||||||
| 27 | 3 | ▶ | $err = 'df output did not parse' unless $mounted_fs; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 28 | 3 | ▶ | return undef if $err; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 29 | |||||||||||||
| 30 | 3 | my ($fstype) = $mounted =~ /on\s$mounted_fs\stype\s(\w+)/; | |||||||||||
| 31 | 3 | $fstype; | |||||||||||
| 32 | } | ||||||||||||
| 33 | |||||||||||||
| 34 | 1 | ▶ | sub diagnose { | ||||||||||
|
Subroutine
diagnose: called CC=3 SCAR=11.7
Pod
undocumented
| |||||||||||||
| 35 | 1 | ▶ | $df ||= 'undef'; | ||||||||||
|
Condition50%1/2
$Filesys::Type::Plugin::Unix::df ||= "undef"
MC/DC0%0/1
$Filesys::Type::Plugin::Unix::df ||= "undef"
$Filesys::Type::Plugin::Unix::df
Truth table50%1/2
A
A= $Filesys::Type::Plugin::Unix::df
| |||||||||||||
| 36 | 1 | ▶ | $mounted ||= 'undef'; | ||||||||||
|
Condition50%1/2
$Filesys::Type::Plugin::Unix::mounted ||= "undef"
MC/DC0%0/1
$Filesys::Type::Plugin::Unix::mounted ||= "undef"
$Filesys::Type::Plugin::Unix::mounted
Truth table50%1/2
A
A= $Filesys::Type::Plugin::Unix::mounted
| |||||||||||||
| 37 | 1 | <<END; | |||||||||||
| 38 | $err | ||||||||||||
| 39 | |||||||||||||
| 40 | df command returned: $df | ||||||||||||
| 41 | |||||||||||||
| 42 | mount command returned: $mounted | ||||||||||||
| 43 | |||||||||||||
| 44 | END | ||||||||||||
| 45 | } | ||||||||||||
| 46 | 1 | 1; | |||||||||||
| 47 | |||||||||||||