diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2005-01-06 10:13:04 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2005-01-06 10:13:04 +0000 |
commit | d5e86a6fc9952b1eea07d5c14dc743fde7692d45 (patch) | |
tree | ae270820de5332ff8d24f3dc85c81a454f4c2f43 /perl-install/fs/format.pm | |
parent | 0d5a1b01a3a92b910347fbbba77ef0b1e18ac3c5 (diff) | |
download | drakx-backup-do-not-use-d5e86a6fc9952b1eea07d5c14dc743fde7692d45.tar drakx-backup-do-not-use-d5e86a6fc9952b1eea07d5c14dc743fde7692d45.tar.gz drakx-backup-do-not-use-d5e86a6fc9952b1eea07d5c14dc743fde7692d45.tar.bz2 drakx-backup-do-not-use-d5e86a6fc9952b1eea07d5c14dc743fde7692d45.tar.xz drakx-backup-do-not-use-d5e86a6fc9952b1eea07d5c14dc743fde7692d45.zip |
- fs::format::part_raw() now takes $wait_message to allow displaying the progress of format
- create fs::format::wait_message() which creates a $wait_message valid to give to fs::format::part
- fs::format::mke2fs() format while parsing the output to display the progress
Diffstat (limited to 'perl-install/fs/format.pm')
-rw-r--r-- | perl-install/fs/format.pm | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/perl-install/fs/format.pm b/perl-install/fs/format.pm index c0f2f791f..7fd7d012e 100644 --- a/perl-install/fs/format.pm +++ b/perl-install/fs/format.pm @@ -49,12 +49,12 @@ sub part { loopback::format_part($part, $prefix); } else { $wait_message->(N("Formatting partition %s", $part->{device})) if $wait_message; - part_raw($part); + part_raw($part, $wait_message); } } sub part_raw { - my ($part) = @_; + my ($part, $wait_message) = @_; $part->{isFormatted} and return; @@ -82,7 +82,15 @@ sub part_raw { my ($_pkg, $cmd, @first_options) = @{$cmds{$fs_type} || die N("I do not know how to format %s in type %s", $part->{device}, $part->{fs_type})}; - run_program::raw({ timeout => 60 * 60 }, $cmd, @first_options, @options, devices::make($dev)) or die N("%s formatting of %s failed", $fs_type, $dev); + my @args = ($cmd, @first_options, @options, devices::make($dev)); + + my $time = time(); + if ($cmd eq 'mke2fs' && $wait_message) { + mke2fs($wait_message, @args) or die N("%s formatting of %s failed", $fs_type, $dev); + } else { + run_program::raw({ timeout => 60 * 60 }, @args) or die N("%s formatting of %s failed", $fs_type, $dev); + } + warn "$cmd took: ", formatTimeRaw(time() - $time); if ($fs_type eq 'ext3') { disable_forced_fsck($dev); @@ -91,9 +99,37 @@ sub part_raw { set_isFormatted($part, 1); } +sub mke2fs { + my ($wait_message, @args) = @_; + + open(my $F, "@args |"); + + local $/ = "\b"; + local $_; + while (<$F>) { + $wait_message->('', $1, $2) if m!^\s*(\d+)/(\d+)\b!; + } + return close($F); +} + sub disable_forced_fsck { my ($dev) = @_; run_program::run("tune2fs", "-c0", "-i0", devices::make($dev)); } +sub wait_message { + my ($in) = @_; + + my $w; + $w, sub { + my ($msg, $current, $total) = @_; + if ($msg) { + $w ||= $in->wait_message('', $msg); + $w->set($msg); + } elsif ($total) { + $w->set("$current / $total"); + } + }; +} + 1; |