| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
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
|
|
|
9
|
|
75
|
use strict; |
|
|
9
|
|
|
|
|
24
|
|
|
|
9
|
|
|
|
|
430
|
|
|
10
|
9
|
|
|
9
|
|
98
|
use warnings; |
|
|
9
|
|
|
|
|
23
|
|
|
|
9
|
|
|
|
|
800
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
9
|
|
|
9
|
|
98
|
use StorageDisplay::Data::Partition; |
|
|
9
|
|
|
|
|
23
|
|
|
|
9
|
|
|
|
|
613
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package StorageDisplay::Data::Loop; |
|
15
|
|
|
|
|
|
|
# ABSTRACT: Handle LVM data for StorageDisplay |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '2.06'; # VERSION |
|
18
|
|
|
|
|
|
|
|
|
19
|
9
|
|
|
9
|
|
63
|
use Moose; |
|
|
9
|
|
|
|
|
25
|
|
|
|
9
|
|
|
|
|
88
|
|
|
20
|
9
|
|
|
9
|
|
82710
|
use namespace::sweep; |
|
|
9
|
|
|
|
|
26
|
|
|
|
9
|
|
|
|
|
111
|
|
|
21
|
|
|
|
|
|
|
extends 'StorageDisplay::Data::Elem'; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
with ( |
|
24
|
|
|
|
|
|
|
'StorageDisplay::Role::HasBlock', |
|
25
|
|
|
|
|
|
|
'StorageDisplay::Role::Style::WithSize', |
|
26
|
|
|
|
|
|
|
'StorageDisplay::Role::Style::FromBlockState', |
|
27
|
|
|
|
|
|
|
); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has 'deleted' => ( |
|
30
|
|
|
|
|
|
|
is => 'ro', |
|
31
|
|
|
|
|
|
|
isa => 'Bool', |
|
32
|
|
|
|
|
|
|
required => 1, |
|
33
|
|
|
|
|
|
|
); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has 'noaccess' => ( |
|
36
|
|
|
|
|
|
|
is => 'ro', |
|
37
|
|
|
|
|
|
|
isa => 'Bool', |
|
38
|
|
|
|
|
|
|
required => 1, |
|
39
|
|
|
|
|
|
|
default => 0, |
|
40
|
|
|
|
|
|
|
); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has 'filename' => ( |
|
43
|
|
|
|
|
|
|
is => 'ro', |
|
44
|
|
|
|
|
|
|
isa => 'Str', |
|
45
|
|
|
|
|
|
|
required => 1, |
|
46
|
|
|
|
|
|
|
); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has 'mountpoint' => ( |
|
49
|
|
|
|
|
|
|
is => 'ro', |
|
50
|
|
|
|
|
|
|
isa => 'Str', |
|
51
|
|
|
|
|
|
|
required => 0, |
|
52
|
|
|
|
|
|
|
predicate => 'has_mountpoint', |
|
53
|
|
|
|
|
|
|
); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
default => sub { |
|
67
|
|
|
|
|
|
|
my $self = shift; |
|
68
|
|
|
|
|
|
|
return $self->size; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
has 'ro' => ( |
|
73
|
|
|
|
|
|
|
is => 'ro', |
|
74
|
|
|
|
|
|
|
isa => 'Bool', |
|
75
|
|
|
|
|
|
|
required => 1, |
|
76
|
|
|
|
|
|
|
); |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
has 'autoclear' => ( |
|
79
|
|
|
|
|
|
|
is => 'ro', |
|
80
|
|
|
|
|
|
|
isa => 'Bool', |
|
81
|
|
|
|
|
|
|
required => 1, |
|
82
|
|
|
|
|
|
|
); |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub majmin2dec { |
|
85
|
0
|
|
|
0
|
0
|
|
my $st = shift; |
|
86
|
0
|
|
|
|
|
|
my $data = shift; |
|
87
|
0
|
|
|
|
|
|
my @parts = split(':', $data); |
|
88
|
0
|
0
|
|
|
|
|
if (scalar(@parts) != 2) { |
|
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
|
|
|
|
|
|
|
around BUILDARGS => sub { |
|
96
|
|
|
|
|
|
|
my $orig = shift; |
|
97
|
|
|
|
|
|
|
my $class = shift; |
|
98
|
|
|
|
|
|
|
my $loop = shift; |
|
99
|
|
|
|
|
|
|
my $st = shift; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
$st->log({level=>1}, 'Loop device '.$loop); |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
my $info = $st->get_info('loops', $loop); |
|
104
|
|
|
|
|
|
|
my $block = $st->block($loop); |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my $file = $st->get_info('files', $info->{'back-file'}); |
|
107
|
|
|
|
|
|
|
my $deleted = 0; |
|
108
|
|
|
|
|
|
|
if ($file->{'deleted'} |
|
109
|
|
|
|
|
|
|
and $file->{'name'} =~ /^(.*) \(deleted\)$/) { |
|
110
|
|
|
|
|
|
|
$file = $st->get_info('files', $1); |
|
111
|
|
|
|
|
|
|
$deleted = 1; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
my @args; |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
#print STDERR "Handling ", $file->{'name'}, " ($deleted)\n"; |
|
116
|
|
|
|
|
|
|
if ($file->{'deleted'} |
|
117
|
|
|
|
|
|
|
or $file->{'inode'} ne $info->{'back-ino'} |
|
118
|
|
|
|
|
|
|
or $file->{'st_dev'} != majmin2dec($st, $info->{'back-maj:min'})) { |
|
119
|
|
|
|
|
|
|
if (! $deleted) { |
|
120
|
|
|
|
|
|
|
$st->warn('Deleted file '.$file->{'name'}.' not announced!'); |
|
121
|
|
|
|
|
|
|
$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
|
|
|
|
|
|
|
if ($deleted) { |
|
129
|
|
|
|
|
|
|
$deleted = 0; |
|
130
|
|
|
|
|
|
|
$st->warn('File '.$file->{'name'}.' wrongly marked as deleted!'); |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
if (!$deleted) { |
|
135
|
|
|
|
|
|
|
my $mountpoint = $file->{'mountpoint'}; |
|
136
|
|
|
|
|
|
|
push @args, 'mountpoint', $mountpoint; |
|
137
|
|
|
|
|
|
|
my $consumename = $st->fs_mountpoint_blockname($mountpoint); |
|
138
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
'sizelimit' => $info->{'sizelimit'}, |
|
153
|
|
|
|
|
|
|
'provide' => [$block], |
|
154
|
|
|
|
|
|
|
@args, |
|
155
|
|
|
|
|
|
|
@_ |
|
156
|
|
|
|
|
|
|
); |
|
157
|
|
|
|
|
|
|
}; |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub BUILD { |
|
160
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
161
|
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
$self->provideBlock($self->block); |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub dotLabel { |
|
166
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
167
|
0
|
|
|
|
|
|
my @label = ( |
|
168
|
|
|
|
|
|
|
'Loop device: '.$self->block->dname, |
|
169
|
|
|
|
|
|
|
); |
|
170
|
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
my @flags; |
|
172
|
0
|
0
|
|
|
|
|
if ($self->ro) { |
|
173
|
0
|
|
|
|
|
|
push @flags, "readonly"; |
|
174
|
|
|
|
|
|
|
} |
|
175
|
0
|
0
|
|
|
|
|
if ($self->autoclear) { |
|
176
|
0
|
|
|
|
|
|
push @flags, "autoclear"; |
|
177
|
|
|
|
|
|
|
} |
|
178
|
0
|
0
|
|
|
|
|
if (scalar(@flags)) { |
|
179
|
0
|
|
|
|
|
|
push @label, join(', ', @flags); |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
|
|
182
|
0
|
0
|
|
|
|
|
push @label, 'Source'.($self->deleted?' [deleted]':'').': '.$self->filename; |
|
183
|
|
|
|
|
|
|
|
|
184
|
0
|
0
|
|
|
|
|
if ($self->offset != 0) { |
|
185
|
0
|
|
|
|
|
|
push @label, 'Offset: '.$self->disp_size($self->offset); |
|
186
|
|
|
|
|
|
|
} |
|
187
|
|
|
|
|
|
|
|
|
188
|
0
|
0
|
|
|
|
|
if ($self->size != $self->sizelimit) { |
|
189
|
0
|
|
|
|
|
|
push @label, 'Size limit: '.$self->disp_size($self->sizelimit); |
|
190
|
|
|
|
|
|
|
} |
|
191
|
|
|
|
|
|
|
|
|
192
|
0
|
|
|
|
|
|
return @label; |
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
around 'dotStyleNode' => sub { |
|
196
|
|
|
|
|
|
|
my $orig = shift; |
|
197
|
|
|
|
|
|
|
my $self = shift; |
|
198
|
|
|
|
|
|
|
return ( |
|
199
|
|
|
|
|
|
|
$self->$orig(@_), |
|
200
|
|
|
|
|
|
|
'style=filled', |
|
201
|
|
|
|
|
|
|
'shape=rectangle', |
|
202
|
|
|
|
|
|
|
); |
|
203
|
|
|
|
|
|
|
}; |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
1; |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
__END__ |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=pod |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=encoding UTF-8 |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 NAME |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
StorageDisplay::Data::Loop - Handle LVM data for StorageDisplay |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head1 VERSION |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
version 2.06 |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head1 AUTHOR |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Vincent Danjean <Vincent.Danjean@ens-lyon.org> |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
This software is copyright (c) 2014-2023 by Vincent Danjean. |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
230
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=cut |