summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2005-06-28 09:12:16 +0000
committerPascal Rigaux <pixel@mandriva.com>2005-06-28 09:12:16 +0000
commitf1323d79cc7dd3aa5f4ebde2e2744d7a7ad56180 (patch)
treec6a37cc1eadd4c1af23c7cda7924d1b42f500344
parent48dc83bc2acf770ec4be3e4be5f74a9d49120f65 (diff)
downloaddrakx-backup-do-not-use-f1323d79cc7dd3aa5f4ebde2e2744d7a7ad56180.tar
drakx-backup-do-not-use-f1323d79cc7dd3aa5f4ebde2e2744d7a7ad56180.tar.gz
drakx-backup-do-not-use-f1323d79cc7dd3aa5f4ebde2e2744d7a7ad56180.tar.bz2
drakx-backup-do-not-use-f1323d79cc7dd3aa5f4ebde2e2744d7a7ad56180.tar.xz
drakx-backup-do-not-use-f1323d79cc7dd3aa5f4ebde2e2744d7a7ad56180.zip
try to cleanup fs.pm
(to have simpler dependencies between modules, esp. have some modules only required by diskdrake): - move some functions from fs to fs::mount (most keep their name, except mount_part and mount_usbfs) - move formatMount_part and formatMount_all from fs to fs::format - move some functions from fs to fs::wild_device (part2wild_device_name -> fs::wild_device::from_part) (subpart_from_wild_device_name -> fs::wild_device::to_subpart) (analyze_wild_device_name -> fs::wild_device::analyse) - formatMount_part(), formatMount_all(), fs::mount::part() don't take a prefix anymore the current situation was quite muddy we now rely on fs::get::mntpoint_prefixed() which will maybe depend on a field in $part for now, we mount every part in chroot, it seems to be what's wanted - fs::format::part() now expect $all_hds instead of $raids - fs::type::carryRootLoopback is now fs::get::carry_root_loopback() - in fs::loopback, most functions don't want a prefix anymore
-rwxr-xr-xglobetrotter/make_live10
-rw-r--r--perl-install/any.pm4
-rw-r--r--perl-install/bootloader.pm2
-rw-r--r--perl-install/commands.pm14
-rw-r--r--perl-install/common.pm2
-rw-r--r--perl-install/diskdrake/interactive.pm10
-rw-r--r--perl-install/fs.pm328
-rw-r--r--perl-install/fs/dmraid.pm3
-rw-r--r--perl-install/fs/format.pm42
-rw-r--r--perl-install/fs/get.pm10
-rw-r--r--perl-install/fs/loopback.pm28
-rw-r--r--perl-install/fs/mount.pm197
-rw-r--r--perl-install/fs/type.pm5
-rw-r--r--perl-install/fs/wild_device.pm101
-rw-r--r--perl-install/install2.pm12
-rw-r--r--perl-install/install_any.pm24
-rw-r--r--perl-install/install_steps.pm20
-rw-r--r--perl-install/install_steps_interactive.pm2
-rw-r--r--perl-install/modules.pm2
-rw-r--r--perl-install/network/thirdparty.pm4
-rw-r--r--perl-install/partition_table.pm4
-rw-r--r--perl-install/pkgs.pm2
-rwxr-xr-xperl-install/standalone/bootloader-config2
-rwxr-xr-xperl-install/standalone/drakautoinst8
24 files changed, 430 insertions, 406 deletions
diff --git a/globetrotter/make_live b/globetrotter/make_live
index 8555b8397..3ec5bd109 100755
--- a/globetrotter/make_live
+++ b/globetrotter/make_live
@@ -312,7 +312,7 @@ sub installPackages() {
$ENV{LD_LIBRARY_PATH} = "/lib:/usr/lib:/usr/X11R6/lib:/usr/lib/qt3/lib";
pkgs::install(0, \@toInstall, $o->{packages});
- eval { fs::umount("$::prefix/proc") };
+ eval { fs::mount::umount("$::prefix/proc") };
}
sub config_X_proprietary_drivers() {
@@ -340,14 +340,14 @@ my $cleaner = before_leaving {
print "Cleaning on exiting\n";
print "- Umounting partitions:\n";
print "\tumounting /proc\n";
- eval { fs::umount("$::prefix/proc") };
+ eval { fs::mount::umount("$::prefix/proc") };
# fs::umount("$::prefix/$_") foreach 'mnt/packages', 'mnt/share', 'home', '';
if ($fstab) {
print "\tumounting everything else\n";
- eval { fs::umount_all($fstab, $::prefix) } or system("umount $::prefix");
+ eval { fs::mount::umount_all($fstab) } or system("umount $::prefix");
}
print "\tumounting /tmp\n";
- eval { fs::umount("/tmp") } if $rescue;
+ eval { fs::mount::umount("/tmp") } if $rescue;
print "Cleaning done\n";
};
@@ -382,7 +382,7 @@ run_program::run('tune2fs', '-L', "MDK-ROOT", "/dev/$root->{device}");
$fstab = [ fs::get::fstab($all_hds) ];
# we need to mount every fs we want to see into /etc/fstab !!!
-fs::mount_part($_, $::prefix) foreach sort { $a->{mntpoint} cmp $b->{mntpoint} } @$fstab;
+fs::mount::part($_) foreach sort { $a->{mntpoint} cmp $b->{mntpoint} } @$fstab;
symlink("$::prefix/mnt/packages", "/export") if $rescue;
diff --git a/perl-install/any.pm b/perl-install/any.pm
index 97953f608..77798e038 100644
--- a/perl-install/any.pm
+++ b/perl-install/any.pm
@@ -573,12 +573,12 @@ sub inspect {
$dir = '';
} else {
mkdir $dir, 0700;
- eval { fs::mount(fs::part2wild_device_name('', $part), $dir, $part->{fs_type}, !$b_rw) };
+ eval { fs::mount::mount(fs::wild_device::from_part('', $part), $dir, $part->{fs_type}, !$b_rw) };
$@ and return;
}
my $h = before_leaving {
if (!$part->{isMounted} && $dir) {
- fs::umount($dir);
+ fs::mount::umount($dir);
unlink($dir);
}
};
diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm
index 67ab14c00..505508fc0 100644
--- a/perl-install/bootloader.pm
+++ b/perl-install/bootloader.pm
@@ -714,7 +714,7 @@ sub suggest {
my ($bootloader, $all_hds, %options) = @_;
my $fstab = [ fs::get::fstab($all_hds) ];
my $root_part = fs::get::root($fstab);
- my $root = isLoopback($root_part) ? '/dev/loop7' : fs::part2wild_device_name('', $root_part);
+ my $root = isLoopback($root_part) ? '/dev/loop7' : fs::wild_device::from_part('', $root_part);
my $boot = fs::get::root($fstab, 'boot')->{device};
#- PPC xfs module requires enlarged initrd
my $xfsroot = $root_part->{fs_type} eq 'xfs';
diff --git a/perl-install/commands.pm b/perl-install/commands.pm
index b15b0a596..ff27efa79 100644
--- a/perl-install/commands.pm
+++ b/perl-install/commands.pm
@@ -63,8 +63,8 @@ sub tr_ {
sub umount {
@_ == 1 or die "umount expects a single argument\n";
- require fs;
- fs::umount($_[0]);
+ require fs::mount;
+ fs::mount::umount($_[0]);
}
sub mkdir_ {
@@ -139,13 +139,13 @@ sub chown_ {
sub swapon {
@_ == 1 or die "swapon <file>\n";
- require fs;
- fs::swapon($_[0]);
+ require fs::mount;
+ fs::mount::swapon($_[0]);
}
sub swapoff {
@_ == 1 or die "swapoff <file>\n";
- require fs;
- fs::swapoff($_[0]);
+ require fs::mount;
+ fs::mount::swapoff($_[0]);
}
sub rights {
@@ -437,7 +437,7 @@ sub bug {
require modules;
require fs;
modules::load_dependencies("/modules/modules.dep");
- fs::mount(devices::make(detect_devices::floppy()), '/fd0', 'vfat');
+ fs::mount::mount(devices::make(detect_devices::floppy()), '/fd0', 'vfat');
require install_any;
output("/fd0/report.bug", install_any::report_bug());
diff --git a/perl-install/common.pm b/perl-install/common.pm
index 3e7a2443d..8f3ad65c7 100644
--- a/perl-install/common.pm
+++ b/perl-install/common.pm
@@ -3,6 +3,8 @@ package common; # $Id$
use MDK::Common;
use diagnostics;
use strict;
+
+use log;
use run_program;
use Exporter;
diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm
index c59973220..a6349b9c5 100644
--- a/perl-install/diskdrake/interactive.pm
+++ b/perl-install/diskdrake/interactive.pm
@@ -573,7 +573,7 @@ First remove a primary partition and create an extended partition."));
if ($migrate_files eq 'migrate') {
format_($in, $hd, $part, $all_hds) or return;
migrate_files($in, $hd, $part);
- fs::mount_part($part);
+ fs::mount::part($part);
}
}
@@ -676,7 +676,7 @@ Remove the loopback first")), return 1;
if ($migrate_files eq 'migrate') {
format_($in, $hd, $part, $all_hds) or return;
migrate_files($in, $hd, $part);
- fs::mount_part($part);
+ fs::mount::part($part);
}
}
sub Mount_point_raw_hd {
@@ -827,7 +827,7 @@ sub Mount {
my ($in, $hd, $part) = @_;
write_partitions($in, $hd) or return;
my $w;
- fs::mount_part($part, $::prefix, 0, sub {
+ fs::mount::part($part, 0, sub {
my ($msg) = @_;
$w ||= $in->wait_message('', $msg);
$w->set($msg);
@@ -875,7 +875,7 @@ sub Add2LVM {
}
sub Unmount {
my ($_in, $_hd, $part) = @_;
- fs::umount_part($part);
+ fs::mount::umount_part($part);
}
sub RemoveFromRAID {
my ($_in, $_hd, $part, $all_hds) = @_;
@@ -1110,7 +1110,7 @@ sub format_ {
}
$part->{isFormatted} = 0; #- force format;
my ($_w, $wait_message) = fs::format::wait_message($in);
- fs::format::part($all_hds->{raids}, $part, $::prefix, $wait_message);
+ fs::format::part($all_hds, $part, $wait_message);
1;
}
diff --git a/perl-install/fs.pm b/perl-install/fs.pm
index aa4ba93f1..850538db5 100644
--- a/perl-install/fs.pm
+++ b/perl-install/fs.pm
@@ -11,6 +11,7 @@ use fs::get;
use fs::format;
use fs::mount_options;
use fs::loopback;
+use fs::mount;
use run_program;
use detect_devices;
use modules;
@@ -75,7 +76,7 @@ sub read_fstab {
if_(member('keep_freq_passno', @reading_options), freq => $freq, passno => $passno),
};
- put_in_hash($h, subpart_from_wild_device_name($dev));
+ put_in_hash($h, fs::wild_device::to_subpart($dev));
if ($h->{device_LABEL} && member('keep_device_LABEL', @reading_options)) {
$h->{prefer_device_LABEL} = 1;
@@ -126,98 +127,6 @@ sub merge_fstabs {
@l;
}
-sub analyze_wild_device_name {
- my ($dev) = @_;
-
- if ($dev =~ m!^/u?dev/(.*)!) {
- 'dev', $dev;
- } elsif ($dev !~ m!^/! && (-e "/dev/$dev" || -e "$::prefix/dev/$dev")) {
- 'dev', "/dev/$dev";
- } elsif ($dev =~ /^LABEL=(.*)/) {
- 'label', $1;
- } elsif ($dev eq 'none' || $dev eq 'rootfs') {
- 'virtual';
- } elsif ($dev =~ m!^(\S+):/\w!) {
- 'nfs';
- } elsif ($dev =~ m!^//\w!) {
- 'smb';
- } elsif ($dev =~ m!^http://!) {
- 'dav';
- }
-}
-
-sub subpart_from_wild_device_name {
- my ($dev) = @_;
-
- my $part = { device => $dev, faked_device => 1 }; #- default
-
- if (my ($kind, $val) = analyze_wild_device_name($dev)) {
- if ($kind eq 'label') {
- $part->{device_LABEL} = $val;
- } elsif ($kind eq 'dev') {
- my %part = (faked_device => 0);
- if (my $rdev = (stat "$::prefix$dev")[6]) {
- ($part{major}, $part{minor}) = unmakedev($rdev);
- }
-
- my $symlink = readlink("$::prefix$dev");
- $dev =~ s!/u?dev/!!;
-
- if ($symlink && $symlink =~ m|^[^/]+$|) {
- $part{device_alias} = $dev;
- $dev = $symlink;
- }
-
- if (my (undef, $part_number) = $dev =~ m!/(disc|part(\d+))$!) {
- $part{part_number} = $part_number if $part_number;
- $part{devfs_device} = $dev;
- } else {
- my $part_number = devices::part_number(\%part);
- $part{part_number} = $part_number if $part_number;
- }
- $part{device} = $dev;
- return \%part;
- }
- } else {
- if ($dev =~ m!^/! && -f "$::prefix$dev") {
- #- it must be a loopback file or directory to bind
- } else {
- log::l("part_from_wild_device_name: unknown device $dev");
- }
- }
- $part;
-}
-
-sub part2wild_device_name {
- my ($prefix, $part) = @_;
-
- if ($part->{prefer_device_LABEL}) {
- 'LABEL=' . $part->{device_LABEL};
- } elsif ($part->{prefer_devfs_name}) {
- "/dev/$part->{devfs_device}";
- } elsif ($part->{device_alias}) {
- "/dev/$part->{device_alias}";
- } else {
- my $faked_device = exists $part->{faked_device} ?
- $part->{faked_device} :
- do {
- #- in case $part has been created without using subpart_from_wild_device_name()
- my ($kind) = analyze_wild_device_name($part->{device});
- $kind ? $kind ne 'dev' : $part->{device} =~ m!^/!;
- };
- if ($faked_device) {
- $part->{device};
- } elsif ($part->{device} =~ m!^/dev/!) {
- log::l("ERROR: i have a full device $part->{device}, this should not happen. use subpart_from_wild_device_name() instead of creating bad part data-structures!");
- $part->{device};
- } else {
- my $dev = "/dev/$part->{device}";
- eval { devices::make("$prefix$dev") };
- $dev;
- }
- }
-}
-
sub add2all_hds {
my ($all_hds, @l) = @_;
@@ -302,17 +211,17 @@ sub prepare_write_fstab {
my $device =
isLoopback($_) ?
($_->{mntpoint} eq '/' ? "/initrd/loopfs" : $_->{loopback_device}{mntpoint}) . $_->{loopback_file} :
- part2wild_device_name($o_prefix, $_);
+ fs::wild_device::from_part($o_prefix, $_);
my $real_mntpoint = $_->{mntpoint} || ${{ '/tmp/hdimage' => '/mnt/hd' }}{$_->{real_mntpoint}};
mkdir_p("$o_prefix$real_mntpoint") if $real_mntpoint =~ m|^/|;
- my $mntpoint = fs::loopback::carryRootLoopback($_) ? '/initrd/loopfs' : $real_mntpoint;
+ my $mntpoint = fs::type::carry_root_loopback($_) ? '/initrd/loopfs' : $real_mntpoint;
my ($freq, $passno) =
exists $_->{freq} ?
($_->{freq}, $_->{passno}) :
isTrueLocalFS($_) && $_->{options} !~ /encryption=/ && (!$_->{is_removable} || member($_->{mntpoint}, fs::type::directories_needed_to_boot())) ?
- (1, $_->{mntpoint} eq '/' ? 1 : fs::loopback::carryRootLoopback($_) ? 0 : 2) :
+ (1, $_->{mntpoint} eq '/' ? 1 : fs::type::carry_root_loopback($_) ? 0 : 2) :
(0, 0);
if (($device eq 'none' || !$new{$device}) && ($mntpoint eq 'swap' || !$new{$mntpoint})) {
@@ -421,222 +330,6 @@ sub get_raw_hds {
];
}
-
-################################################################################
-# mounting functions
-################################################################################
-sub set_loop {
- my ($part) = @_;
- $part->{real_device} ||= devices::set_loop(devices::make($part->{device}), $part->{encrypt_key}, $part->{options} =~ /encryption=(\w+)/);
-}
-
-sub swapon {
- my ($dev) = @_;
- log::l("swapon called with $dev");
- syscall_('swapon', devices::make($dev), 0) or die "swapon($dev) failed: $!";
-}
-
-sub swapoff {
- my ($dev) = @_;
- syscall_('swapoff', devices::make($dev)) or die "swapoff($dev) failed: $!";
-}
-
-sub formatMount_part {
- my ($part, $raids, $fstab, $prefix, $wait_message) = @_;
-
- if (isLoopback($part)) {
- formatMount_part($part->{loopback_device}, $raids, $fstab, $prefix, $wait_message);
- }
- if (my $p = fs::get::up_mount_point($part->{mntpoint}, $fstab)) {
- formatMount_part($p, $raids, $fstab, $prefix, $wait_message) if !fs::loopback::carryRootLoopback($part);
- }
- if ($part->{toFormat}) {
- fs::format::part($raids, $part, $prefix, $wait_message);
- }
- mount_part($part, $prefix, 0, $wait_message);
-}
-
-sub formatMount_all {
- my ($raids, $fstab, $prefix, $wait_message) = @_;
- formatMount_part($_, $raids, $fstab, $prefix, $wait_message)
- foreach sort { isLoopback($a) ? 1 : isSwap($a) ? -1 : 0 } grep { $_->{mntpoint} } @$fstab;
-
- #- ensure the link is there
- fs::loopback::carryRootCreateSymlink($_, $prefix) foreach @$fstab;
-
- #- for fun :)
- #- that way, when install exits via ctrl-c, it gives hand to partition
- eval {
- my ($_type, $major, $minor) = devices::entry(fs::get::root($fstab)->{device});
- output "/proc/sys/kernel/real-root-dev", makedev($major, $minor);
- };
-}
-
-sub mount {
- my ($dev, $where, $fs, $b_rdonly, $o_options, $o_wait_message) = @_;
- log::l("mounting $dev on $where as type $fs, options $o_options");
-
- mkdir_p($where);
-
- $fs or log::l("not mounting $dev partition"), return;
-
- {
- my @fs_modules = qw(ext3 hfs jfs nfs ntfs romfs reiserfs ufs xfs vfat);
- my @types = (qw(ext2 proc sysfs usbfs usbdevfs iso9660 devfs devpts), @fs_modules);
-
- push @types, 'smb', 'smbfs', 'davfs' if !$::isInstall;
-
- if (!member($fs, @types) && !$::move) {
- log::l("skipping mounting $dev partition ($fs)");
- return;
- }
- if ($::isInstall) {
- if (member($fs, @fs_modules)) {
- eval { modules::load($fs) };
- } elsif ($fs eq 'iso9660') {
- eval { modules::load('isofs') };
- }
- }
- }
-
- $where =~ s|/$||;
-
- my @mount_opt = split(',', $o_options || '');
-
- if ($fs eq 'vfat') {
- @mount_opt = 'check=relaxed';
- } elsif ($fs eq 'nfs') {
- push @mount_opt, 'nolock', 'soft', 'intr' if $::isInstall;
- } elsif ($fs eq 'jfs' && !$b_rdonly) {
- fsck_jfs($dev, $o_wait_message);
- } elsif ($fs eq 'ext2' && !$b_rdonly) {
- fsck_ext2($dev, $o_wait_message);
- }
-
- push @mount_opt, 'ro' if $b_rdonly;
-
- log::l("calling mount -t $fs $dev $where @mount_opt");
- $o_wait_message->(N("Mounting partition %s", $dev)) if $o_wait_message;
- run_program::run('mount', '-t', $fs, $dev, $where, if_(@mount_opt, '-o', join(',', @mount_opt))) or die N("mounting partition %s in directory %s failed", $dev, $where);
-}
-
-sub fsck_ext2 {
- my ($dev, $o_wait_message) = @_;
- $o_wait_message->(N("Checking %s", $dev)) if $o_wait_message;
- foreach ('-a', '-y') {
- run_program::raw({ timeout => 60 * 60 }, "fsck.ext2", $_, $dev);
- my $err = $?;
- if ($err & 0x0100) {
- log::l("fsck corrected partition $dev");
- }
- if ($err & 0xfeff) {
- my $txt = sprintf("fsck failed on %s with exit code %d or signal %d", $dev, $err >> 8, $err & 255);
- $_ eq '-y' ? die($txt) : cdie($txt);
- } else {
- last;
- }
- }
-}
-sub fsck_jfs {
- my ($dev, $o_wait_message) = @_;
- $o_wait_message->(N("Checking %s", $dev)) if $o_wait_message;
- #- needed if the system is dirty otherwise mounting read-write simply fails
- run_program::raw({ timeout => 60 * 60 }, "fsck.jfs", $dev) or do {
- my $err = $?;
- die "fsck.jfs failed" if $err & 0xfc00;
- };
-}
-
-#- takes the mount point to umount (can also be the device)
-sub umount {
- my ($mntpoint) = @_;
- $mntpoint =~ s|/$||;
- log::l("calling umount($mntpoint)");
-
- syscall_('umount2', $mntpoint, 0) or do {
- kill 15, fuzzy_pidofs('^fam\b');
- syscall_('umount2', $mntpoint, 0) or die N("error unmounting %s: %s", $mntpoint, $!);
- };
-
- substInFile { $_ = '' if /(^|\s)$mntpoint\s/ } '/etc/mtab'; #- do not care about error, if we can not read, we will not manage to write... (and mess mtab)
-}
-
-sub mount_part {
- my ($part, $o_prefix, $b_rdonly, $o_wait_message) = @_;
-
- #- root carrier's link can not be mounted
- fs::loopback::carryRootCreateSymlink($part, $o_prefix);
-
- log::l("mount_part: " . join(' ', map { "$_=$part->{$_}" } 'device', 'mntpoint', 'isMounted', 'real_mntpoint'));
- if ($part->{isMounted} && $part->{real_mntpoint} && $part->{mntpoint}) {
- log::l("remounting partition on $o_prefix$part->{mntpoint} instead of $part->{real_mntpoint}");
- if ($::isInstall) { #- ensure partition will not be busy.
- require install_any;
- install_any::getFile('XXX');
- }
- eval {
- umount($part->{real_mntpoint});
- rmdir $part->{real_mntpoint};
- symlinkf "$o_prefix$part->{mntpoint}", $part->{real_mntpoint};
- delete $part->{real_mntpoint};
- $part->{isMounted} = 0;
- };
- }
-
- return if $part->{isMounted};
-
- unless ($::testing) {
- if (isSwap($part)) {
- $o_wait_message->(N("Enabling swap partition %s", $part->{device})) if $o_wait_message;
- swapon($part->{device});
- } else {
- $part->{mntpoint} or die "missing mount point for partition $part->{device}";
-
- my $mntpoint = ($o_prefix || '') . $part->{mntpoint};
- if (isLoopback($part) || $part->{encrypt_key}) {
- set_loop($part);
- } elsif ($part->{options} =~ /encrypted/) {
- log::l("skip mounting $part->{device} since we do not have the encrypt_key");
- return;
- } elsif (fs::loopback::carryRootLoopback($part)) {
- $mntpoint = "/initrd/loopfs";
- }
- my $dev = $part->{real_device} || part2wild_device_name('', $part);
- mount($dev, $mntpoint, $part->{fs_type}, $b_rdonly, $part->{options}, $o_wait_message);
- }
- }
- $part->{isMounted} = 1;
- set_isFormatted($part, 1); #- assume that if mount works, partition is formatted
-}
-
-sub umount_part {
- my ($part, $o_prefix) = @_;
-
- $part->{isMounted} || $part->{real_mntpoint} or return;
-
- unless ($::testing) {
- if (isSwap($part)) {
- swapoff($part->{device});
- } elsif (fs::loopback::carryRootLoopback($part)) {
- umount("/initrd/loopfs");
- } else {
- umount(($o_prefix || '') . $part->{mntpoint} || devices::make($part->{device}));
- devices::del_loop(delete $part->{real_device}) if $part->{real_device};
- }
- }
- $part->{isMounted} = 0;
-}
-
-sub umount_all($;$) {
- my ($fstab, $prefix) = @_;
-
- log::l("unmounting all filesystems");
-
- foreach (sort { $b->{mntpoint} cmp $a->{mntpoint} } @$fstab) {
- $_->{mntpoint} and umount_part($_, $prefix);
- }
-}
-
################################################################################
# various functions
################################################################################
@@ -652,7 +345,7 @@ sub df {
return; #- will not even try!
} else {
mkdir_p($dir);
- eval { mount(devices::make($part->{device}), $dir, $part->{fs_type}, 'readonly') };
+ eval { fs::mount::mount(devices::make($part->{device}), $dir, $part->{fs_type}, 'readonly') };
if ($@) {
set_isFormatted($part, 0);
unlink $dir;
@@ -662,7 +355,7 @@ sub df {
my (undef, $free) = MDK::Common::System::df($dir);
if (!$part->{isMounted}) {
- umount($dir);
+ fs::mount::umount($dir);
unlink($dir);
}
@@ -670,11 +363,4 @@ sub df {
$part->{free};
}
-sub mount_usbfs {
- my ($prefix) = @_;
-
- my $fs = cat_('/proc/filesystems') =~ /usbfs/ ? 'usbfs' : 'usbdevfs';
- mount('none', "$prefix/proc/bus/usb", $fs);
-}
-
1;
diff --git a/perl-install/fs/dmraid.pm b/perl-install/fs/dmraid.pm
index 7166ce12d..6916ab324 100644
--- a/perl-install/fs/dmraid.pm
+++ b/perl-install/fs/dmraid.pm
@@ -10,6 +10,7 @@ use common;
use modules;
use devices;
use fs::type;
+use fs::wild_device;
use run_program;
@@ -44,7 +45,7 @@ sub vgs() {
my %vg2pv; push @{$vg2pv{$_->{vg}}}, $_->{pv} foreach @l;
map {
my $dev = "mapper/$_->{vg}";
- my $vg = fs::subpart_from_wild_device_name("/dev/$dev");
+ my $vg = fs::wild_device::to_subpart("/dev/$dev");
add2hash($vg, { media_type => 'hd', prefix => $dev, bus => "dm_$_->{format}", disks => $vg2pv{$_->{vg}} });
#- device should exist, created by dmraid(8) using libdevmapper
diff --git a/perl-install/fs/format.pm b/perl-install/fs/format.pm
index 3238df33c..93882788f 100644
--- a/perl-install/fs/format.pm
+++ b/perl-install/fs/format.pm
@@ -52,14 +52,14 @@ sub check_package_is_installed {
}
sub part {
- my ($raids, $part, $prefix, $wait_message) = @_;
+ my ($all_hds, $part, $wait_message) = @_;
if (isRAID($part)) {
$wait_message->(N("Formatting partition %s", $part->{device})) if $wait_message;
require raid;
- raid::format_part($raids, $part);
+ raid::format_part($all_hds->{raids}, $part);
} elsif (isLoopback($part)) {
$wait_message->(N("Creating and formatting file %s", $part->{loopback_file})) if $wait_message;
- fs::loopback::format_part($part, $prefix);
+ fs::loopback::format_part($part);
} else {
$wait_message->(N("Formatting partition %s", $part->{device})) if $wait_message;
part_raw($part, $wait_message);
@@ -72,8 +72,7 @@ sub part_raw {
$part->{isFormatted} and return;
if ($part->{encrypt_key}) {
- require fs;
- fs::set_loop($part);
+ fs::mount::set_loop($part);
}
my $dev = $part->{real_device} || $part->{device};
@@ -179,4 +178,37 @@ sub wait_message {
};
}
+
+sub formatMount_part {
+ my ($part, $all_hds, $fstab, $wait_message) = @_;
+
+ if (isLoopback($part)) {
+ formatMount_part($part->{loopback_device}, $all_hds, $fstab, $wait_message);
+ }
+ if (my $p = fs::get::up_mount_point($part->{mntpoint}, $fstab)) {
+ formatMount_part($p, $all_hds, $fstab, $wait_message) if !fs::type::carry_root_loopback($part);
+ }
+ if ($part->{toFormat}) {
+ fs::format::part($all_hds, $part, $wait_message);
+ }
+ fs::mount::part($part, 0, $wait_message);
+}
+
+sub formatMount_all {
+ my ($all_hds, $fstab, $wait_message) = @_;
+ formatMount_part($_, $all_hds, $fstab, $wait_message)
+ foreach sort { isLoopback($a) ? 1 : isSwap($a) ? -1 : 0 } grep { $_->{mntpoint} } @$fstab;
+
+ #- ensure the link is there
+ fs::loopback::carryRootCreateSymlink($_) foreach @$fstab;
+
+ #- for fun :)
+ #- that way, when install exits via ctrl-c, it gives hand to partition
+ eval {
+ my ($_type, $major, $minor) = devices::entry(fs::get::root($fstab)->{device});
+ output "/proc/sys/kernel/real-root-dev", makedev($major, $minor);
+ };
+}
+
+
1;
diff --git a/perl-install/fs/get.pm b/perl-install/fs/get.pm
index 5ea9071a8..1db2d3002 100644
--- a/perl-install/fs/get.pm
+++ b/perl-install/fs/get.pm
@@ -6,6 +6,7 @@ use strict;
use partition_table;
use fs::type;
use fs::loopback;
+use fs::wild_device;
use fs;
use common;
use log;
@@ -70,7 +71,7 @@ sub hds_fstab_and_holes {
sub device2part {
my ($dev, $fstab) = @_;
- my $subpart = fs::subpart_from_wild_device_name($dev);
+ my $subpart = fs::wild_device::to_subpart($dev);
my $part = find { is_same_hd($subpart, $_) } @$fstab;
log::l("fs::get::device2part: unknown device <<$dev>>") if !$part;
$part;
@@ -88,7 +89,7 @@ sub file2part {
$file = $b_keep_simple_symlinks ? common::expand_symlinks_but_simple("$::prefix$file") : expand_symlinks("$::prefix$file");
unless ($file =~ s/^$::prefix//) {
- my $part = find { fs::loopback::carryRootLoopback($_) } @$fstab or die;
+ my $part = find { fs::type::carry_root_loopback($_) } @$fstab or die;
log::l("found $part->{mntpoint}");
$file =~ s|/initrd/loopfs|$part->{mntpoint}|;
}
@@ -140,4 +141,9 @@ sub is_same_hd {
}
}
+sub mntpoint_prefixed {
+ my ($part) = @_;
+ $::prefix . $part->{mntpoint};
+}
+
1;
diff --git a/perl-install/fs/loopback.pm b/perl-install/fs/loopback.pm
index a7c6c913d..572c79f67 100644
--- a/perl-install/fs/loopback.pm
+++ b/perl-install/fs/loopback.pm
@@ -12,12 +12,6 @@ use fs;
use log;
-sub carryRootLoopback {
- my ($part) = @_;
- $_->{mntpoint} eq '/' and return 1 foreach @{$part->{loopback} || []};
- 0;
-}
-
sub check_circular_mounts {
my ($part, $all_hds) = @_;
@@ -30,7 +24,7 @@ sub check_circular_mounts {
@seen > 1 && $part->{mntpoint} eq $base_mntpoint and die N("Circular mounts %s\n", join(", ", @seen));
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);
+ $check->($part, @seen) if !fs::type::carry_root_loopback($part);
}
if (isLoopback($part)) {
$check->($part->{loopback_device}, @seen);
@@ -40,34 +34,34 @@ sub check_circular_mounts {
}
sub carryRootCreateSymlink {
- my ($part, $prefix) = @_;
+ my ($part) = @_;
- carryRootLoopback($part) or return;
+ fs::type::carry_root_loopback($part) or return;
- my $mntpoint = "$prefix$part->{mntpoint}";
+ my $mntpoint = fs::get::mntpoint_prefixed($part);
unless (-e $mntpoint) {
eval { mkdir_p(dirname($mntpoint)) };
#- do non-relative link for install, should be changed to relative link before rebooting
symlink "/initrd/loopfs", $mntpoint;
mkdir_p("/initrd/loopfs/lnx4win/boot");
- symlink "/initrd/loopfs/lnx4win/boot", "$prefix/boot";
+ symlink "/initrd/loopfs/lnx4win/boot", "$::prefix/boot";
}
#- indicate kernel to keep initrd
- mkdir_p("$prefix/initrd");
+ mkdir_p("$::prefix/initrd");
}
sub format_part {
- my ($part, $prefix) = @_;
- fs::mount_part($part->{loopback_device}, $prefix);
- create($part, $prefix);
+ my ($part) = @_;
+ fs::mount::part($part->{loopback_device});
+ create($part);
fs::format::part_raw($part, undef);
}
sub create {
- my ($part, $prefix) = @_;
- my $f = $part->{device} = "$prefix$part->{loopback_device}{mntpoint}$part->{loopback_file}";
+ my ($part) = @_;
+ my $f = $part->{device} = fs::get::mntpoint_prefixed($part->{loopback_device}) . $part->{loopback_file};
return if -e $f;
eval { mkdir_p(dirname($f)) };
diff --git a/perl-install/fs/mount.pm b/perl-install/fs/mount.pm
new file mode 100644
index 000000000..40bc07f05
--- /dev/null
+++ b/perl-install/fs/mount.pm
@@ -0,0 +1,197 @@
+package fs::mount; # $Id$
+
+use diagnostics;
+use strict;
+
+use run_program;
+use common;
+use fs::type;
+use log;
+
+
+sub set_loop {
+ my ($part) = @_;
+ $part->{real_device} ||= devices::set_loop(devices::make($part->{device}), $part->{encrypt_key}, $part->{options} =~ /encryption=(\w+)/);
+}
+
+sub swapon {
+ my ($dev) = @_;
+ log::l("swapon called with $dev");
+ syscall_('swapon', devices::make($dev), 0) or die "swapon($dev) failed: $!";
+}
+
+sub swapoff {
+ my ($dev) = @_;
+ syscall_('swapoff', devices::make($dev)) or die "swapoff($dev) failed: $!";
+}
+
+sub mount {
+ my ($dev, $where, $fs, $b_rdonly, $o_options, $o_wait_message) = @_;
+ log::l("mounting $dev on $where as type $fs, options $o_options");
+
+ mkdir_p($where);
+
+ $fs or log::l("not mounting $dev partition"), return;
+
+ {
+ my @fs_modules = qw(ext3 hfs jfs nfs ntfs romfs reiserfs ufs xfs vfat);
+ my @types = (qw(ext2 proc sysfs usbfs usbdevfs iso9660 devfs devpts), @fs_modules);
+
+ push @types, 'smb', 'smbfs', 'davfs' if !$::isInstall;
+
+ if (!member($fs, @types) && !$::move) {
+ log::l("skipping mounting $dev partition ($fs)");
+ return;
+ }
+ if ($::isInstall) {
+ if (member($fs, @fs_modules)) {
+ eval { modules::load($fs) };
+ } elsif ($fs eq 'iso9660') {
+ eval { modules::load('isofs') };
+ }
+ }
+ }
+
+ $where =~ s|/$||;
+
+ my @mount_opt = split(',', $o_options || '');
+
+ if ($fs eq 'vfat') {
+ @mount_opt = 'check=relaxed';
+ } elsif ($fs eq 'nfs') {
+ push @mount_opt, 'nolock', 'soft', 'intr' if $::isInstall;
+ } elsif ($fs eq 'jfs' && !$b_rdonly) {
+ fsck_jfs($dev, $o_wait_message);
+ } elsif ($fs eq 'ext2' && !$b_rdonly) {
+ fsck_ext2($dev, $o_wait_message);
+ }
+
+ push @mount_opt, 'ro' if $b_rdonly;
+
+ log::l("calling mount -t $fs $dev $where @mount_opt");
+ $o_wait_message->(N("Mounting partition %s", $dev)) if $o_wait_message;
+ run_program::run('mount', '-t', $fs, $dev, $where, if_(@mount_opt, '-o', join(',', @mount_opt))) or die N("mounting partition %s in directory %s failed", $dev, $where);
+}
+
+sub fsck_ext2 {
+ my ($dev, $o_wait_message) = @_;
+ $o_wait_message->(N("Checking %s", $dev)) if $o_wait_message;
+ foreach ('-a', '-y') {
+ run_program::raw({ timeout => 60 * 60 }, "fsck.ext2", $_, $dev);
+ my $err = $?;
+ if ($err & 0x0100) {
+ log::l("fsck corrected partition $dev");
+ }
+ if ($err & 0xfeff) {
+ my $txt = sprintf("fsck failed on %s with exit code %d or signal %d", $dev, $err >> 8, $err & 255);
+ $_ eq '-y' ? die($txt) : cdie($txt);
+ } else {
+ last;
+ }
+ }
+}
+sub fsck_jfs {
+ my ($dev, $o_wait_message) = @_;
+ $o_wait_message->(N("Checking %s", $dev)) if $o_wait_message;
+ #- needed if the system is dirty otherwise mounting read-write simply fails
+ run_program::raw({ timeout => 60 * 60 }, "fsck.jfs", $dev) or do {
+ my $err = $?;
+ die "fsck.jfs failed" if $err & 0xfc00;
+ };
+}
+
+#- takes the mount point to umount (can also be the device)
+sub umount {
+ my ($mntpoint) = @_;
+ $mntpoint =~ s|/$||;
+ log::l("calling umount($mntpoint)");
+
+ syscall_('umount2', $mntpoint, 0) or do {
+ kill 15, fuzzy_pidofs('^fam\b');
+ syscall_('umount2', $mntpoint, 0) or die N("error unmounting %s: %s", $mntpoint, $!);
+ };
+
+ substInFile { $_ = '' if /(^|\s)$mntpoint\s/ } '/etc/mtab'; #- do not care about error, if we can not read, we will not manage to write... (and mess mtab)
+}
+
+sub part {
+ my ($part, $b_rdonly, $o_wait_message) = @_;
+
+ log::l("mount_part: " . join(' ', map { "$_=$part->{$_}" } 'device', 'mntpoint', 'isMounted', 'real_mntpoint'));
+ if ($part->{isMounted} && $part->{real_mntpoint} && $part->{mntpoint}) {
+ log::l("remounting partition on " . fs::get::mntpoint_prefixed($part) . " instead of $part->{real_mntpoint}");
+ if ($::isInstall) { #- ensure partition will not be busy.
+ require install_any;
+ install_any::getFile('XXX');
+ }
+ eval {
+ umount($part->{real_mntpoint});
+ rmdir $part->{real_mntpoint};
+ symlinkf fs::get::mntpoint_prefixed($part), $part->{real_mntpoint};
+ delete $part->{real_mntpoint};
+ $part->{isMounted} = 0;
+ };
+ }
+
+ return if $part->{isMounted};
+
+ unless ($::testing) {
+ if (isSwap($part)) {
+ $o_wait_message->(N("Enabling swap partition %s", $part->{device})) if $o_wait_message;
+ swapon($part->{device});
+ } else {
+ $part->{mntpoint} or die "missing mount point for partition $part->{device}";
+
+ my $mntpoint = fs::get::mntpoint_prefixed($part);
+ if (isLoopback($part) || $part->{encrypt_key}) {
+ set_loop($part);
+ } elsif ($part->{options} =~ /encrypted/) {
+ log::l("skip mounting $part->{device} since we do not have the encrypt_key");
+ return;
+ } elsif (fs::type::carry_root_loopback($part)) {
+ $mntpoint = "/initrd/loopfs";
+ }
+ my $dev = $part->{real_device} || fs::wild_device::from_part('', $part);
+ mount($dev, $mntpoint, $part->{fs_type}, $b_rdonly, $part->{options}, $o_wait_message);
+ }
+ }
+ $part->{isMounted} = 1;
+ set_isFormatted($part, 1); #- assume that if mount works, partition is formatted
+}
+
+sub umount_part {
+ my ($part) = @_;
+
+ $part->{isMounted} || $part->{real_mntpoint} or return;
+
+ unless ($::testing) {
+ if (isSwap($part)) {
+ swapoff($part->{device});
+ } elsif (fs::type::carry_root_loopback($part)) {
+ umount("/initrd/loopfs");
+ } else {
+ umount(fs::get::mntpoint_prefixed($part) || devices::make($part->{device}));
+ devices::del_loop(delete $part->{real_device}) if $part->{real_device};
+ }
+ }
+ $part->{isMounted} = 0;
+}
+
+sub umount_all {
+ my ($fstab) = @_;
+
+ log::l("unmounting all filesystems");
+
+ foreach (sort { $b->{mntpoint} cmp $a->{mntpoint} } @$fstab) {
+ $_->{mntpoint} and umount_part($_);
+ }
+}
+
+sub usbfs {
+ my ($prefix) = @_;
+
+ my $fs = cat_('/proc/filesystems') =~ /usbfs/ ? 'usbfs' : 'usbdevfs';
+ mount('none', "$prefix/proc/bus/usb", $fs);
+}
+
+1;
diff --git a/perl-install/fs/type.pm b/perl-install/fs/type.pm
index 51b0e8503..1d036d7bb 100644
--- a/perl-install/fs/type.pm
+++ b/perl-install/fs/type.pm
@@ -380,3 +380,8 @@ sub guessed_by_mount() {
sub directories_needed_to_boot() {
qw(/ /usr /var /boot /tmp);
}
+
+sub carry_root_loopback {
+ my ($part) = @_;
+ any { $_->{mntpoint} eq '/' } @{$part->{loopback} || []};
+}
diff --git a/perl-install/fs/wild_device.pm b/perl-install/fs/wild_device.pm
new file mode 100644
index 000000000..8fd38b0ce
--- /dev/null
+++ b/perl-install/fs/wild_device.pm
@@ -0,0 +1,101 @@
+package fs::wild_device; # $Id$
+
+use diagnostics;
+use strict;
+
+use common;
+
+
+sub analyze {
+ my ($dev) = @_;
+
+ if ($dev =~ m!^/u?dev/(.*)!) {
+ 'dev', $dev;
+ } elsif ($dev !~ m!^/! && (-e "/dev/$dev" || -e "$::prefix/dev/$dev")) {
+ 'dev', "/dev/$dev";
+ } elsif ($dev =~ /^LABEL=(.*)/) {
+ 'label', $1;
+ } elsif ($dev eq 'none' || $dev eq 'rootfs') {
+ 'virtual';
+ } elsif ($dev =~ m!^(\S+):/\w!) {
+ 'nfs';
+ } elsif ($dev =~ m!^//\w!) {
+ 'smb';
+ } elsif ($dev =~ m!^http://!) {
+ 'dav';
+ }
+}
+
+sub to_subpart {
+ my ($dev) = @_;
+
+ my $part = { device => $dev, faked_device => 1 }; #- default
+
+ if (my ($kind, $val) = analyze($dev)) {
+ if ($kind eq 'label') {
+ $part->{device_LABEL} = $val;
+ } elsif ($kind eq 'dev') {
+ my %part = (faked_device => 0);
+ if (my $rdev = (stat "$::prefix$dev")[6]) {
+ ($part{major}, $part{minor}) = unmakedev($rdev);
+ }
+
+ my $symlink = readlink("$::prefix$dev");
+ $dev =~ s!/u?dev/!!;
+
+ if ($symlink && $symlink =~ m|^[^/]+$|) {
+ $part{device_alias} = $dev;
+ $dev = $symlink;
+ }
+
+ if (my (undef, $part_number) = $dev =~ m!/(disc|part(\d+))$!) {
+ $part{part_number} = $part_number if $part_number;
+ $part{devfs_device} = $dev;
+ } else {
+ my $part_number = devices::part_number(\%part);
+ $part{part_number} = $part_number if $part_number;
+ }
+ $part{device} = $dev;
+ return \%part;
+ }
+ } else {
+ if ($dev =~ m!^/! && -f "$::prefix$dev") {
+ #- it must be a loopback file or directory to bind
+ } else {
+ log::l("part_from_wild_device_name: unknown device $dev");
+ }
+ }
+ $part;
+}
+
+sub from_part {
+ my ($prefix, $part) = @_;
+
+ if ($part->{prefer_device_LABEL}) {
+ 'LABEL=' . $part->{device_LABEL};
+ } elsif ($part->{prefer_devfs_name}) {
+ "/dev/$part->{devfs_device}";
+ } elsif ($part->{device_alias}) {
+ "/dev/$part->{device_alias}";
+ } else {
+ my $faked_device = exists $part->{faked_device} ?
+ $part->{faked_device} :
+ do {
+ #- in case $part has been created without using fs::wild_device::to_subpart()
+ my ($kind) = analyze($part->{device});
+ $kind ? $kind ne 'dev' : $part->{device} =~ m!^/!;
+ };
+ if ($faked_device) {
+ $part->{device};
+ } elsif ($part->{device} =~ m!^/dev/!) {
+ log::l("ERROR: i have a full device $part->{device}, this should not happen. use fs::wild_device::to_subpart() instead of creating bad part data-structures!");
+ $part->{device};
+ } else {
+ my $dev = "/dev/$part->{device}";
+ eval { devices::make("$prefix$dev") };
+ $dev;
+ }
+ }
+}
+
+1;
diff --git a/perl-install/install2.pm b/perl-install/install2.pm
index 823d03386..1fab5e8f3 100644
--- a/perl-install/install2.pm
+++ b/perl-install/install2.pm
@@ -187,9 +187,9 @@ sub formatPartitions {
devices::make("$o->{prefix}/dev/null");
chmod 0666, "$o->{prefix}/dev/null";
- eval { fs::mount('none', "$o->{prefix}/proc", 'proc') };
- eval { fs::mount('none', "$o->{prefix}/sys", 'sysfs') };
- eval { fs::mount_usbfs($o->{prefix}) };
+ eval { fs::mount::mount('none', "$::prefix/proc", 'proc') };
+ eval { fs::mount::mount('none', "$::prefix/sys", 'sysfs') };
+ eval { fs::mount::usbfs($::prefix) };
install_any::screenshot_dir__and_move();
install_any::move_clp_to_disk();
@@ -422,7 +422,7 @@ sub main {
log::l("second stage install running (", install_any::drakx_version(), ")");
eval { output('/proc/sys/kernel/modprobe', "\n") } if !$::local_install && !$::testing; #- disable kmod, otherwise we get a different behaviour in kernel vs kernel-BOOT
- eval { fs::mount('none', '/sys', 'sysfs', 1) };
+ eval { fs::mount::mount('none', '/sys', 'sysfs', 1) };
if ($::move) {
require move;
@@ -432,13 +432,13 @@ sub main {
push @auto,
# 'selectLanguage', 'selectKeyboard', 'miscellaneous', 'selectInstallClass',
'doPartitionDisks', 'formatPartitions', 'setupBootloader';
- fs::mount_usbfs(''); #- do it now so that when_load doesn't do it
+ fs::mount::usbfs(''); #- do it now so that when_load doesn't do it
}
cp_f(glob('/stage1/tmp/*'), '/tmp');
#- free up stage1 memory
- eval { fs::umount($_) } foreach qw(/stage1/proc/bus/usb /stage1/proc /stage1);
+ eval { fs::mount::umount($_) } foreach qw(/stage1/proc/bus/usb /stage1/proc /stage1);
$o->{prefix} = $::prefix = $::testing ? "/tmp/test-perl-install" : $::move ? "" : "/mnt";
mkdir $o->{prefix}, 0755;
diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm
index 70ceb6d2e..0e09e6f6a 100644
--- a/perl-install/install_any.pm
+++ b/perl-install/install_any.pm
@@ -49,7 +49,7 @@ my %iso_images;
sub mountCdrom {
my ($mountpoint, $o_cdrom) = @_;
$o_cdrom = $cdrom if !defined $o_cdrom;
- eval { fs::mount($o_cdrom, $mountpoint, "iso9660", 'readonly') };
+ eval { fs::mount::mount($o_cdrom, $mountpoint, "iso9660", 'readonly') };
}
sub useMedium($) {
@@ -135,13 +135,13 @@ sub changeIso($) {
my ($iso_label) = @_;
my $iso_info = find_ISO_image_labelled($iso_label) or return;
- eval { fs::umount($iso_images{mountpoint}) };
+ eval { fs::mount::umount($iso_images{mountpoint}) };
$@ and warnAboutFilesStillOpen();
devices::del_loop($iso_images{loopdev});
$iso_images{loopdev} = devices::set_loop($iso_info->{file});
eval {
- fs::mount($iso_images{loopdev}, $iso_images{mountpoint}, "iso9660", 'readonly');
+ fs::mount::mount($iso_images{loopdev}, $iso_images{mountpoint}, "iso9660", 'readonly');
log::l("using ISO image '$iso_label'");
1;
};
@@ -501,7 +501,7 @@ sub selectSupplMedia {
#- umount supplementary CD. Will re-ask for it later
getFile("XXX"); #- close still opened filehandles
log::l("Umounting suppl. CD, back to medium 1");
- eval { fs::umount("/mnt/cdrom") };
+ eval { fs::mount::umount("/mnt/cdrom") };
#- re-mount CD 1 if this was a cdrom install
remountCD1($o, $cdrom);
} else {
@@ -526,7 +526,7 @@ sub selectSupplMedia {
$url = "$::prefix$mediadir";
-d $url or mkdir_p($url);
my $dev = "$host:$dir";
- eval { fs::mount($dev, $url, 'nfs'); 1 }
+ eval { fs::mount::mount($dev, $url, 'nfs'); 1 }
or do { log::l("Mount failed: $@"); return 'error' };
#- add $mediadir in fstab for post-installation
push @{$o->{all_hds}{nfss}}, { fs_type => 'nfs', mntpoint => $mediadir, device => $dev, options => "noauto,ro,nosuid,soft,rsize=8192,wsize=8192" };
@@ -978,7 +978,7 @@ sub ejectCdrom {
#- umount BEFORE opening the cdrom device otherwise the umount will
#- D state if the cdrom is already removed
- $o_mountpoint and eval { fs::umount($o_mountpoint) };
+ $o_mountpoint and eval { fs::mount::umount($o_mountpoint) };
$@ and warnAboutFilesStillOpen();
return if is_xbox();
openCdromTray($cdrom);
@@ -1261,7 +1261,7 @@ sub getAndSaveAutoInstallFloppies {
foreach my $img (@imgs) {
my $dev = devices::set_loop($img) or log::l("couldn't set loopback device"), return;
- find { eval { fs::mount($dev, $mountdir, $_, 0); 1 } } qw(ext2 vfat) or return;
+ find { eval { fs::mount::mount($dev, $mountdir, $_, 0); 1 } } qw(ext2 vfat) or return;
if (-e "$mountdir/menu.lst") {
# hd_grub boot disk is different than others
@@ -1291,7 +1291,7 @@ sub getAndSaveAutoInstallFloppies {
$@ and log::l("Warning: <", formatError($@), ">");
}
- fs::umount($mountdir);
+ fs::mount::umount($mountdir);
devices::del_loop($dev);
}
rmdir $mountdir;
@@ -1322,7 +1322,7 @@ sub loadO {
unless ($::testing) {
my $dev = devices::make(detect_devices::floppy());
foreach my $fs (arch() =~ /sparc/ ? 'romfs' : ('ext2', 'vfat')) {
- eval { fs::mount($dev, '/mnt', $fs, 'readonly'); 1 } and goto mount_ok;
+ eval { fs::mount::mount($dev, '/mnt', $fs, 'readonly'); 1 } and goto mount_ok;
}
die "Could not mount floppy [$dev]";
mount_ok:
@@ -1331,7 +1331,7 @@ sub loadO {
-e $f or $f .= '.pl';
my $_b = before_leaving {
- fs::umount("/mnt") unless $::testing;
+ fs::mount::umount("/mnt") unless $::testing;
modules::unload(qw(vfat fat));
};
$o = loadO($O, $f);
@@ -1747,13 +1747,13 @@ sub media_browser {
{ val => \$media_browser{nfs} }
]) or last;
- my ($kind) = fs::analyze_wild_device_name($media_browser{nfs});
+ my ($kind) = fs::wild_device::analyze($media_browser{nfs});
if ($kind ne 'nfs') {
$in->ask_warn('', N("Bad NFS name"));
next;
}
- my $nfs = fs::subpart_from_wild_device_name($media_browser{nfs});
+ my $nfs = fs::wild_device::to_subpart($media_browser{nfs});
$nfs->{fs_type} = 'nfs';
if (my ($h, $file) = $inspect_and_browse->($nfs)) {
diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm
index d0167b40e..4acb70a9e 100644
--- a/perl-install/install_steps.pm
+++ b/perl-install/install_steps.pm
@@ -177,11 +177,11 @@ sub selectInstallClass {
sub doPartitionDisksBefore {
my ($o) = @_;
eval {
- eval { fs::umount("$o->{prefix}/sys") };
- eval { fs::umount("$o->{prefix}/proc/bus/usb") };
- eval { fs::umount("$o->{prefix}/proc") };
- eval { fs::umount_all($o->{fstab}, $o->{prefix}) };
- eval { sleep 1; fs::umount_all($o->{fstab}, $o->{prefix}) } if $@; #- HACK
+ eval { fs::mount::umount("$::prefix/sys") };
+ eval { fs::mount::umount("$::prefix/proc/bus/usb") };
+ eval { fs::mount::umount("$::prefix/proc") };
+ eval { fs::mount::umount_all($o->{fstab}) };
+ eval { sleep 1; fs::mount::umount_all($o->{fstab}) } if $@; #- HACK
} if $o->{fstab} && !$::testing;
}
@@ -220,8 +220,8 @@ sub doPartitionDisksAfter {
if ($o->{partitioning}{use_existing_root}) {
#- ensure those partitions are mounted so that they are not proposed in choosePartitionsToFormat
- fs::mount_part($_, $o->{prefix}) foreach sort { $a->{mntpoint} cmp $b->{mntpoint} }
- grep { $_->{mntpoint} && maybeFormatted($_) } @{$o->{fstab}};
+ fs::mount::part($_) foreach sort { $a->{mntpoint} cmp $b->{mntpoint} }
+ grep { $_->{mntpoint} && maybeFormatted($_) } @{$o->{fstab}};
}
cat_("/proc/mounts") =~ m|(\S+)\s+/tmp/nfsimage| &&
@@ -290,7 +290,7 @@ sub choosePartitionsToFormat($$) {
sub formatMountPartitions {
my ($o) = @_;
- fs::formatMount_all($o->{all_hds}{raids}, $o->{fstab}, $o->{prefix}, undef);
+ fs::format::formatMount_all($o->{all_hds}, $o->{fstab}, undef);
}
#------------------------------------------------------------------------------
@@ -596,7 +596,7 @@ sub updatemodules {
my $mount_dir = '/updatemodules';
find {
- eval { fs::mount($dev, $mount_dir, $_, 0); 1 };
+ eval { fs::mount::mount($dev, $mount_dir, $_, 0); 1 };
} 'ext2', 'vfat' or log::l("updatemodules: can't mount $dev"), return;
my $dir = "$mount_dir$rel_dir";
@@ -623,7 +623,7 @@ sub updatemodules {
}
}
- fs::umount($mount_dir);
+ fs::mount::umount($mount_dir);
}
#------------------------------------------------------------------------------
diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm
index 7e791dd2b..c9b306377 100644
--- a/perl-install/install_steps_interactive.pm
+++ b/perl-install/install_steps_interactive.pm
@@ -377,7 +377,7 @@ sub formatMountPartitions {
my ($o, $_fstab) = @_;
my ($w, $wait_message) = fs::format::wait_message($o);
catch_cdie {
- fs::formatMount_all($o->{all_hds}{raids}, $o->{fstab}, $o->{prefix}, $wait_message);
+ fs::format::formatMount_all($o->{all_hds}, $o->{fstab}, $wait_message);
} sub {
$@ =~ /fsck failed on (\S+)/ or return;
$o->ask_yesorno('', N("Failed to check filesystem %s. Do you want to repair the errors? (beware, you can lose data)", $1), 1);
diff --git a/perl-install/modules.pm b/perl-install/modules.pm
index 1188f5f7d..028cd248d 100644
--- a/perl-install/modules.pm
+++ b/perl-install/modules.pm
@@ -259,7 +259,7 @@ sub when_load_category {
} elsif ($category eq 'bus/usb') {
$conf->add_probeall('usb-interface', $name);
-f '/proc/bus/usb/devices' or eval {
- require fs; fs::mount_usbfs('');
+ require fs::mount; fs::mount::usbfs('');
#- ensure keyboard is working, the kernel must do the job the BIOS was doing
sleep 4;
load("usbkbd", "keybdev") if detect_devices::usbKeyboards();
diff --git a/perl-install/network/thirdparty.pm b/perl-install/network/thirdparty.pm
index 8950832e6..2110fc5f2 100644
--- a/perl-install/network/thirdparty.pm
+++ b/perl-install/network/thirdparty.pm
@@ -321,9 +321,9 @@ sub find_file_on_floppy {
my $h;
$in->ask_okcancel(N("Insert floppy"),
N("Insert a FAT formatted floppy in drive %s with %s in root directory and press %s", $floppy, $file, N("Next"))) or return;
- if (eval { fs::mount(devices::make($floppy), $mountpoint, 'vfat', 'readonly'); 1 }) {
+ if (eval { fs::mount::mount(devices::make($floppy), $mountpoint, 'vfat', 'readonly'); 1 }) {
log::explanations("Mounting floppy device $floppy in $mountpoint");
- $h = before_leaving { fs::umount($mountpoint) };
+ $h = before_leaving { fs::mount::umount($mountpoint) };
if ($h->{file} = first(glob("$mountpoint/$file"))) {
log::explanations("Found $h->{file} on floppy device");
} else {
diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm
index b80707927..651de92fe 100644
--- a/perl-install/partition_table.pm
+++ b/perl-install/partition_table.pm
@@ -119,8 +119,8 @@ sub assign_device_numbers {
my $dev = $hd->{prefix} . $i;
my $renumbered = $_->{device} && $dev ne $_->{device};
if ($renumbered) {
- require fs;
- eval { fs::umount_part($_) }; #- at least try to umount it
+ require fs::mount;
+ eval { fs::mount::umount_part($_) }; #- at least try to umount it
will_tell_kernel($hd, del => $_, 'delay_del');
push @{$hd->{partitionsRenumbered}}, [ $_->{device}, $dev ];
}
diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm
index 7a738b9e6..af8cbb4f3 100644
--- a/perl-install/pkgs.pm
+++ b/perl-install/pkgs.pm
@@ -1257,7 +1257,7 @@ sub install {
log::l("closing install.log file");
close $LOG;
- eval { fs::umount("/mnt/cdrom") };
+ eval { fs::mount::umount("/mnt/cdrom") };
cleanHeaders();
diff --git a/perl-install/standalone/bootloader-config b/perl-install/standalone/bootloader-config
index e167a5e54..5903b0226 100755
--- a/perl-install/standalone/bootloader-config
+++ b/perl-install/standalone/bootloader-config
@@ -120,7 +120,7 @@ sub add_kernel() {
my $root_part = fs::get::root([ fs::get::fstab($all_hds) ]) or die "can not find root partition\n";
my %opts = (
- root => fs::part2wild_device_name('', $root_part),
+ root => fs::wild_device::from_part('', $root_part),
initrd_options => $initrd_options,
if_($label, label => $label),
if_($bootloader->{default_vga}, vga => $bootloader->{default_vga}),
diff --git a/perl-install/standalone/drakautoinst b/perl-install/standalone/drakautoinst
index 6dbfb3a36..b4b1e3453 100755
--- a/perl-install/standalone/drakautoinst
+++ b/perl-install/standalone/drakautoinst
@@ -82,11 +82,11 @@ do {
};
$again = $@; #- grrr... $@ is localized in code block :-(
} while $again;
-fs::mount($dev, $mountdir, 'vfat', 0);
+fs::mount::mount($dev, $mountdir, 'vfat', 0);
if (-f $imagefile2) {
do {
- eval { fs::umount($mountdir) };
+ eval { fs::mount::umount($mountdir) };
$in->ask_okcancel('', N("Insert another blank floppy in drive %s (for drivers disk)", $floppy), 1) or quit_global($in, 0);
log::explanations(N("Creating auto install floppy (drivers disk)"));
my $_w = $in->wait_message('', N("Creating auto install floppy"));
@@ -96,7 +96,7 @@ if (-f $imagefile2) {
};
$again = $@; #- grrr... $@ is localized in code block :-(
} while $again;
- fs::mount($dev, $mountdir, 'ext2', 0);
+ fs::mount::mount($dev, $mountdir, 'ext2', 0);
}
my $cfgfile = "$mountdir/auto_inst.cfg";
@@ -245,7 +245,7 @@ my $str = join('',
$str =~ s/ {8}/\t/g; #- replace all 8 space char by only one tabulation, this reduces file size so much :-)
output($cfgfile, $str);
-fs::umount($mountdir);
+fs::mount::umount($mountdir);
$in->ask_okcancel(N("Congratulations!"),
N("The floppy has been successfully generated.