-----Original Message----- From: libguestfs-bounces@redhat.com [mailto:libguestfs-bounces@redhat.com] On Behalf Of Pino Toscano Sent: Friday, March 13, 2015 6:32 PM To: libguestfs@redhat.com Subject: Re: [Libguestfs] [PATCH] part-list: add support for show partition type
On Friday 13 March 2015 05:04:56 Chen Hanxiao wrote:
We lack of showing parttition type for part-list command. This patch will add support for this.
You cannot extend the struct returned by part_init with new members, that will cause compatibility issues with existing C users of that API.
Also 'parted -m' did not provide partition type info, remove code section for 'parted -m' process.
diff --git a/generator/structs.ml b/generator/structs.ml index ea110a1..e7a9fa6 100644 --- a/generator/structs.ml +++ b/generator/structs.ml @@ -240,6 +240,7 @@ let structs = [ "part_start", FBytes; "part_end", FBytes; "part_size", FBytes; + "part_type", FString; ]; s_camel_name = "Partition" };
I'd just add a new part_get_type (or something similar), which would call parted to return "primary"/etc. This would match what we do already with other attributes of partitions, and not force part_list to use a non-machine output type (which is not really meant for machine parsing).
Alright. A new API would keep compatibility safe.
diff --git a/resize/resize.ml b/resize/resize.ml index 84fd6d4..8f8f67f 100644 --- a/resize/resize.ml +++ b/resize/resize.ml @@ -1078,7 +1078,7 @@ read the man page virt-resize(1). *) p_name = ""; p_part = { G.part_num = 0l; part_start = 0L; part_end = 0L; - part_size = 0L }; + part_size = 0L; part_type = "" }; p_bootable = false; p_id = No_ID; p_type = ContentUnknown; p_label = None; p_guid = None;
Better add this information directly in the type partition, possibly also making use of type partition_type.
Also this could go in a different patch than the above changes to get the primary/extended/etc type of a partition.
I'll send a different patch for virt-resize on this. Regards, - Chen