blib/lib/StorageDisplay/Data/Partition.pm

filter: Statementstmt 96.3% 286 / 297 Branchbran 84.0% 42 / 50 Conditioncond 69.2% 9 / 13 MC/DCmcdc 42.8% 3 / 7 Subroutinesub 95.0% 58 / 61 Podpod 0.0% 0 / 27 totaltotal 87.4% 398 / 455 CC 34 SCAR 10.0
CC
34
Cov
94%
BUILD
8.0
addPart
6.0
__ANON__
5.0
CRAP 2.7
« /usr/local/bin/perldoc ↑ Summary blib/lib/StorageDisplay/Data/LVM.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::Partition;
13 # ABSTRACT: Handle partition tables 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::HasBlock',
23 'StorageDisplay::Role::Style::Label::HTML::Table',
24 'StorageDisplay::Role::Style::WithSize',
25 );
26  
27 226 ▶sub disk {
Subroutine disk: called CC=1 SCAR=0.0
Pod undocumented
28 226 my $self = shift;
29 226 return $self->block(@_);
30 }
31  
32 9 has 'kind' => (
33 is => 'ro',
34 isa => 'Str',
35 required => 1,
36 );
37  
38 21 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
39 21 my $orig = shift;
40 21 my $class = shift;
41 21 my $block = shift;
42 21 my $st = shift;
43  
44 21 $st->log({level=>1}, 'Partition table on '.$block->dname);
45  
46 21 return $class->$orig(
47 'name' => $block->name,
48 'part_infos' => $st->get_info('partitions', $block->name),
49 'block' => $block,
50 'consume' => [$block],
51 @_
52 );
53 9 };
54  
55 has 'table' => (
56 is => 'ro',
57 isa => 'StorageDisplay::Data::Partition::Table',
58 required => 1,
59 21 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
60 21 my $self = shift;
61 21 return $self->newChild(
62 'Partition::Table',
63 'ignore_name' => 1,
64 'partition' => $self,
65 );
66 },
67 9 lazy => 1,
68 );
69  
70 42 ▶sub dotStyleNode {
Subroutine dotStyleNode: called CC=4 SCAR=13.9
Pod undocumented
71 42 my $self=shift;
72 42 my $t=shift;
73  
74 42 my $fc='';
75 my $it = $self->table->iterator(
76 recurse => 1,
77 236 ▶ filter => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
78 236 my $part = shift;
79 236 return ! $part->isa('StorageDisplay::Data::Partition::Table::Part::SubTable');
80 },
81 42 );
82 42 ▶ while (defined(my $part = $it->next)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $part = $it->next)) 234 42 276
83 234 my $state="free";
84 234 ▶ if (! $part->isa("StorageDisplay::Data::Partition::Table::Part::Free")) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($part->isa("StorageDisplay::Data::Partition::Table::Part::Free")) 134 100 234
85 134 $state = "busy";#$part->block->state;
86 }
87 234 my $color=$self->statecolor($state);
88 234 ▶ $fc .= ':' if $fc ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $fc ne "" 192 42 234
89 234 $fc .= "$color;".sprintf("%.6f", $part->size/$self->size);
90 }
91 return (
92 42 $self->_dotDefaultStyleNode($t, @_),
93 "// Style node",
94 "color=white;",
95 "fillcolor=lightgrey;",
96 'shape="rectangle";',
97 #'gradientangle="270";',
98 'style=striped;',
99 'fillcolor="'.$fc.'";',
100 );
101 }
102  
103 42 ▶sub dotStyleTable {
Subroutine dotStyleTable: called CC=1 SCAR=0.0
Pod undocumented
104 42 my $self=shift;
105  
106 42 return "BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\"";
107 }
108  
109 42 ▶sub dotLabel {
Subroutine dotLabel: called CC=3 SCAR=11.0
Pod undocumented
110 42 my $self = shift;
111 42 my @label = ($self->disk->dname);
112 42 ▶ if (defined($self->disk->blk_info('MODEL'))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->disk->blk_info("MODEL")) 40 2 42
113 40 push @label, 'Model: '.$self->disk->blk_info('MODEL');
114 }
115 42 ▶ if (defined($self->disk->blk_info('SERIAL'))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->disk->blk_info("SERIAL")) 40 2 42
116 40 push @label, 'Serial: '.$self->disk->blk_info('SERIAL');
117 }
118 42 push @label, 'Label: '.$self->kind;
119 42 return @label;
120 }
121  
122 42 ▶sub dotTable {
Subroutine dotTable: called CC=2 SCAR=7.0
Pod undocumented
123 42 my $self = shift;
124 42 ▶ my $t = shift // "\t";
Condition50%1/2
shift() // "\t"
l!l
420
MC/DC0%0/1
shift() // "\t"
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
125 42 my $it = shift;
126  
127 42 my @tablecontents = (
128 "<TR> <TD COLSPAN=\"2\">".$self->label."</TD> </TR>".
129 "<TR><TD >".$self->dotFormatedFullLabel($t, @_)."</TD>".
130 " <TD BGCOLOR=\"lightgrey\">",
131 $self->table->dotNode($t, @_),
132 "</TD> </TR>".
133 "<TR> <TD COLSPAN=\"2\"> </TD> </TR>");
134  
135 42 return @tablecontents;
136 }
137  
138 9 1;
139  
140 ##################
141 package StorageDisplay::Data::Partition::Table;
142  
143 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
144 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
145  
146 9 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
147  
148 9 extends 'StorageDisplay::Data::Elem';
149  
150 9 with (
151 'StorageDisplay::Role::Style::IsLabel',
152 'StorageDisplay::Role::Style::Label::HTML::Table',
153 );
154  
155 has 'disk' => (
156 is => 'ro',
157 isa => 'StorageDisplay::Block',
158 20 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
159 20 my $self = shift;
160 20 return $self->elem->disk;
161 },
162 9 lazy => 1,
163 required => 1,
164 );
165  
166 9 has 'partition' => (
167 is => 'ro',
168 isa => 'StorageDisplay::Data::Partition',
169 required => 1,
170 );
171  
172 68 ▶sub elem {
Subroutine elem: called CC=1 SCAR=0.0
Pod undocumented
173 68 my $self = shift;
174 68 return $self->partition(@_);
175 }
176  
177 118 ▶sub addPart {
Subroutine addPart: called CC=6 SCAR=18.0
Pod undocumented
178 118 my $self = shift;
179 118 my $part = shift;
180  
181 118 ▶ if ($part->isa('StorageDisplay::Data::Partition::Table::Part::SubTable')) {
Branch: 3 branches
BranchTrueFalseTotal
if ($part->isa('StorageDisplay::Data::Partition::Table::Part::SubTable')) { } 1 117 118
elsif ($part->isa('StorageDisplay::Data::Partition::Table::Part::Data')) { } 67 50 117
elsif ($part->isa('StorageDisplay::Data::Partition::Table::Part::Free')) { } 50 0 50
182 1 $part->block->state("special");
183 } elsif ($part->isa('StorageDisplay::Data::Partition::Table::Part::Data')) {
184 67 ▶ if ($part->label =~ /efi|grub/i || $part->flags =~ /boot/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($part->label =~ /efi|grub/i or $part->flags =~ /boot/i) 15 52 67
Condition100%3/3
$part->label =~ /efi|grub/i or $part->flags =~ /boot/i
l!l&&r!l&&!r
14152
MC/DC100%2/2
$part->label =~ /efi|grub/i or $part->flags =~ /boot/i
$part->label =~ /efi|grub/i $part->flags =~ /boot/i
Truth table100%3/3
A or B
A= $part->label =~ /efi|grub/iB= $part->flags =~ /boot/i
ABresult
1X1
011
000
185 15 $part->block->state("special");
186 }
187 } elsif ($part->isa('StorageDisplay::Data::Partition::Table::Part::Free')) {
188  
189 } else {
190 0 carp "W: unsupported part ".$part->name." (".$part.")\n";
191 }
192 118 return $self->addChild($part);
193 }
194  
195 42 ▶sub dotTable {
Subroutine dotTable: called CC=1 SCAR=0.0
Pod undocumented
196 42 my $self = shift;
197 42 return $self->partDotTable(@_);
198 }
199  
200 44 ▶sub partDotTable {
Subroutine partDotTable: called CC=2 SCAR=6.9
Pod undocumented
201 44 my $self = shift;
202 44 my $t = shift;
203 44 my $it = shift;
204  
205 44 my @text;
206 #print STDERR "dotTable in ".$self->name." (".$self.")\n";
207 44 ▶ while (defined(my $e = $it->next)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $e = $it->next)) 236 44 280
208 236 push @text, '<TR>',
209 $self->dotIndent($t, $e->dotNode($t, @_)),
210 '</TR>';
211 }
212 #use Data::Dumper;
213 #print STDERR "RES: ", Dumper(\@text);
214 44 return @text;
215 }
216  
217 9 1;
218  
219 ##################
220 package StorageDisplay::Data::Partition::Table::Part;
221  
222 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
223 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
224  
225 9 extends 'StorageDisplay::Data::Elem';
226  
227 9 with (
228 'StorageDisplay::Role::Style::Label::HTML',
229 'StorageDisplay::Role::Style::IsLabel',
230 'StorageDisplay::Role::Style::WithSize',
231 );
232  
233 9 has 'table' => (
234 is => 'ro',
235 isa => 'StorageDisplay::Data::Partition::Table',
236 required => 1,
237 );
238  
239 9 has 'start' => (
240 is => 'ro',
241 isa => 'Int',
242 required => 1,
243 );
244  
245 9 has 'label' => (
246 is => 'ro',
247 isa => 'Str',
248 required => 0,
249 );
250  
251 118 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
252 118 my $self = shift;
253  
254 #print STDERR "BUILD in ".__PACKAGE__."\n";
255 118 $self->table->addPart($self);
256 }
257  
258 0 ▶sub partStyle {
Subroutine partStyle: not called CC=1 SCAR=6.9
Pod undocumented
259 0 my $self = shift;
260  
261 0 return '';
262 }
263  
264 234 ▶sub dotNode {
Subroutine dotNode: called CC=1 SCAR=0.0
Pod undocumented
265 234 my $self = shift;
266 return (
267 234 "<TD ".$self->partStyle(@_).">",
268 $self->_dotDefaultNode(@_),
269 "</TD>",
270 );
271 }
272  
273 9 1;
274  
275 ##################
276 package StorageDisplay::Data::Partition::Table::Part::Data;
277  
278 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
279 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
280 9 extends 'StorageDisplay::Data::Partition::Table::Part';
281  
282 9 has 'id' => (
283 is => 'ro',
284 isa => 'Int',
285 required => 1,
286 );
287  
288 9 has 'flags' => (
289 is => 'ro',
290 isa => 'Str',
291 required => 0,
292 );
293  
294  
295 9 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
296 68 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
297 68 my $orig = shift;
298 68 my $class = shift;
299 68 my $args = { @_ };
300  
301 68 my $block;
302  
303 #print STDERR "BUILDARGS in ".__PACKAGE__."\n";
304 68 my $part_id = $args->{id};
305 68 my $table = $args->{table};
306 68 my $it = $table->disk->iterator(
307 'recurse' => 0,
308 'uniq' => 1,
309 );
310 68 ▶ while(defined(my $b=$it->next)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $b = $it->next)) 182 3 185
311 # PARTN does not exists for kpartx mapped partitions
312 182 ▶ my $num = $b->udev_info("ID_PART_ENTRY_NUMBER") // -1;
Condition50%1/2
$b->udev_info("ID_PART_ENTRY_NUMBER") // -1
l!l
1820
MC/DC0%0/1
$b->udev_info("ID_PART_ENTRY_NUMBER") // -1
$b->udev_info("ID_PART_ENTRY_NUMBER")
Truth table50%1/2
A
A= $b->udev_info("ID_PART_ENTRY_NUMBER")
Aresult
11
00
313 182 ▶ next if $num != $part_id;
Branch: 1 branch
BranchTrueFalseTotal
if $num != $part_id 117 65 182
314 65 $block = $b;
315 65 last;
316 }
317 68 ▶ if (! defined($block)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $block) 3 65 68
318 3 my $b = StorageDisplay::Block::NoSystem->new(
319 'id' => $part_id,
320 );
321 3 $block=$b;
322 }
323  
324 68 return $class->$orig(
325 'name' => $block->name,
326 'block' => $block,
327 @_
328 );
329 9 };
330  
331 68 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
332 68 my $self = shift;
333  
334 #print STDERR "BUILD in ".__PACKAGE__."\n";
335 #print STDERR "Looking for ", $self->id, " into ", $self->table->disk->name, "\n";
336 68 $self->provideBlock($self->block);
337 }
338  
339 0 ▶sub rawlinkname {
Subroutine rawlinkname: not called CC=1 SCAR=6.9
Pod undocumented
340 0 my $self = shift;
341  
342 0 confess "No rawlinkname for ".$self->fullname;
343 }
344  
345 48 ▶sub linkname {
Subroutine linkname: called CC=1 SCAR=0.0
Pod undocumented
346 48 my $self = shift;
347  
348 48 return $self->table->elem->linkname.':"'.$self->id.'"';
349 }
350  
351 136 ▶sub partStyle {
Subroutine partStyle: called CC=2 SCAR=7.0
Pod undocumented
352 136 my $self = shift;
353  
354 136 my $state = "unknown";
355 136 ▶ if (defined($self->block)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->block) 136 0 136
356 136 $state = $self->block->state;
357 }
358  
359 136 return 'PORT="'.$self->id.'"'.
360 ' BGCOLOR="'.$self->statecolor($state).'"';
361 }
362  
363 136 ▶sub dotLabel {
Subroutine dotLabel: called CC=3 SCAR=11.1
Pod undocumented
364 136 my $self = shift;
365 136 my $dev;
366 136 ▶ if (defined($self->block)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->block) { } 136 0 136
367 136 $dev = $self->block->dname;
368 } else {
369 0 $dev = $self->name;
370 }
371 136 ▶ if ($self->label) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->label) { } 126 10 136
372 126 return ($dev, $self->label);
373 } else {
374 10 return $dev;
375 }
376 }
377  
378 9 with (
379 'StorageDisplay::Role::HasBlock',
380 );
381  
382 9 1;
383  
384 ##################
385 package StorageDisplay::Data::Partition::Table::Part::SubTable;
386  
387 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
388 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
389  
390 # keep Table::Part::Data first to pick its dotNode redefinition
391 9 extends
392 'StorageDisplay::Data::Partition::Table::Part::Data',
393 'StorageDisplay::Data::Partition::Table';
394  
395 2 ▶sub dotNode {
Subroutine dotNode: called CC=1 SCAR=0.0
Pod undocumented
396 2 my $self = shift;
397 2 my $t = shift;
398 #print STDERR "BUILD in ".__PACKAGE__."\n";
399 return (
400 2 '<TD>',
401 $self->dotIndent(
402 $t,
403 '<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"><TR>',
404 '<TD '.$self->partStyle($t, @_).'>',
405 #$self->dotLabel($t, @_),
406 $self->dotFormatedFullLabel($t, @_),
407 '</TD></TR><TR><TD>',
408 $self->_dotDefaultNode(@_),
409 '</TD></TR></TABLE>',
410 ),
411 '</TD>',
412 );
413 }
414  
415 2 ▶sub dotTable {
Subroutine dotTable: called CC=1 SCAR=0.0
Pod undocumented
416 2 my $self = shift;
417 2 return $self->partDotTable(@_);
418 }
419  
420 9 with (
421 'StorageDisplay::Role::Style::IsLabel',
422 'StorageDisplay::Role::Style::Label::HTML::Table',
423 );
424  
425 9 1;
426  
427 ##################
428 package StorageDisplay::Data::Partition::Table::Part::Free;
429  
430 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
431 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
432 9 extends 'StorageDisplay::Data::Partition::Table::Part';
433  
434 0 ▶sub block {
Subroutine block: not called CC=1 SCAR=6.9
Pod undocumented
435 0 my $self = shift;
436 return
437 0 }
438  
439 100 ▶sub dotLabel {
Subroutine dotLabel: called CC=1 SCAR=0.0
Pod undocumented
440 100 my $self = shift;
441 100 return "Free";
442 }
443  
444 100 ▶sub partStyle {
Subroutine partStyle: called CC=1 SCAR=0.0
Pod undocumented
445 100 my $self = shift;
446 100 return 'bgcolor="green"';
447 }
448  
449 9 1;
450  
451 ##################################################################
452 package StorageDisplay::Data::Partition::None;
453  
454 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
455 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
456 9 extends 'StorageDisplay::Data::Elem';
457  
458 9 with (
459 'StorageDisplay::Role::HasBlock',
460 'StorageDisplay::Role::Style::WithSize',
461 'StorageDisplay::Role::Style::FromBlockState',
462 );
463  
464 30 ▶sub disk {
Subroutine disk: called CC=1 SCAR=0.0
Pod undocumented
465 30 my $self = shift;
466 30 return $self->block(@_);
467 }
468  
469 3 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
470 3 my $orig = shift;
471 3 my $class = shift;
472 3 my $block = shift;
473 3 my $st = shift;
474  
475 3 $st->log({level=>1}, 'Disk with no partition tables on '.$block->dname);
476  
477 3 return $class->$orig(
478 'name' => $block->name,
479 'block' => $block,
480 'provide' => [$block],
481 'size' => $st->get_info('lsblk', $block->name, 'size'),
482 @_
483 );
484 9 };
485  
486 3 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
487 3 my $self = shift;
488  
489 #print STDERR "BUILD in ".__PACKAGE__."\n";
490 #print STDERR "Looking for ", $self->id, " into ", $self->table->disk->name, "\n";
491 3 $self->provideBlock($self->block);
492 }
493  
494 6 ▶sub dotLabel {
Subroutine dotLabel: called CC=3 SCAR=11.2
Pod undocumented
495 6 my $self = shift;
496 6 my @label = ($self->disk->dname);
497 6 ▶ if (defined($self->disk->blk_info('MODEL'))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->disk->blk_info("MODEL")) 6 0 6
498 6 push @label, 'Model: '.$self->disk->blk_info('MODEL');
499 }
500 6 ▶ if (defined($self->disk->blk_info('SERIAL'))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->disk->blk_info("SERIAL")) 6 0 6
501 6 push @label, 'Serial: '.$self->disk->blk_info('SERIAL');
502 }
503 6 return @label;
504 }
505  
506 6 ▶around 'dotStyleNode' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
507 6 my $orig = shift;
508 6 my $self = shift;
509 return (
510 6 $self->$orig(@_),
511 'style=filled',
512 'shape=rectangle',
513 );
514 9 };
515  
516 9 1;
517  
518 ##################################################################
519 package StorageDisplay::Data::Partition::GPT;
520  
521 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
522 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
523 9 extends 'StorageDisplay::Data::Partition';
524  
525 9 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
526  
527 19 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
528 19 my $orig = shift;
529 19 my $class = shift;
530 19 my $block = shift;
531 19 my $st = shift;
532  
533 return $class->$orig(
534 $block,
535 $st,
536 'kind' => 'gpt',
537 19 ▶ %{$st->get_info('partitions', $block->name) // {} }, # size, label, parts
Condition50%1/2
$st->get_info("partitions", $block->name) // {}
l!l
190
MC/DC0%0/1
$st->get_info("partitions", $block->name) // {}
$st->get_info("partitions", $block->name)
Truth table50%1/2
A
A= $st->get_info("partitions", $block->name)
Aresult
11
00
538 @_
539 );
540 9 };
541  
542 19 ▶sub BUILD {
Subroutine BUILD: called CC=4 SCAR=14.0
Pod undocumented
543 19 my $self = shift;
544 19 my $args = shift;
545  
546 #print STDERR "Managing ".$self->disk->dname." (".($self->disk).")\n";
547  
548 19 my $id_free = 1;
549  
550 19 foreach my $part (@{$args->{'parts'}}) {
551 #print STDERR "*******************\n";
552  
553 112 ▶ if ($part->{kind} eq 'free') {
Branch: 2 branches
BranchTrueFalseTotal
if ($part->{'kind'} eq 'free') { } 48 64 112
elsif ($part->{'kind'} eq 'part') { } 64 0 64
554 48 delete($part->{kind});
555 StorageDisplay::Data::Partition::Table::Part::Free->new(
556 'name' => '_'.$id_free,
557 'table' => $self->table,
558 48 %{$part},
559 );
560 48 $id_free ++;
561 } elsif ($part->{kind} eq 'part') {
562 64 delete($part->{kind});
563 StorageDisplay::Data::Partition::Table::Part::Data->new(
564 'table' => $self->table,
565 64 %{$part},
566 );
567 } else {
568 9 ▶ use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
569 0 print STDERR Dumper($part);
570 0 croak "ARghh for ".$self->disk->dname;
571 }
572 }
573 }
574  
575 9 1;
576  
577 ##################################################################
578 package StorageDisplay::Data::Partition::MSDOS;
579  
580 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
581 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
582 9 extends 'StorageDisplay::Data::Partition';
583  
584 9 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
585  
586 2 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
587 2 my $orig = shift;
588 2 my $class = shift;
589 2 my $block = shift;
590 2 my $st = shift;
591  
592 2 ▶ my $info = $st->get_info('partitions', $block->name) // {};
Condition50%1/2
$st->get_info("partitions", $block->name) // {}
l!l
20
MC/DC0%0/1
$st->get_info("partitions", $block->name) // {}
$st->get_info("partitions", $block->name)
Truth table50%1/2
A
A= $st->get_info("partitions", $block->name)
Aresult
11
00
593  
594 return $class->$orig(
595 $block,
596 $st,
597 'kind' => 'msdos',
598 6 (map { $_ => $info->{$_} } ("size", "label", "parts")),
599 2 'extended_num' => $info->{'extended'},
600 @_
601 );
602 9 };
603  
604 9 has 'extended' => (
605 is => 'rw',
606 isa => 'StorageDisplay::Data::Partition::Table',
607 required => 0,
608 );
609  
610 2 ▶sub BUILD {
Subroutine BUILD: called CC=8 SCAR=20.9
Pod undocumented
611 2 my $self = shift;
612 2 my $args = shift;
613  
614 2 ▶ my $extended = $args->{'extended_num'} // '';
Condition100%2/2
$args->{"extended_num"} // ""
l!l
11
MC/DC100%1/1
$args->{"extended_num"} // ""
$args->{"extended_num"}
Truth table100%2/2
A
A= $args->{"extended_num"}
Aresult
11
00
615 2 my $id_free = 1;
616  
617 2 foreach my $part (@{$args->{'parts'}}) {
618 6 ▶ if ($part->{kind} eq 'free') {
Branch: 2 branches
BranchTrueFalseTotal
if ($part->{'kind'} eq 'free') { } 2 4 6
elsif ($part->{'kind'} eq 'part') { } 4 0 4
619 2 delete($part->{kind});
620 StorageDisplay::Data::Partition::Table::Part::Free->new(
621 'name' => '_'.$id_free,
622 'table' => $self->table,
623 2 %{$part},
624 );
625 2 $id_free ++;
626 } elsif ($part->{kind} eq 'part') {
627 4 delete($part->{kind});
628 4 ▶ if ($part->{id} eq $extended) {
Branch: 2 branches
BranchTrueFalseTotal
if ($part->{'id'} eq $extended) { } 1 3 4
elsif ($part->{'id'} <= 4) { } 2 1 3
629 $self->extended(
630 StorageDisplay::Data::Partition::Table::Part::SubTable->new(
631 'table' => $self->table,
632 'partition' => $self,
633 1 %{$part},
634 ));
635 } elsif ($part->{id} <= 4) {
636 StorageDisplay::Data::Partition::Table::Part::Data->new(
637 'table' => $self->table,
638 2 %{$part},
639 );
640 } else {
641 1 ▶ confess if not defined($self->extended);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->extended 0 1 1
642 StorageDisplay::Data::Partition::Table::Part::Data->new(
643 'table' => $self->extended,
644 1 %{$part},
645 );
646 }
647 } else {
648 0 croak "ARghh";
649 }
650 }
651 }
652  
653 9 1;
654  
655 __END__
« /usr/local/bin/perldoc ↑ Summary blib/lib/StorageDisplay/Data/LVM.pm »