diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2004-07-23 02:00:02 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2004-07-23 02:00:02 +0000 |
commit | 073e42bbfcd75d102a71e328f12b3ab3eeb7d047 (patch) | |
tree | 9d231c54862926160aa220972612c95920089709 /perl-install/fs | |
parent | 7a399c64f3a1ea29198e94dec585271c20861a1b (diff) | |
download | drakx-backup-do-not-use-073e42bbfcd75d102a71e328f12b3ab3eeb7d047.tar drakx-backup-do-not-use-073e42bbfcd75d102a71e328f12b3ab3eeb7d047.tar.gz drakx-backup-do-not-use-073e42bbfcd75d102a71e328f12b3ab3eeb7d047.tar.bz2 drakx-backup-do-not-use-073e42bbfcd75d102a71e328f12b3ab3eeb7d047.tar.xz drakx-backup-do-not-use-073e42bbfcd75d102a71e328f12b3ab3eeb7d047.zip |
- move format related functions out of fs.pm to new module fs/format.pm
- remove swap.pm, moving its few functions to fs/format.pm or fs.pm
Diffstat (limited to 'perl-install/fs')
-rw-r--r-- | perl-install/fs/format.pm | 77 |
1 files changed, 77 insertions, 0 deletions
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; |