blob: 2eb9347dd9e822119dde6693cb33d62670f469b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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;
|