summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2002-03-11 17:18:16 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2002-03-11 17:18:16 +0000
commit3d4b77b51c4830844b14dd0b3bceae2bdfefb4b5 (patch)
tree8a2544d40eef817c628b98027dbcd2db038d09ad
parent52692356c991723e364db31d48e5ac96a14ba7ac (diff)
downloaddrakx-backup-do-not-use-3d4b77b51c4830844b14dd0b3bceae2bdfefb4b5.tar
drakx-backup-do-not-use-3d4b77b51c4830844b14dd0b3bceae2bdfefb4b5.tar.gz
drakx-backup-do-not-use-3d4b77b51c4830844b14dd0b3bceae2bdfefb4b5.tar.bz2
drakx-backup-do-not-use-3d4b77b51c4830844b14dd0b3bceae2bdfefb4b5.tar.xz
drakx-backup-do-not-use-3d4b77b51c4830844b14dd0b3bceae2bdfefb4b5.zip
Reverted parts of the last change, they broke in non-DevFS environments (e. g. during installation).
-rw-r--r--perl-install/detect_devices.pm120
1 files changed, 51 insertions, 69 deletions
diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm
index 99bb57928..ada7297d6 100644
--- a/perl-install/detect_devices.pm
+++ b/perl-install/detect_devices.pm
@@ -455,76 +455,58 @@ sub whatUsbport() {
my $realport = devices::make("$port");
next if (!$realport);
next if (! -r $realport);
- # Try up to three times, sometimes the IOCTL request fails.
- my $j;
- for ($j = 0; $j < 3; $j ++) {
- open PORT, "$realport" or do { sleep 1; next; };
- my $idstr = "";
- # Calculation of IOCTL function 0x84005001 (to get device ID
- # string):
- # len = 1024
- # IOCNR_GET_DEVICE_ID = 1
- # LPIOC_GET_DEVICE_ID(len) =
- # _IOC(_IOC_READ, 'P', IOCNR_GET_DEVICE_ID, len)
- # _IOC(), _IOC_READ as defined in /usr/include/asm/ioctl.h
- # Use "eval" so that program does not stop when IOCTL fails
- eval{ my $output = "\0" x 1024;
- ioctl(PORT, 0x84005001, $output);
- $idstr = $output; } or do {
- close PORT;
- sleep 1;
- next;
- };
- close PORT;
- # Remove non-printable characters
- $idstr =~ tr/[\x00-\x1f]/\./;
- # Extract the printer data from the ID string
- my ($manufacturer, $model, $description) = ("", "", "");
- if (($idstr =~ /MFG:([^;]+);/) ||
- ($idstr =~ /MANUFACTURER:([^;]+);/)) {
- $manufacturer = $1;
- $manufacturer =~ s/Hewlett[-\s_]Packard/HP/;
- $manufacturer =~ s/HEWLETT[-\s_]PACKARD/HP/;
- }
- if (($idstr =~ /MDL:([^;]+);/) ||
- ($idstr =~ /MODEL:([^;]+);/)) {
- $model = $1;
- }
- if (($idstr =~ /DES:([^;]+);/) ||
- ($idstr =~ /DESCRIPTION:([^;]+);/)) {
- $description = $1;
- $description =~ s/Hewlett[-\s_]Packard/HP/;
- $description =~ s/HEWLETT[-\s_]PACKARD/HP/;
- }
- # Was there a manufacturer and a model in the string?
- if (($manufacturer eq "") || ($model eq "")) {
- sleep 1;
- next;
- }
- # No description field? Make one out of manufacturer and model.
- if ($description eq "") {
- $description = "$manufacturer $model";
- }
- # Store this auto-detection result in the data structure
- push @res, { port => $port, val =>
- { CLASS => 'PRINTER',
- MODEL => $model,
- MANUFACTURER => $manufacturer,
- DESCRIPTION => $description,
- }};
- # We have succeded for this device, do not try again
- last;
- }
- if ($j == 3) {
- # There is a printer, but it did not reply with a usable ID
- # string
- push @res, { port => $port, val =>
- { CLASS => 'PRINTER',
- MODEL => _("Unknown model"),
- MANUFACTURER => "",
- DESCRIPTION => _("Unknown model"),
- }};
+ open PORT, "$realport" or do next;
+ my $idstr = "";
+ # Calculation of IOCTL function 0x84005001 (to get device ID
+ # string):
+ # len = 1024
+ # IOCNR_GET_DEVICE_ID = 1
+ # LPIOC_GET_DEVICE_ID(len) =
+ # _IOC(_IOC_READ, 'P', IOCNR_GET_DEVICE_ID, len)
+ # _IOC(), _IOC_READ as defined in /usr/include/asm/ioctl.h
+ # Use "eval" so that program does not stop when IOCTL fails
+ eval{ my $output = "\0" x 1024;
+ ioctl(PORT, 0x84005001, $output);
+ $idstr = $output; } or do {
+ close PORT;
+ next;
+ };
+ close PORT;
+ # Remove non-printable characters
+ $idstr =~ tr/[\x00-\x1f]/\./;
+ # Extract the printer data from the ID string
+ my ($manufacturer, $model, $description) = ("", "", "");
+ if (($idstr =~ /MFG:([^;]+);/) ||
+ ($idstr =~ /MANUFACTURER:([^;]+);/)) {
+ $manufacturer = $1;
+ $manufacturer =~ s/Hewlett[-\s_]Packard/HP/;
+ $manufacturer =~ s/HEWLETT[-\s_]PACKARD/HP/;
+ }
+ if (($idstr =~ /MDL:([^;]+);/) ||
+ ($idstr =~ /MODEL:([^;]+);/)) {
+ $model = $1;
+ }
+ if (($idstr =~ /DES:([^;]+);/) ||
+ ($idstr =~ /DESCRIPTION:([^;]+);/)) {
+ $description = $1;
+ $description =~ s/Hewlett[-\s_]Packard/HP/;
+ $description =~ s/HEWLETT[-\s_]PACKARD/HP/;
+ }
+ # Was there a manufacturer and a model in the string?
+ if (($manufacturer eq "") || ($model eq "")) {
+ next;
+ }
+ # No description field? Make one out of manufacturer and model.
+ if ($description eq "") {
+ $description = "$manufacturer $model";
}
+ # Store this auto-detection result in the data structure
+ push @res, { port => $port, val =>
+ { CLASS => 'PRINTER',
+ MODEL => $model,
+ MANUFACTURER => $manufacturer,
+ DESCRIPTION => $description,
+ }};
}
@res;
}