]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: count gaps to possible size when resize
authorKarel Zak <kzak@redhat.com>
Mon, 17 Sep 2018 09:58:50 +0000 (11:58 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 17 Sep 2018 09:58:50 +0000 (11:58 +0200)
The current code counts only partition sizes when it counts possible
space, but we have gaps between the partitions. It seems better to
count all based on offsets rather than sizes.

Addresses: https://github.com/karelzak/util-linux/issues/693
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/partition.c

index a790dc9c9420f7a115bdaa2224e9ab706406f690..ebcf6bf5c756b09e662c169851f8eec7f26dd3a7 100644 (file)
@@ -1113,7 +1113,7 @@ static int resize_get_last_possible(
                        break;
                } else {
                        last = pa;
-                       *maxsz += pa->size;
+                       *maxsz = pa->size - (start - pa->start);
                        DBG(TAB, ul_debugobj(tb, "  new max=%ju (last updated)", (uintmax_t) *maxsz));
                }
        }