Blame SOURCES/0062-libparted-set-swap-flag-on-GPT-partitions.patch

003ee8
From f209b71efc693b97b7c812678e811698ffd2bc79 Mon Sep 17 00:00:00 2001
003ee8
From: Arvin Schnell <aschnell@suse.com>
003ee8
Date: Thu, 22 Dec 2016 14:36:43 -0800
003ee8
Subject: [PATCH 62/75] libparted: set swap flag on GPT partitions
003ee8
003ee8
The filesystem type is still detected as befor, but now setting the
003ee8
'swap' flag will set the partition GUID to PARTITION_SWAP_GUID.
003ee8
003ee8
Signed-off-by: Brian C. Lane <bcl@redhat.com>
003ee8
---
003ee8
 libparted/labels/gpt.c | 42 +++++++++++++++++++++++++++++++++++++++---
003ee8
 1 file changed, 39 insertions(+), 3 deletions(-)
003ee8
003ee8
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
003ee8
index 6027eb3..4f922b2 100644
003ee8
--- a/libparted/labels/gpt.c
003ee8
+++ b/libparted/labels/gpt.c
003ee8
@@ -290,6 +290,7 @@ typedef struct _GPTPartitionData
003ee8
   efi_char16_t name[37];
003ee8
   char *translated_name;
003ee8
   int lvm;
003ee8
+  int swap;
003ee8
   int raid;
003ee8
   int boot;
003ee8
   int bios_grub;
003ee8
@@ -818,7 +819,8 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
003ee8
   gpt_part_data->name[i] = 0;
003ee8
   gpt_part_data->translated_name = 0;
003ee8
 
003ee8
-  gpt_part_data->lvm = gpt_part_data->raid
003ee8
+  gpt_part_data->lvm = gpt_part_data->swap
003ee8
+    = gpt_part_data->raid
003ee8
     = gpt_part_data->boot = gpt_part_data->hp_service
003ee8
     = gpt_part_data->hidden = gpt_part_data->msftres
003ee8
     = gpt_part_data->msftdata
003ee8
@@ -841,6 +843,8 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
003ee8
     gpt_part_data->raid = 1;
003ee8
   else if (!guid_cmp (gpt_part_data->type, PARTITION_LVM_GUID))
003ee8
     gpt_part_data->lvm = 1;
003ee8
+  else if (!guid_cmp (gpt_part_data->type, PARTITION_SWAP_GUID))
003ee8
+    gpt_part_data->swap = 1;
003ee8
   else if (!guid_cmp (gpt_part_data->type, PARTITION_HPSERVICE_GUID))
003ee8
     gpt_part_data->hp_service = 1;
003ee8
   else if (!guid_cmp (gpt_part_data->type, PARTITION_MSFT_RESERVED_GUID))
