summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mandriva.org>2009-06-19 13:43:13 +0000
committerPascal Terjan <pterjan@mandriva.org>2009-06-19 13:43:13 +0000
commita20652dde2e5d98c758cf868ab732257b42933a6 (patch)
treeef1a2b957dd07f3885753f7d7057989c0854a99f
parentc5cfca81e636cdbe5b0c2a3b9723f7524dcdee22 (diff)
downloaddrakx-a20652dde2e5d98c758cf868ab732257b42933a6.tar
drakx-a20652dde2e5d98c758cf868ab732257b42933a6.tar.gz
drakx-a20652dde2e5d98c758cf868ab732257b42933a6.tar.bz2
drakx-a20652dde2e5d98c758cf868ab732257b42933a6.tar.xz
drakx-a20652dde2e5d98c758cf868ab732257b42933a6.zip
lookup unlisted devices in /sys (or /proc) when looking for major/minor of a device (#49339)
-rw-r--r--perl-install/NEWS3
-rw-r--r--perl-install/devices.pm50
2 files changed, 28 insertions, 25 deletions
diff --git a/perl-install/NEWS b/perl-install/NEWS
index c496c25f2..67cf8beb0 100644
--- a/perl-install/NEWS
+++ b/perl-install/NEWS
@@ -1,4 +1,5 @@
-- handle virtio when looking for major/minor of a block device (#49339)
+- lookup unlisted devices in /sys (or /proc) when looking for
+ major/minor of a device (#49339)
Version 12.39 - 16 Jun 2009
diff --git a/perl-install/devices.pm b/perl-install/devices.pm
index 886e2e4f6..b6764bdd4 100644
--- a/perl-install/devices.pm
+++ b/perl-install/devices.pm
@@ -77,29 +77,6 @@ sub entry {
if (/^0x([\da-f]{3,4})$/i) {
$type = c::S_IFBLK();
($major, $minor) = unmakedev(hex $1);
- } elsif (/^([sv]d.)(\d{0,2})/) {
- my $path = $2 ? "/sys/block/$1/$1$2/dev" : "/sys/block/$1/dev";
- ($major, $minor) = split(':', chomp_(cat_($path)));
- $type = c::S_IFBLK();
- } elsif (/^hd(.)(\d{0,2})/) {
- $type = c::S_IFBLK();
- ($major, $minor) =
- @{ ${{'a' => [3, 0], 'b' => [3, 64],
- 'c' => [22,0], 'd' => [22,64],
- 'e' => [33,0], 'f' => [33,64],
- 'g' => [34,0], 'h' => [34,64],
- 'i' => [56,0], 'j' => [56,64],
- 'k' => [57,0], 'l' => [57,64],
- 'm' => [88,0], 'n' => [88,64],
- 'o' => [89,0], 'p' => [89,64],
- 'q' => [90,0], 'r' => [90,64],
- 's' => [91,0], 't' => [91,64],
- }}{$1} or internal_error("unknown device $_") };
- $minor += $2 || 0;
- } elsif (/^ram(.*)/) {
- $type = c::S_IFBLK();
- $major = 1;
- $minor = $1 eq '' ? 1 : $1;
} elsif (m|^rd/c(\d+)d(\d+)(p(\d+))?|) {
# dac 960 "rd/cXdXXpX"
$type = c::S_IFBLK();
@@ -164,8 +141,33 @@ sub entry {
"console" => [ c::S_IFCHR(), 5, 1 ],
"systty" => [ c::S_IFCHR(), 4, 0 ],
"lvm" => [ c::S_IFBLK(), 109, 0 ],
- }}{$_} or internal_error("unknown device $_") };
+ }}{$_} };
+ }
+ # Lookup non listed devices in /sys
+ unless ($type) {
+ my $sysdev;
+ if (m!input/(.*)! && -e "/sys/class/input/$1/dev") {
+ $sysdev = "/sys/class/input/$1/dev";
+ $type = c::S_IFCHR();
+ } elsif (-e "/sys/block/$_/dev") {
+ $sysdev = "/sys/block/$_/dev";
+ $type = c::S_IFBLK();
+ } elsif (/(.+)(\d+)$/ && -e "/sys/block/$1/$2/dev") {
+ $sysdev = "/sys/block/$_/dev";
+ $type = c::S_IFBLK();
+ }
+ ($major, $minor) = split(':', chomp_(cat_($sysdev)));
+ }
+ # Lookup partitions in /proc/partitions in case /sys was not available
+ unless ($type) {
+ if (-e "/proc/partitions") {
+ if (cat_("/proc/partitions") =~ /^\s*(\d+)\s+(\d+)\s+\d+\s+$_$/m) {
+ ($major, $minor) = ($1, $2);
+ $type = c::S_IFBLK();
+ }
+ }
}
+ $type or internal_error("unknown device $_");
($type, $major, $minor);
}