[parted-devel] [PATCH] disk.c: Update metadata after reading partition table

Pascal Hambourg pascal at plouf.fr.eu.org
Tue Nov 4 21:07:28 GMT 2025


Make sure metadata and free space are updated after reading the
partition table. Else non-standard metadata length for an empty GPT
table may be incorrectly reported until a change is performed.

Fixes: #79720
Signed-off-by: Pascal Hambourg <pascal at plouf.fr.eu.org>
---
 libparted/disk.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libparted/disk.c b/libparted/disk.c
index 0db7b5c9..35148100 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -200,6 +200,11 @@ ped_disk_new (PedDevice* dev)
 		goto error_close_dev;
 	if (!type->ops->read (disk))
 		goto error_destroy_disk;
+	/* Kludge to make sure metadata are updated after read */
+	if (!_disk_push_update_mode (disk))
+		goto error_destroy_disk;
+	if (!_disk_pop_update_mode (disk))
+		goto error_destroy_disk;
 	disk->needs_clobber = 0;
 	ped_device_close (dev);
 	return disk;
-- 
2.39.5



More information about the parted-devel mailing list