summaryrefslogtreecommitdiffstats
path: root/perl-install/diskdrake
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2005-06-14 05:54:20 +0000
committerPascal Rigaux <pixel@mandriva.com>2005-06-14 05:54:20 +0000
commit14047f8c38d4a83ef5cc7c4b98b451d843119d7d (patch)
tree2d6fd1bd34f3b87235e6e246bdd1645e6931451b /perl-install/diskdrake
parentc705204cfd50582efa294f56c2da624a25f3019d (diff)
downloaddrakx-14047f8c38d4a83ef5cc7c4b98b451d843119d7d.tar
drakx-14047f8c38d4a83ef5cc7c4b98b451d843119d7d.tar.gz
drakx-14047f8c38d4a83ef5cc7c4b98b451d843119d7d.tar.bz2
drakx-14047f8c38d4a83ef5cc7c4b98b451d843119d7d.tar.xz
drakx-14047f8c38d4a83ef5cc7c4b98b451d843119d7d.zip
move ext2 resizing code here so that it's easier to use
Diffstat (limited to 'perl-install/diskdrake')
-rw-r--r--perl-install/diskdrake/resize_ext2.pm42
1 files changed, 42 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..2eb9347dd
--- /dev/null
+++ b/perl-install/diskdrake/resize_ext2.pm
@@ -0,0 +1,42 @@
+package diskdrake::resize_ext2; # $Id$
+
+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 check_prog {
+ my ($in) = @_;
+ $::isInstall || $in->do_pkgs->ensure_binary_is_installed('ntfsprogs', 'ntfsresize');
+}
+
+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::run("resize2fs", "-pf", $o->{dev}, $s);
+}
+
+1;