util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sanity check, to prevent overlapping partitions from being partly reported as free
@ 2019-02-13 14:49 Fabian.Kirsch
  2019-02-18 12:05 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Fabian.Kirsch @ 2019-02-13 14:49 UTC (permalink / raw)
  To: util-linux

Hi,

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

---
 libfdisk/src/table.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libfdisk/src/table.c b/libfdisk/src/table.c
index 4881db68e..3d32695f4 100644
--- a/libfdisk/src/table.c
+++ b/libfdisk/src/table.c
@@ -582,7 +582,7 @@ int fdisk_get_freespaces(struct fdisk_context *cxt, struct fdisk_table **tb)
 {
 	int rc = 0;
 	size_t nparts = 0;
-	fdisk_sector_t last, grain;
+	fdisk_sector_t last, grain, pa_end;
 	struct fdisk_table *parts = NULL;
 	struct fdisk_partition *pa;
 	struct fdisk_iter itr;
@@ -632,7 +632,11 @@ 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)) {
+			pa_end = fdisk_partition_get_end(pa);
+			if(pa_end > last)
+				last = pa_end;
+		}
 		nparts++;
 	}
 
-- 
2.12.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] sanity check, to prevent overlapping partitions from being partly reported as free
  2019-02-13 14:49 [PATCH] sanity check, to prevent overlapping partitions from being partly reported as free Fabian.Kirsch
@ 2019-02-18 12:05 ` Karel Zak
  0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2019-02-18 12:05 UTC (permalink / raw)
  To: Fabian.Kirsch; +Cc: util-linux

On Wed, Feb 13, 2019 at 02:49:10PM +0000, Fabian.Kirsch@dlr.de wrote:
>  libfdisk/src/table.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

Applied, thanks.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-18 12:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-13 14:49 [PATCH] sanity check, to prevent overlapping partitions from being partly reported as free Fabian.Kirsch
2019-02-18 12:05 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).