From 837e99171e20798228ce71d01cfe5bea971a222c Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Wed, 5 Oct 2005 17:43:07 +0000 Subject: (get_sysfs_usbpath_for_block) introduce it in order to factorize code (complete_usb_storage_info) use sane way for handling multiple USB disks of the same vendor (aka compare hosts) --- perl-install/detect_devices.pm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'perl-install/detect_devices.pm') diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm index 41ae7181f..44e0dff8b 100644 --- a/perl-install/detect_devices.pm +++ b/perl-install/detect_devices.pm @@ -141,8 +141,15 @@ sub complete_usb_storage_info { foreach my $usb (usb_probe()) { if (my $e = find { !$_->{found} && $_->{usb_vendor} == $usb->{vendor} && $_->{usb_id} == $usb->{id} } @usb) { + my $host = get_sysfs_usbpath_for_block($e->{device}); + if ($host) { + $e->{info} = chomp_(cat_("/sys/block/$e->{device}/$host/../serial")); + $e->{usb_description} = join('|', + chomp_(cat_("/sys/block/$e->{device}/$host/../manufacturer")), + chomp_(cat_("/sys/block/$e->{device}/$host/../product"))); + } local $e->{found} = 1; - $e->{"usb_$_"} = $usb->{$_} foreach keys %$usb; + $e->{"usb_$_"} ||= $usb->{$_} foreach keys %$usb; } } } @@ -192,13 +199,19 @@ sub may_be_a_hd { ); } +sub get_sysfs_usbpath_for_block { + my ($device) = @_; + my $host = readlink("/sys/block/$device/device"); + $host =~ s!/host.*!!; + $host; +} + sub get_scsi_driver { my (@l) = @_; # find driver of host controller from sysfs: foreach (@l) { next if $_->{driver}; - my $host = readlink("/sys/block/$_->{device}/device"); - $host =~ s!/host.*!!; + my $host = get_sysfs_usbpath_for_block($_->{device}); $_->{driver} = readlink("/sys/block/$_->{device}/$host/driver"); $_->{driver} =~ s!.*/!!; } -- cgit v1.2.1