line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HPUX::Ioscan; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1086
|
use 5.006; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
41
|
|
5
|
|
|
|
|
|
|
#use warnings; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
1
|
|
|
1
|
|
2332
|
use AutoLoader qw(AUTOLOAD); |
|
1
|
|
|
|
|
1687
|
|
|
1
|
|
|
|
|
7
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
13
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
14
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# This allows declaration use HPUX::Ioscan ':all'; |
17
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
18
|
|
|
|
|
|
|
# will save memory. |
19
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
) ] ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @EXPORT = qw(ioscan |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
our $VERSION = '1.09_01'; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Preloaded methods go here. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Autoload methods go after =cut, and are processed by the autosplit program. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
## start |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
1
|
|
1086
|
use FileHandle ; |
|
1
|
|
|
|
|
14233
|
|
|
1
|
|
|
|
|
8
|
|
39
|
1
|
|
|
1
|
|
428
|
use Carp ; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
175
|
|
40
|
1
|
|
|
1
|
|
7
|
use vars qw/@ISA @EXPORT $test $VERSION $AUTOLOAD/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
78
|
|
41
|
1
|
|
|
1
|
|
11976
|
use Storable; |
|
1
|
|
|
|
|
10338
|
|
|
1
|
|
|
|
|
3174
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my @list = |
44
|
|
|
|
|
|
|
qw/bus_type |
45
|
|
|
|
|
|
|
cdio |
46
|
|
|
|
|
|
|
is_block |
47
|
|
|
|
|
|
|
is_char |
48
|
|
|
|
|
|
|
is_pseudo |
49
|
|
|
|
|
|
|
block_major_number |
50
|
|
|
|
|
|
|
character_major_number |
51
|
|
|
|
|
|
|
minor_number |
52
|
|
|
|
|
|
|
class |
53
|
|
|
|
|
|
|
driver |
54
|
|
|
|
|
|
|
hardware_path |
55
|
|
|
|
|
|
|
identify_bytes |
56
|
|
|
|
|
|
|
instance_number |
57
|
|
|
|
|
|
|
module_path |
58
|
|
|
|
|
|
|
module_name |
59
|
|
|
|
|
|
|
software_state |
60
|
|
|
|
|
|
|
hardware_type |
61
|
|
|
|
|
|
|
description |
62
|
|
|
|
|
|
|
card_instance/; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $cache ; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub ioscan |
67
|
|
|
|
|
|
|
{ |
68
|
0
|
|
|
0
|
1
|
0
|
my %args = @_ ; |
69
|
0
|
|
|
|
|
0
|
my $tmp_path ; |
70
|
0
|
|
0
|
|
|
0
|
my $force = $args{force} || 0; |
71
|
|
|
|
|
|
|
|
72
|
0
|
0
|
0
|
|
|
0
|
if (not defined $cache or $force) |
73
|
|
|
|
|
|
|
{ |
74
|
0
|
|
|
|
|
0
|
my @scan ; |
75
|
0
|
0
|
|
|
|
0
|
if (defined $test) |
76
|
|
|
|
|
|
|
{ |
77
|
0
|
|
|
|
|
0
|
@scan = @$test ; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
else |
80
|
|
|
|
|
|
|
{ |
81
|
0
|
|
|
|
|
0
|
my $fh = new FileHandle; |
82
|
0
|
0
|
|
|
|
0
|
$fh->open ('ioscan -nF |') |
83
|
|
|
|
|
|
|
or croak "can't open ioscan pipe $!\n"; |
84
|
0
|
|
|
|
|
0
|
@scan = <$fh>; |
85
|
0
|
|
|
|
|
0
|
$fh->close; |
86
|
0
|
0
|
|
|
|
0
|
die "Ioscan error: $!\n" if $! ; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
0
|
foreach my $line (@scan) |
90
|
|
|
|
|
|
|
{ |
91
|
|
|
|
|
|
|
#print $line ,"\n"; |
92
|
0
|
0
|
|
|
|
0
|
if ($line =~ s/^\s+//) |
93
|
|
|
|
|
|
|
{ |
94
|
|
|
|
|
|
|
# file line |
95
|
0
|
|
|
|
|
0
|
push @{$cache->{$tmp_path}{device_files}}, split /\s+/,$line ; |
|
0
|
|
|
|
|
0
|
|
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
else |
98
|
|
|
|
|
|
|
{ |
99
|
|
|
|
|
|
|
#device line |
100
|
0
|
|
|
|
|
0
|
my @fields = split(':',$line) ; |
101
|
|
|
|
|
|
|
#print "nb field ", scalar @fields, " nb list ", scalar @list, "\n"; |
102
|
0
|
|
|
|
|
0
|
my $i=0; |
103
|
0
|
|
|
|
|
0
|
my %tmp ; |
104
|
0
|
|
|
|
|
0
|
while (defined $list[$i]) |
105
|
|
|
|
|
|
|
{ |
106
|
|
|
|
|
|
|
#print "$i: $list[$i], $fields[$i]\n"; |
107
|
0
|
|
|
|
|
0
|
$tmp{$list[$i++]} = $fields[$i] ; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
0
|
$tmp_path = $tmp{hardware_path} ; |
111
|
0
|
|
|
|
|
0
|
$cache->{$tmp_path} = \%tmp ; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
0
|
0
|
|
|
|
0
|
return $cache->{hardware_path} if defined $args{hardware_path}; |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
0
|
return $cache ; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub new |
122
|
|
|
|
|
|
|
{ |
123
|
1
|
|
|
1
|
1
|
448
|
my $debug=0; |
124
|
1
|
|
|
|
|
3
|
my $debug2=0; |
125
|
|
|
|
|
|
|
|
126
|
1
|
|
|
|
|
4
|
my ($class, @subargs) = @_ ; |
127
|
|
|
|
|
|
|
|
128
|
1
|
|
|
|
|
11
|
my %arglist = ( |
129
|
|
|
|
|
|
|
target_type => "local" , |
130
|
|
|
|
|
|
|
persistance => "new" , |
131
|
|
|
|
|
|
|
datafile => "/tmp/ioscan.dat" , |
132
|
|
|
|
|
|
|
access_prog => "ssh" , |
133
|
|
|
|
|
|
|
access_system => "localhost" , |
134
|
|
|
|
|
|
|
access_user => "root" , |
135
|
|
|
|
|
|
|
remote_command1 => '/usr/sbin/ioscan -Fn', |
136
|
|
|
|
|
|
|
@subargs, |
137
|
|
|
|
|
|
|
); |
138
|
|
|
|
|
|
|
|
139
|
1
|
50
|
|
|
|
4
|
if ($debug) { |
140
|
0
|
|
|
|
|
0
|
print "target_type : $arglist{target_type}\n"; |
141
|
0
|
|
|
|
|
0
|
print "persistance : $arglist{persistance}\n"; |
142
|
0
|
|
|
|
|
0
|
print "datafile : $arglist{datafile}\n"; |
143
|
0
|
|
|
|
|
0
|
print "access_prog : $arglist{access_prog}\n"; |
144
|
0
|
|
|
|
|
0
|
print "access_system: $arglist{access_system}\n"; |
145
|
0
|
|
|
|
|
0
|
print "access_user : $arglist{access_user}\n"; |
146
|
0
|
|
|
|
|
0
|
print "remote_command1: $arglist{remote_command1}\n"; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
1
|
|
|
|
|
4
|
my $source_access =$arglist{target_type}; |
150
|
1
|
|
|
|
|
2
|
my $new_or_saved =$arglist{persistance}; |
151
|
1
|
|
|
|
|
3
|
my $datafile =$arglist{datafile}; |
152
|
1
|
|
|
|
|
2
|
my $remote_access =$arglist{access_prog}; |
153
|
1
|
|
|
|
|
2
|
my $remote_system =$arglist{access_system}; |
154
|
1
|
|
|
|
|
1
|
my $remote_user =$arglist{access_user}; |
155
|
1
|
|
|
|
|
2
|
my $remote_command =$arglist{remote_command1}; |
156
|
|
|
|
|
|
|
|
157
|
1
|
|
|
|
|
3
|
my $line; |
158
|
|
|
|
|
|
|
my $ioscan_hashref; |
159
|
0
|
|
|
|
|
0
|
my @ioscan_out; |
160
|
0
|
|
|
|
|
0
|
my %ioscan_info; |
161
|
1
|
|
|
|
|
2
|
my $ioscan_object_ref = \%ioscan_info; |
162
|
|
|
|
|
|
|
|
163
|
1
|
50
|
|
|
|
5
|
print "I'm :".ref($ioscan_object_ref)."\n" if $debug; |
164
|
|
|
|
|
|
|
|
165
|
1
|
|
|
|
|
1
|
my @ioscan_split; |
166
|
|
|
|
|
|
|
my $tmp_path ; |
167
|
|
|
|
|
|
|
|
168
|
1
|
50
|
|
|
|
4
|
print "I'm in class: $class\n" if $debug; |
169
|
1
|
50
|
|
|
|
2
|
print "Command: $remote_access $remote_system -l $remote_user -n $remote_command\n" if $debug; |
170
|
|
|
|
|
|
|
|
171
|
1
|
50
|
|
|
|
4
|
if ( $new_or_saved eq "old" ) { |
172
|
1
|
50
|
|
|
|
4
|
print "retrieving a copy from prosperity...\n" if $debug; |
173
|
1
|
50
|
|
|
|
8
|
$ioscan_hashref = Storable::retrieve $datafile |
174
|
|
|
|
|
|
|
or die "unable to retrieve hash data in /tmp\n"; |
175
|
1
|
|
|
|
|
730
|
return bless($ioscan_hashref,$class); |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
0
|
0
|
|
|
|
0
|
@ioscan_out=`$remote_access $remote_system -l $remote_user -n $remote_command` |
179
|
|
|
|
|
|
|
or die "Could not execute remote command: $@\n"; |
180
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
0
|
foreach my $line (@ioscan_out) |
182
|
|
|
|
|
|
|
{ |
183
|
0
|
0
|
|
|
|
0
|
print $line ,"\n" if $debug; |
184
|
0
|
0
|
|
|
|
0
|
if ($line =~ s/^\s+//) |
185
|
|
|
|
|
|
|
{ # file line |
186
|
0
|
0
|
|
|
|
0
|
print "Matched line starting with device file\n" if $debug; |
187
|
0
|
|
|
|
|
0
|
push @{ $ioscan_info{$ioscan_split[10]}->{device_files} }, split /\s+/, $line; |
|
0
|
|
|
|
|
0
|
|
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
else |
191
|
|
|
|
|
|
|
{ |
192
|
0
|
0
|
|
|
|
0
|
print "Matched actual device line\n" if $debug; |
193
|
0
|
|
|
|
|
0
|
@ioscan_split = split /:/, $line; |
194
|
|
|
|
|
|
|
# match keys to values from list above |
195
|
0
|
|
|
|
|
0
|
for (my $i=0 ; $i<19 ; $i++) { $ioscan_info{$ioscan_split[10]}{$list[$i]} = $ioscan_split[$i] }; |
|
0
|
|
|
|
|
0
|
|
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
} |
198
|
0
|
0
|
|
|
|
0
|
if ( $new_or_saved eq "new" ) { |
199
|
0
|
0
|
|
|
|
0
|
print "saving a copy for prosperity...\n" if $debug; |
200
|
0
|
0
|
|
|
|
0
|
Storable::nstore \%ioscan_info, $datafile |
201
|
|
|
|
|
|
|
or die "unable to store hash data in $datafile\n"; |
202
|
|
|
|
|
|
|
} |
203
|
0
|
|
|
|
|
0
|
return bless($ioscan_object_ref,$class); |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
sub AUTOLOAD { |
207
|
6
|
|
|
6
|
|
279
|
my ($self, @subargs) = @_; |
208
|
|
|
|
|
|
|
|
209
|
6
|
|
|
|
|
12
|
my %arglist = ( |
210
|
|
|
|
|
|
|
hwpath => "" , |
211
|
|
|
|
|
|
|
@subargs, |
212
|
|
|
|
|
|
|
); |
213
|
6
|
|
|
|
|
7
|
my $debug = 0; |
214
|
6
|
50
|
|
|
|
11
|
print "Passed: @_<--\n" if $debug; |
215
|
6
|
50
|
|
|
|
10
|
print "Yoyoyoyo got called here\n" if $debug; |
216
|
6
|
|
|
|
|
9
|
my $HWPATH = $arglist{hwpath}; |
217
|
6
|
50
|
|
|
|
25
|
print "HWPATH: $HWPATH\n" if $debug; |
218
|
6
|
50
|
|
|
|
10
|
print "AUTOLOAD: $AUTOLOAD\n" if $debug; |
219
|
6
|
50
|
|
|
|
25
|
$AUTOLOAD =~ /.*::get_(\w+)/ or croak "No Such method: $AUTOLOAD\n"; |
220
|
6
|
50
|
|
|
|
12
|
print "AUTOLOAD is now: $AUTOLOAD\n" if $debug; |
221
|
6
|
50
|
|
|
|
13
|
croak "$self not an object" unless ref($self); |
222
|
6
|
50
|
|
|
|
10
|
return if $AUTOLOAD =~ /::DESTROY$/; |
223
|
6
|
50
|
|
|
|
18
|
unless (exists $self->{$HWPATH}->{$1}) { |
224
|
0
|
|
|
|
|
0
|
croak "Cannot access $1 field in $self->{$HWPATH}\n"; |
225
|
|
|
|
|
|
|
} |
226
|
6
|
50
|
|
|
|
12
|
print "self says its: $self->{$1}\n" if $debug; |
227
|
6
|
|
|
|
|
24
|
return $self->{$HWPATH}->{$1}; |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
sub traverse { |
231
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
232
|
0
|
|
|
|
|
0
|
my $debug=1; |
233
|
0
|
0
|
|
|
|
0
|
print "I am self: $self\n" if $debug; |
234
|
0
|
|
|
|
|
0
|
my $mainkey; |
235
|
|
|
|
|
|
|
my $subkey; |
236
|
0
|
|
|
|
|
0
|
my $dev_file; |
237
|
|
|
|
|
|
|
|
238
|
0
|
|
|
|
|
0
|
foreach $mainkey ( keys %{ $self } ) { |
|
0
|
|
|
|
|
0
|
|
239
|
0
|
|
|
|
|
0
|
print "Main Key: $mainkey\n"; |
240
|
0
|
|
|
|
|
0
|
print "Values:\n"; |
241
|
0
|
|
|
|
|
0
|
foreach $subkey ( keys %{ $self->{$mainkey} } ) { |
|
0
|
|
|
|
|
0
|
|
242
|
0
|
|
|
|
|
0
|
print "SubKey: $subkey, Value: $self->{$mainkey}->{$subkey}\n"; |
243
|
|
|
|
|
|
|
} |
244
|
0
|
|
|
|
|
0
|
foreach $dev_file ( @{ $self->{$mainkey}->{device_files} } ) { |
|
0
|
|
|
|
|
0
|
|
245
|
0
|
|
|
|
|
0
|
print "Mainkey : $mainkey\n"; |
246
|
0
|
|
|
|
|
0
|
print "Device File: $dev_file\n"; |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
sub get_disk_controllers { |
252
|
1
|
|
|
1
|
1
|
165
|
my $self = shift; |
253
|
1
|
|
|
|
|
2
|
my $debug = 1; |
254
|
1
|
|
|
|
|
2
|
my $mainkey; |
255
|
|
|
|
|
|
|
my $subkey; |
256
|
|
|
|
|
|
|
|
257
|
0
|
|
|
|
|
0
|
my @controllers; |
258
|
0
|
|
|
|
|
0
|
my @disks; |
259
|
|
|
|
|
|
|
|
260
|
1
|
|
|
|
|
2
|
foreach $mainkey ( keys %{ $self } ) { |
|
1
|
|
|
|
|
569
|
|
261
|
31
|
|
|
|
|
24
|
foreach $subkey ( keys %{ $self->{$mainkey} } ) { |
|
31
|
|
|
|
|
118
|
|
262
|
601
|
100
|
|
|
|
1143
|
if ($self->{$mainkey}->{$subkey} eq "ext_bus") { |
263
|
4
|
|
|
|
|
7
|
push @controllers, $mainkey; |
264
|
|
|
|
|
|
|
} |
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
} |
267
|
1
|
|
|
|
|
6
|
return \@controllers; |
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
sub get_all_disks_on_controller { |
271
|
1
|
|
|
1
|
1
|
136
|
my ($self, @subargs) = @_; |
272
|
|
|
|
|
|
|
|
273
|
1
|
|
|
|
|
4
|
my %arglist = ( |
274
|
|
|
|
|
|
|
controller => "" , |
275
|
|
|
|
|
|
|
@subargs, |
276
|
|
|
|
|
|
|
); |
277
|
1
|
|
|
|
|
1
|
my $debug=0; |
278
|
1
|
|
|
|
|
2
|
my $mainkey; |
279
|
|
|
|
|
|
|
my $subkey; |
280
|
0
|
|
|
|
|
0
|
my $subval; |
281
|
0
|
|
|
|
|
0
|
my $instance; |
282
|
0
|
|
|
|
|
0
|
my @disks; |
283
|
|
|
|
|
|
|
|
284
|
0
|
|
|
|
|
0
|
my $cval; # added to support device file sort |
285
|
0
|
|
|
|
|
0
|
my $tval; # added to support device file sort |
286
|
0
|
|
|
|
|
0
|
my $dval; # added to support device file sort |
287
|
0
|
|
|
|
|
0
|
my %devfile; #added to numerically sort device files |
288
|
0
|
|
|
|
|
0
|
my $devfile1; #temp variable in foreach loop |
289
|
0
|
|
|
|
|
0
|
my $total; # added to support device file sort |
290
|
0
|
|
|
|
|
0
|
my @sorted_disks; |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
# First find the instance |
293
|
|
|
|
|
|
|
|
294
|
1
|
|
|
|
|
3
|
$instance = $self->{ $arglist{controller} }->{card_instance}; |
295
|
1
|
50
|
|
|
|
3
|
print "Instance: $instance\n" if $debug; |
296
|
1
|
|
|
|
|
1
|
foreach $mainkey ( keys %{ $self } ) { |
|
1
|
|
|
|
|
6
|
|
297
|
31
|
50
|
|
|
|
48
|
print "MainKey: $mainkey\n" if $debug; |
298
|
31
|
|
|
|
|
29
|
while ( ($subkey, $subval)= sort each %{ $self->{ $mainkey } } ) { |
|
632
|
|
|
|
|
1877
|
|
299
|
601
|
50
|
|
|
|
1006
|
print "Subkey: $subkey\n" if $debug; |
300
|
601
|
50
|
|
|
|
868
|
print "Subval: $subval\n" if $debug; |
301
|
601
|
100
|
100
|
|
|
1339
|
if ( $subkey eq "class" && $subval eq "disk" && $self->{ $mainkey }->{card_instance} eq $instance ) { |
|
|
|
100
|
|
|
|
|
302
|
1
|
50
|
|
|
|
3
|
print "Gotta match of class, disk and instance\n" if $debug; |
303
|
1
|
50
|
|
|
|
3
|
print "This is what it is: @{ $self->{ $mainkey}->{device_files} }\n" if $debug; |
|
0
|
|
|
|
|
0
|
|
304
|
1
|
|
|
|
|
1
|
push @disks, ${ $self->{ $mainkey }->{device_files} }[0]; |
|
1
|
|
|
|
|
3
|
|
305
|
|
|
|
|
|
|
} |
306
|
|
|
|
|
|
|
} |
307
|
|
|
|
|
|
|
} |
308
|
1
|
|
|
|
|
69
|
while (<@disks>) { |
309
|
|
|
|
|
|
|
|
310
|
1
|
|
|
|
|
8
|
/c(\d+)t(\d+)d(\d+)/; |
311
|
|
|
|
|
|
|
|
312
|
1
|
|
|
|
|
3
|
$cval = $1; |
313
|
1
|
50
|
|
|
|
5
|
if ( length($cval) < 2 ) { $cval="0".$cval }; |
|
1
|
|
|
|
|
2
|
|
314
|
1
|
|
|
|
|
3
|
$tval = $2; |
315
|
1
|
50
|
|
|
|
5
|
if ( length($tval) < 2 ) { $tval="0".$tval }; |
|
1
|
|
|
|
|
2
|
|
316
|
1
|
|
|
|
|
3
|
$dval = $3; |
317
|
1
|
50
|
|
|
|
4
|
if ( length($dval) < 2 ) { $dval="0".$dval }; |
|
1
|
|
|
|
|
3
|
|
318
|
|
|
|
|
|
|
|
319
|
1
|
|
|
|
|
3
|
$total = $cval.$tval.$dval; |
320
|
1
|
50
|
|
|
|
3
|
print "total: $total\n" if $debug; |
321
|
|
|
|
|
|
|
|
322
|
1
|
|
|
|
|
6
|
$devfile{$total}=$_; |
323
|
|
|
|
|
|
|
} |
324
|
1
|
|
|
|
|
4
|
foreach $devfile1 ( sort keys %devfile ) { |
325
|
1
|
|
|
|
|
3
|
push @sorted_disks, $devfile{$devfile1}; |
326
|
|
|
|
|
|
|
} |
327
|
1
|
|
|
|
|
7
|
return \@sorted_disks; |
328
|
|
|
|
|
|
|
} |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
sub get_device_hwpath { |
331
|
0
|
|
|
0
|
1
|
|
my ($self, @subargs) = @_; |
332
|
|
|
|
|
|
|
|
333
|
0
|
|
|
|
|
|
my %arglist = ( |
334
|
|
|
|
|
|
|
device_name => "" , |
335
|
|
|
|
|
|
|
@subargs, |
336
|
|
|
|
|
|
|
); |
337
|
0
|
|
|
|
|
|
my $debug=0; |
338
|
0
|
|
|
|
|
|
my $mainkey; |
339
|
|
|
|
|
|
|
my $subkey; |
340
|
0
|
|
|
|
|
|
my $subval; |
341
|
0
|
|
|
|
|
|
my $device_name = $arglist{device_name}; |
342
|
0
|
|
|
|
|
|
my $hwpath; |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
# First find the instance |
345
|
|
|
|
|
|
|
|
346
|
0
|
|
|
|
|
|
foreach $mainkey ( sort keys %{ $self } ) { |
|
0
|
|
|
|
|
|
|
347
|
0
|
0
|
|
|
|
|
print "MainKey: $mainkey\n" if $debug; |
348
|
|
|
|
|
|
|
|
349
|
0
|
|
|
|
|
|
while ( ($subkey, $subval)= sort each %{ $self->{ $mainkey } } ) { |
|
0
|
|
|
|
|
|
|
350
|
0
|
0
|
|
|
|
|
print "Subkey: $subkey\n" if $debug; |
351
|
0
|
0
|
|
|
|
|
print "Subval: $subval\n" if $debug; |
352
|
0
|
0
|
|
|
|
|
if (defined ${ $self->{$mainkey}->{device_files} }[0]) { |
|
0
|
|
|
|
|
|
|
353
|
0
|
0
|
|
|
|
|
if ( ${ $self->{ $mainkey }->{device_files} }[0] eq "$device_name" ) { |
|
0
|
|
|
|
|
|
|
354
|
0
|
|
|
|
|
|
$hwpath = $self->{ $mainkey }->{hardware_path}; |
355
|
0
|
|
|
|
|
|
return $hwpath; |
356
|
|
|
|
|
|
|
} |
357
|
|
|
|
|
|
|
} |
358
|
|
|
|
|
|
|
} |
359
|
|
|
|
|
|
|
} |
360
|
0
|
|
|
|
|
|
$device_name=0; |
361
|
0
|
|
|
|
|
|
return undef; |
362
|
|
|
|
|
|
|
} |
363
|
|
|
|
|
|
|
1; |
364
|
|
|
|
|
|
|
__END__ |