From: Karel Zak Date: Thu, 23 Apr 2015 09:34:05 +0000 (+0200) Subject: libfdisk: (gpt) fix end sector calculation on resize X-Git-Tag: v2.26.2~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b1d300f5a926888bd148ae4dd33f50b574d35601;p=thirdparty%2Futil-linux.git libfdisk: (gpt) fix end sector calculation on resize Signed-off-by: Karel Zak --- diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c index 34e5d85318..fd49c1349b 100644 --- a/libfdisk/src/gpt.c +++ b/libfdisk/src/gpt.c @@ -1643,8 +1643,11 @@ static int gpt_set_partition(struct fdisk_context *cxt, size_t n, if (fdisk_partition_has_start(pa)) start = pa->start; - if (fdisk_partition_has_size(pa)) - end = gpt_partition_start(e) + pa->size - 1ULL; + if (fdisk_partition_has_size(pa) || fdisk_partition_has_start(pa)) { + uint64_t xstart = fdisk_partition_has_start(pa) ? pa->start : gpt_partition_start(e); + uint64_t xsize = fdisk_partition_has_size(pa) ? pa->size : gpt_partition_size(e); + end = xstart + xsize - 1ULL; + } if (!FDISK_IS_UNDEF(start)) e->lba_start = cpu_to_le64(start);