util-linux/libfdisk
Tobias Stoeckmann 1037269fec libfdisk: Distinguish between first LBA sector and partition
An insufficient check leads to an invalid free space output, as seen here:

$ dd if=/dev/zero of=cfdisk.iso bs=1M count=1
$ losetup -f cfdisk.iso
$ echo w | fdisk /dev/loop0
$ echo '1,1' | sfdisk /dev/loop0 --append
$ echo '3,' | sfdisk /dev/loop0 --append
$ sfdisk --list-free /dev/loop0
Start End Sectors Size
    1   2       2   1K
$ _

In this case, libfdisk fails to notice that it tries to calculate space
between two partitions, not between start of disk and first partition.
Currently, the code tries to achieve that by checking the address of the
last "partition", which is the first_lba block.  Now if the first
partition is merely 1 block in size, the "last" address is still equal
to the first_lba block, which renders the check in libfdisk for the next
partition invalid.

I chose to use "nparts == 0" for this check, because the partitions are
properly sorted before iterating over them.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2016-08-29 13:22:24 +02:00
..
docs libfdisk: cleanup fdisk_gpt_set_npartitions() 2016-06-21 14:21:30 +02:00
src libfdisk: Distinguish between first LBA sector and partition 2016-08-29 13:22:24 +02:00
COPYING COPYING: fix grammar of referring phrase, and indicate location better 2013-10-08 15:38:39 +02:00
Makemodule.am libfdisk: add API docs 2014-11-26 19:13:57 +01:00
fdisk.pc.in build-sys: add fdisk.pc 2014-11-26 13:20:16 +01:00