003ee8
@@ -1361,6 +1365,7 @@ gpt_partition_new (const PedDisk *disk,
003ee8
 
003ee8
   gpt_part_data->type = PARTITION_LINUX_DATA_GUID;
003ee8
   gpt_part_data->lvm = 0;
003ee8
+  gpt_part_data->swap = 0;
003ee8
   gpt_part_data->raid = 0;
003ee8
   gpt_part_data->boot = 0;
003ee8
   gpt_part_data->bios_grub = 0;
003ee8
@@ -1449,6 +1454,11 @@ gpt_partition_set_system (PedPartition *part,
003ee8
       gpt_part_data->type = PARTITION_LVM_GUID;
003ee8
       return 1;
003ee8
     }
003ee8
+  if (gpt_part_data->swap)
003ee8
+    {
003ee8
+      gpt_part_data->type = PARTITION_SWAP_GUID;
003ee8
+      return 1;
003ee8
+    }
003ee8
   if (gpt_part_data->raid)
003ee8
     {
003ee8
       gpt_part_data->type = PARTITION_RAID_GUID;
003ee8
@@ -1636,6 +1646,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
003ee8
       if (state)
003ee8
         gpt_part_data->raid
003ee8
           = gpt_part_data->lvm
003ee8
+          = gpt_part_data->swap
003ee8
           = gpt_part_data->bios_grub
003ee8
           = gpt_part_data->hp_service
003ee8
           = gpt_part_data->msftres
003ee8
@@ -1650,6 +1661,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
003ee8
       if (state)
003ee8
         gpt_part_data->raid
003ee8
           = gpt_part_data->lvm
003ee8
+          = gpt_part_data->swap
003ee8
           = gpt_part_data->boot
003ee8
           = gpt_part_data->hp_service
003ee8
           = gpt_part_data->msftres
003ee8
@@ -1664,6 +1676,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
003ee8
       if (state)
003ee8
         gpt_part_data->boot
003ee8
           = gpt_part_data->lvm
003ee8
+          = gpt_part_data->swap
003ee8
           = gpt_part_data->bios_grub
003ee8
           = gpt_part_data->hp_service
003ee8
           = gpt_part_data->msftres
003ee8
@@ -1677,6 +1690,22 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
003ee8
       gpt_part_data->lvm = state;
003ee8
       if (state)
003ee8
         gpt_part_data->boot
003ee8
+          = gpt_part_data->swap
003ee8
+          = gpt_part_data->raid
003ee8
+          = gpt_part_data->bios_grub
003ee8
+          = gpt_part_data->hp_service
003ee8
+          = gpt_part_data->msftres
003ee8
+          = gpt_part_data->msftdata
003ee8
+          = gpt_part_data->msftrecv
003ee8
+          = gpt_part_data->prep
003ee8
+          = gpt_part_data->irst
003ee8
+          = gpt_part_data->atvrecv = 0;
003ee8
+      return gpt_partition_set_system (part, part->fs_type);
003ee8
+    case PED_PARTITION_SWAP:
003ee8
+      gpt_part_data->swap = state;
003ee8
+      if (state)
003ee8
+        gpt_part_data->boot
003ee8
+          = gpt_part_data->lvm
003ee8
           = gpt_part_data->raid
003ee8
           = gpt_part_data->bios_grub
003ee8
           = gpt_part_data->hp_service
003ee8
@@ -1693,6 +1722,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
003ee8
         gpt_part_data->boot
003ee8
           = gpt_part_data->raid
003ee8
           = gpt_part_data->lvm
003ee8
+          = gpt_part_data->swap
003ee8
           = gpt_part_data->bios_grub
003ee8
           = gpt_part_data->msftres
003ee8
           = gpt_part_data->msftdata
003ee8
@@ -1707,6 +1737,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
003ee8
         gpt_part_data->boot
003ee8
           = gpt_part_data->raid
003ee8
           = gpt_part_data->lvm
003ee8
+          = gpt_part_data->swap
003ee8
           = gpt_part_data->bios_grub
003ee8
           = gpt_part_data->hp_service
003ee8
           = gpt_part_data->msftdata
003ee8
@@ -1721,6 +1752,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
003ee8
         gpt_part_data->boot
003ee8
           = gpt_part_data->raid
003ee8
           = gpt_part_data->lvm
003ee8
+          = gpt_part_data->swap
003ee8
           = gpt_part_data->bios_grub
003ee8
           = gpt_part_data->hp_service
003ee8
           = gpt_part_data->msftres
003ee8
@@ -1739,6 +1771,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
003ee8
         gpt_part_data->boot
003ee8
           = gpt_part_data->raid
003ee8
           = gpt_part_data->lvm
003ee8
+          = gpt_part_data->swap
003ee8
           = gpt_part_data->bios_grub
003ee8
           = gpt_part_data->hp_service
003ee8
           = gpt_part_data->msftdata
003ee8
@@ -1753,6 +1786,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
003ee8
         gpt_part_data->boot
003ee8
           = gpt_part_data->raid
003ee8
           = gpt_part_data->lvm
003ee8
+          = gpt_part_data->swap
003ee8
           = gpt_part_data->bios_grub
003ee8
           = gpt_part_data->hp_service
003ee8
           = gpt_part_data->msftres
003ee8
@@ -1766,6 +1800,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
003ee8
         gpt_part_data->boot
003ee8
           = gpt_part_data->raid
003ee8
           = gpt_part_data->lvm
003ee8
+          = gpt_part_data->swap
003ee8
           = gpt_part_data->bios_grub
003ee8
           = gpt_part_data->hp_service
003ee8
           = gpt_part_data->msftres
003ee8
@@ -1779,6 +1814,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
003ee8
         gpt_part_data->boot
003ee8
           = gpt_part_data->raid
003ee8
           = gpt_part_data->lvm
003ee8
+          = gpt_part_data->swap
003ee8
           = gpt_part_data->bios_grub
003ee8
           = gpt_part_data->hp_service
003ee8
           = gpt_part_data->msftres
003ee8
@@ -1793,7 +1829,6 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
003ee8
     case PED_PARTITION_LEGACY_BOOT:
003ee8
       gpt_part_data->legacy_boot = state;
003ee8
       return 1;
003ee8
-    case PED_PARTITION_SWAP:
003ee8
     case PED_PARTITION_ROOT:
003ee8
     case PED_PARTITION_LBA:
003ee8
     default:
003ee8
@@ -1839,6 +1874,7 @@ gpt_partition_get_flag (const PedPartition *part, PedPartitionFlag flag)
003ee8
     case PED_PARTITION_IRST:
003ee8
       return gpt_part_data->irst;
003ee8
     case PED_PARTITION_SWAP:
003ee8
+	return gpt_part_data->swap;
003ee8
     case PED_PARTITION_LBA:
003ee8
     case PED_PARTITION_ROOT:
003ee8
     default:
003ee8
@@ -1855,6 +1891,7 @@ gpt_partition_is_flag_available (const PedPartition *part,
003ee8
     {
003ee8
     case PED_PARTITION_RAID:
003ee8
     case PED_PARTITION_LVM:
003ee8
+    case PED_PARTITION_SWAP:
003ee8
     case PED_PARTITION_BOOT:
003ee8
     case PED_PARTITION_BIOS_GRUB:
003ee8
     case PED_PARTITION_HPSERVICE:
003ee8
@@ -1868,7 +1905,6 @@ gpt_partition_is_flag_available (const PedPartition *part,
003ee8
     case PED_PARTITION_IRST:
003ee8
     case PED_PARTITION_ESP:
003ee8
       return 1;
003ee8
-    case PED_PARTITION_SWAP:
003ee8
     case PED_PARTITION_ROOT:
003ee8
     case PED_PARTITION_LBA:
003ee8
     default:
003ee8
-- 
003ee8
2.9.3
003ee8