From c6c0fcdea5abef05a11b63679f46ad01fdfcceba Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 6 May 2010 09:12:29 +0000 Subject: [PATCH] - Also recognize recovery partitions with id 27 / on gpt (#589451) --- parted-2.2-extend-diag-flag-rh589451.patch | 217 +++++++++++++++++++++ parted.spec | 8 +- 2 files changed, 224 insertions(+), 1 deletion(-) create mode 100644 parted-2.2-extend-diag-flag-rh589451.patch diff --git a/parted-2.2-extend-diag-flag-rh589451.patch b/parted-2.2-extend-diag-flag-rh589451.patch new file mode 100644 index 0000000..bdfc9d4 --- /dev/null +++ b/parted-2.2-extend-diag-flag-rh589451.patch @@ -0,0 +1,217 @@ +From 72a58fb27c71a8f74fd31c4ca734536e20ac7918 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Thu, 6 May 2010 09:54:45 +0200 +Subject: [PATCH parted 1/2] msdos: recognize id 27 as a diagnostics (recovery) partition + +msdos partitiontable partition id 27 is recommended by microsoft for +use as id for recovery partitions, see: +http://technet.microsoft.com/en-us/library/dd744364%28WS.10%29.aspx +http://bugzilla.redhat.com/show_bug.cgi?id=534066 + +* libparted/labels/dos.c(PARTITION_MSFT_RECOVERY): add define +* libparted/labels/dos.c(raw_part_parse): recognize id 27 +* libparted/labels/dos.c(msdos_partition_set_system): recognize id 27 +--- + libparted/labels/dos.c | 3 +++ + 1 files changed, 3 insertions(+), 0 deletions(-) + +diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c +index fdc679b..cb51491 100644 +--- a/libparted/labels/dos.c ++++ b/libparted/labels/dos.c +@@ -81,6 +81,7 @@ static const char MBR_BOOT_CODE[] = { + #define PARTITION_FAT16_LBA_H (PARTITION_FAT16_LBA | PART_FLAG_HIDDEN) + + #define PARTITION_COMPAQ_DIAG 0x12 ++#define PARTITION_MSFT_RECOVERY 0x27 + #define PARTITION_LDM 0x42 + #define PARTITION_LINUX_SWAP 0x82 + #define PARTITION_LINUX 0x83 +@@ -837,6 +838,7 @@ raw_part_parse (const PedDisk* disk, con + dos_data->palo = raw_part->type == PARTITION_PALO; + dos_data->prep = raw_part->type == PARTITION_PREP; + dos_data->diag = raw_part->type == PARTITION_COMPAQ_DIAG || ++ raw_part->type == PARTITION_MSFT_RECOVERY || + raw_part->type == PARTITION_DELL_DIAG; + dos_data->orig = ped_malloc (sizeof (OrigState)); + if (!dos_data->orig) { +@@ -1334,6 +1336,7 @@ msdos_partition_set_system (PedPartition* part, + /* Don't change the system if it already is a diag type, + otherwise use Compaq as almost all vendors use that. */ + if (dos_data->system != PARTITION_COMPAQ_DIAG && ++ dos_data->system != PARTITION_MSFT_RECOVERY && + dos_data->system != PARTITION_DELL_DIAG) + dos_data->system = PARTITION_COMPAQ_DIAG; + return 1; +-- +1.7.0.1 + +From 042f7dae4b95681cc613b4aad7c0339e2eef0bbe Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Thu, 6 May 2010 10:10:03 +0200 +Subject: [PATCH parted 2/2] gpt: recognize microsoft recovery GUID + +Microsoft advices creating recovery partitions with a GUID of +de94bba4-06d1-4d40-a16a-bfd50179d6ac, see: +http://technet.microsoft.com/en-us/library/dd744301%28WS.10%29.aspx + +This patch makes parted recognize this guid (using the DIAG flag). +* libparted/labels/gpt.c(PARTITION_MSFT_RECOVERY, GPTPartitionData, +_parse_part_entry, gpt_partition_new, gpt_partition_set_system, +gpt_partition_set_flag, gpt_partition_get_flag, +gpt_partition_is_flag_available): support microsoft recovery GUID +--- + libparted/labels/gpt.c | 39 +++++++++++++++++++++++++++++++++++++-- + 1 files changed, 39 insertions(+), 4 deletions(-) + +diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c +index 4793315..4aedd6d 100644 +--- a/libparted/labels/gpt.c ++++ b/libparted/labels/gpt.c +@@ -103,6 +103,10 @@ typedef struct + ((efi_guid_t) { PED_CPU_TO_LE32 (0xE3C9E316), PED_CPU_TO_LE16 (0x0B5C), \ + PED_CPU_TO_LE16 (0x4DB8), 0x81, 0x7D, \ + { 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE }}) ++#define PARTITION_MSFT_RECOVERY \ ++ ((efi_guid_t) { PED_CPU_TO_LE32 (0xDE94BBA4), PED_CPU_TO_LE16 (0x06D1), \ ++ PED_CPU_TO_LE16 (0x4D40), 0xA1, 0x6A, \ ++ { 0xBF, 0xD5, 0x01, 0x79, 0xD6, 0xAC }}) + #define PARTITION_BASIC_DATA_GUID \ + ((efi_guid_t) { PED_CPU_TO_LE32 (0xEBD0A0A2), PED_CPU_TO_LE16 (0xB9E5), \ + PED_CPU_TO_LE16 (0x4433), 0x87, 0xC0, \ +@@ -269,6 +273,7 @@ typedef struct _GPTPartitionData + int hidden; + int msftres; + int atvrecv; ++ int msftrecv; + } GPTPartitionData; + + static PedDiskType gpt_disk_type; +@@ -773,6 +778,7 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte) + gpt_part_data->lvm = gpt_part_data->raid + = gpt_part_data->boot = gpt_part_data->hp_service + = gpt_part_data->hidden = gpt_part_data->msftres ++ = gpt_part_data->msftrecv + = gpt_part_data->bios_grub = gpt_part_data->atvrecv = 0; + + if (pte->Attributes.RequiredToFunction & 0x1) +@@ -790,6 +796,8 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte) + gpt_part_data->hp_service = 1; + else if (!guid_cmp (gpt_part_data->type, PARTITION_MSFT_RESERVED_GUID)) + gpt_part_data->msftres = 1; ++ else if (!guid_cmp (gpt_part_data->type, PARTITION_MSFT_RECOVERY)) ++ gpt_part_data->msftrecv = 1; + else if (!guid_cmp (gpt_part_data->type, PARTITION_APPLE_TV_RECOVERY_GUID)) + gpt_part_data->atvrecv = 1; + +@@ -1291,6 +1299,7 @@ gpt_partition_new (const PedDisk *disk, + gpt_part_data->hp_service = 0; + gpt_part_data->hidden = 0; + gpt_part_data->msftres = 0; ++ gpt_part_data->msftrecv = 0; + gpt_part_data->atvrecv = 0; + uuid_generate ((unsigned char *) &gpt_part_data->uuid); + swap_uuid_and_efi_guid ((unsigned char *) (&gpt_part_data->uuid)); +@@ -1387,6 +1396,11 @@ gpt_partition_set_system (PedPartition *part, + gpt_part_data->type = PARTITION_MSFT_RESERVED_GUID; + return 1; + } ++ if (gpt_part_data->msftrecv) ++ { ++ gpt_part_data->type = PARTITION_MSFT_RECOVERY; ++ return 1; ++ } + if (gpt_part_data->atvrecv) + { + gpt_part_data->type = PARTITION_APPLE_TV_RECOVERY_GUID; +@@ -1491,6 +1505,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + = gpt_part_data->bios_grub + = gpt_part_data->hp_service + = gpt_part_data->msftres ++ = gpt_part_data->msftrecv + = gpt_part_data->atvrecv = 0; + return gpt_partition_set_system (part, part->fs_type); + case PED_PARTITION_BIOS_GRUB: +@@ -1501,6 +1516,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + = gpt_part_data->boot + = gpt_part_data->hp_service + = gpt_part_data->msftres ++ = gpt_part_data->msftrecv + = gpt_part_data->atvrecv = 0; + return gpt_partition_set_system (part, part->fs_type); + case PED_PARTITION_RAID: +@@ -1511,6 +1527,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + = gpt_part_data->bios_grub + = gpt_part_data->hp_service + = gpt_part_data->msftres ++ = gpt_part_data->msftrecv + = gpt_part_data->atvrecv = 0; + return gpt_partition_set_system (part, part->fs_type); + case PED_PARTITION_LVM: +@@ -1521,6 +1538,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + = gpt_part_data->bios_grub + = gpt_part_data->hp_service + = gpt_part_data->msftres ++ = gpt_part_data->msftrecv + = gpt_part_data->atvrecv = 0; + return gpt_partition_set_system (part, part->fs_type); + case PED_PARTITION_HPSERVICE: +@@ -1531,6 +1549,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + = gpt_part_data->lvm + = gpt_part_data->bios_grub + = gpt_part_data->msftres ++ = gpt_part_data->msftrecv + = gpt_part_data->atvrecv = 0; + return gpt_partition_set_system (part, part->fs_type); + case PED_PARTITION_MSFT_RESERVED: +@@ -1541,6 +1560,18 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + = gpt_part_data->lvm + = gpt_part_data->bios_grub + = gpt_part_data->hp_service ++ = gpt_part_data->msftrecv ++ = gpt_part_data->atvrecv = 0; ++ return gpt_partition_set_system (part, part->fs_type); ++ case PED_PARTITION_DIAG: ++ gpt_part_data->msftrecv = state; ++ if (state) ++ gpt_part_data->boot ++ = gpt_part_data->raid ++ = gpt_part_data->lvm ++ = gpt_part_data->bios_grub ++ = gpt_part_data->hp_service ++ = gpt_part_data->msftres + = gpt_part_data->atvrecv = 0; + return gpt_partition_set_system (part, part->fs_type); + case PED_PARTITION_APPLE_TV_RECOVERY: +@@ -1551,7 +1582,8 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + = gpt_part_data->lvm + = gpt_part_data->bios_grub + = gpt_part_data->hp_service +- = gpt_part_data->msftres = 0; ++ = gpt_part_data->msftres ++ = gpt_part_data->msftrecv = 0; + return gpt_partition_set_system (part, part->fs_type); + case PED_PARTITION_HIDDEN: + gpt_part_data->hidden = state; +@@ -1586,7 +1618,9 @@ gpt_partition_get_flag (const PedPartition *part, PedPartitionFlag flag) + return gpt_part_data->hp_service; + case PED_PARTITION_MSFT_RESERVED: + return gpt_part_data->msftres; +- case PED_PARTITION_APPLE_TV_RECOVERY: ++ case PED_PARTITION_DIAG: ++ return gpt_part_data->msftrecv; ++ case PED_PARTITION_APPLE_TV_RECOVERY: + return gpt_part_data->atvrecv; + case PED_PARTITION_HIDDEN: + return gpt_part_data->hidden; +@@ -1611,6 +1645,7 @@ gpt_partition_is_flag_available (const PedPartition *part, + case PED_PARTITION_BIOS_GRUB: + case PED_PARTITION_HPSERVICE: + case PED_PARTITION_MSFT_RESERVED: ++ case PED_PARTITION_DIAG: + case PED_PARTITION_APPLE_TV_RECOVERY: + case PED_PARTITION_HIDDEN: + return 1; +-- +1.7.0.1 + diff --git a/parted.spec b/parted.spec index f971ff9..0f9d50c 100644 --- a/parted.spec +++ b/parted.spec @@ -4,7 +4,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 2.2 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv3+ Group: Applications/System URL: http://www.gnu.org/software/parted @@ -21,6 +21,8 @@ Patch1: parted-2.2-add-diag-flag-rh583626.patch Patch2: parted-2.2-dm_task_run-retcode-rh585158.patch # Fix mkpartfs (ext2) on partition >2TB Patch3: parted-2.2-blkoflow-rh585159.patch +# Also recognize recovery partitions with id 27 / on gpt +Patch4: parted-2.2-extend-diag-flag-rh589451.patch Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: e2fsprogs-devel @@ -64,6 +66,7 @@ Parted library, you need to install this package. %patch1 -p1 %patch2 -p1 %patch3 -p1 +%patch4 -p1 iconv -f ISO-8859-1 -t UTF8 AUTHORS > tmp; touch -r AUTHORS tmp; mv tmp AUTHORS @@ -139,6 +142,9 @@ fi %changelog +* Thu May 6 2010 Hans de Goede 2.2-5 +- Also recognize recovery partitions with id 27 / on gpt (#589451) + * Fri Apr 23 2010 Hans de Goede 2.2-4 - Properly check dm_task_run return value (#585158) - Fix mkpartfs (ext2) on partitions >2TB (#585159)