Pass gap_start to calculate_target_partitions
when calculating logical partitions.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
resize/resize.ml | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/resize/resize.ml b/resize/resize.ml
index 511ce64..5a4bd82 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -1207,9 +1207,24 @@ read the man page virt-resize(1).
calculate_target_partitions 1 start ~create_surplus:true partitions in
+ let logical_partitions =
+ let start = List.fold_left (
+ fun total p ->
+ match p.p_type with
+ | ContentExtendedPartition -> total +^ p.p_target_start
+ | _ -> total +^ 0L
+ ) 0L partitions in
+
+ let gap_start = (roundup64 (start +^ 1L) alignment) -^ start in
+ (* align logical partitions, too *)
+ let start = roundup64 (start +^ 1L) alignment in
+
+ calculate_target_partitions 5 start ~create_surplus:false ~gap_start
logical_partitions in
+
if verbose () then (
printf "After calculate target partitions:\n";
- List.iter (debug_partition ~sectsize) partitions
+ List.iter (debug_partition ~sectsize) partitions;
+ List.iter (debug_partition ~sectsize) logical_partitions
);
let mbr_part_type x =
--
2.1.0