diff options
author | Karel Zak | 2017-06-19 16:03:41 +0200 |
---|---|---|
committer | Karel Zak | 2017-06-19 16:03:41 +0200 |
commit | c134c8b10192f138aeecdcd4b977e9c0b653e8c5 (patch) | |
tree | 1a23c6d913c13b13614a780c569046ad05c27ac3 /libfdisk/src/partition.c | |
parent | libfdisk: allow to resize container (diff) | |
download | kernel-qcow2-util-linux-c134c8b10192f138aeecdcd4b977e9c0b653e8c5.tar.gz kernel-qcow2-util-linux-c134c8b10192f138aeecdcd4b977e9c0b653e8c5.tar.xz kernel-qcow2-util-linux-c134c8b10192f138aeecdcd4b977e9c0b653e8c5.zip |
libfdisk: support logical partition resize
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/partition.c')
-rw-r--r-- | libfdisk/src/partition.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/libfdisk/src/partition.c b/libfdisk/src/partition.c index 4455432cd..3dd68b8ba 100644 --- a/libfdisk/src/partition.c +++ b/libfdisk/src/partition.c @@ -1054,7 +1054,7 @@ static int resize_get_last_possible( fdisk_reset_iter(&itr, FDISK_ITER_FORWARD); *maxsz = 0; - DBG(TAB, ul_debugobj(tb, "checking last possible for start=%ju", start)); + DBG(TAB, ul_debugobj(tb, "checking last possible for start=%ju", (uintmax_t) start)); while (fdisk_table_next_partition(tb, &itr, &pa) == 0) { @@ -1082,6 +1082,13 @@ static int resize_get_last_possible( continue; } + /* The current is nested, free space has to be nested within the same parent */ + if (fdisk_partition_is_nested(cur) + && pa->parent_partno != cur->parent_partno) { + DBG(TAB, ul_debugobj(tb, " ignore (nested required)")); + continue; + } + if (!last) { if (start >= pa->start && start < pa->start + pa->size) { if (fdisk_partition_is_freespace(pa) || pa == cur) { @@ -1092,7 +1099,9 @@ static int resize_get_last_possible( break; } + *maxsz = pa->size - (start - pa->start); + DBG(TAB, ul_debugobj(tb, " new max=%ju", (uintmax_t) *maxsz)); } } else if (!fdisk_partition_is_freespace(pa) && pa != cur) { DBG(TAB, ul_debugobj(tb, " no free space behind current")); @@ -1100,6 +1109,7 @@ static int resize_get_last_possible( } else { last = pa; *maxsz += pa->size; + DBG(TAB, ul_debugobj(tb, " new max=%ju (last updated)", (uintmax_t) *maxsz)); } } |