summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-07-09 22:48:50 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-07-09 22:48:50 +0000
commita9ac8c788ca39dada84b48444ae77d8f067c740a (patch)
tree8083292b115629bbfe080d5b4dc44d6b5f80dbfd /perl-install
parentc24f9dfdd1534e69a9feedd1460c2f45970515eb (diff)
downloaddrakx-a9ac8c788ca39dada84b48444ae77d8f067c740a.tar
drakx-a9ac8c788ca39dada84b48444ae77d8f067c740a.tar.gz
drakx-a9ac8c788ca39dada84b48444ae77d8f067c740a.tar.bz2
drakx-a9ac8c788ca39dada84b48444ae77d8f067c740a.tar.xz
drakx-a9ac8c788ca39dada84b48444ae77d8f067c740a.zip
rewrite getSCSI, now handling scanners
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/detect_devices.pm56
1 files changed, 30 insertions, 26 deletions
diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm
index 893161f08..1f545520e 100644
--- a/perl-install/detect_devices.pm
+++ b/perl-install/detect_devices.pm
@@ -149,33 +149,37 @@ sub isFloppyOrHD {
}
sub getSCSI() {
- my @drives;
- my ($driveNum, $cdromNum, $tapeNum) = qw(0 0 0);
- my $err = sub { chop; die "unexpected line in /proc/scsi/scsi: $_"; };
- local $_;
+ my $err = sub { log::l("ERROR: unexpected line in /proc/scsi/scsi: $_[0]"); };
- local *F;
- open F, "/proc/scsi/scsi" or return;
- local $_ = <F>; /^Attached devices:/ or return &$err();
- while ($_ = <F>) {
- my ($id) = /^Host:.*?Id: (\d+)/ or return &$err();
- $_ = <F>; my ($vendor, $model) = /^\s*Vendor:\s*(.*?)\s+Model:\s*(.*?)\s+Rev:/ or return &$err();
- $_ = <F>; my ($type) = /^\s*Type:\s*(.*)/ or &$err();
- my $dev = { info => "$vendor $model", id => $id, bus => 0 };
- if ($type =~ /Direct-Access/) {
- $dev->{device} = "sd" . chr($driveNum++ + ord('a'));
- $dev->{media_type} = isZipDrive($dev) ? 'hd' : isFloppyOrHD($dev->{device});
- } elsif ($type =~ /Sequential-Access/) {
- $dev->{device} = "st" . $tapeNum++;
- $dev->{media_type} = 'tape';
- } elsif ($type =~ /(CD-ROM|WORM)/) {
- $dev->{device} = "scd" . $cdromNum++;
- $dev->{media_type} = 'cdrom';
- }
- push @drives, $dev if $dev->{device};
- }
- get_sys_cdrom_info(@drives);
- @drives;
+ my ($first, @l) = common::join_lines(cat_("/proc/scsi/scsi"));
+ $first =~ /^Attached devices:/ or $err->($first);
+
+ @l = map_index {
+ my ($id) = /^Host:.*?Id: (\d+)/ or $err->($_);
+ my ($vendor, $model) = /^\s*Vendor:\s*(.*?)\s+Model:\s*(.*?)\s+Rev:/m or $err->($_);
+ my ($type) = /^\s*Type:\s*(.*)/m or $err->($_);
+ { info => "$vendor $model", id => $id, bus => 0, device => "sg$::i", raw_type => $type };
+ } @l;
+
+ each_index {
+ my $dev = "sd" . chr($::i + ord('a'));
+ put_in_hash $_, { device => $dev, media_type => isZipDrive($_) ? 'hd' : isFloppyOrHD($dev) };
+ } grep { $_->{raw_type} =~ /Direct-Access/ } @l;
+
+ each_index {
+ put_in_hash $_, { device => "st$::i", media_type => 'tape' };
+ } grep { $_->{raw_type} =~ /Sequential-Access/ } @l;
+
+ each_index {
+ put_in_hash $_, { device => "scd$::i", media_type => 'cdrom' };
+ } grep { $_->{raw_type} =~ /CD-ROM|WORM/ } @l;
+
+ each_index {
+ put_in_hash $_, { media_type => 'scanner' };
+ } grep { $_->{raw_type} =~ /Scanner/ } @l;
+
+ get_sys_cdrom_info(@l);
+ @l;
}
sub getIDE() {