3 # ScsiDev -- the probed values for a SCSI device, as found in /sys.
4 # Copyright (C) 2005 Erik van Konijnenburg
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # Like IDE devices, SCSI devices need a protocol driver, based
21 # on device type, without hardware probing and matching against
22 # a kernel generated table.
24 # The type and module knowledge is based in /etc/hotplug/scsi.agent,
25 # that attributes scsi/scsi.h.
36 $self->takeArgs ('path');
37 my $path = $self->path;
38 my $name = readlink ("$path/block");
39 if (defined ($name)) {
40 $name = Base::basename ($name);
41 $self->{name} = $name;
44 $self->{name} = undef;
46 $self->{vendor} = Base::getStringFile ("$path/vendor");
47 $self->{model} = Base::getStringFile ("$path/model");
49 my $type = Base::getStringFile ("$path/type");
50 $self->{type} = "disk" if $type eq '0';
51 $self->{type} = "tape" if $type eq '1';
52 $self->{type} = "printer" if $type eq '2';
53 $self->{type} = "processor" if $type eq '3';
54 $self->{type} = "worm" if $type eq '4';
55 $self->{type} = "cdrom" if $type eq '5';
56 $self->{type} = "scanner" if $type eq '6';
57 $self->{type} = "mod" if $type eq '7';
58 $self->{type} = "changer" if $type eq '8';
59 $self->{type} = "comm" if $type eq '9';
60 $self->{type} = "enclosure" if $type eq '14';
61 $self->{type} = "type$type" if (!defined ($self->{type}));
64 sub path { return $_[0]->{path}; }
65 sub name { return $_[0]->{name}; }
66 sub vendor { return $_[0]->{vendor}; }
67 sub model { return $_[0]->{model}; }
68 sub type { return $_[0]->{type}; }
72 my $path = $self->path();
73 my $name = $self->name();
74 my $vendor = $self->vendor();
75 my $model = $self->model();
76 my $type = $self->type();
77 $name = "---" if (! defined ($name));
78 return "$name ($type) = $vendor, $model at $path";
83 # findModuleByScsiDev -- list of required SCSI drivers
85 sub findModuleByScsiDev ($) {
87 my $type = $scsiDev->type();
89 $driver = "sd-mod" if $type eq "disk";
90 # "FIXME some tapes use 'osst'"
91 $driver = "st" if $type eq "tape";
92 # if $type eq "printer";
93 # if $type eq "processor";
94 $driver = "sr-mod" if $type eq "worm";
95 $driver = "sr-mod" if $type eq "cdrom";
96 # if $type eq "scanner";
97 $driver = "sd-mod" if $type eq "mod";
98 # if $type eq "changer";
100 # if $type eq "enclosure";
101 $driver = "sg" if (! defined ($driver));