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_ntfs.pm | |
download | drakx-backup-do-not-use-a9b2bdafaf625d10aef2f476aa4014fd36c846bc.tar drakx-backup-do-not-use-a9b2bdafaf625d10aef2f476aa4014fd36c846bc.tar.gz drakx-backup-do-not-use-a9b2bdafaf625d10aef2f476aa4014fd36c846bc.tar.bz2 drakx-backup-do-not-use-a9b2bdafaf625d10aef2f476aa4014fd36c846bc.tar.xz drakx-backup-do-not-use-a9b2bdafaf625d10aef2f476aa4014fd36c846bc.zip |
Branch for updates
Diffstat (limited to 'perl-install/diskdrake/resize_ntfs.pm')
-rw-r--r-- | perl-install/diskdrake/resize_ntfs.pm | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/perl-install/diskdrake/resize_ntfs.pm b/perl-install/diskdrake/resize_ntfs.pm new file mode 100644 index 000000000..1b24a9707 --- /dev/null +++ b/perl-install/diskdrake/resize_ntfs.pm @@ -0,0 +1,36 @@ +package diskdrake::resize_ntfs; + +use diagnostics; +use strict; + +use run_program; +use common; + + +sub new { + my ($type, $_device, $dev) = @_; + bless { dev => $dev }, $type; +} + +sub check_prog { + my ($in) = @_; + #- ensure_binary_is_installed checks binary chrooted, whereas we run the binary non-chrooted (pb for Mageia One) + $::isInstall || whereis_binary('ntfsresize') || $in->do_pkgs->ensure_binary_is_installed('ntfsprogs', 'ntfsresize'); +} + +sub min_size { + my ($o) = @_; + my $r; + run_program::run('ntfsresize', '>', \$r, '-f', '-i', $o->{dev}) or die "ntfsresize failed:\n$r\n"; + $r =~ /minimal size: (\d+) KiB/ && $1 * 2; +} + +sub resize { + my ($o, $size) = @_; + my @l = ('-ff', '-s' . int($size / 2) . 'ki', $o->{dev}); + my $r; + run_program::run('ntfsresize', '>', \$r, '-n', @l) or die "ntfsresize failed: $r\n"; + run_program::raw({ timeout => 'never' }, 'ntfsresize', '>', \$r, @l) or die "ntfsresize failed: $r\n"; +} + +1; |