line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Copyright (c) 2002 Paul Winkeler. All Rights Reserved. |
3
|
|
|
|
|
|
|
# This program is free software; you may redistribute it and/or modify it under |
4
|
|
|
|
|
|
|
# the same terms as Perl itself. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package NBU::Mount; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
9
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
66
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
564
|
use NBU::Drive; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
12
|
1
|
|
|
1
|
|
620
|
use NBU::Path; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
BEGIN { |
15
|
1
|
|
|
1
|
|
8
|
use Exporter (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
16
|
1
|
|
|
1
|
|
4
|
use AutoLoader qw(AUTOLOAD); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
17
|
1
|
|
|
1
|
|
41
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
157
|
|
18
|
1
|
|
|
1
|
|
2
|
$VERSION = do { my @r=(q$Revision: 1.13 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r }; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
8
|
|
19
|
1
|
|
|
|
|
15
|
@ISA = qw(); |
20
|
1
|
|
|
|
|
2
|
@EXPORT = qw(); |
21
|
1
|
|
|
|
|
2
|
@EXPORT_OK = qw(); |
22
|
1
|
|
|
|
|
990
|
%EXPORT_TAGS = qw(); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new { |
26
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
27
|
0
|
|
|
|
|
|
my $mount = { |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
bless $mount, $class; |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
if (@_) { |
33
|
0
|
|
|
|
|
|
my ($job, $volume, $drive, $tm) = @_; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# |
36
|
|
|
|
|
|
|
# The bpdbjobs output, for example, is devoid of drive |
37
|
|
|
|
|
|
|
# references hence we may not be able to record an actual |
38
|
|
|
|
|
|
|
# mount event at this time... |
39
|
0
|
0
|
|
|
|
|
if (defined($drive)) { |
40
|
0
|
|
|
|
|
|
$mount->drive($drive)->use($mount, $tm); |
41
|
0
|
|
|
|
|
|
$volume->mount($mount, $drive, $tm); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$mount->{JOB} = $job; |
45
|
0
|
|
|
|
|
|
$mount->{TARGET} = $volume; |
46
|
0
|
|
|
|
|
|
$mount->{MOUNTTIME} = $tm; |
47
|
0
|
0
|
|
|
|
|
$mount->{MOUNTDELAY} = $tm - $volume->selected |
48
|
|
|
|
|
|
|
if ($volume->selected); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return $mount; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub job { |
56
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
return $self->{JOB}; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub unmount { |
62
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
63
|
0
|
|
|
|
|
|
my $job = $self->{JOB}; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $tm = $self->{UNMOUNTTIME} = shift; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
if (defined($job->mount)) { |
69
|
0
|
0
|
|
|
|
|
if ($job->mount == $self) { |
70
|
0
|
|
|
|
|
|
$job->mount(undef); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
|
$self->drive->free($tm, $self->usedBy) |
74
|
|
|
|
|
|
|
if ($self->drive); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
return $self->{UNMOUNTTIME}; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub start { |
81
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
return $self->{MOUNTTIME}; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub stop { |
87
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
return $self->{UNMOUNTTIME}; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub startPositioning { |
93
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
94
|
0
|
|
|
|
|
|
my $fileNumber = shift; |
95
|
0
|
|
|
|
|
|
my $tm = shift; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub positioned { |
100
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
101
|
0
|
|
|
|
|
|
my $tm = shift; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub mountPoint { |
106
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
107
|
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
|
if (@_) { |
109
|
0
|
|
|
|
|
|
$self->{MP} = shift; |
110
|
|
|
|
|
|
|
} |
111
|
0
|
|
|
|
|
|
return $self->{MP}; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub drive { |
115
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
return $self->mountPoint(@_); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub path { |
121
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
return $self->mountPoint(@_); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub target { |
127
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
return $self->{TARGET}; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub volume { |
133
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
return $self->target(@_); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub file { |
139
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
return $self->target(@_); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub usedBy { |
145
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
146
|
|
|
|
|
|
|
|
147
|
0
|
0
|
|
|
|
|
if (@_) { |
148
|
0
|
|
|
|
|
|
$self->{USEDBY} = shift; |
149
|
|
|
|
|
|
|
} |
150
|
0
|
|
|
|
|
|
return $self->{USEDBY}; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub read { |
154
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
155
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
|
my ($fragmentNumber, $size, $speed) = @_; |
157
|
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
|
$self->{FRAGMENT} = $fragmentNumber; |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
# |
161
|
|
|
|
|
|
|
# Grow size and keep running average speed |
162
|
0
|
|
|
|
|
|
$self->{SIZE} += $size; |
163
|
0
|
|
|
|
|
|
$self->{READINGTIME} += ($size / $speed); |
164
|
0
|
|
|
|
|
|
$self->{SPEED} = $self->{SIZE} / $self->{READINGTIME}; |
165
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
$self->volume->read($size, $speed); |
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
return $self; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub write { |
172
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
173
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
my ($fragmentNumber, $size, $speed) = @_; |
175
|
|
|
|
|
|
|
|
176
|
0
|
|
|
|
|
|
$self->{FRAGMENT} = $fragmentNumber; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
# |
179
|
|
|
|
|
|
|
# Grow size and keep running average speed |
180
|
0
|
|
|
|
|
|
$self->{SIZE} += $size; |
181
|
0
|
|
|
|
|
|
$self->{WRITINGTIME} += ($size / $speed); |
182
|
0
|
|
|
|
|
|
$self->{SPEED} = $self->{SIZE} / $self->{WRITINGTIME}; |
183
|
|
|
|
|
|
|
|
184
|
0
|
|
|
|
|
|
$self->volume->write($size, $speed); |
185
|
|
|
|
|
|
|
|
186
|
0
|
|
|
|
|
|
return $self; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub speed { |
190
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
191
|
|
|
|
|
|
|
|
192
|
0
|
|
|
|
|
|
return $self->{SPEED}; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub writeTime { |
196
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
197
|
|
|
|
|
|
|
|
198
|
0
|
0
|
|
|
|
|
if (my $speed = $self->{SPEED}) { |
199
|
0
|
|
|
|
|
|
my $size = $self->{SIZE}; |
200
|
0
|
|
|
|
|
|
return ($size / $speed); |
201
|
|
|
|
|
|
|
} |
202
|
0
|
|
|
|
|
|
return undef; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub dataRead { |
206
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
207
|
|
|
|
|
|
|
|
208
|
0
|
|
|
|
|
|
return $self->data(@_); |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
sub dataWritten { |
212
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
213
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
return $self->data(@_); |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
sub data { |
218
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
219
|
|
|
|
|
|
|
|
220
|
0
|
|
|
|
|
|
return $self->{SIZE}; |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
1; |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
__END__ |