From 637c9dc0d7a80cb1e5551939637046fb57cb7555 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Fri, 31 Jul 2009 13:44:59 +0000 Subject: use partition_table module instead of hardcoded fdisk commands --- draklive | 72 +++++++++++++++------------------------------------------------- 1 file changed, 17 insertions(+), 55 deletions(-) diff --git a/draklive b/draklive index b94d9e5..141fc2c 100755 --- a/draklive +++ b/draklive @@ -693,62 +693,24 @@ sub allocate_master { MDV::Draklive::Utils::device_allocate_file($dest, $disk_size); - my $slash = find { $_->{mntpoint} eq '/' } @{$media->{partitions}}; - my $fs = $slash->{fs_type}; - - #- FIXME: use fsedit::allocatePartitions and $media->{partitions}? - # foreach (@{$media->{partitions}}) { # set pt_type } - - require fs::type; - my $pt_type = sprintf('%x', fs::type::fs_type2subpart($fs)->{pt_type}); - open(my $fdisk, "| fdisk -C $geom->{cylinders} -S $geom->{sectors} -H $geom->{heads} $dest"); - - my $oem_rescue_idx = $media->find_partition_index('OEM_RESCUE'); - if (defined $oem_rescue_idx) { - my $rescue_partition = $media->{partitions}[$oem_rescue_idx]; - $rescue_partition->{fs_type} = $live->{oem_rescue}{media}->get_media_setting('fs'); - my $rescue_pt_type = sprintf('%x', fs::type::fs_type2subpart($rescue_partition->{fs_type})->{pt_type}); - - #- FIXME: respect partitions layout from $media->{partitions} (currently hardcoded here :/) - print $fdisk < $geom->{cylinders} * $geom->{heads} * $geom->{sectors}, + geom => $geom, + file => $dest, + }, 'partition_table::dos'; + + partition_table::raw::zero_MBR($hd); + + #- FIXME: maybe use fsedit::allocatePartitions to factorize even more? + foreach my $part (@{$media->{partitions}}) { + my $hole = find { fs::type::isEmpty($_) && $_->{size} >= $part->{size} } partition_table::get_normal_parts_and_holes($hd) + or die "not enough room for $part->{mntpoint}"; + $part->{start} = $hole->{start}; + fs::type::set_fs_type($part, $part->{fs_type}); + partition_table::add($hd, $part, 'Primary'); + } - close($fdisk) or die "unable to run fdisk\n" . ("$!" ? "Error closing fdisk pipe: $!" : "Exit status $? from fdisk"); + partition_table::write($hd); my $inode_size = $media->get_media_setting('inode_size'); map_index { allocate_partition($dest, $::i, $sector_size, $_->{fs_type}, $inode_size) } @{$media->{partitions}}; -- cgit v1.2.1