diff options
author | Fabian.Kirsch@dlr.de | 2019-02-13 15:49:10 +0100 |
---|---|---|
committer | Karel Zak | 2019-02-18 12:58:07 +0100 |
commit | 9a76780f861628aeb5af7d799f0ae004a09fa360 (patch) | |
tree | 21ee4d709eb1cab8024973210e100becf147137f /libfdisk | |
parent | libmount: (tabdiff) use list_add_tail() in more robust way (diff) | |
download | kernel-qcow2-util-linux-9a76780f861628aeb5af7d799f0ae004a09fa360.tar.gz kernel-qcow2-util-linux-9a76780f861628aeb5af7d799f0ae004a09fa360.tar.xz kernel-qcow2-util-linux-9a76780f861628aeb5af7d799f0ae004a09fa360.zip |
libfdisk: sanity check, to prevent overlapping partitions from being partly reported as free
i noticed wrongly reported free space when looking with cfdisk on
an USB drive prepared with the latest alpine *.iso[1].
Feel free to apply below patch, which fixed the issue for me.
Greetings
Fabian
[1]: http://dl-cdn.alpinelinux.org/alpine/v3.9/releases/x86/alpine-extended-3.9.0-x86.iso
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk')
-rw-r--r-- | libfdisk/src/table.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libfdisk/src/table.c b/libfdisk/src/table.c index 7718daebb..99a669ca2 100644 --- a/libfdisk/src/table.c +++ b/libfdisk/src/table.c @@ -578,7 +578,7 @@ done: * * Note that free space smaller than grain (see fdisk_get_grain_size()) is * ignored. - + * * Returns: 0 on success, otherwise, a corresponding error. */ int fdisk_get_freespaces(struct fdisk_context *cxt, struct fdisk_table **tb) @@ -635,7 +635,12 @@ int fdisk_get_freespaces(struct fdisk_context *cxt, struct fdisk_table **tb) /* add gaps between logical partitions */ if (fdisk_partition_is_container(pa)) rc = check_container_freespace(cxt, parts, *tb, pa); - last = fdisk_partition_get_end(pa); + + if (fdisk_partition_has_end(pa)) { + fdisk_sector_t pa_end = fdisk_partition_get_end(pa); + if (pa_end > last) + last = fdisk_partition_get_end(pa); + } nparts++; } |