Add support for logical partitions. - count number of logical_partition (we've split partitions list) - don't count size of extended partition For it'll duplicate with logical partition, we'll count it later - we need at leat 1 gap between logical partitions. so --aligment=1 will be increased by 1
Signed-off-by: Chen Hanxiao <[email protected]> --- resize/resize.ml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/resize/resize.ml b/resize/resize.ml index 92f7304..a0ed713 100644 --- a/resize/resize.ml +++ b/resize/resize.ml @@ -741,8 +741,10 @@ read the man page virt-resize(1). (* We need some overhead for partitioning. *) let overhead = let maxl64 = List.fold_left max 0L in + (* We need at least 1 sector gap between logical partitions *) + let alignment = if alignment = 1L then 2L else alignment in - let nr_partitions = List.length partitions in + let nr_partitions = List.length partitions + List.length logical_partitions in let gpt_start_sects = 64L in let gpt_end_sects = gpt_start_sects in @@ -770,12 +772,23 @@ read the man page virt-resize(1). let required = List.fold_left ( fun total p -> let newsize = + (* size of extended partition is calculated seperately *) + if p.p_type = ContentExtendedPartition then 0L else + match p.p_operation with + | OpCopy | OpIgnore -> p.p_part.G.part_size + | OpDelete -> 0L + | OpResize newsize -> newsize in + total +^ newsize + ) 0L partitions in + let required = required +^ List.fold_left ( + fun total p -> + let newsize = match p.p_operation with | OpCopy | OpIgnore -> p.p_part.G.part_size | OpDelete -> 0L | OpResize newsize -> newsize in total +^ newsize - ) 0L partitions in + ) 0L logical_partitions in let surplus = outsize -^ (required +^ overhead) in -- 2.1.0 _______________________________________________ Libguestfs mailing list [email protected] https://www.redhat.com/mailman/listinfo/libguestfs
