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

Brian C. Lane bcl at redhat.com
Fri Mar 20 21:55:48 GMT 2026


On Tue, Nov 04, 2025 at 10:07:28PM +0100, Pascal Hambourg wrote:
> 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
> 

I'm going back through things, trying to catch up. I think this one is
ok, the push removes free and metadata, then pop replaces them with the
updated ones so I'm adding it to my stack of patches.

Brian

-- 
Brian C. Lane (PST8PDT) - weldr.io - lorax - parted - pykickstart




More information about the parted-devel mailing list