[parted-devel] [PATCH] libparted: preserve GUID-specific attributes for GPT disks

James Forcier csssuf at csssuf.net
Thu Aug 2 05:56:56 BST 2018


libparted will currently clobber partition type GUID-specific bits in
partition entries when editing GPT disks in violation of the GPT
specification (UEFI specification version 2.7, Section 5.3.3, Table 23).
Preserve them instead.
---
 libparted/labels/gpt.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 4f922b2..1f0b54d 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -289,6 +289,7 @@ typedef struct _GPTPartitionData
   efi_guid_t uuid;
   efi_char16_t name[37];
   char *translated_name;
+  uint16_t guid_specific_attributes;
   int lvm;
   int swap;
   int raid;
@@ -818,6 +819,7 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
     gpt_part_data->name[i] = (efi_char16_t) pte->PartitionName[i];
   gpt_part_data->name[i] = 0;
   gpt_part_data->translated_name = 0;
+  gpt_part_data->guid_specific_attributes = pte->Attributes.GuidSpecific;
 
   gpt_part_data->lvm = gpt_part_data->swap
     = gpt_part_data->raid
@@ -1234,6 +1236,8 @@ _partition_generate_part_entry (PedPartition *part, GuidPartitionEntry_t *pte)
   if (gpt_part_data->legacy_boot)
     pte->Attributes.LegacyBIOSBootable = 1;
 
+  pte->Attributes.GuidSpecific = gpt_part_data->guid_specific_attributes;
+
   for (i = 0; i < 36; i++)
     pte->PartitionName[i] = gpt_part_data->name[i];
 }
-- 
2.18.0




More information about the parted-devel mailing list