summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/commands.pm8
-rw-r--r--perl-install/diskdrake/interactive.pm4
-rw-r--r--perl-install/fs.pm118
-rw-r--r--perl-install/fs/format.pm77
-rw-r--r--perl-install/loopback.pm2
-rw-r--r--perl-install/raid.pm2
-rw-r--r--perl-install/swap.pm32
7 files changed, 100 insertions, 143 deletions
diff --git a/perl-install/commands.pm b/perl-install/commands.pm
index 76f648a8f..071c72b83 100644
--- a/perl-install/commands.pm
+++ b/perl-install/commands.pm
@@ -159,13 +159,13 @@ sub chown_ {
sub swapon {
@_ == 1 or die "swapon <file>\n";
- require swap;
- swap::swapon($_[0]);
+ require fs;
+ fs::swapon($_[0]);
}
sub swapoff {
@_ == 1 or die "swapoff <file>\n";
- require swap;
- swap::swapoff($_[0]);
+ require fs;
+ fs::swapoff($_[0]);
}
sub uncpio {
diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm
index b1457060c..fb2676114 100644
--- a/perl-install/diskdrake/interactive.pm
+++ b/perl-install/diskdrake/interactive.pm
@@ -582,7 +582,7 @@ sub Type {
$part->{isFormatted} = 1; #- assume that if tune2fs works, partition is formatted
#- disable the fsck (don't do it together with -j in case -j fails?)
- fs::disable_forced_fsck($part->{device});
+ fs::format::disable_forced_fsck($part->{device});
return;
}
}
@@ -1083,7 +1083,7 @@ sub format_ {
ask_alldatawillbelost($in, $part, N_("After formatting partition %s, all data on this partition will be lost")) or return;
$part->{isFormatted} = 0; #- force format;
my $w;
- fs::format_part($all_hds->{raids}, $part, $::prefix, sub {
+ fs::format::part($all_hds->{raids}, $part, $::prefix, sub {
my ($msg) = @_;
$w ||= $in->wait_message('', $msg);
$w->set($msg);
diff --git a/perl-install/fs.pm b/perl-install/fs.pm
index 4e5277c11..b19eaf9f1 100644
--- a/perl-install/fs.pm
+++ b/perl-install/fs.pm
@@ -10,11 +10,11 @@ use log;
use devices;
use partition_table qw(:types);
use run_program;
-use swap;
use detect_devices;
use modules;
use fsedit;
use loopback;
+use fs::format;
sub read_fstab {
@@ -617,105 +617,6 @@ sub get_raw_hds {
];
}
-################################################################################
-# formatting functions
-################################################################################
-sub disable_forced_fsck {
- my ($dev) = @_;
- run_program::run("tune2fs", "-c0", "-i0", devices::make($dev));
-}
-
-sub format_ext2($@) {
- #- mke2fs -b (1024|2048|4096) -c -i(1024 > 262144) -N (1 > 100000000) -m (0-100%) -L volume-label
- #- tune2fs
- my ($dev, @options) = @_;
- $dev =~ m,(rd|ida|cciss)/, and push @options, qw(-b 4096 -R stride=16); #- For RAID only.
- push @options, qw(-b 1024 -O none) if arch() =~ /alpha/;
- run_program::raw({ timeout => 60 * 60 }, 'mke2fs', '-F', @options, devices::make($dev)) or die N("%s formatting of %s failed", (any { $_ eq '-j' } @options) ? "ext3" : "ext2", $dev);
-}
-sub format_ext3 {
- my ($dev, @options) = @_;
- format_ext2($dev, "-j", @options);
- disable_forced_fsck($dev);
-}
-sub format_reiserfs {
- my ($dev, @options) = @_;
- #TODO add -h tea
- run_program::raw({ timeout => 60 * 60 }, "mkreiserfs", "-ff", @options, devices::make($dev)) or die N("%s formatting of %s failed", "reiserfs", $dev);
-}
-sub format_xfs {
- my ($dev, @options) = @_;
- run_program::raw({ timeout => 60 * 60 }, "mkfs.xfs", "-f", "-q", @options, devices::make($dev)) or die N("%s formatting of %s failed", "xfs", $dev);
-}
-sub format_jfs {
- my ($dev, @options) = @_;
- run_program::raw({ timeout => 60 * 60 }, "mkfs.jfs", "-f", @options, devices::make($dev)) or die N("%s formatting of %s failed", "jfs", $dev);
-}
-sub format_dos {
- my ($dev, @options) = @_;
- run_program::raw({ timeout => 60 * 60 }, "mkdosfs", @options, devices::make($dev)) or die N("%s formatting of %s failed", "dos", $dev);
-}
-sub format_hfs {
- my ($dev, @options) = @_;
- run_program::raw({ timeout => 60 * 60 }, "hformat", @options, devices::make($dev)) or die N("%s formatting of %s failed", "HFS", $dev);
-}
-sub real_format_part {
- my ($part) = @_;
-
- $part->{isFormatted} and return;
-
- if ($part->{encrypt_key}) {
- set_loop($part);
- }
-
- my $dev = $part->{real_device} || $part->{device};
-
- my @options = if_($part->{toFormatCheck}, "-c");
- log::l("formatting device $dev (type ", pt_type2name($part->{pt_type}), ")");
-
- if (isExt2($part)) {
- push @options, "-F" if isLoopback($part);
- push @options, "-m", "0" if $part->{mntpoint} =~ m|^/home|;
- format_ext2($dev, @options);
- } elsif (isThisFs("ext3", $part)) {
- push @options, "-m", "0" if $part->{mntpoint} =~ m|^/home|;
- format_ext3($dev, @options);
- } elsif (isThisFs("reiserfs", $part)) {
- format_reiserfs($dev, @options);
- } elsif (isThisFs("xfs", $part)) {
- format_xfs($dev, @options);
- } elsif (isThisFs("jfs", $part)) {
- format_jfs($dev, @options);
- } elsif (isDos($part)) {
- format_dos($dev, @options);
- } elsif (isWin($part) || isEfi($part)) {
- format_dos($dev, @options, '-F', 32);
- } elsif (isThisFs('hfs', $part)) {
- format_hfs($dev, @options, '-l', "Untitled");
- } elsif (isAppleBootstrap($part)) {
- format_hfs($dev, @options, '-l', "bootstrap");
- } elsif (isSwap($part)) {
- my $check_blocks = any { /^-c$/ } @options;
- swap::make($dev, $check_blocks);
- } else {
- die N("I don't know how to format %s in type %s", $part->{device}, pt_type2name($part->{pt_type}));
- }
- $part->{isFormatted} = 1;
-}
-sub format_part {
- my ($raids, $part, $prefix, $wait_message) = @_;
- if (isRAID($part)) {
- $wait_message->(N("Formatting partition %s", $part->{device})) if $wait_message;
- require raid;
- raid::format_part($raids, $part);
- } elsif (isLoopback($part)) {
- $wait_message->(N("Creating and formatting file %s", $part->{loopback_file})) if $wait_message;
- loopback::format_part($part, $prefix);
- } else {
- $wait_message->(N("Formatting partition %s", $part->{device})) if $wait_message;
- real_format_part($part);
- }
-}
################################################################################
# mounting functions
@@ -725,6 +626,17 @@ sub set_loop {
$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) = @_;
@@ -735,7 +647,7 @@ sub formatMount_part {
formatMount_part($p, $raids, $fstab, $prefix, $wait_message) unless loopback::carryRootLoopback($part);
}
if ($part->{toFormat}) {
- format_part($raids, $part, $prefix, $wait_message);
+ fs::format::part($raids, $part, $prefix, $wait_message);
}
mount_part($part, $prefix, 0, $wait_message);
}
@@ -868,7 +780,7 @@ sub mount_part {
unless ($::testing) {
if (isSwap($part)) {
$o_wait_message->(N("Enabling swap partition %s", $part->{device})) if $o_wait_message;
- swap::swapon($part->{device});
+ swapon($part->{device});
} else {
$part->{mntpoint} or die "missing mount point for partition $part->{device}";
@@ -893,7 +805,7 @@ sub umount_part {
unless ($::testing) {
if (isSwap($part)) {
- swap::swapoff($part->{device});
+ swapoff($part->{device});
} elsif (loopback::carryRootLoopback($part)) {
umount("/initrd/loopfs");
} else {
diff --git a/perl-install/fs/format.pm b/perl-install/fs/format.pm
new file mode 100644
index 000000000..6f5dff294
--- /dev/null
+++ b/perl-install/fs/format.pm
@@ -0,0 +1,77 @@
+package fs::format;
+
+use run_program;
+use common;
+use log;
+use partition_table qw(:types);
+
+my %cmds = (
+ ext2 => 'mke2fs -F',
+ ext3 => 'mke2fs -F -j',
+ reiserfs => 'mkreiserfs -ff',
+ xfs => 'mkfs.xfs -f -q',
+ jfs => 'mkfs.jfs -f',
+ hfs => 'hformat',
+ dos => 'mkdosfs',
+ vfat => 'mkdosfs -F 32',
+ swap => 'mkswap',
+);
+
+sub part {
+ my ($raids, $part, $prefix, $wait_message) = @_;
+ if (isRAID($part)) {
+ $wait_message->(N("Formatting partition %s", $part->{device})) if $wait_message;
+ require raid;
+ raid::format_part($raids, $part);
+ } elsif (isLoopback($part)) {
+ $wait_message->(N("Creating and formatting file %s", $part->{loopback_file})) if $wait_message;
+ loopback::format_part($part, $prefix);
+ } else {
+ $wait_message->(N("Formatting partition %s", $part->{device})) if $wait_message;
+ part_raw($part);
+ }
+}
+
+sub part_raw {
+ my ($part) = @_;
+
+ $part->{isFormatted} and return;
+
+ if ($part->{encrypt_key}) {
+ fs::set_loop($part);
+ }
+
+ my $dev = $part->{real_device} || $part->{device};
+
+ my @options = if_($part->{toFormatCheck}, "-c");
+ log::l("formatting device $dev (type ", pt_type2name($part->{pt_type}), ")");
+
+ my $fs_type = type2fs($part);
+
+ if ($fs_type eq 'ext2' || $fs_type eq 'ext3') {
+ push @options, "-m", "0" if $part->{mntpoint} =~ m|^/home|;
+ } elsif (isDos($part)) {
+ $fs_type = 'dos';
+ } elsif ($fs_type eq 'hfs') {
+ push @options, '-l', "Untitled";
+ } elsif (isAppleBootstrap($part)) {
+ push @options, '-l', 'bootstrap';
+ }
+
+ my $cmd = $cmds{$fs_type} or die N("I don't know how to format %s in type %s", $part->{device}, pt_type2name($part->{pt_type}));
+
+ run_program::raw({ timeout => 60 * 60 }, $cmd, @options, devices::make($dev)) or die N("%s formatting of %s failed", $fs_type, $dev);
+
+ if ($fs_type eq 'ext3') {
+ disable_forced_fsck($dev);
+ }
+
+ $part->{isFormatted} = 1;
+}
+
+sub disable_forced_fsck {
+ my ($dev) = @_;
+ run_program::run("tune2fs", "-c0", "-i0", devices::make($dev));
+}
+
+1;
diff --git a/perl-install/loopback.pm b/perl-install/loopback.pm
index f945adede..64dbe079e 100644
--- a/perl-install/loopback.pm
+++ b/perl-install/loopback.pm
@@ -64,7 +64,7 @@ sub format_part {
my ($part, $prefix) = @_;
fs::mount_part($part->{loopback_device}, $prefix);
create($part, $prefix);
- fs::real_format_part($part);
+ fs::format::part_raw($part);
}
sub create {
diff --git a/perl-install/raid.pm b/perl-install/raid.pm
index 8579c26ac..8b03e3375 100644
--- a/perl-install/raid.pm
+++ b/perl-install/raid.pm
@@ -144,7 +144,7 @@ sub format_part {
$part->{isFormatted} and return;
make($raids, $part);
- fs::real_format_part($part);
+ fs::format::part_raw($part);
$_->{isFormatted} = 1 foreach @{$part->{disks}};
}
diff --git a/perl-install/swap.pm b/perl-install/swap.pm
deleted file mode 100644
index 564513ad9..000000000
--- a/perl-install/swap.pm
+++ /dev/null
@@ -1,32 +0,0 @@
-package swap; # $Id$
-
-use diagnostics;
-use strict;
-
-use common;
-use log;
-use devices;
-
-sub make {
- my ($dev, $checkBlocks) = @_;
- run_program::raw({ timeout => 60 * 60 }, "mkswap", if_($checkBlocks, '-c'), devices::make($dev)) or die N("%s formatting of %s failed", 'swap', $dev);
-}
-
-sub enable {
- my ($dev, $checkBlocks) = @_;
- make($dev, $checkBlocks);
- swapon($dev);
-}
-
-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: $!";
-}
-
-1;