diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2004-08-03 05:41:59 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2004-08-03 05:41:59 +0000 |
commit | f8d30c05a05c1c01b3f8a758c54f4af07d7b114e (patch) | |
tree | 195d64c8532c126b49c0e71f649d08fbfe8f330b | |
parent | 607de8e2fa2b83e8b9cefd4ced24d3b4e24fc007 (diff) | |
download | drakx-backup-do-not-use-f8d30c05a05c1c01b3f8a758c54f4af07d7b114e.tar drakx-backup-do-not-use-f8d30c05a05c1c01b3f8a758c54f4af07d7b114e.tar.gz drakx-backup-do-not-use-f8d30c05a05c1c01b3f8a758c54f4af07d7b114e.tar.bz2 drakx-backup-do-not-use-f8d30c05a05c1c01b3f8a758c54f4af07d7b114e.tar.xz drakx-backup-do-not-use-f8d30c05a05c1c01b3f8a758c54f4af07d7b114e.zip |
many functions in fsedit don't modify anything, they are simply accessors.
create fs::get and move them into it
- device2part(), up_mount_point() moved from fs to fs::get
- part2hd(), file2part(), has_mntpoint(), mntpoint2part(), empty_all_hds() moved from fsedit to fs::get
- fsedit::get_root() -> fs::get::root()
- fsedit::get_root_() -> fs::get::root_()
- fsedit::get_really_all_fstab() -> fs::get::really_all_fstab()
- fsedit::get_all_fstab_and_holes() -> fs::get::fstab_and_holes()
- fsedit::get_all_fstab() -> fs::get::fstab()
- fsedit::get_all_holes() -> fs::get::holes()
- fsedit::all_free_space -> fs::get::free_space()
- fsedit::get_really_all_fstab() -> fs::get::really_all_fstab()
- fsedit::get_fstab_and_holes() -> fs::get::hds_fstab_and_holes()
- fsedit::get_holes() -> fs::get::hds_holes()
- fsedit::get_fstab() -> fs::get::hds_fstab()
- fsedit::free_space() -> fs::get::hds_free_space()
- fsedit::get_visible_fstab() unused, removed
25 files changed, 226 insertions, 232 deletions
diff --git a/perl-install/any.pm b/perl-install/any.pm index c0c25ed13..ddd6379a7 100644 --- a/perl-install/any.pm +++ b/perl-install/any.pm @@ -10,14 +10,13 @@ use common; use detect_devices; use partition_table; use fs::type; -use fsedit; -use fs; use lang; use run_program; use keyboard; use devices; use modules; use log; +use fs; use c; sub drakx_version() { @@ -159,7 +158,7 @@ sub setupBootloader__mbr_or_not { my @l = ( [ N("First sector of drive (MBR)") => '/dev/' . $hds->[0]{device} ], - [ N("First sector of the root partition") => '/dev/' . fsedit::get_root($fstab, 'boot')->{device} ], + [ N("First sector of the root partition") => '/dev/' . fs::get::root($fstab, 'boot')->{device} ], if_($floppy, [ N("On Floppy") => "/dev/$floppy" ], ), @@ -265,7 +264,7 @@ sub setupBootloader__general { } if ($prev_clean_tmp != $clean_tmp) { - if ($clean_tmp && !fsedit::has_mntpoint('/tmp', $all_hds)) { + if ($clean_tmp && !fs::get::has_mntpoint('/tmp', $all_hds)) { push @{$all_hds->{special}}, { device => 'none', mntpoint => '/tmp', fs_type => 'tmpfs' }; } else { @{$all_hds->{special}} = grep { $_->{mntpoint} ne '/tmp' } @{$all_hds->{special}}; @@ -344,7 +343,7 @@ sub setupBootloader__entries { N_("Other OS (MacOS...)") : N_("Other OS (Windows...)") ] ) eq "Linux") { $e = { type => 'image', - root => '/dev/' . fsedit::get_root($fstab)->{device}, #- assume a good default. + root => '/dev/' . fs::get::root($fstab)->{device}, #- assume a good default. }; $prefix = "linux"; } else { diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm index 8481d0445..2bcd76798 100644 --- a/perl-install/bootloader.pm +++ b/perl-install/bootloader.pm @@ -10,9 +10,9 @@ use vars qw(%vga_modes); use common; use partition_table; use fs::type; +use fs::get; use log; use any; -use fsedit; use devices; use loopback; use detect_devices; @@ -579,10 +579,10 @@ sub sanitize_ver { sub suggest { my ($bootloader, $hds, %options) = @_; - my $fstab = [ fsedit::get_fstab(@$hds) ]; - my $root_part = fsedit::get_root($fstab); + my $fstab = [ fs::get::hds_fstab(@$hds) ]; + my $root_part = fs::get::root($fstab); my $root = '/dev/' . (isLoopback($root_part) ? 'loop7' : $root_part->{device}); - my $boot = fsedit::get_root($fstab, 'boot')->{device}; + my $boot = fs::get::root($fstab, 'boot')->{device}; #- PPC xfs module requires enlarged initrd my $xfsroot = $root_part->{fs_type} eq 'xfs'; @@ -605,7 +605,7 @@ sub suggest { timeout => $onmbr && 10, nowarn => 1, if_(arch() !~ /ia64/, - boot => "/dev/" . ($onmbr ? $hds->[0]{device} : fsedit::get_root($fstab, 'boot')->{device}), + boot => "/dev/" . ($onmbr ? $hds->[0]{device} : fs::get::root($fstab, 'boot')->{device}), map => "/boot/map", color => 'black/cyan yellow/cyan', ), @@ -746,9 +746,9 @@ sub method_choices { my ($fstab) = @_; grep { - !(/lilo/ && isLoopback(fsedit::get_root($fstab))) + !(/lilo/ && isLoopback(fs::get::root($fstab))) && !(/lilo-graphic/ && detect_devices::matching_desc('ProSavageDDR')) - && !(/grub/ && isRAID(fsedit::get_root($fstab))); + && !(/grub/ && isRAID(fs::get::root($fstab))); } method_choices_raw(); } @@ -908,8 +908,8 @@ sub write_lilo { my $file2fullname = sub { my ($file) = @_; if (arch() =~ /ia64/) { - my $fstab = [ fsedit::get_fstab(@$hds) ]; - (my $part, $file) = fsedit::file2part($fstab, $file); + my $fstab = [ fs::get::hds_fstab(@$hds) ]; + (my $part, $file) = fs::get::file2part($fstab, $file); my %hds = map_index { $_ => "hd$::i" } map { $_->{device} } sort { my ($a_is_fat, $b_is_fat) = ($a->{fs_type} eq 'vfat', $b->{fs_type} eq 'vfat'); @@ -971,7 +971,7 @@ sub write_lilo { push @entry_conf, "unsafe" if $entry->{unsafe} && !$entry->{table}; if ($entry->{table}) { - my $hd = fs::device2part($entry->{table}, $hds); + my $hd = fs::get::device2part($entry->{table}, $hds); if ($hd != $sorted_hds[0]) { #- boot off the nth drive, so reverse the BIOS maps my $nb = sprintf("0x%x", 0x80 + (find_index { $hd == $_ } @sorted_hds)); @@ -1030,7 +1030,7 @@ sub mixed_kind_of_disks { sub sort_hds_according_to_bios { my ($bootloader, $hds) = @_; - my $boot_hd = fs::device2part($bootloader->{first_hd_device} || $bootloader->{boot}, $hds); #- $boot_hd is undefined when installing on floppy + my $boot_hd = fs::get::device2part($bootloader->{first_hd_device} || $bootloader->{boot}, $hds); #- $boot_hd is undefined when installing on floppy my $boot_kind = $boot_hd && hd2bios_kind($boot_hd); my $translate = sub { @@ -1043,9 +1043,9 @@ sub sort_hds_according_to_bios { sub device_string2grub { my ($dev, $legacy_floppies, $sorted_hds) = @_; - if (my $device = fs::device2part($dev, [ @$sorted_hds, fsedit::get_fstab(@$sorted_hds) ])) { + if (my $device = fs::get::device2part($dev, [ @$sorted_hds, fs::get::hds_fstab(@$sorted_hds) ])) { device2grub($device, $sorted_hds); - } elsif (my $floppy = fs::device2part($dev, $legacy_floppies)) { + } elsif (my $floppy = fs::get::device2part($dev, $legacy_floppies)) { my $bios = find_index { $floppy eq $_ } @$legacy_floppies; "(fd$bios)"; } else { @@ -1056,7 +1056,7 @@ sub device2grub { my ($device, $sorted_hds) = @_; my ($hd, $part_nb) = $device->{rootDevice} ? - (fs::device2part($device->{rootDevice}, $sorted_hds), $device->{device} =~ /(\d+)$/) : + (fs::get::device2part($device->{rootDevice}, $sorted_hds), $device->{device} =~ /(\d+)$/) : $device; my $bios = find_index { $hd eq $_ } @$sorted_hds; my $part_string = defined $part_nb ? ',' . ($part_nb - 1) : ''; @@ -1093,7 +1093,7 @@ sub grub2dev { sub grub2file { my ($grub_file, $grub2dev, $fstab) = @_; if (my ($device, $rel_file) = grub2dev_and_file($grub_file, $grub2dev)) { - my $part = fs::device2part($device, $fstab) or log::l("ERROR: unknown device $device (computed from $grub_file)"); + my $part = fs::get::device2part($device, $fstab) or log::l("ERROR: unknown device $device (computed from $grub_file)"); my $mntpoint = $part->{mntpoint} || ''; ($mntpoint eq '/' ? '' : $mntpoint) . '/' . $rel_file; } else { @@ -1104,14 +1104,14 @@ sub grub2file { sub write_grub { my ($bootloader, $hds) = @_; - my $fstab = [ fsedit::get_fstab(@$hds) ]; + my $fstab = [ fs::get::hds_fstab(@$hds) ]; my @legacy_floppies = detect_devices::floppies(); my @sorted_hds = sort_hds_according_to_bios($bootloader, $hds); write_grub_device_map(\@legacy_floppies, \@sorted_hds); my $file2grub = sub { - my ($part, $file) = fsedit::file2part($fstab, $_[0], 'keep_simple_symlinks'); + my ($part, $file) = fs::get::file2part($fstab, $_[0], 'keep_simple_symlinks'); device2grub($part, \@sorted_hds) . $file; }; { @@ -1146,7 +1146,7 @@ sub write_grub { push @conf, $title, "root $dev"; if ($_->{table}) { - if (my $hd = fs::device2part($_->{table}, \@sorted_hds)) { + if (my $hd = fs::get::device2part($_->{table}, \@sorted_hds)) { if (my $bios = find_index { $hd eq $_ } @sorted_hds) { #- boot off the nth drive, so reverse the BIOS maps my $nb = sprintf("0x%x", 0x80 + $bios); @@ -1211,7 +1211,7 @@ sub action { sub install { my ($bootloader, $hds) = @_; - if (my $part = fs::device2part($bootloader->{boot}, [ fsedit::get_fstab(@$hds) ])) { + if (my $part = fs::get::device2part($bootloader->{boot}, [ fs::get::hds_fstab(@$hds) ])) { die N("You can't install the bootloader on a %s partition\n", $part->{fs_type}) if $part->{fs_type} eq 'xfs'; } @@ -1239,7 +1239,7 @@ sub update_for_renumbered_partitions { my @sorted_hds; { my $grub2dev = read_grub_device_map(); map_each { - $sorted_hds[$1] = fs::device2part($::b, $hds) if $::a =~ /hd(\d+)/; + $sorted_hds[$1] = fs::get::device2part($::b, $hds) if $::a =~ /hd(\d+)/; } %$grub2dev; }; @@ -1266,7 +1266,7 @@ sub update_for_renumbered_partitions { } } - my $main_method = detect_main_method([ fsedit::get_fstab(@$hds) ]); + my $main_method = detect_main_method([ fs::get::hds_fstab(@$hds) ]); my @needed = $main_method ? $main_method : ('lilo', 'grub'); if (find { my $config = $_ eq 'grub' ? 'grub_install' : $_; diff --git a/perl-install/diskdrake/dav.pm b/perl-install/diskdrake/dav.pm index 7481cb631..1229d5f3f 100644 --- a/perl-install/diskdrake/dav.pm +++ b/perl-install/diskdrake/dav.pm @@ -4,8 +4,6 @@ use diagnostics; use strict; use diskdrake::interactive; use common; -use fsedit; -use fs; sub main { my ($in, $all_hds) = @_; diff --git a/perl-install/diskdrake/hd_gtk.pm b/perl-install/diskdrake/hd_gtk.pm index 8aff39d06..4af2a36a1 100644 --- a/perl-install/diskdrake/hd_gtk.pm +++ b/perl-install/diskdrake/hd_gtk.pm @@ -16,7 +16,6 @@ use raid; use any; use log; use fsedit; -use fs; my ($width, $height, $minwidth) = (400, 50, 5); my ($all_hds, $in, $do_force_reload, $current_kind, $current_entry, $update_all); @@ -76,7 +75,7 @@ sub main { $update_all = sub { $lock and return; $lock = 1; - partition_table::assign_device_numbers($_) foreach fsedit::all_hds($all_hds); + partition_table::assign_device_numbers($_) foreach fs::get::hds($all_hds); create_automatic_notebooks($notebook_widget); general_action_box($general_action_box, $nowizard, $interactive_help); per_kind_action_box($per_kind_action_box, $current_kind); @@ -217,7 +216,7 @@ sub current_kind_changed { my $v = $kind->{val}; my @parts = $kind->{type} eq 'raid' ? grep { $_ } @$v : - $kind->{type} eq 'loopback' ? @$v : fsedit::get_fstab_and_holes($v); + $kind->{type} eq 'loopback' ? @$v : fs::get::hds_fstab_and_holes($v); my $totalsectors = $kind->{type} =~ /raid|loopback/ ? sum(map { $_->{size} } @parts) : $v->{totalsectors}; create_buttons4partitions($kind, $totalsectors, @parts); @@ -341,7 +340,7 @@ sub filesystems_button_box() { sub createOrChangeType { my ($in, $fs_type, $hd, $part, $all_hds) = @_; - $part ||= !fsedit::get_fstab($hd) && + $part ||= !fs::get::hds_fstab($hd) && { pt_type => 0, start => 1, size => $hd->{totalsectors} - 1 }; $part or return; if ($fs_type eq 'other') { diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm index 53f006b87..5bf3e436c 100644 --- a/perl-install/diskdrake/interactive.pm +++ b/perl-install/diskdrake/interactive.pm @@ -15,7 +15,6 @@ use fsedit; use raid; use any; use log; -use fs; =begin @@ -184,14 +183,14 @@ sub main { while (1) { my $choose_txt = $current_part ? N_("Choose another partition") : N_("Choose a partition"); - my $parts_and_holes = [ fsedit::get_all_fstab_and_holes($all_hds) ]; + my $parts_and_holes = [ fs::get::fstab_and_holes($all_hds) ]; my $choose_part = sub { $current_part = $in->ask_from_listf('diskdrake', translate($choose_txt), sub { - my $hd = fsedit::part2hd($_[0] || return, $all_hds); + my $hd = fs::get::part2hd($_[0] || return, $all_hds); format_part_info_short($hd, $_[0]); }, $parts_and_holes, $current_part) || return; - $current_hd = fsedit::part2hd($current_part, $all_hds); + $current_hd = fs::get::part2hd($current_part, $all_hds); }; $choose_part->() if !$current_part; @@ -228,7 +227,7 @@ sub main { } else { $choose_part->(); } - partition_table::assign_device_numbers($_) foreach fsedit::all_hds($all_hds); + partition_table::assign_device_numbers($_) foreach fs::get::hds($all_hds); } return if eval { Done($in, $all_hds) }; if (my $err = $@) { @@ -604,7 +603,7 @@ sub Mount_point { my $mntpoint = $part->{mntpoint} || do { my $part_ = { %$part }; if (fsedit::suggest_part($part_, $all_hds)) { - fsedit::has_mntpoint('/', $all_hds) || $part_->{mntpoint} eq '/boot' ? $part_->{mntpoint} : '/'; + fs::get::has_mntpoint('/', $all_hds) || $part_->{mntpoint} eq '/boot' ? $part_->{mntpoint} : '/'; } else { '' } }; $in->ask_from_({ messages => @@ -973,7 +972,7 @@ sub Options { sub is_part_existing { my ($part, $all_hds) = @_; - $part && any { fsedit::are_same_partitions($part, $_) } fsedit::get_all_fstab_and_holes($all_hds); + $part && any { fsedit::are_same_partitions($part, $_) } fs::get::fstab_and_holes($all_hds); } sub modifyRAID { diff --git a/perl-install/diskdrake/removable.pm b/perl-install/diskdrake/removable.pm index d2c7ad32c..14eb26772 100644 --- a/perl-install/diskdrake/removable.pm +++ b/perl-install/diskdrake/removable.pm @@ -4,7 +4,6 @@ use diagnostics; use strict; use diskdrake::interactive; use common; -use fsedit; use fs; sub main { diff --git a/perl-install/diskdrake/smbnfs_gtk.pm b/perl-install/diskdrake/smbnfs_gtk.pm index 393245a8f..01b0074a1 100644 --- a/perl-install/diskdrake/smbnfs_gtk.pm +++ b/perl-install/diskdrake/smbnfs_gtk.pm @@ -4,7 +4,7 @@ use diagnostics; use strict; use any; -use fs; +use fs::get; use diskdrake::interactive; use common; use interactive; @@ -47,7 +47,7 @@ sub try_ { sub raw_hd_options { my ($in, $raw_hd) = @_; - diskdrake::interactive::Options($in, {}, $raw_hd, fsedit::empty_all_hds()); + diskdrake::interactive::Options($in, {}, $raw_hd, fs::get::empty_all_hds()); } sub raw_hd_mount_point { my ($in, $raw_hd) = @_; diff --git a/perl-install/fs.pm b/perl-install/fs.pm index 4e9312d4f..3f6d1619d 100644 --- a/perl-install/fs.pm +++ b/perl-install/fs.pm @@ -163,18 +163,10 @@ sub subpart_from_wild_device_name { { 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 { my ($all_hds, @l) = @_; - @l = merge_fstabs('', [ fsedit::get_really_all_fstab($all_hds) ], @l); + @l = merge_fstabs('', [ fs::get::really_all_fstab($all_hds) ], @l); foreach (@l) { my $s = @@ -227,7 +219,7 @@ sub merge_info_from_fstab { my @l = grep { if ($uniq) { - my $part = fsedit::mntpoint2part($_->{mntpoint}, $fstab); + my $part = fs::get::mntpoint2part($_->{mntpoint}, $fstab); !$part || fsedit::is_same_hd($part, $_); #- keep it only if it is the mountpoint AND the same device } else { 1; @@ -315,7 +307,7 @@ sub prepare_write_fstab { sub fstab_to_string { my ($all_hds, $o_prefix) = @_; - my $fstab = [ fsedit::get_really_all_fstab($all_hds), @{$all_hds->{special}} ]; + my $fstab = [ fs::get::really_all_fstab($all_hds), @{$all_hds->{special}} ]; my ($s, undef) = prepare_write_fstab($fstab, $o_prefix, 'keep_smb_credentials'); $s; } @@ -323,7 +315,7 @@ sub fstab_to_string { sub write_fstab { my ($all_hds, $o_prefix) = @_; log::l("writing $o_prefix/etc/fstab"); - my $fstab = [ fsedit::get_really_all_fstab($all_hds), @{$all_hds->{special}} ]; + my $fstab = [ fs::get::really_all_fstab($all_hds), @{$all_hds->{special}} ]; my ($s, $smb_credentials) = prepare_write_fstab($fstab, $o_prefix, ''); output("$o_prefix/etc/fstab", $s); network::smb::save_credentials($_) foreach @$smb_credentials; @@ -579,7 +571,7 @@ sub set_all_default_options { my ($all_hds, %opts) = @_; #- opts are: useSupermount security iocharset codepage - foreach my $part (fsedit::get_really_all_fstab($all_hds)) { + foreach my $part (fs::get::really_all_fstab($all_hds)) { set_default_options($part, %opts); } } @@ -642,7 +634,7 @@ sub formatMount_part { if (isLoopback($part)) { formatMount_part($part->{loopback_device}, $raids, $fstab, $prefix, $wait_message); } - if (my $p = up_mount_point($part->{mntpoint}, $fstab)) { + if (my $p = fs::get::up_mount_point($part->{mntpoint}, $fstab)) { formatMount_part($p, $raids, $fstab, $prefix, $wait_message) unless loopback::carryRootLoopback($part); } if ($part->{toFormat}) { @@ -662,7 +654,7 @@ sub formatMount_all { #- for fun :) #- that way, when install exits via ctrl-c, it gives hand to partition eval { - my ($_type, $major, $minor) = devices::entry(fsedit::get_root($fstab)->{device}); + my ($_type, $major, $minor) = devices::entry(fs::get::root($fstab)->{device}); output "/proc/sys/kernel/real-root-dev", makedev($major, $minor); }; } @@ -859,13 +851,4 @@ sub df { $part->{free}; } -sub up_mount_point { - my ($mntpoint, $fstab) = @_; - while (1) { - $mntpoint = dirname($mntpoint); - $mntpoint ne "." or return; - $_->{mntpoint} eq $mntpoint and return $_ foreach @$fstab; - } -} - 1; diff --git a/perl-install/fs/format.pm b/perl-install/fs/format.pm index ad4eebdd2..eb3f89be4 100644 --- a/perl-install/fs/format.pm +++ b/perl-install/fs/format.pm @@ -54,6 +54,7 @@ sub part_raw { $part->{isFormatted} and return; if ($part->{encrypt_key}) { + require fs; fs::set_loop($part); } diff --git a/perl-install/fs/get.pm b/perl-install/fs/get.pm new file mode 100644 index 000000000..5b5b75077 --- /dev/null +++ b/perl-install/fs/get.pm @@ -0,0 +1,128 @@ +package fs::get; # $Id$ + +use diagnostics; +use strict; + +use partition_table; +use fs::type; +use fs; +use common; +use log; + +sub empty_all_hds() { + { hds => [], lvms => [], raids => [], loopbacks => [], raw_hds => [], nfss => [], smbs => [], davs => [], special => [] }; +} +sub fstab { + my ($all_hds) = @_; + my @parts = map { partition_table::get_normal_parts($_) } hds($all_hds); + my @raids = grep { $_ } @{$all_hds->{raids}}; + @parts, @raids, @{$all_hds->{loopbacks}}; +} +sub really_all_fstab { + my ($all_hds) = @_; + my @l = fstab($all_hds); + @l, @{$all_hds->{raw_hds}}, @{$all_hds->{nfss}}, @{$all_hds->{smbs}}, @{$all_hds->{davs}}; +} + +sub fstab_and_holes { + my ($all_hds) = @_; + my @raids = grep { $_ } @{$all_hds->{raids}}; + hds_fstab_and_holes(hds($all_hds)), @raids, @{$all_hds->{loopbacks}}; +} + +sub holes { + my ($all_hds) = @_; + grep { $_->{pt_type} == 0 } fstab_and_holes($all_hds); +} +sub hds_holes { + grep { $_->{pt_type} == 0 } hds_fstab_and_holes(@_); +} +sub free_space { + my ($all_hds) = @_; + sum map { $_->{size} } holes($all_hds); +} +sub hds_free_space { + sum map { $_->{size} } hds_holes(@_); +} + +sub hds { + my ($all_hds) = @_; + (@{$all_hds->{hds}}, @{$all_hds->{lvms}}); +} + +#- get all normal partition including special ones as found on sparc. +sub hds_fstab { + map { partition_table::get_normal_parts($_) } @_; +} + +sub hds_fstab_and_holes { + map { + if (isLVM($_)) { + my @parts = partition_table::get_normal_parts($_); + my $free = $_->{totalsectors} - sum map { $_->{size} } @parts; + my $free_part = { start => 0, size => $free, pt_type => 0, rootDevice => $_->{VG_name} }; + @parts, if_($free >= $_->cylinder_size, $free_part); + } else { + partition_table::get_normal_parts_and_holes($_); + } + } @_; +} + + +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 part2hd { + my ($part, $all_hds) = @_; + my $hd = find { $part->{rootDevice} eq ($_->{device} || $_->{VG_name}) } hds($all_hds); + $hd; +} + +sub file2part { + my ($fstab, $file, $b_keep_simple_symlinks) = @_; + my $part; + + $file = $b_keep_simple_symlinks ? common::expand_symlinks_but_simple("$::prefix$file") : expand_symlinks("$::prefix$file"); + unless ($file =~ s/^$::prefix//) { + my $part = find { loopback::carryRootLoopback($_) } @$fstab or die; + log::l("found $part->{mntpoint}"); + $file =~ s|/initrd/loopfs|$part->{mntpoint}|; + } + foreach (@$fstab) { + my $m = $_->{mntpoint}; + $part = $_ if + $file =~ /^\Q$m/ && + (!$part || length $part->{mntpoint} < length $m); + } + $part or die "file2part: not found $file"; + $file =~ s|$part->{mntpoint}/?|/|; + ($part, $file); +} + +sub mntpoint2part { + my ($mntpoint, $fstab) = @_; + find { $mntpoint eq $_->{mntpoint} } @$fstab; +} +sub has_mntpoint { + my ($mntpoint, $all_hds) = @_; + mntpoint2part($mntpoint, [ really_all_fstab($all_hds) ]); +} +sub root_ { + my ($fstab, $o_boot) = @_; + $o_boot && mntpoint2part("/boot", $fstab) || mntpoint2part("/", $fstab); +} +sub root { &root_ || {} } + +sub up_mount_point { + my ($mntpoint, $fstab) = @_; + while (1) { + $mntpoint = dirname($mntpoint); + $mntpoint ne "." or return; + $_->{mntpoint} eq $mntpoint and return $_ foreach @$fstab; + } +} diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm index 26051f800..7fae25536 100644 --- a/perl-install/fsedit.pm +++ b/perl-install/fsedit.pm @@ -12,7 +12,6 @@ use partition_table; use partition_table::raw; use fs::type; use detect_devices; -use fsedit; use devices; use loopback; use log; @@ -52,19 +51,16 @@ my @suggestions_mntpoints = ( #-###################################################################################### #- Functions #-###################################################################################### -sub empty_all_hds() { - { hds => [], lvms => [], raids => [], loopbacks => [], raw_hds => [], nfss => [], smbs => [], davs => [], special => [] }; -} sub recompute_loopbacks { my ($all_hds) = @_; - my @fstab = get_all_fstab($all_hds); + my @fstab = fs::get::fstab($all_hds); @{$all_hds->{loopbacks}} = map { isPartOfLoopback($_) ? @{$_->{loopback}} : () } @fstab; } sub raids { my ($hds) = @_; - my @parts = get_fstab(@$hds); + my @parts = fs::get::hds_fstab(@$hds); { my @l = grep { isRawRAID($_) } @parts or return []; detect_devices::raidAutoStart(@l); @@ -120,7 +116,7 @@ sub raids { sub lvms { my ($all_hds) = @_; - my @pvs = grep { isRawLVM($_) } get_all_fstab($all_hds) or return; + my @pvs = grep { isRawLVM($_) } fs::get::fstab($all_hds) or return; #- otherwise vgscan won't find them devices::make($_->{device}) foreach @pvs; @@ -256,11 +252,11 @@ Do you agree to lose all the partitions? #- detect raids before LVM allowing LVM on raid my $raids = raids(\@hds); - my $all_hds = { %{ empty_all_hds() }, hds => \@hds, raw_hds => \@raw_hds, lvms => [], raids => $raids }; + my $all_hds = { %{ fs::get::empty_all_hds() }, hds => \@hds, raw_hds => \@raw_hds, lvms => [], raids => $raids }; $all_hds->{lvms} = [ lvms($all_hds) ]; - fs::get_major_minor(get_all_fstab($all_hds)); + fs::get_major_minor(fs::get::fstab($all_hds)); $all_hds; } @@ -303,16 +299,6 @@ sub read_proc_partitions { @$parts; } -sub all_hds { - my ($all_hds) = @_; - (@{$all_hds->{hds}}, @{$all_hds->{lvms}}); -} -sub part2hd { - my ($part, $all_hds) = @_; - my $hd = find { $part->{rootDevice} eq ($_->{device} || $_->{VG_name}) } all_hds($all_hds); - $hd; -} - sub is_same_hd { my ($hd1, $hd2) = @_; if ($hd1->{major} && $hd2->{major}) { @@ -336,90 +322,12 @@ sub are_same_partitions { 1; } -#- get all normal partition including special ones as found on sparc. -sub get_fstab { - map { partition_table::get_normal_parts($_) } @_; -} - -#- get normal partition that should be visible for working on. -sub get_visible_fstab { - grep { $_ && !isWholedisk($_) && !isHiddenMacPart($_) } - map { partition_table::get_normal_parts($_) } @_; -} - -sub get_fstab_and_holes { - map { - if (isLVM($_)) { - my @parts = partition_table::get_normal_parts($_); - my $free = $_->{totalsectors} - sum map { $_->{size} } @parts; - my $free_part = { start => 0, size => $free, pt_type => 0, rootDevice => $_->{VG_name} }; - @parts, if_($free >= $_->cylinder_size, $free_part); - } else { - partition_table::get_normal_parts_and_holes($_); - } - } @_; -} -sub get_holes { - grep { $_->{pt_type} == 0 } get_fstab_and_holes(@_); -} - -sub get_all_fstab { - my ($all_hds) = @_; - my @parts = map { partition_table::get_normal_parts($_) } all_hds($all_hds); - my @raids = grep { $_ } @{$all_hds->{raids}}; - @parts, @raids, @{$all_hds->{loopbacks}}; -} -sub get_really_all_fstab { - my ($all_hds) = @_; - my @parts = map { partition_table::get_normal_parts($_) } all_hds($all_hds); - my @raids = grep { $_ } @{$all_hds->{raids}}; - @parts, @raids, @{$all_hds->{loopbacks}}, @{$all_hds->{raw_hds}}, @{$all_hds->{nfss}}, @{$all_hds->{smbs}}, @{$all_hds->{davs}}; -} -sub get_all_fstab_and_holes { - my ($all_hds) = @_; - my @raids = grep { $_ } @{$all_hds->{raids}}; - get_fstab_and_holes(all_hds($all_hds)), @raids, @{$all_hds->{loopbacks}}; -} -sub get_all_holes { - my ($all_hds) = @_; - grep { $_->{pt_type} == 0 } get_all_fstab_and_holes($all_hds); -} - -sub all_free_space { - my ($all_hds) = @_; - sum map { $_->{size} } get_all_holes($all_hds); -} -sub free_space { - sum map { $_->{size} } get_holes(@_); -} - sub is_one_big_fat_or_NT { my ($hds) = @_; @$hds == 1 or return; - my @l = get_fstab(@$hds); - @l == 1 && isFat_or_NTFS($l[0]) && free_space(@$hds) < 10 << 11; -} - -sub file2part { - my ($fstab, $file, $b_keep_simple_symlinks) = @_; - my $part; - - $file = $b_keep_simple_symlinks ? common::expand_symlinks_but_simple("$::prefix$file") : expand_symlinks("$::prefix$file"); - unless ($file =~ s/^$::prefix//) { - my $part = find { loopback::carryRootLoopback($_) } @$fstab or die; - log::l("found $part->{mntpoint}"); - $file =~ s|/initrd/loopfs|$part->{mntpoint}|; - } - foreach (@$fstab) { - my $m = $_->{mntpoint}; - $part = $_ if - $file =~ /^\Q$m/ && - (!$part || length $part->{mntpoint} < length $m); - } - $part or die "file2part: not found $file"; - $file =~ s|$part->{mntpoint}/?|/|; - ($part, $file); + my @l = fs::get::hds_fstab(@$hds); + @l == 1 && isFat_or_NTFS($l[0]) && fs::get::hds_free_space(@$hds) < 10 << 11; } @@ -428,7 +336,7 @@ sub computeSize { my $max = $part->{maxsize} || $part->{size}; return min($max, $best->{size}) unless $best->{ratio}; - my $free_space = all_free_space($all_hds); + my $free_space = fs::get::free_space($all_hds); my @l = my @L = grep { if ($free_space >= $_->{size}) { $free_space -= $_->{size}; @@ -450,7 +358,7 @@ sub computeSize { return min($max, $best->{maxsize}) if $best->{mntpoint} eq $_->{mntpoint}; $free_space -= $_->{maxsize} - $_->{size}; if (!$cylinder_size_maxsize_adjusted++) { - eval { $free_space += part2hd($part, $all_hds)->cylinder_size - 1 }; + eval { $free_space += fs::get::part2hd($part, $all_hds)->cylinder_size - 1 }; } 0; } else { @@ -472,10 +380,10 @@ sub suggest_part { fs::type::set_pt_type($_, $_->{pt_type}) if !exists $_->{fs_type}; } - my $has_swap = any { isSwap($_) } get_all_fstab($all_hds); + my $has_swap = any { isSwap($_) } fs::get::fstab($all_hds); my @local_suggestions = - grep { !has_mntpoint($_->{mntpoint}, $all_hds) || isSwap($_) && !$has_swap } + grep { !fs::get::has_mntpoint($_->{mntpoint}, $all_hds) || isSwap($_) && !$has_swap } grep { !$_->{hd} || $_->{hd} eq $part->{rootDevice} } @$suggestions; @@ -498,24 +406,10 @@ sub suggest_part { sub suggestions_mntpoint { my ($all_hds) = @_; - sort grep { !/swap/ && !has_mntpoint($_, $all_hds) } + sort grep { !/swap/ && !fs::get::has_mntpoint($_, $all_hds) } (@suggestions_mntpoints, map { $_->{mntpoint} } @{$suggestions{server} || $suggestions{simple}}); } -sub mntpoint2part { - my ($mntpoint, $fstab) = @_; - find { $mntpoint eq $_->{mntpoint} } @$fstab; -} -sub has_mntpoint { - my ($mntpoint, $all_hds) = @_; - mntpoint2part($mntpoint, [ get_really_all_fstab($all_hds) ]); -} -sub get_root_ { - my ($fstab, $o_boot) = @_; - $o_boot && mntpoint2part("/boot", $fstab) || mntpoint2part("/", $fstab); -} -sub get_root { &get_root_ || {} } - #- you can do this before modifying $part->{mntpoint} #- so $part->{mntpoint} should not be used here, use $mntpoint instead sub check_mntpoint { @@ -524,16 +418,16 @@ sub check_mntpoint { $mntpoint eq '' || isSwap($part) || isNonMountable($part) and return; $mntpoint =~ m|^/| or die N("Mount points must begin with a leading /"); $mntpoint =~ m|[\x7f-\xff]| and cdie N("Mount points should contain only alphanumerical characters"); - mntpoint2part($mntpoint, [ grep { $_ ne $part } get_really_all_fstab($all_hds) ]) and die N("There is already a partition with mount point %s\n", $mntpoint); + fs::get::mntpoint2part($mntpoint, [ grep { $_ ne $part } fs::get::really_all_fstab($all_hds) ]) and die N("There is already a partition with mount point %s\n", $mntpoint); cdie N("You've selected a software RAID partition as root (/). No bootloader is able to handle this without a /boot partition. -Please be sure to add a /boot partition") if $mntpoint eq "/" && isRAID($part) && !has_mntpoint("/boot", $all_hds); +Please be sure to add a /boot partition") if $mntpoint eq "/" && isRAID($part) && !fs::get::has_mntpoint("/boot", $all_hds); die N("You can't use a LVM Logical Volume for mount point %s", $mntpoint) if $mntpoint eq '/boot' && isLVM($hd); cdie N("You've selected a LVM Logical Volume as root (/). The bootloader is not able to handle this without a /boot partition. -Please be sure to add a /boot partition") if $mntpoint eq "/" && isLVM($part) && !has_mntpoint("/boot", $all_hds); +Please be sure to add a /boot partition") if $mntpoint eq "/" && isLVM($part) && !fs::get::has_mntpoint("/boot", $all_hds); cdie N("You may not be able to install lilo (since lilo doesn't handle a LV on multiple PVs)") if 0; # arch() =~ /i.86/ && $mntpoint eq '/' && isLVM($hd) && @{$hd->{disks} || []} > 1; @@ -571,12 +465,12 @@ sub add { sub allocatePartitions { my ($all_hds, $to_add) = @_; - foreach my $part_ (get_all_holes($all_hds)) { + foreach my $part_ (fs::get::holes($all_hds)) { my ($start, $size, $dev) = @$part_{"start", "size", "rootDevice"}; my $part; while (suggest_part($part = { start => $start, size => 0, maxsize => $size, rootDevice => $dev }, $all_hds, $to_add)) { - my $hd = part2hd($part, $all_hds); + my $hd = fs::get::part2hd($part, $all_hds); add($hd, $part, $all_hds, {}); $size -= $part->{size} + $part->{start} - $start; $start = $part->{start} + $part->{size}; @@ -586,7 +480,7 @@ sub allocatePartitions { sub auto_allocate { my ($all_hds, $o_suggestions) = @_; - my $before = listlength(get_all_fstab($all_hds)); + my $before = listlength(fs::get::fstab($all_hds)); my $suggestions = $o_suggestions || $suggestions{simple}; allocatePartitions($all_hds, $suggestions); @@ -603,9 +497,9 @@ sub auto_allocate { partition_table::assign_device_numbers($_) foreach @{$all_hds->{hds}}; - if ($before == listlength(get_all_fstab($all_hds))) { + if ($before == listlength(fs::get::fstab($all_hds))) { # find out why auto_allocate failed - if (any { !has_mntpoint($_->{mntpoint}, $all_hds) } @$suggestions) { + if (any { !fs::get::has_mntpoint($_->{mntpoint}, $all_hds) } @$suggestions) { die N("Not enough free space for auto-allocating"); } else { die N("Nothing to do"); @@ -616,7 +510,7 @@ sub auto_allocate { sub auto_allocate_raids { my ($all_hds, $suggestions) = @_; - my @raids = grep { isRawRAID($_) } get_all_fstab($all_hds) or return; + my @raids = grep { isRawRAID($_) } fs::get::fstab($all_hds) or return; require raid; my @mds = grep { $_->{hd} =~ /md/ } @$suggestions; @@ -636,7 +530,7 @@ sub auto_allocate_raids { sub auto_allocate_vgs { my ($all_hds, $suggestions) = @_; - my @pvs = grep { isRawLVM($_) } get_all_fstab($all_hds) or return; + my @pvs = grep { isRawLVM($_) } fs::get::fstab($all_hds) or return; my @vgs = grep { $_->{VG_name} } @$suggestions or return; diff --git a/perl-install/install2.pm b/perl-install/install2.pm index 0ffa83454..5b3211dd3 100644 --- a/perl-install/install2.pm +++ b/perl-install/install2.pm @@ -15,7 +15,6 @@ use install_any; use lang; use keyboard; use mouse; -use fsedit; use devices; use partition_table; use modules; @@ -162,10 +161,10 @@ sub formatPartitions { $o->{steps}{choosePackages}{done} = 0; installStepsCall($o, $auto, 'choosePartitionsToFormat', $o->{fstab}) if !$o->{isUpgrade}; - my $want_root_formated = fsedit::get_root($o->{fstab})->{toFormat}; + my $want_root_formated = fs::get::root($o->{fstab})->{toFormat}; if ($want_root_formated) { foreach ('/usr') { - my $part = fsedit::mntpoint2part($_, $o->{fstab}) or next; + my $part = fs::get::mntpoint2part($_, $o->{fstab}) or next; $part->{toFormat} or die N("You must also format %s", $_); } } diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index 5c30dcf40..661de041d 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -25,7 +25,6 @@ use detect_devices; use lang; use any; use log; -use fs; #- boot medium (the first medium to take into account). $boot_medium = 1; @@ -476,7 +475,7 @@ sub setDefaultPackages { push @{$o->{default_packages}}, "raidtools" if !is_empty_array_ref($o->{all_hds}{raids}); push @{$o->{default_packages}}, "lvm2" if !is_empty_array_ref($o->{all_hds}{lvms}); push @{$o->{default_packages}}, "alsa", "alsa-utils" if any { $o->{modules_conf}->get_alias("sound-slot-$_") =~ /^snd-/ } 0 .. 4; - push @{$o->{default_packages}}, "grub" if isLoopback(fsedit::get_root($o->{fstab})); + push @{$o->{default_packages}}, "grub" if isLoopback(fs::get::root($o->{fstab})); push @{$o->{default_packages}}, uniq(grep { $_ } map { fs::format::package_needed_for_partition_type($_) } @{$o->{fstab}}); #- if no cleaning needed, populate by default, clean is used for second or more call to this function. @@ -1067,7 +1066,7 @@ sub suggest_mount_points { my ($mnt, $handle) = guess_mount_point($part, $prefix, \$user) or next; - next if $uniq && fsedit::mntpoint2part($mnt, $fstab); + next if $uniq && fs::get::mntpoint2part($mnt, $fstab); $part->{mntpoint} = $mnt; delete $part->{unsafeMntpoint}; #- try to find other mount points via fstab @@ -1096,7 +1095,7 @@ sub use_root_part { my $handle = any::inspect($part, $prefix) or die; fs::get_info_from_fstab($all_hds, $handle->{dir}); } - isSwap($_) and $_->{mntpoint} = 'swap' foreach fsedit::get_really_all_fstab($all_hds); #- use all available swap. + isSwap($_) and $_->{mntpoint} = 'swap' foreach fs::get::really_all_fstab($all_hds); #- use all available swap. } sub getHds { @@ -1117,7 +1116,7 @@ sub getHds { fs::add2all_hds($all_hds, @{$o->{manualFstab}}); $o->{all_hds} = $all_hds; - $o->{fstab} = [ fsedit::get_really_all_fstab($all_hds) ]; + $o->{fstab} = [ fs::get::really_all_fstab($all_hds) ]; fs::merge_info_from_mtab($o->{fstab}); my @win = grep { isFat_or_NTFS($_) && maybeFormatted($_) && !$_->{is_removable} } @{$o->{fstab}}; diff --git a/perl-install/install_interactive.pm b/perl-install/install_interactive.pm index 79d768736..14a791e1f 100644 --- a/perl-install/install_interactive.pm +++ b/perl-install/install_interactive.pm @@ -13,7 +13,6 @@ use install_any; use devices; use fsedit; use log; -use fs; sub tellAboutProprietaryModules { @@ -42,7 +41,7 @@ sub partition_with_diskdrake { do { $ok = 1; my $do_force_reload = sub { - $o->{all_hds} = fsedit::empty_all_hds(); + $o->{all_hds} = fs::get::empty_all_hds(); install_any::getHds($o, $o); $all_hds = $o->{all_hds}; $o->{all_hds}; @@ -56,9 +55,9 @@ sub partition_with_diskdrake { partitionWizard($o, 'nodiskdrake') or redo; return 1; } - my @fstab = fsedit::get_all_fstab($all_hds); + my @fstab = fs::get::fstab($all_hds); - unless (fsedit::get_root_(\@fstab)) { + unless (fs::get::root_(\@fstab)) { $ok = 0; $o->ask_okcancel('', N("You must have a root partition. For this, create a partition (or click on an existing one). @@ -67,7 +66,7 @@ Then choose action ``Mount point'' and set it to `/'"), 1) or return; if (!any { isSwap($_) } @fstab) { $ok &&= $o->ask_okcancel('', N("You don't have a swap partition.\n\nContinue anyway?")); } - if (arch() =~ /ia64/ && !fsedit::has_mntpoint("/boot/efi", $all_hds)) { + if (arch() =~ /ia64/ && !fs::get::has_mntpoint("/boot/efi", $all_hds)) { $o->ask_warn('', N("You must have a FAT partition mounted in /boot/efi")); $ok = ''; } @@ -78,7 +77,7 @@ Then choose action ``Mount point'' and set it to `/'"), 1) or return; sub partitionWizardSolutions { my ($o, $all_hds) = @_; my $hds = $all_hds->{hds}; - my $fstab = [ fsedit::get_all_fstab($all_hds) ]; + my $fstab = [ fs::get::fstab($all_hds) ]; my @wizlog; my (%solutions); @@ -92,12 +91,12 @@ sub partitionWizardSolutions { my @hds_rw = grep { !$_->{readonly} } @$hds; my @hds_can_add = grep { $_->can_raw_add } @hds_rw; - if (fsedit::free_space(@hds_can_add) > $min_linux) { + if (fs::get::hds_free_space(@hds_can_add) > $min_linux) { $solutions{free_space} = [ 20, N("Use free space"), sub { fsedit::auto_allocate($all_hds); 1 } ] } else { push @wizlog, N("Not enough free space to allocate new partitions") . ": " . (@hds_can_add ? - fsedit::free_space(@hds_can_add) . " < $min_linux" : + fs::get::hds_free_space(@hds_can_add) . " < $min_linux" : "no harddrive on which partitions can be added"); } @@ -133,14 +132,14 @@ sub partitionWizardSolutions { } - if (my @ok_for_resize_fat = grep { isFat_or_NTFS($_) && !fsedit::part2hd($_, $all_hds)->{readonly} } @$fstab) { + if (my @ok_for_resize_fat = grep { isFat_or_NTFS($_) && !fs::get::part2hd($_, $all_hds)->{readonly} } @$fstab) { $solutions{resize_fat} = [ 6 - @ok_for_resize_fat, N("Use the free space on the Windows partition"), sub { my $part = $o->ask_from_listf_raw({ messages => N("Which partition do you want to resize?"), interactive_help_id => 'resizeFATChoose', }, \&partition_table::description, \@ok_for_resize_fat) or return; - my $hd = fsedit::part2hd($part, $all_hds); + my $hd = fs::get::part2hd($part, $all_hds); my $resize_fat = eval { my $pkg = $part->{fs_type} eq 'vfat' ? do { require resize_fat::main; diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm index 8ee2cceef..96b5c6021 100644 --- a/perl-install/install_steps.pm +++ b/perl-install/install_steps.pm @@ -22,7 +22,6 @@ use do_pkgs; use pkgs; use any; use log; -use fs; our @ISA = qw(do_pkgs); @@ -168,7 +167,7 @@ sub selectInstallClass { if ($o->{partitioning}{use_existing_root} || $o->{isUpgrade}) { # either one root is defined (and all is ok), or we take the first one we find - my $p = fsedit::get_root_($o->{fstab}) || (first(install_any::find_root_parts($o->{fstab}, $o->{prefix})) || die)->{part}; + my $p = fs::get::root_($o->{fstab}) || (first(install_any::find_root_parts($o->{fstab}, $o->{prefix})) || die)->{part}; install_any::use_root_part($o->{all_hds}, $p, $o->{prefix}); } } @@ -197,14 +196,14 @@ sub doPartitionDisksAfter { fs::set_all_default_options($o->{all_hds}, %$o, lang::fs_options($o->{locale})) if !$o->{isUpgrade}; - $o->{fstab} = [ fsedit::get_all_fstab($o->{all_hds}) ]; - fsedit::get_root_($o->{fstab}) or die "Oops, no root partition"; + $o->{fstab} = [ fs::get::fstab($o->{all_hds}) ]; + fs::get::root_($o->{fstab}) or die "Oops, no root partition"; if (arch() =~ /ppc/ && detect_devices::get_mac_generation() =~ /NewWorld/) { die "Need bootstrap partition to boot system!" if !(defined $partition_table::mac::bootstrap_part); } - if (arch() =~ /ia64/ && !fsedit::has_mntpoint("/boot/efi", $o->{all_hds})) { + if (arch() =~ /ia64/ && !fs::get::has_mntpoint("/boot/efi", $o->{all_hds})) { die N("You must have a FAT partition mounted in /boot/efi"); } diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm index 962c59328..8b7357375 100644 --- a/perl-install/install_steps_interactive.pm +++ b/perl-install/install_steps_interactive.pm @@ -29,7 +29,6 @@ use modules::interactive; use lang; use keyboard; use any; -use fs; use log; #-###################################################################################### @@ -265,7 +264,7 @@ sub ask_mntpoint_s { #- }{} [ map { { label => partition_table::description($_), val => \$_->{mntpoint}, not_edit => 0, - list => [ '', fsedit::suggestions_mntpoint(fsedit::empty_all_hds()) ] } + list => [ '', fsedit::suggestions_mntpoint(fs::get::empty_all_hds()) ] } } grep { !$_->{real_mntpoint} || common::usingRamdisk() } @fstab ]) or return; } $o->SUPER::ask_mntpoint_s($fstab); diff --git a/perl-install/loopback.pm b/perl-install/loopback.pm index bdb580a8b..3be5a87bb 100644 --- a/perl-install/loopback.pm +++ b/perl-install/loopback.pm @@ -10,7 +10,6 @@ use MDK::Common::System; use common; use fs::type; use fs; -use fsedit; use log; @@ -23,14 +22,14 @@ sub carryRootLoopback { sub check_circular_mounts { my ($_hd, $part, $all_hds) = @_; - my $fstab = [ fsedit::get_all_fstab($all_hds), $part ]; # no pb if $part is already in $all_hds + my $fstab = [ fs::get::fstab($all_hds), $part ]; # no pb if $part is already in $all_hds my $base_mntpoint = $part->{mntpoint}; my $check; $check = sub { my ($part, @seen) = @_; push @seen, $part->{mntpoint} || return; @seen > 1 && $part->{mntpoint} eq $base_mntpoint and die N("Circular mounts %s\n", join(", ", @seen)); - if (my $part = fs::up_mount_point($part->{mntpoint}, $fstab)) { + if (my $part = fs::get::up_mount_point($part->{mntpoint}, $fstab)) { #- '/' carrier is a special case, it will be mounted first $check->($part, @seen) if !carryRootLoopback($part); } diff --git a/perl-install/lvm.pm b/perl-install/lvm.pm index baf8e6f00..23a069565 100644 --- a/perl-install/lvm.pm +++ b/perl-install/lvm.pm @@ -8,7 +8,6 @@ use strict; #-###################################################################################### use common; use modules; -use fsedit; use devices; use fs::type; use run_program; diff --git a/perl-install/network/netconnect.pm b/perl-install/network/netconnect.pm index e08914a7e..d3aac8101 100644 --- a/perl-install/network/netconnect.pm +++ b/perl-install/network/netconnect.pm @@ -7,6 +7,7 @@ use detect_devices; use run_program; use modules; use any; +use fs; use mouse; use network::network; use network::tools; diff --git a/perl-install/network/tools.pm b/perl-install/network/tools.pm index 0e5439594..bdfa8a13a 100644 --- a/perl-install/network/tools.pm +++ b/perl-install/network/tools.pm @@ -3,6 +3,7 @@ package network::tools; # $Id$ use strict; use common; use run_program; +use fsedit; use c; use vars qw(@ISA @EXPORT @EXPORT_OK); use MDK::Common::System qw(getVarsFromSh); @@ -156,7 +157,7 @@ sub use_windows { my ($file) = @_; my $all_hds = fsedit::get_hds({}, undef); fs::get_info_from_fstab($all_hds, ''); - my $part = find { $_->{device_windobe} eq 'C' } fsedit::get_fstab(@{$all_hds->{hds}}); + my $part = find { $_->{device_windobe} eq 'C' } fs::get::fstab($all_hds); $part or my $failed = N("No partition available"); my $source = find { -d $_ && -r "$_/$file" } map { "$part->{mntpoint}/$_" } qw(windows/system winnt/system windows/system32/drivers winnt/system32/drivers); log::explanations($failed || "Seek in $source to find firmware"); diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm index e9bdfb4fc..caa231238 100644 --- a/perl-install/partition_table.pm +++ b/perl-install/partition_table.pm @@ -7,7 +7,6 @@ use common; use fs::type; use partition_table::raw; use detect_devices; -use fs::type; use log; our @fields2save = qw(primary extended totalsectors isDirty will_tell_kernel); diff --git a/perl-install/standalone/bootloader-config b/perl-install/standalone/bootloader-config index 56245dcd3..cf2fbcb56 100755 --- a/perl-install/standalone/bootloader-config +++ b/perl-install/standalone/bootloader-config @@ -57,7 +57,7 @@ my $all_hds = fsedit::get_hds(); fs::get_info_from_fstab($all_hds, ''); my $hds = $all_hds->{hds}; -my $bootloader = bootloader::read([ fsedit::get_fstab(@$hds) ]) or die "Cannot find a boot loader installed\n"; +my $bootloader = bootloader::read([ fs::get::fstab($all_hds) ]) or die "Cannot find a boot loader installed\n"; $action =~ s/-/_/g; @@ -100,7 +100,7 @@ sub add_kernel() { my $kernel_str = bootloader::vmlinuz2kernel_str($image); - my $root_part = fsedit::get_root([ fsedit::get_fstab(@$hds) ]); + my $root_part = fs::get::root([ fs::get::fstab($all_hds) ]); my %opts = ( root => "/dev/$root_part->{device}", initrd_options => $initrd_options, diff --git a/perl-install/standalone/diskdrake b/perl-install/standalone/diskdrake index f8fbda251..870d115b0 100755 --- a/perl-install/standalone/diskdrake +++ b/perl-install/standalone/diskdrake @@ -74,12 +74,12 @@ my $all_hds = fsedit::get_hds({}, $in); fs::get_raw_hds('', $all_hds); fs::get_info_from_fstab($all_hds, ''); -fs::merge_info_from_mtab([ fsedit::get_really_all_fstab($all_hds) ]); +fs::merge_info_from_mtab([ fs::get::really_all_fstab($all_hds) ]); $all_hds->{current_fstab} = fs::fstab_to_string($all_hds, ''); if ($type eq 'list-hd') { - print partition_table::description($_), "\n" foreach fsedit::get_all_fstab($all_hds); + print partition_table::description($_), "\n" foreach fs::get::fstab($all_hds); } elsif ($type eq 'change-geometry') { $para =~ s|^/dev/||; my ($device, undef, $heads, $sectors) = $para =~ /(.+)=(\d+,)?(\d+),(\d+)$/ or die "usage: diskdrake --change-geometry=<device>=[<cylinders>,]<heads>,<sectors>\n"; @@ -100,7 +100,7 @@ if ($type eq 'list-hd') { if (!$raw_hd->{mntpoint}) { my $mntpoint = detect_devices::suggest_mount_point($raw_hd); - $raw_hd->{mntpoint} ||= find { !fsedit::has_mntpoint($_, $all_hds) } map { "/mnt/$mntpoint$_" } '', 2 .. 10; + $raw_hd->{mntpoint} ||= find { !fs::get::has_mntpoint($_, $all_hds) } map { "/mnt/$mntpoint$_" } '', 2 .. 10; $raw_hd->{is_removable} = 1; #- force removable flag my $useSupermount = 'magicdev'; diff --git a/perl-install/standalone/drakboot b/perl-install/standalone/drakboot index b03056148..d6b72bdde 100755 --- a/perl-install/standalone/drakboot +++ b/perl-install/standalone/drakboot @@ -44,7 +44,7 @@ my $in = 'interactive'->vnew('su'); my $all_hds = fsedit::get_hds(); fs::get_raw_hds('', $all_hds); fs::get_info_from_fstab($all_hds, ''); -my $fstab = [ fsedit::get_all_fstab($all_hds) ]; +my $fstab = [ fs::get::fstab($all_hds) ]; my $bootloader = bootloader::read($fstab); if (!$in->isa('interactive::gtk') || any { /^--boot$/ } @ARGV) { diff --git a/perl-install/standalone/drakupdate_fstab b/perl-install/standalone/drakupdate_fstab index 77c07ef89..711df4e45 100755 --- a/perl-install/standalone/drakupdate_fstab +++ b/perl-install/standalone/drakupdate_fstab @@ -108,7 +108,7 @@ sub set_mount_point { $mntpoint = "/mnt/$mntpoint"; foreach ('', 2 .. 10) { - next if fsedit::mntpoint2part("$mntpoint$_", $fstab); + next if fs::get::mntpoint2part("$mntpoint$_", $fstab); $part->{mntpoint} = "$mntpoint$_"; return 1; } |