| 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 | 9 | ▶ | use StorageDisplay::Data::Partition; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | package StorageDisplay::Data::Loop; | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # ABSTRACT: Handle LVM data for StorageDisplay | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 9 | our $VERSION = '2.06'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 9 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 9 | ▶ | use namespace::sweep; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 9 | extends 'StorageDisplay::Data::Elem'; | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 9 | with ( | |||||||||||||||||||||||||||||||||||||||||
| 24 | 'StorageDisplay::Role::HasBlock', | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 'StorageDisplay::Role::Style::WithSize', | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 'StorageDisplay::Role::Style::FromBlockState', | ||||||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 9 | has 'deleted' => ( | |||||||||||||||||||||||||||||||||||||||||
| 30 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 31 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||
| 32 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 9 | has 'noaccess' => ( | |||||||||||||||||||||||||||||||||||||||||
| 36 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 37 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||
| 38 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 9 | has 'filename' => ( | |||||||||||||||||||||||||||||||||||||||||
| 43 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 44 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 45 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 9 | has 'mountpoint' => ( | |||||||||||||||||||||||||||||||||||||||||
| 49 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 50 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 51 | required => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | predicate => 'has_mountpoint', | ||||||||||||||||||||||||||||||||||||||||||
| 53 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 9 | has 'offset' => ( | |||||||||||||||||||||||||||||||||||||||||
| 56 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 57 | isa => 'Num', | ||||||||||||||||||||||||||||||||||||||||||
| 58 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | has 'sizelimit' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 62 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 63 | isa => 'Num', | ||||||||||||||||||||||||||||||||||||||||||
| 64 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 65 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | return $self->size; | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 9 | ); | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 9 | has 'ro' => ( | |||||||||||||||||||||||||||||||||||||||||
| 73 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 74 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||
| 75 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 76 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 9 | has 'autoclear' => ( | |||||||||||||||||||||||||||||||||||||||||
| 79 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 80 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||
| 81 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 82 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub majmin2dec { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
majmin2dec: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $st = shift; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my @parts = split(':', $data); | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if (scalar(@parts) != 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $st->warn('Loop device with bad maj/min '.$data); | |||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | return $parts[0]*256+$parts[1]; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | around BUILDARGS => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $orig = shift; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my $loop = shift; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my $st = shift; | |||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $st->log({level=>1}, 'Loop device '.$loop); | |||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my $info = $st->get_info('loops', $loop); | |||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my $block = $st->block($loop); | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my $file = $st->get_info('files', $info->{'back-file'}); | |||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my $deleted = 0; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if ($file->{'deleted'} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$file->{"deleted"} and $file->{"name"} =~ /^(.*) \(deleted\)$/
MC/DC0%0/2
$file->{"deleted"} and $file->{"name"} =~ /^(.*) \(deleted\)$/
$file->{"deleted"}
$file->{"name"} =~ /^(.*) \(deleted\)$/
Truth table0%0/3
A and B
A= $file->{"deleted"}B= $file->{"name"} =~ /^(.*) \(deleted\)$/
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | and $file->{'name'} =~ /^(.*) \(deleted\)$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $file = $st->get_info('files', $1); | |||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $deleted = 1; | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my @args; | |||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | #print STDERR "Handling ", $file->{'name'}, " ($deleted)\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | if ($file->{'deleted'} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$file->{"deleted"} or $file->{"inode"} ne $info->{"back-ino"} or $file->{"st_dev"} != majmin2dec($st, $info->{"back-maj:min"})
$file->{"deleted"} or $file->{"inode"} ne $info->{"back-ino"}
MC/DC0%0/3
$file->{"deleted"} or $file->{"inode"} ne $info->{"back-ino"} or $file->{"st_dev"} != majmin2dec($st, $info->{"back-maj:min"})
$file->{"deleted"}
$file->{"inode"} ne $info->{"back-ino"}
$file->{"st_dev"} != majmin2dec($st, $info->{"back-maj:min"})
Truth table0%0/4
A or B or C
A= $file->{"deleted"}B= $file->{"inode"} ne $info->{"back-ino"}C= $file->{"st_dev"} != majmin2dec($st, $info->{"back-maj:min"})
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | or $file->{'inode'} ne $info->{'back-ino'} | ||||||||||||||||||||||||||||||||||||||||||
| 118 | or $file->{'st_dev'} != majmin2dec($st, $info->{'back-maj:min'})) { | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | if (! $deleted) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $st->warn('Deleted file '.$file->{'name'}.' not announced!'); | |||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $deleted = 1; | |||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | #if ($info->{'back-file'} =~ /(.*) \(deleted\)$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 124 | # # file exists, but root does not have access to it | ||||||||||||||||||||||||||||||||||||||||||
| 125 | # push @args, 'noaccess', 1; | ||||||||||||||||||||||||||||||||||||||||||
| 126 | #} | ||||||||||||||||||||||||||||||||||||||||||
| 127 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | if ($deleted) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $deleted = 0; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $st->warn('File '.$file->{'name'}.' wrongly marked as deleted!'); | |||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if (!$deleted) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $mountpoint = $file->{'mountpoint'}; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | push @args, 'mountpoint', $mountpoint; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my $consumename = $st->fs_mountpoint_blockname($mountpoint); | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | push @args, 'consume' => [$st->block($consumename)]; | |||||||||||||||||||||||||||||||||||||||||
| 139 | #print STDERR $block->name, " consomme ", $consumename, "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | return $class->$orig( | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 'name' => $block->name, | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 'block' => $block, | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 'st' => $st, | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 'deleted' => $deleted, | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 'filename' => $file->{'name'}, | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 'size' => $block->size, | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 'offset' => $info->{'offset'}, | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 'ro' => $info->{'ro'}, | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 'autoclear' => $info->{'autoclear'}, | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | 'sizelimit' => $info->{'sizelimit'}, | |||||||||||||||||||||||||||||||||||||||||
| 153 | 'provide' => [$block], | ||||||||||||||||||||||||||||||||||||||||||
| 154 | @args, | ||||||||||||||||||||||||||||||||||||||||||
| 155 | @_ | ||||||||||||||||||||||||||||||||||||||||||
| 156 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $self->provideBlock($self->block); | |||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | sub dotLabel { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dotLabel: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my @label = ( | |||||||||||||||||||||||||||||||||||||||||
| 168 | 'Loop device: '.$self->block->dname, | ||||||||||||||||||||||||||||||||||||||||||
| 169 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | my @flags; | |||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if ($self->ro) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | push @flags, "readonly"; | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | if ($self->autoclear) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | push @flags, "autoclear"; | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if (scalar(@flags)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | push @label, join(', ', @flags); | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | push @label, 'Source'.($self->deleted?' [deleted]':'').': '.$self->filename; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | if ($self->offset != 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | push @label, 'Offset: '.$self->disp_size($self->offset); | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if ($self->size != $self->sizelimit) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | push @label, 'Size limit: '.$self->disp_size($self->sizelimit); | |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | return @label; | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | around 'dotStyleNode' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my $orig = shift; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 198 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $self->$orig(@_), | |||||||||||||||||||||||||||||||||||||||||
| 200 | 'style=filled', | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 'shape=rectangle', | ||||||||||||||||||||||||||||||||||||||||||
| 202 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | __END__ | ||||||||||||||||||||||||||||||||||||||||||