diff options
author | Karel Zak | 2015-02-03 12:44:00 +0100 |
---|---|---|
committer | Karel Zak | 2015-02-03 12:44:00 +0100 |
commit | 1bb387bdbd25b241929ddf5e28f187f4968677a1 (patch) | |
tree | a502fec5126095b61d8913c6fe05649bd1c8019e /libfdisk/src/dos.c | |
parent | libfdisk: (dos) write new empty label too (diff) | |
download | kernel-qcow2-util-linux-1bb387bdbd25b241929ddf5e28f187f4968677a1.tar.gz kernel-qcow2-util-linux-1bb387bdbd25b241929ddf5e28f187f4968677a1.tar.xz kernel-qcow2-util-linux-1bb387bdbd25b241929ddf5e28f187f4968677a1.zip |
libfdisk: fix issues with very small partitions
- cfdisk: minimal partitions size is 1 sector
- dos: when align last sector then don't set partition size to zero
for very small partitions.
- don't ignore tiny partitions before free space when define
free-space start offset
- improve some debug messages
Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/dos.c')
-rw-r--r-- | libfdisk/src/dos.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index e6f4e4f8c..73b985b88 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -852,7 +852,7 @@ static void set_partition(struct fdisk_context *cxt, offset = pe->offset; } - DBG(LABEL, ul_debug("DOS: setting partition %d%s, offset=%zu, start=%zu, stop=%zu, sysid=%02x", + DBG(LABEL, ul_debug("DOS: setting partition %d%s, offset=%zu, start=%zu, size=%zu, sysid=%02x", i, doext ? " [extended]" : "", (size_t) offset, (size_t) (start - offset), @@ -1204,9 +1204,12 @@ static int add_partition(struct fdisk_context *cxt, size_t n, * align the end of the partition. The next partition * will start at phy.block boundary. */ - stop = fdisk_align_lba_in_range(cxt, stop, start, limit) - 1; + stop = fdisk_align_lba_in_range(cxt, stop, start, limit); + if (stop > start) + stop -= 1; if (stop > limit) stop = limit; + DBG(LABEL, ul_debug("DOS: aligned stop: %ju", (uintmax_t) stop)); } } |