diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2004-06-25 05:08:11 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2004-06-25 05:08:11 +0000 |
commit | 03d73bbd5b9499943c9553c2a42f050ce7a43c5a (patch) | |
tree | d7ff3e34597c879ad700ffb20cf769fe0e69ba61 /perl-install/fs.pm | |
parent | 96ecfbd0955ddb86f22e1ef524edc4f502b65cc3 (diff) | |
download | drakx-03d73bbd5b9499943c9553c2a42f050ce7a43c5a.tar drakx-03d73bbd5b9499943c9553c2a42f050ce7a43c5a.tar.gz drakx-03d73bbd5b9499943c9553c2a42f050ce7a43c5a.tar.bz2 drakx-03d73bbd5b9499943c9553c2a42f050ce7a43c5a.tar.xz drakx-03d73bbd5b9499943c9553c2a42f050ce7a43c5a.zip |
- enhance subpart_from_wild_device_name() to handle "sda" the same as "/dev/sda" (when /dev/sda exists)
- new function device2part() which uses subpart_from_wild_device_name and the
given fstab to convert the device name to the corresponding structure
(this allows not relying too much on the device name)
Diffstat (limited to 'perl-install/fs.pm')
-rw-r--r-- | perl-install/fs.pm | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/perl-install/fs.pm b/perl-install/fs.pm index 0219aaaa6..62d286dc4 100644 --- a/perl-install/fs.pm +++ b/perl-install/fs.pm @@ -128,33 +128,47 @@ sub subpart_from_wild_device_name { my ($dev) = @_; if ($dev =~ /^LABEL=(.*)/) { - { device_LABEL => $1 }; - } elsif ($dev =~ m,^/(tmp|dev)/,) { - my %part; - ($part{major}, $part{minor}) = unmakedev((stat "$::prefix$dev")[6]); - - if (my $symlink = readlink("$::prefix$dev")) { - if ($symlink =~ m|^[^/]+$|) { - $part{device_alias} = $dev; - $dev = $symlink; - } + return { device_LABEL => $1 }; + } elsif ($dev eq 'none') { + } elsif ($dev =~ m!^(\w+):/\w!) { + #- nfs + } elsif ($dev =~ m!^//\w!) { + #- smb + } elsif ($dev =~ m!^http://!) { + #- http + } else { + if ($dev !~ m!^/! && -e "$::prefix/dev/$dev") { + $dev = "/dev/$dev"; } - $dev =~ s,^/(tmp|dev)/,,; + if ($dev =~ m!^/(tmp|dev)/(.*)!) { + my %part; + ($part{major}, $part{minor}) = unmakedev((stat "$::prefix$dev")[6]); + + if (my $symlink = readlink("$::prefix$dev")) { + if ($symlink =~ m|^[^/]+$|) { + $part{device_alias} = $dev; + $dev = $symlink; + } + } + $dev =~ s!/(tmp|dev)/!!; - my $is_devfs = $dev =~ m!/(disc|part\d+)$!; - $part{$is_devfs ? 'devfs_device' : 'device'} = $dev; - \%part; - } else { - if ($dev eq 'none') { - } elsif ($dev =~ m!^(\w+):/\w!) { - #- nfs - } elsif ($dev =~ m!^//\w!) { - #- smb + my $is_devfs = $dev =~ m!/(disc|part\d+)$!; + $part{$is_devfs ? 'devfs_device' : 'device'} = $dev; + return \%part; } else { log::l("part_from_wild_device_name: unknown device $dev"); } - { device => $dev }; } + #- default + { device => $dev }; +} + +sub device2part { + my ($dev, $fstab) = @_; + my $subpart = fs::subpart_from_wild_device_name($dev); + my $part = find { fsedit::is_same_hd($subpart, $_) } @$fstab; + log::l("fs::device2part: unknown device <<$dev>>") if !$part; + $part; } sub add2all_hds { |