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 5deaa74..7d99b38 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -1223,9 +1223,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