diff options
author | Dexter Morgan <dmorgan@mageia.org> | 2011-06-02 20:51:35 +0000 |
---|---|---|
committer | Dexter Morgan <dmorgan@mageia.org> | 2011-06-02 20:51:35 +0000 |
commit | a9b2bdafaf625d10aef2f476aa4014fd36c846bc (patch) | |
tree | 2364afc0ee6739b59a25c44d68c9f003bcaf03d9 /perl-install/diskdrake/resize_ext2.pm | |
download | drakx-a9b2bdafaf625d10aef2f476aa4014fd36c846bc.tar drakx-a9b2bdafaf625d10aef2f476aa4014fd36c846bc.tar.gz drakx-a9b2bdafaf625d10aef2f476aa4014fd36c846bc.tar.bz2 drakx-a9b2bdafaf625d10aef2f476aa4014fd36c846bc.tar.xz drakx-a9b2bdafaf625d10aef2f476aa4014fd36c846bc.zip |
Branch for updates
Diffstat (limited to 'perl-install/diskdrake/resize_ext2.pm')
-rw-r--r-- | perl-install/diskdrake/resize_ext2.pm | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/perl-install/diskdrake/resize_ext2.pm b/perl-install/diskdrake/resize_ext2.pm new file mode 100644 index 000000000..ca222b35a --- /dev/null +++ b/perl-install/diskdrake/resize_ext2.pm @@ -0,0 +1,37 @@ +package diskdrake::resize_ext2; # $Id: resize_ext2.pm 214945 2006-02-13 16:10:35Z tvignaud $ + +use diagnostics; +use strict; + +use run_program; +use common; + + +sub new { + my ($type, $_device, $dev) = @_; + + my $o = bless { dev => $dev }, $type; + + my $r = run_program::get_stdout('dumpe2fs', $dev); + $o->{block_count} = $r =~ /^Block count:\s*(\d+)/m && $1; + $o->{free_block} = $r =~ /^Free blocks:\s*(\d+)/m && $1; + $o->{block_size} = $r =~ /^Block size:\s*(\d+)/m && $1; + log::l("dumpe2fs $dev gives: Block_count=$o->{block_count}, Free_blocks=$o->{free_block}, Block_size=$o->{block_size}"); + + $o->{block_size} && $o; +} + +sub min_size { + my ($o) = @_; + ($o->{block_count} - $o->{free_block}) * ($o->{block_size} / 512); +} + +sub resize { + my ($o, $size) = @_; + + my $s = int($size / ($o->{block_size} / 512)); + log::l("resize2fs $o->{dev} to size $s in block of $o->{block_size} bytes"); + run_program::raw({ timeout => 60 * 60 }, "resize2fs", "-pf", $o->{dev}, $s) or die "resize2fs failed"; +} + +1; |