lib/File/Information/Filesystem.pm

filter: Statementstmt 48.7% 20 / 41 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 11 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 71.4% 5 / 7 Podpod n/a totaltotal 30.1% 25 / 83 CC 18 SCAR 55.5
CC
18
Cov
29%
_new
342.0
_default_device_search_paths
2.0
BEGIN
1.0
CRAP 256.8
« lib/File/Information/Deep.pm ↑ Summary lib/File/Information/VerifyResult.pm »
1 # Copyright (c) 2024-2026 Philipp Schafft <lion@cpan.org>
2  
3 # licensed under Artistic License 2.0 (see LICENSE file)
4  
5 # ABSTRACT: generic module for extracting information from filesystems
6  
7  
8 package File::Information::Filesystem;
9  
10 3 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 3 ▶use parent 'File::Information::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 3 our $VERSION = v0.17;
19  
20 3 my @_copy_properties = (
21 qw(dos_device dos_path),
22 qw(mountpoint fs_type),
23 qw(linux_mount_options linux_superblock_options),
24 );
25  
26 my %_properties = (
27 dev_disk_by_uuid => {rawtype => 'uuid'},
28 dev_disk_by_label => {},
29 dev_name => {},
30 dev_mapper_name => {},
31 3 (map {$_ => {}}
32 @_copy_properties,
33 ),
34 );
35  
36 3 my %_known_paths = (
37 '/dev/disk/by-uuid' => 'uuid',
38 '/dev/disk/by-label' => 'label',
39 '/dev/mapper' => 'mapper',
40 '/dev' => 'dev',
41 );
42  
43 0 ▶sub _new {
Subroutine _new: not called CC=18 SCAR=58.3
44 0 my ($pkg, %opts) = @_;
45 0 my $self = $pkg->SUPER::_new(%opts, properties => \%_properties);
46 0 ▶ my $pv = ($self->{properties_values} //= {})->{current} //= {};
Condition0%0/4
+($self->{"properties_values"} //= {})->{"current"} //= {}
l!l
00
$self->{"properties_values"} //= {}
l!l
00
MC/DC0%0/1
+($self->{"properties_values"} //= {})->{"current"} //= {}
+($self->{"properties_values"} //= {})->{"current"}
MC/DC0%0/1
$self->{"properties_values"} //= {}
$self->{"properties_values"}
Truth table0%0/2
A
A= +($self->{"properties_values"} //= {})->{"current"}
Aresult
11
00
Truth table0%0/2
A
A= $self->{"properties_values"}
Aresult
11
00
47  
48 0 ▶ croak 'No stat or dirstat is given' unless defined($self->{stat}) || defined($self->{dirstat});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"stat"} or defined $self->{"dirstat"} 0 0 0
Condition0%0/3
defined $self->{"stat"} or defined $self->{"dirstat"}
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $self->{"stat"} or defined $self->{"dirstat"}
defined $self->{"stat"} defined $self->{"dirstat"}
Truth table0%0/3
A or B
A= defined $self->{"stat"}B= defined $self->{"dirstat"}
ABresult
1X1
011
000
49 0 ▶ croak 'No paths is given' unless defined $self->{paths};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"paths"} 0 0 0
50  
51 0 foreach my $key (keys %{$self->{paths}}) {
52 0 ▶ my $known = $_known_paths{$key} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $known = $_known_paths{$key} or next 0 0 0
53 0 foreach my $value (@{$self->{paths}{$key}}) {
54 0 ▶ if ($known eq 'uuid') {
Branch: 4 branches
BranchTrueFalseTotal
if ($known eq 'uuid') { } 0 0 0
elsif ($known eq 'label') { } 0 0 0
elsif ($known eq 'dev') { } 0 0 0
elsif ($known eq 'mapper') { } 0 0 0
55 0 ▶ if ($value =~ __PACKAGE__->SUPER::RE_UUID) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ __PACKAGE__->SUPER::RE_UUID) 0 0 0
56 0 $pv->{dev_disk_by_uuid} = {raw => $value};
57 }
58 } elsif ($known eq 'label') {
59 0 $pv->{dev_disk_by_label} = {raw => $value};
60 } elsif ($known eq 'dev') {
61 0 ▶ $pv->{dev_name} //= {raw => $value};
Condition0%0/2
$pv->{"dev_name"} //= {"raw", $value}
l!l
00
MC/DC0%0/1
$pv->{"dev_name"} //= {"raw", $value}
$pv->{"dev_name"}
Truth table0%0/2
A
A= $pv->{"dev_name"}
Aresult
11
00
62 } elsif ($known eq 'mapper') {
63 0 ▶ $pv->{dev_mapper_name} //= {raw => $value};
Condition0%0/2
$pv->{"dev_mapper_name"} //= {"raw", $value}
l!l
00
MC/DC0%0/1
$pv->{"dev_mapper_name"} //= {"raw", $value}
$pv->{"dev_mapper_name"}
Truth table0%0/2
A
A= $pv->{"dev_mapper_name"}
Aresult
11
00
64 }
65 }
66 }
67  
68 # Simple keys:
69 0 foreach my $key (@_copy_properties) {
70 0 ▶ if (defined $self->{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{$key}) 0 0 0
71 0 $pv->{$key} = {raw => $self->{$key}};
72 }
73 }
74  
75 0 return $self;
76 }
77  
78 # ----------------
79  
80 0 ▶sub _default_device_search_paths {
Subroutine _default_device_search_paths: not called CC=1 SCAR=6.9
81 0 return state $defaults = [qw(/dev /dev/disk/by-id /dev/mapper), keys %_known_paths];
82 }
83  
84 3 1;
85  
86 __END__
« lib/File/Information/Deep.pm ↑ Summary lib/File/Information/VerifyResult.pm »