summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2003-06-24 08:28:20 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2003-06-24 08:28:20 +0000
commitfb99dc7d1bc34c5d8a57d27410a47f24e1ef2454 (patch)
tree28dda586ce0e106bce78309670f711fe332645b5
parent770f6285158aa54966b9fbf220e16db58f7babc8 (diff)
downloaddrakx-fb99dc7d1bc34c5d8a57d27410a47f24e1ef2454.tar
drakx-fb99dc7d1bc34c5d8a57d27410a47f24e1ef2454.tar.gz
drakx-fb99dc7d1bc34c5d8a57d27410a47f24e1ef2454.tar.bz2
drakx-fb99dc7d1bc34c5d8a57d27410a47f24e1ef2454.tar.xz
drakx-fb99dc7d1bc34c5d8a57d27410a47f24e1ef2454.zip
- move read_proc_partitions_raw() from fsedit.pm to devices.pm
- (devices::from_devfs, devices::from_devfs) handle block devices too, with read_proc_partitions_raw() helper
-rw-r--r--perl-install/devices.pm20
-rw-r--r--perl-install/fsedit.pm16
2 files changed, 20 insertions, 16 deletions
diff --git a/perl-install/devices.pm b/perl-install/devices.pm
index e3ecc3185..c4b6126ce 100644
--- a/perl-install/devices.pm
+++ b/perl-install/devices.pm
@@ -201,7 +201,19 @@ sub to_devfs {
my $r = $to_devfs_prefix{$1};
return "$r$2" if $r;
}
- undef;
+ readlink("/dev/" . $dev);
+}
+
+sub read_proc_partitions_raw() {
+ my (undef, undef, @all) = cat_("/proc/partitions");
+ grep {
+ $_->{size} != 1 && # skip main extended partition
+ $_->{size} != 0x3fffffff # skip cdroms (otherwise stops cd-audios)
+ } map {
+ my %l;
+ @l{qw(major minor size dev)} = split;
+ \%l;
+ } @all;
}
sub from_devfs {
@@ -214,7 +226,11 @@ sub from_devfs {
my $r = $from_devfs_prefix{$1};
return "$r$2" if $r;
}
- undef;
+ $dev = "/dev/" . $dev;
+ if (-e $dev) {
+ my ($major, $minor) = unmakedev((stat($dev))[6]);
+ (find { $_->{major} == $major && $_->{minor} == $minor } read_proc_partitions_raw())->{dev};
+ }
}
1;
diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm
index be136e0aa..e6c8873a0 100644
--- a/perl-install/fsedit.pm
+++ b/perl-install/fsedit.pm
@@ -119,7 +119,7 @@ sub raids {
device => "md$nb", notFormatted => !$type, level => $level };
}
- my %devname2part = map { $_->{dev} => { %$_, device => $_->{dev} } } read_proc_partitions_raw();
+ my %devname2part = map { $_->{dev} => { %$_, device => $_->{dev} } } devices::read_proc_partitions_raw();
each_index {
my $raw_mdparts = delete $_->{raw_mdparts};
my @mdparts =
@@ -258,22 +258,10 @@ Do you agree to loose all the partitions?
}
}
-sub read_proc_partitions_raw() {
- my (undef, undef, @all) = cat_("/proc/partitions");
- grep {
- $_->{size} != 1 && # skip main extended partition
- $_->{size} != 0x3fffffff # skip cdroms (otherwise stops cd-audios)
- } map {
- my %l;
- @l{qw(major minor size dev)} = split;
- \%l;
- } @all;
-}
-
sub read_proc_partitions {
my ($hds) = @_;
- my @all = read_proc_partitions_raw();
+ my @all = devices::read_proc_partitions_raw();
my @parts = grep { $_->{dev} =~ /\d$/ } @all;
my @disks = grep { $_->{dev} !~ /\d$/ } @all;