47 lines
1.7 KiB
Diff
47 lines
1.7 KiB
Diff
From: Sebastian Parschauer <sparschauer@suse.de>
|
|
Date: Thu, 15 Jun 2017 18:50:32 +0200
|
|
Subject: parted: mkpart: set a swap flag if available
|
|
References: fate#314888, bsc#1044536
|
|
Patch-mainline: no, upstream wants to drop the swap flag
|
|
|
|
libparted can't differentiate if ped_partition_set_system() is
|
|
called from mkpart context or when reading from disk. This makes
|
|
it hard to handle the linux-swap partition type properly.
|
|
|
|
So check in do_mkpart() if a swap flag is available and only set it
|
|
there if the selected FS type name starts with "linux-swap".
|
|
|
|
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
|
|
---
|
|
parted/parted.c | 10 ++++++++++
|
|
1 file changed, 10 insertions(+)
|
|
|
|
Index: parted-3.3/parted/parted.c
|
|
===================================================================
|
|
--- parted-3.3.orig/parted/parted.c
|
|
+++ parted-3.3/parted/parted.c
|
|
@@ -656,6 +656,13 @@ _adjust_end_if_iec (PedSector* start, Pe
|
|
}
|
|
|
|
|
|
+static inline int
|
|
+is_linux_swap (char const *fs_type_name)
|
|
+{
|
|
+ char const *prefix = "linux-swap";
|
|
+ return strncmp (fs_type_name, prefix, strlen (prefix)) == 0;
|
|
+}
|
|
+
|
|
static int
|
|
do_mkpart (PedDevice** dev, PedDisk** diskp)
|
|
{
|
|
@@ -852,6 +859,9 @@ do_mkpart (PedDevice** dev, PedDisk** di
|
|
goto error_remove_part;
|
|
if (ped_partition_is_flag_available (part, PED_PARTITION_LBA))
|
|
ped_partition_set_flag (part, PED_PARTITION_LBA, 1);
|
|
+ if (ped_partition_is_flag_available (part, PED_PARTITION_SWAP) &&
|
|
+ fs_type && is_linux_swap(fs_type->name))
|
|
+ ped_partition_set_flag (part, PED_PARTITION_SWAP, 1);
|
|
|
|
if (wipesignatures) {
|
|
if (!ped_device_wipe_signatures(*dev, part->geom.start, part->geom.length))
|