diff options
author | Karel Zak | 2014-02-03 18:05:57 +0100 |
---|---|---|
committer | Karel Zak | 2014-03-11 11:35:14 +0100 |
commit | aa423fd39eabdcc2e315997018eece3cd0c41951 (patch) | |
tree | b9ff2539b33fa57096bad31921396e2d7d119a34 /libfdisk | |
parent | cfdisk: use tree-mode for extended, colorize freesapce (diff) | |
download | kernel-qcow2-util-linux-aa423fd39eabdcc2e315997018eece3cd0c41951.tar.gz kernel-qcow2-util-linux-aa423fd39eabdcc2e315997018eece3cd0c41951.tar.xz kernel-qcow2-util-linux-aa423fd39eabdcc2e315997018eece3cd0c41951.zip |
libfdisk: again improve freespace code
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk')
-rw-r--r-- | libfdisk/src/table.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libfdisk/src/table.c b/libfdisk/src/table.c index a78be477f..6b8c6e3a3 100644 --- a/libfdisk/src/table.c +++ b/libfdisk/src/table.c @@ -438,10 +438,11 @@ int fdisk_get_freespaces(struct fdisk_context *cxt, struct fdisk_table **tb) fdisk_reset_iter(&itr, FDISK_ITER_FORWARD); while (fdisk_table_next_partition(parts, &itr, &pa) == 0) { - uint64_t lastfree = pa->start - 1 - cxt->first_lba; + uint64_t lastfree; if (!pa->used || !pa->nested) continue; + lastfree = pa->start - 1 - cxt->first_lba; if (last + grain < lastfree) { rc = table_add_freespace(cxt, *tb, last + grain, lastfree, @@ -457,7 +458,7 @@ int fdisk_get_freespaces(struct fdisk_context *cxt, struct fdisk_table **tb) /* free-space remaining in extended partition */ x = fdisk_partition_get_start(parent) + fdisk_partition_get_size(parent) - 1; - if (last + grain < x) + if (last + grain < x) { rc = table_add_freespace(cxt, *tb, last + grain, x - 1, dosort, &fr); @@ -466,6 +467,7 @@ int fdisk_get_freespaces(struct fdisk_context *cxt, struct fdisk_table **tb) fr->nested = 1; } } + } done: fdisk_unref_table(parts); |