From e1b4c144e966808bfa3f2985082029c2fdbd2e70 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Mon, 3 Aug 2009 13:40:23 +0000 Subject: extract get_hd_from_layout --- draklive | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/draklive b/draklive index 9a90d79..b3b2e87 100755 --- a/draklive +++ b/draklive @@ -691,24 +691,27 @@ sub get_harddisk_geometry { }; } -sub allocate_master { - my ($live, $media, $dest) = @_; - +sub get_hd_from_layout { + my ($media, $dest) = @_; my $geom = get_harddisk_geometry($media); - my $required_sectors = fold_left { $::a + $::b } map { $_->{size} } @{$media->{partitions}}; $required_sectors += $geom->{sectors}; # keep one more track $geom->{cylinders} = int($required_sectors / ($geom->{sectors} * $geom->{heads})); my $total_sectors = $geom->{cylinders} * $geom->{heads} * $geom->{sectors}; - - mkdir_p(dirname($dest)); - MDV::Draklive::Utils::device_allocate_file($dest, $total_sectors * $common::SECTORSIZE); - my $hd = bless { totalsectors => $total_sectors, geom => $geom, file => $dest, }, 'partition_table::dos'; +} + +sub allocate_master { + my ($live, $media, $dest) = @_; + + my $hd = get_hd_from_layout($media, $dest); + + mkdir_p(dirname($dest)); + MDV::Draklive::Utils::device_allocate_file($dest, $hd->{totalsectors} * $common::SECTORSIZE); partition_table::raw::zero_MBR($hd); -- cgit v1.2.1