parted/parted-3.1-libparted-preserve-the-uuid-on-dm-partitions.patch
Brian C. Lane 5c7b01233e - use dm_udev_wait to synchronize with udev
- use largest_partnum in dm_reread_part_table (#803108)
- preserve the uuid on dm partitions (#832145)
2012-08-07 12:39:09 -07:00

72 lines
2.5 KiB
Diff

From 399cfc2a9cfc60a46ab9094b4c999bb11a36033e Mon Sep 17 00:00:00 2001
From: Fedora Ninjas <parted-owner@fedoraproject.org>
Date: Fri, 3 Aug 2012 17:03:50 -0700
Subject: [PATCH] libparted: preserve the uuid on dm partitions (#832145)
* libparted/arch/linux.c (_dm_add_partition): Set the uuid if there was
one.
---
libparted/arch/linux.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 37ddb5f..9f0434a 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2803,6 +2803,8 @@ _dm_add_partition (PedDisk* disk, PedPartition* part)
{
char* vol_name = NULL;
const char* dev_name = NULL;
+ char* vol_uuid = NULL;
+ const char* dev_uuid = NULL;
char* params = NULL;
LinuxSpecific* arch_specific = LINUX_SPECIFIC (disk->dev);
uint32_t cookie = 0;
@@ -2820,6 +2822,7 @@ _dm_add_partition (PedDisk* disk, PedPartition* part)
goto err;
dev_name = dm_task_get_name (task);
+ dev_uuid = dm_task_get_uuid (task);
if (isdigit (dev_name[strlen (dev_name) - 1])) {
if ( ! (vol_name = zasprintf ("%sp%d", dev_name, part->num)))
@@ -2827,6 +2830,10 @@ _dm_add_partition (PedDisk* disk, PedPartition* part)
} else if ( ! (vol_name = zasprintf ("%s%d", dev_name, part->num)))
goto err;
+ if ( dev_uuid && (strlen(dev_uuid) > 0) \
+ && ! (vol_uuid = zasprintf ("%sp%d", dev_uuid, part->num)))
+ goto err;
+
/* Caution: dm_task_destroy frees dev_name. */
dm_task_destroy (task);
task = NULL;
@@ -2840,6 +2847,8 @@ _dm_add_partition (PedDisk* disk, PedPartition* part)
goto err;
dm_task_set_name (task, vol_name);
+ if (vol_uuid)
+ dm_task_set_uuid (task, vol_uuid);
dm_task_add_target (task, 0, part->geom.length,
"linear", params);
if (!dm_task_set_cookie(task, &cookie, 0))
@@ -2850,6 +2859,7 @@ _dm_add_partition (PedDisk* disk, PedPartition* part)
dm_task_update_nodes();
dm_task_destroy(task);
free(params);
+ free(vol_uuid);
free(vol_name);
return 1;
} else {
@@ -2861,6 +2871,7 @@ err:
if (task)
dm_task_destroy (task);
free (params);
+ free (vol_uuid);
free (vol_name);
return 0;
}
--
1.7.7.6