blib/lib/StorageDisplay/Data/FS.pm

filter: Statementstmt 88.2% 271 / 307 Branchbran 64.0% 32 / 50 Conditioncond 66.6% 10 / 15 MC/DCmcdc 50.0% 4 / 8 Subroutinesub 95.6% 44 / 46 Podpod 0.0% 0 / 16 totaltotal 81.6% 361 / 442 CC 38 SCAR 17.3
CC
38
Cov
84%
BUILD
16.2
__ANON__
12.1
__ANON__
12.0
CRAP 5.7
« blib/lib/StorageDisplay/Collect.pm ↑ Summary blib/lib/StorageDisplay/Role.pm »
1 #
2 # This file is part of StorageDisplay
3 #
4 # This software is copyright (c) 2014-2023 by Vincent Danjean.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 package StorageDisplay::Data::FS;
13 # ABSTRACT: Handle filesystem data for StorageDisplay
14  
15 9 our $VERSION = '2.06'; # VERSION
16  
17 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 9 extends 'StorageDisplay::Data::Elem';
20  
21 9 with (
22 'StorageDisplay::Role::Style::IsSubGraph',
23 'StorageDisplay::Role::Style::Grey',
24 );
25  
26 has '_swaps' => (
27 traits => [ 'Array' ],
28 is => 'ro',
29 isa => 'ArrayRef[StorageDisplay::Data::FS::SWAP::Elem]',
30 required => 1,
31 7 ▶ default => sub { return []; },
Subroutine __ANON__: called CC=1 SCAR=0.0
32 9 handles => {
33 '_add_swap' => 'push',
34 'all_swap' => 'elements',
35 'nb_swap' => 'count',
36 }
37 );
38  
39 7 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
40 7 my $orig = shift;
41 7 my $class = shift;
42 7 my $st = shift;
43  
44 7 $st->log('Creating FS');
45 7 ▶ my $info = $st->get_info('fs')//{};
Condition50%1/2
$st->get_info("fs") // {}
l!l
70
MC/DC0%0/1
$st->get_info("fs") // {}
$st->get_info("fs")
Truth table50%1/2
A
A= $st->get_info("fs")
Aresult
11
00
46  
47 7 return $class->$orig(
48 'ignore_name' => 1,
49 'consume' => [],
50 'st' => $st,
51 @_
52 );
53 9 };
54  
55 261 ▶sub keep {
Subroutine keep: called CC=1 SCAR=0.0
Pod undocumented
56 261 my $self = shift;
57 261 my $fs = shift;
58  
59 261 return $fs->useblock;
60 }
61  
62 7 ▶sub BUILD {
Subroutine BUILD: called CC=10 SCAR=27.8
Pod undocumented
63 7 my $self=shift;
64 7 my $args=shift;
65  
66 7 my $st = $args->{'st'};
67 # in case FS hierachy is not initialized
68 # and 'parent' not present (old versions of findmnt)
69 7 my $rootid = $st->fs_mountpoint_id('/');
70 7 ▶ my $allfs = $st->get_info('fs')//{};
Condition50%1/2
$st->get_info("fs") // {}
l!l
70
MC/DC0%0/1
$st->get_info("fs") // {}
$st->get_info("fs")
Truth table50%1/2
A
A= $st->get_info("fs")
Aresult
11
00
71  
72 7 foreach my $mp (sort keys %{$allfs->{swap}}) {
73 5 my $fs = $allfs->{swap}->{$mp};
74 5 ▶ if ($fs->{'fstype'} eq 'partition') {
Branch: 2 branches
BranchTrueFalseTotal
if ($fs->{'fstype'} eq 'partition') { } 5 0 5
elsif ($fs->{'fstype'} eq 'file') { } 0 0 0
75 $self->_add_swap(
76 $self->newElem('FS::SWAP::Partition',
77 5 $fs->{filesystem}, $st, $fs),
78 );
79 } elsif ($fs->{'fstype'} eq 'file') {
80 $self->_add_swap(
81 $self->newElem('FS::SWAP::File',
82 0 $fs->{filesystem}, $st, $fs),
83 );
84 } else {
85 0 $self->error("Unknown swap type ".$fs->{'fstype'}." for ".$fs->{filesystem});
86 }
87 }
88 7 ▶ if ($self->nb_swap == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->nb_swap == 1) { } 5 2 7
89 5 my $s = ($self->all_swap)[0];
90 5 $s->onlyoneswap;
91 5 $self->addChild($s);
92 } else {
93 2 $self->newChild('FS::SWAP', $st, [$self->all_swap()]);
94 }
95 #foreach my $mp (sort keys %{$allfs->{df}}) {
96 # my $fs = $allfs->{df}->{$mp};
97 # $self->newChild('FS::FS', $fs->{filesystem}, $st, $fs);
98 #}
99 7 my $fullfs = $allfs->{flatfull};
100 7 my $flat=0;
101 7 ▶ if ($flat) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flat) { } 0 7 7
102 0 foreach my $id (keys %{$fullfs}) {
103 0 my $fs = $fullfs->{$id};
104 0 my $fs_elem = $self->newElem('FS::MP::FS', $st, $fs);
105 0 ▶ if ($self->keep($fs_elem)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->keep($fs_elem)) 0 0 0
106 0 $self->addChild($fs_elem);
107 }
108 }
109 } else {
110 7 ▶ while ($fullfs->{$rootid}->{parent} != 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fullfs->{$rootid}{"parent"} != 1) 0 7 7
111 0 $rootid = $fullfs->{$rootid}->{parent};
112 }
113 #my $
114 7 $self->addChild($self->createFS($st, $fullfs, $rootid));
115 }
116 }
117  
118 272 ▶sub createFS {
Subroutine createFS: called CC=7 SCAR=19.5
Pod undocumented
119 272 my $self = shift;
120 272 my $st = shift;
121 272 my $fullfs = shift;
122 272 my $id = shift;
123  
124 272 my $fs = $fullfs->{$id};
125 272 my $fs_elem = $self->newElem('FS::MP::FS', $st, $fs);
126 272 ▶ if (! exists($fs->{children})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $fs->{"children"}) 210 62 272
127 210 ▶ if ($self->keep($fs_elem)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->keep($fs_elem)) 27 183 210
128 27 return $fs_elem;
129 }
130 183 return;
131 }
132 62 ▶ if (exists($fs->{children})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $fs->{"children"}) 62 0 62
133 my @fs_children = map
134 {
135 265 my $fs = $self->createFS($st, $fullfs, $_);
136 265 ▶ defined($fs) ? $fs : ()
Branch: 1 branch
BranchTrueFalseTotal
defined $fs ? : 32 233 265
137 }
138 62 @{$fs->{children}};
139  
140 62 ▶ if (scalar(@fs_children) == 0 && ! $self->keep($fs_elem)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @fs_children == 0 and not $self->keep($fs_elem)) 50 12 62
Condition100%3/3
scalar @fs_children == 0 and not $self->keep($fs_elem)
!ll&&!rl&&r
11150
MC/DC100%2/2
scalar @fs_children == 0 and not $self->keep($fs_elem)
scalar @fs_children == 0 not $self->keep($fs_elem)
Truth table100%3/3
A and not(B)
A= scalar @fs_children == 0B= not $self->keep($fs_elem)
ABresult
0X0
100
111
141 50 return;
142 }
143 12 return $self->newElem('FS::MP',
144 'st' => $st,
145 'fs' => $fs,
146 'fs_elem' => $fs_elem,
147 'fs_children' => \@fs_children);
148 }
149 }
150  
151 14 ▶sub dotLabel {
Subroutine dotLabel: called CC=1 SCAR=0.0
Pod undocumented
152 14 my $self = shift;
153 14 return "Mounted FS and swap";
154 }
155  
156 9 1;
157  
158 ##################################################################
159 package StorageDisplay::Data::FS::MP::FS;
160 # Basic FS info
161  
162 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
163 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
164 9 extends 'StorageDisplay::Data::Elem';
165  
166 9 with (
167 'StorageDisplay::Role::HasBlock',
168 'StorageDisplay::Role::Style::WithUsed',
169 );
170  
171 9 has 'mountpoint' => (
172 is => 'ro',
173 isa => 'Str',
174 required => 1,
175 );
176  
177 9 has 'fstype' => (
178 is => 'ro',
179 isa => 'Str',
180 required => 1,
181 );
182  
183 9 has 'sourcenames' => (
184 is => 'ro',
185 isa => 'Str',
186 required => 1,
187 );
188  
189 9 has 'special' => (
190 is => 'ro',
191 isa => 'Bool',
192 required => 1,
193 default => 0,
194 );
195  
196 9 has 'useblock' => (
197 is => 'ro',
198 isa => 'Bool',
199 required => 1,
200 default => 0,
201 );
202  
203 9 has 'fsroot' => (
204 is => 'ro',
205 isa => 'Str',
206 required => 1,
207 );
208  
209 9 has 'parentfsid' => (
210 is => 'ro',
211 isa => 'Num',
212 required => 1,
213 );
214  
215 9 has 'sd' => (
216 is => 'ro',
217 isa => 'StorageDisplay',
218 required => 1,
219 );
220  
221 272 ▶around 'BUILDARGS' => sub {
Subroutine __ANON__: called CC=12 SCAR=24.9
222 272 my $orig = shift;
223 272 my $class = shift;
224 272 my $st = shift;
225 272 my $fs = shift;
226  
227 272 my @consume = ();
228 272 my $has_sources = exists($fs->{'sources'});
229 272 my @sources;
230 272 ▶ if ($has_sources) {
Branch: 1 branch
BranchTrueFalseTotal
if ($has_sources) { } 43 229 272
231 43 @sources = @{$fs->{'sources'}};
232 } else {
233 229 @sources = ($fs->{'source'});
234 }
235 272 my @sourcenames;
236 272 ▶ if (! defined($fs->{'fsroot'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fs->{"fsroot"}) 0 272 272
237 9 ▶ use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
238 9 ▶ use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
239 0 print STDERR Dumper($fs), "\n";
240 0 confess "coucou\n";
241 }
242 272 my $use_block = 0;
243 272 my $special = 0;
244 272 for my $source (@sources) {
245 272 ▶ if (! $has_sources # old software, no 'sources' entry
Branch: 1 branch
BranchTrueFalseTotal
if (not $has_sources and $fs->{"fsroot"} ne "/" and $source =~ /^(.*)\[$fs->{"fsroot"}\]$/) 2 270 272
Condition83%5/6
not $has_sources and $fs->{"fsroot"} ne "/" and $source =~ /^(.*)\[$fs->{"fsroot"}\]$/
!ll&&!rl&&r
27002
not $has_sources and $fs->{"fsroot"} ne "/"
!ll&&!rl&&r
432272
MC/DC66%2/3
not $has_sources and $fs->{"fsroot"} ne "/" and $source =~ /^(.*)\[$fs->{"fsroot"}\]$/
not $has_sources $fs->{"fsroot"} ne "/" $source =~ /^(.*)\[$fs->{"fsroot"}\]$/
Truth table75%3/4
not(A) and B and C
A= not $has_sourcesB= $fs->{"fsroot"} ne "/"C= $source =~ /^(.*)\[$fs->{"fsroot"}\]$/
ABCresult
0XX0
10X0
1100
1111
246 && $fs->{'fsroot'} ne '/'
247 && $source =~ m,^(.*)\[$fs->{'fsroot'}\]$,) {
248 2 $source = $1; # only keep relevant part of 'source' entry
249 }
250 272 my $block;
251 272 ▶ if ($source =~ m,^/dev/,) {
Branch: 2 branches
BranchTrueFalseTotal
if ($source =~ m[^/dev/]) { } 39 233 272
elsif ($source =~ m[^/]) { } 19 214 233
252 39 $block = $st->block($source);
253 39 push @sourcenames, 'Device: '.$block->dname;
254 39 $use_block=1;
255 } elsif ($source =~ m,^/,) {
256 # TODO : wrong if $target is not a mountpoint
257 19 $block = $st->block($source);
258 19 push @sourcenames, 'Source: '.$source;
259 #$block = $st->block($st->fs_mountpoint_blockname($source));
260 } else {
261 214 push @sourcenames, 'Source: '.$source;
262 214 $block = $st->block($source);
263 214 $special = 1;
264 }
265 272 push @consume, $block;
266 }
267 272 ▶ if ($fs->{fsroot} ne '/') {
Branch: 1 branch
BranchTrueFalseTotal
if ($fs->{"fsroot"} ne "/") 3 269 272
268 3 push @sourcenames, "Subdir: ".$fs->{fsroot};
269 }
270  
271 272 $st->log({level=>1}, $fs->{target});
272  
273 272 my $name = $st->fs_mountpoint_blockname_by_id($fs->{id}, $fs->{target});
274 272 ▶ if (not exists($fs->{free})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $fs->{"free"}) 272 0 272
275 272 $fs->{free} = $fs->{avail};
276 }
277 272 ▶ if (exists($fs->{label})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $fs->{"label"}) 272 0 272
278 272 delete $fs->{label};
279 }
280  
281 #if ($fs->{parent} != 1) {
282 # push @consume, $st->block($st->fs_mountpoint_blockname_by_id($fs->{parent}));
283 #}
284 272 my $block = $st->block($name);
285 return $class->$orig(
286 'name' => $name,
287 'consume' => \@consume,
288 'provide' => $block,
289 'sd' => $st,
290 'block' => $block,
291 'free' => $fs->{free},
292 'used' => $fs->{used},
293 'size' => $fs->{size},
294 'special' => $special,
295 'useblock' => $use_block,
296 'sourcenames' => join("\n", @sourcenames),
297 'fsroot' => $fs->{fsroot},
298 'fstype' => $fs->{fstype},
299 'mountpoint' => $fs->{target},
300 'parentfsid' => $fs->{parent},
301 #%{$fs},
302 @_
303 272 );
304 9 };
305  
306 272 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
307 272 my $self=shift;
308 272 my $args=shift;
309 272 $self->provideBlock($args->{provide});
310 }
311  
312 78 ▶sub dotLabel {
Subroutine dotLabel: called CC=3 SCAR=16.0
Pod undocumented
313 78 my $self = shift;
314 #if ($self->size == 0 && $self->special) {
315 78 ▶ if ($self->sourcenames eq 'Source: '.$self->{fstype}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->sourcenames eq 'Source: ' . $self->{"fstype"}) 0 78 78
316 0 ▶ if ($self->size == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->size == 0) { } 0 0 0
317 0 return ($self->mountpoint.' ('.$self->fstype.')');
318 } else {
319 return (
320 0 $self->mountpoint,
321 $self->fstype,
322 );
323 }
324 }
325 return (
326 78 $self->mountpoint,
327 $self->sourcenames,
328 $self->fstype,
329 );
330 }
331  
332 78 ▶around 'sizeLabel' => sub {
Subroutine __ANON__: called CC=2 SCAR=7.4
333 78 my $orig = shift;
334 78 my $self = shift;
335  
336 78 ▶ if ($self->size == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->size == 0) 0 78 78
337 0 return;
338 }
339 78 return $self->$orig(@_);
340 9 };
341  
342 39 ▶around dotLinks => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
343 39 my $orig = shift;
344 39 my $self = shift;
345  
346 39 my @links = $self->$orig(@_);
347 39 ▶ if ($self->parentfsid != 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->parentfsid != 1) 32 7 39
348 32 push @links, $self->sd->block($self->sd->fs_mountpoint_blockname_by_id($self->parentfsid))->elem->linkname.' -> '.$self->linkname.' [style=invis]';
349 }
350 #if ($fs->{parent} != 1) {
351 # push @consume, $st->block($st->fs_mountpoint_blockname_by_id($fs->{parent}));
352 #}
353 39 return @links;
354 9 };
355  
356 9 1;
357  
358 ##################################################################
359 package StorageDisplay::Data::FS::MP;
360 # Container for FS that has children FS
361  
362 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
363 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
364  
365 9 extends 'StorageDisplay::Data::Elem';
366  
367 9 with (
368 'StorageDisplay::Role::Style::IsSubGraph',
369 'StorageDisplay::Role::Style::Grey',
370 #'StorageDisplay::Role::Style::SubInternal',
371 );
372  
373 12 ▶around 'BUILDARGS' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
374 12 my $orig = shift;
375 12 my $class = shift;
376 #my $args = shift;
377 #for my $i (@_) {
378 # print STDERR "args=$i\n";
379 #}
380 12 my %args=(@_);
381 12 my $fs = $args{fs};
382  
383 return $class->$orig(
384 'name' => $fs->{id}.'@'.$fs->{target},
385 12 %args,
386 );
387 9 };
388  
389 12 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
390 12 my $self=shift;
391 12 my $args=shift;
392  
393 12 $self->addChild($args->{fs_elem});
394 12 $self->newChild('FS::MP::C', $args);
395 }
396  
397 24 ▶sub dotLabel {
Subroutine dotLabel: called CC=1 SCAR=0.0
Pod undocumented
398 24 return ();
399 }
400  
401 9 1;
402  
403 ##################################################################
404 package StorageDisplay::Data::FS::MP::C;
405 # Container for children FS
406  
407 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
408 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
409  
410 9 extends 'StorageDisplay::Data::Elem';
411  
412 9 with (
413 'StorageDisplay::Role::Style::IsSubGraph',
414 #'StorageDisplay::Role::Style::Grey',
415 'StorageDisplay::Role::Style::SubInternal',
416 #'StorageDisplay::Role::HasBlock',
417 #'StorageDisplay::Role::Style::WithUsed',
418 );
419  
420 12 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=6.9
Pod undocumented
421 12 my $self=shift;
422 12 my $args=shift;
423  
424 12 my $st = $args->{st};
425 12 my $SDFS = $args->{SDFS};
426 12 my $fullfs = $args->{fullfs};
427 12 my $fs = $args->{fs};
428  
429 12 for my $child (@{$args->{fs_children}}) {
430 32 $self->addChild($child);
431 }
432 }
433  
434 24 ▶sub dotLabel {
Subroutine dotLabel: called CC=1 SCAR=0.0
Pod undocumented
435 24 return ();
436 }
437  
438 9 1;
439  
440 ##################################################################
441 package StorageDisplay::Data::FS::SWAP;
442  
443 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
444 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
445 9 extends 'StorageDisplay::Data::Elem';
446  
447 9 with (
448 'StorageDisplay::Role::Style::IsSubGraph',
449 'StorageDisplay::Role::Style::WithUsed',
450 );
451  
452 9 has '_swaps' => (
453 traits => [ 'Array' ],
454 is => 'ro',
455 isa => 'ArrayRef[StorageDisplay::Data::FS::SWAP::Elem]',
456 required => 1,
457 handles => {
458 '_add_swap' => 'push',
459 'all_swap' => 'elements',
460 'nb_swap' => 'count',
461 }
462 );
463  
464 2 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=2 SCAR=7.2
465 2 my $orig = shift;
466 2 my $class = shift;
467 2 my $st = shift;
468 2 my $swaps = shift;
469  
470 2 $st->log({level=>1}, "SWAP");
471  
472 2 my $name = '@FS@SWAP';
473  
474 2 my ($size, $free, $used) = (0, 0, 0);
475 2 for my $s (@{$swaps}) {
476 0 $size += $s->size;
477 0 $free += $s->free;
478 0 $used += $s->used;
479 }
480  
481 2 return $class->$orig(
482 'name' => $name,
483 'st' => $st,
484 'free' => $free,
485 'size' => $size,
486 'used' => $used,
487 '_swaps' => $swaps,
488 @_
489 );
490 9 };
491  
492 2 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=7.2
Pod undocumented
493 2 my $self=shift;
494 2 my $args=shift;
495  
496 2 for my $s ($self->all_swap) {
497 0 $self->addChild($s);
498 }
499 }
500  
501 4 ▶sub dotLabel {
Subroutine dotLabel: called CC=1 SCAR=0.0
Pod undocumented
502 4 my $self = shift;
503 4 my $nb_swap = $self->nb_swap;
504 return (
505 4 "SWAP",
506 );
507 }
508  
509 0 ▶sub dotStyle2 {
Subroutine dotStyle2: not called CC=1 SCAR=6.9
Pod undocumented
510 0 my $orig = shift;
511 0 my $self = shift;
512  
513 return (
514 0 "style=filled;",
515 "color=lightgrey;",
516 "fillcolor=lightgrey;",
517 "node [style=filled,color=lightgrey,fillcolor=lightgrey,shape=rectangle];",
518 );
519 };
520  
521 4 ▶around 'dotStyle' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
522 4 my $orig = shift;
523 4 my $self = shift;
524  
525 my @config = (map {
526 4 my $val = $_;
527 16 $val =~ s/^color=.*;/color=white/;
528 16 $val =~ s/,color=[^,]*,/,color=white,/;
529 16 $val;
530 } ($self->$orig(@_)));
531 4 return @config;
532 9 };
533  
534 9 1;
535  
536 ##################################################################
537 package StorageDisplay::Data::FS::SWAP::Elem;
538  
539 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
540 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
541 9 extends 'StorageDisplay::Data::Elem';
542  
543 9 with (
544 'StorageDisplay::Role::HasBlock',
545 'StorageDisplay::Role::Style::WithUsed',
546 );
547  
548 9 has 'fstype' => (
549 is => 'ro',
550 isa => 'Str',
551 );
552  
553 9 has 'standalone' => (
554 is => 'ro',
555 isa => 'Bool',
556 default => 0,
557 required => 1,
558 writer => '_standalone'
559 );
560  
561 5 ▶sub onlyoneswap {
Subroutine onlyoneswap: called CC=1 SCAR=0.0
Pod undocumented
562 5 my $self = shift;
563 5 return $self->_standalone(1);
564 }
565  
566 5 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
567 5 my $self=shift;
568 5 my $args=shift;
569 5 $self->provideBlock($args->{'provide'});
570 }
571  
572 10 ▶sub dotLabel {
Subroutine dotLabel: called CC=2 SCAR=7.6
Pod undocumented
573 10 my $self = shift;
574 10 ▶ if ($self->standalone) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->standalone) 10 0 10
575 return (
576 10 'SWAP',
577 'Device: '.$self->block->dname,
578 );
579 }
580 return (
581 0 $self->block->dname,
582 );
583 }
584  
585 9 1;
586  
587 ##################################################################
588 package StorageDisplay::Data::FS::SWAP::Partition;
589  
590 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
591 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
592 9 extends 'StorageDisplay::Data::FS::SWAP::Elem';
593  
594 5 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
595 5 my $orig = shift;
596 5 my $class = shift;
597 5 my $dev = shift;
598 5 my $st = shift;
599 5 my $fs = shift;
600  
601 5 my $block = $st->block($dev);
602 5 $st->log({level=>1}, "SWAP@".$dev);
603  
604 5 my $name = $block->name;
605  
606 return $class->$orig(
607 'name' => $name,
608 'consume' => [$block],
609 'provide' => $st->block($st->fs_swap_blockname($name)),
610 'st' => $st,
611 'block' => $block,
612 5 %{$fs},
613 @_
614 );
615 9 };
616  
617 9 1;
618  
619 ##################################################################
620 package StorageDisplay::Data::FS::SWAP::File;
621  
622 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
623 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
624 9 extends 'StorageDisplay::Data::FS::SWAP::Elem';
625  
626 0 ▶around BUILDARGS => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
627 0 my $orig = shift;
628 0 my $class = shift;
629 0 my $file = shift;
630 0 my $st = shift;
631 0 my $fs = shift;
632  
633 0 my $block = $st->block($file);
634 0 $st->log({level=>1}, "SWAP@".$file);
635  
636 0 my $name = $file;
637 0 ▶ my $fblock = $st->block($st->fs_mountpoint_blockname($fs->{'file-mountpoint'} // '@none@'));
Condition0%0/2
$fs->{"file-mountpoint"} // "\@none\@"
l!l
00
MC/DC0%0/1
$fs->{"file-mountpoint"} // "\@none\@"
$fs->{"file-mountpoint"}
Truth table0%0/2
A
A= $fs->{"file-mountpoint"}
Aresult
11
00
638 0 ▶ if (defined($fs->{'file-size'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fs->{"file-size"}) 0 0 0
639 0 $fblock->size($fs->{'file-size'});
640 }
641  
642 return $class->$orig(
643 'name' => $name,
644 'consume' => [$fblock],
645 'provide' => $st->block($st->fs_swap_blockname($file)),
646 'st' => $st,
647 'block' => $block,
648 0 %{$fs},
649 @_
650 );
651 9 };
652  
653 9 1;
654  
655 __END__
« blib/lib/StorageDisplay/Collect.pm ↑ Summary blib/lib/StorageDisplay/Role.pm »