]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: (gpt) fix end sector calculation on resize
authorKarel Zak <kzak@redhat.com>
Thu, 23 Apr 2015 09:34:05 +0000 (11:34 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 23 Apr 2015 09:34:05 +0000 (11:34 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/gpt.c

index 34e5d8531832bb408bdd1c425fee256bd145bc80..fd49c1349b4dc8acc10b47e492f3ec4a906ec649 100644 (file)
@@ -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);