|
|
5972c3 |
From 430952f254cddf1ccb47a5f8caf5b5cd64193c3a Mon Sep 17 00:00:00 2001
|
|
|
5972c3 |
From: Karel Zak <kzak@redhat.com>
|
|
|
5972c3 |
Date: Mon, 10 Aug 2020 11:37:32 +0200
|
|
|
5972c3 |
Subject: [PATCH] libfdisk: fix last free sector detection if partition size
|
|
|
5972c3 |
specified
|
|
|
5972c3 |
|
|
|
5972c3 |
We need to skip useless gaps between partition if the gap is no large
|
|
|
5972c3 |
enough for a new partition. Unfortunately, the current code checks
|
|
|
5972c3 |
size of the gap, but does not care for location of the gap -- this is
|
|
|
5972c3 |
good enough for dialog driven partitioning, but it's pretty bad if
|
|
|
5972c3 |
start of the partition is explicitly specified (e.g. sfdisk).
|
|
|
5972c3 |
|
|
|
5972c3 |
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1860461
|
|
|
5972c3 |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
5972c3 |
---
|
|
|
5972c3 |
libfdisk/src/dos.c | 4 ++--
|
|
|
5972c3 |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
5972c3 |
|
|
|
5972c3 |
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c
|
|
|
5972c3 |
index 176969883..890e33a26 100644
|
|
|
5972c3 |
--- a/libfdisk/src/dos.c
|
|
|
5972c3 |
+++ b/libfdisk/src/dos.c
|
|
|
5972c3 |
@@ -1274,14 +1274,14 @@ static int add_partition(struct fdisk_context *cxt, size_t n,
|
|
|
5972c3 |
fdisk_sector_t last;
|
|
|
5972c3 |
|
|
|
5972c3 |
rc = find_last_free(cxt, is_logical, start, limit, &last);
|
|
|
5972c3 |
-
|
|
|
5972c3 |
if (rc == 0 && last - start + 1 < fdisk_partition_get_size(pa)) {
|
|
|
5972c3 |
DBG(LABEL, ul_debug("DOS: area <%ju,%ju> too small [wanted=%ju aval=%ju]",
|
|
|
5972c3 |
(uintmax_t) start, (uintmax_t) last,
|
|
|
5972c3 |
fdisk_partition_get_size(pa),
|
|
|
5972c3 |
last - start));
|
|
|
5972c3 |
|
|
|
5972c3 |
- if (fdisk_partition_has_start(pa))
|
|
|
5972c3 |
+ if (fdisk_partition_has_start(pa)
|
|
|
5972c3 |
+ && fdisk_partition_get_start(pa) <= last)
|
|
|
5972c3 |
rc = -ENOSPC;
|
|
|
5972c3 |
else {
|
|
|
5972c3 |
start = last + 1;
|
|
|
5972c3 |
--
|
|
|
5972c3 |
2.25.4
|
|
|
5972c3 |
|