parted/libparted-set-swap-flag-on-GPT-partitions.patch
2017-06-15 19:25:03 +00:00

214 lines
7.4 KiB
Diff

From: Arvin Schnell <aschnell@suse.com>
Date: Thu, 22 Dec 2016 14:36:43 -0800
Subject: libparted: set swap flag on GPT partitions
References: fate#314888, bsc#1044536
Patch-mainline: v3.3
Git-commit: c7ce5d48f6facccf617467d79c68ccce0bc27dcd
The filesystem type is still detected as befor, but now setting the
'swap' flag will set the partition GUID to PARTITION_SWAP_GUID.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
[sparschauer: Drop setting PARTITION_SWAP_GUID when the FS is swap]
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
libparted/labels/gpt.c | 42 +++++++++++++++++++++++++++++++++++++++---
1 file changed, 39 insertions(+), 3 deletions(-)
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -290,6 +290,7 @@ typedef struct _GPTPartitionData
efi_char16_t name[37];
char *translated_name;
int lvm;
+ int swap;
int raid;
int boot;
int bios_grub;
@@ -918,7 +919,8 @@ _parse_part_entry (PedDisk *disk, GuidPa
gpt_part_data->name[i] = 0;
gpt_part_data->translated_name = 0;
- gpt_part_data->lvm = gpt_part_data->raid
+ gpt_part_data->lvm = gpt_part_data->swap
+ = gpt_part_data->raid
= gpt_part_data->boot = gpt_part_data->hp_service
= gpt_part_data->hidden = gpt_part_data->msftres
= gpt_part_data->msftdata
@@ -941,6 +943,8 @@ _parse_part_entry (PedDisk *disk, GuidPa
gpt_part_data->raid = 1;
else if (!guid_cmp (gpt_part_data->type, PARTITION_LVM_GUID))
gpt_part_data->lvm = 1;
+ else if (!guid_cmp (gpt_part_data->type, PARTITION_SWAP_GUID))
+ gpt_part_data->swap = 1;
else if (!guid_cmp (gpt_part_data->type, PARTITION_HPSERVICE_GUID))
gpt_part_data->hp_service = 1;
else if (!guid_cmp (gpt_part_data->type, PARTITION_MSFT_RESERVED_GUID))
@@ -1568,6 +1572,7 @@ gpt_partition_new (const PedDisk *disk,
gpt_part_data->type = PARTITION_LINUX_DATA_GUID;
gpt_part_data->lvm = 0;
+ gpt_part_data->swap = 0;
gpt_part_data->raid = 0;
gpt_part_data->boot = 0;
gpt_part_data->bios_grub = 0;
@@ -1656,6 +1661,11 @@ gpt_partition_set_system (PedPartition *
gpt_part_data->type = PARTITION_LVM_GUID;
return 1;
}
+ if (gpt_part_data->swap)
+ {
+ gpt_part_data->type = PARTITION_SWAP_GUID;
+ return 1;
+ }
if (gpt_part_data->raid)
{
gpt_part_data->type = PARTITION_RAID_GUID;
@@ -1720,11 +1730,6 @@ gpt_partition_set_system (PedPartition *
gpt_part_data->type = PARTITION_APPLE_HFS_GUID;
return 1;
}
- if (strstr (fs_type->name, "swap"))
- {
- gpt_part_data->type = PARTITION_SWAP_GUID;
- return 1;
- }
}
gpt_part_data->type = PARTITION_LINUX_DATA_GUID;
@@ -1843,6 +1848,7 @@ gpt_partition_set_flag (PedPartition *pa
if (state)
gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1857,6 +1863,7 @@ gpt_partition_set_flag (PedPartition *pa
if (state)
gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->boot
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1871,6 +1878,7 @@ gpt_partition_set_flag (PedPartition *pa
if (state)
gpt_part_data->boot
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1884,6 +1892,22 @@ gpt_partition_set_flag (PedPartition *pa
gpt_part_data->lvm = state;
if (state)
gpt_part_data->boot
+ = gpt_part_data->swap
+ = gpt_part_data->raid
+ = gpt_part_data->bios_grub
+ = gpt_part_data->hp_service
+ = gpt_part_data->msftres
+ = gpt_part_data->msftdata
+ = gpt_part_data->msftrecv
+ = gpt_part_data->prep
+ = gpt_part_data->irst
+ = gpt_part_data->atvrecv = 0;
+ return gpt_partition_set_system (part, part->fs_type);
+ case PED_PARTITION_SWAP:
+ gpt_part_data->swap = state;
+ if (state)
+ gpt_part_data->boot
+ = gpt_part_data->lvm
= gpt_part_data->raid
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
@@ -1900,6 +1924,7 @@ gpt_partition_set_flag (PedPartition *pa
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->msftres
= gpt_part_data->msftdata
@@ -1914,6 +1939,7 @@ gpt_partition_set_flag (PedPartition *pa
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftdata
@@ -1928,6 +1954,7 @@ gpt_partition_set_flag (PedPartition *pa
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1946,6 +1973,7 @@ gpt_partition_set_flag (PedPartition *pa
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftdata
@@ -1960,6 +1988,7 @@ gpt_partition_set_flag (PedPartition *pa
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1973,6 +2002,7 @@ gpt_partition_set_flag (PedPartition *pa
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1986,6 +2016,7 @@ gpt_partition_set_flag (PedPartition *pa
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -2000,7 +2031,6 @@ gpt_partition_set_flag (PedPartition *pa
case PED_PARTITION_LEGACY_BOOT:
gpt_part_data->legacy_boot = state;
return 1;
- case PED_PARTITION_SWAP:
case PED_PARTITION_ROOT:
case PED_PARTITION_LBA:
default:
@@ -2046,6 +2076,7 @@ gpt_partition_get_flag (const PedPartiti
case PED_PARTITION_IRST:
return gpt_part_data->irst;
case PED_PARTITION_SWAP:
+ return gpt_part_data->swap;
case PED_PARTITION_LBA:
case PED_PARTITION_ROOT:
default:
@@ -2062,6 +2093,7 @@ gpt_partition_is_flag_available (const P
{
case PED_PARTITION_RAID:
case PED_PARTITION_LVM:
+ case PED_PARTITION_SWAP:
case PED_PARTITION_BOOT:
case PED_PARTITION_BIOS_GRUB:
case PED_PARTITION_HPSERVICE:
@@ -2075,7 +2107,6 @@ gpt_partition_is_flag_available (const P
case PED_PARTITION_IRST:
case PED_PARTITION_ESP:
return 1;
- case PED_PARTITION_SWAP:
case PED_PARTITION_ROOT:
case PED_PARTITION_LBA:
default: