2014-03-25 00:09:24 +00:00
|
|
|
From 39e38c0a4c0f3ad0e029792e0ddee9761b956c1e Mon Sep 17 00:00:00 2001
|
2013-08-28 16:13:40 +00:00
|
|
|
From: "Brian C. Lane" <bcl@redhat.com>
|
2014-03-25 00:09:24 +00:00
|
|
|
Date: Wed, 11 Sep 2013 12:24:54 -0700
|
|
|
|
Subject: [PATCH 71/89] libparted: preserve the uuid on dm partitions (#832145)
|
2013-08-28 16:13:40 +00:00
|
|
|
|
|
|
|
* libparted/arch/linux.c (_dm_add_partition): Set the uuid if there was
|
|
|
|
one.
|
|
|
|
---
|
|
|
|
libparted/arch/linux.c | 20 ++++++++++++++++----
|
|
|
|
1 file changed, 16 insertions(+), 4 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
|
2014-03-25 00:09:24 +00:00
|
|
|
index 452ea7f..4376d17 100644
|
2013-08-28 16:13:40 +00:00
|
|
|
--- a/libparted/arch/linux.c
|
|
|
|
+++ b/libparted/arch/linux.c
|
2014-03-25 00:09:24 +00:00
|
|
|
@@ -2710,9 +2710,12 @@ static int
|
2013-08-28 16:13:40 +00:00
|
|
|
_dm_add_partition (PedDisk* disk, const PedPartition* part)
|
|
|
|
{
|
|
|
|
LinuxSpecific* arch_specific = LINUX_SPECIFIC (disk->dev);
|
|
|
|
- char *params = NULL;
|
|
|
|
- char *vol_name = NULL;
|
|
|
|
- uint32_t cookie = 0;
|
|
|
|
+ char* params = NULL;
|
|
|
|
+ char* vol_name = NULL;
|
|
|
|
+ const char* dev_name = NULL;
|
|
|
|
+ char* vol_uuid = NULL;
|
|
|
|
+ const char* dev_uuid = NULL;
|
|
|
|
+ uint32_t cookie = 0;
|
|
|
|
|
|
|
|
/* Get map name from devicemapper */
|
|
|
|
struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
|
2014-03-25 00:09:24 +00:00
|
|
|
@@ -2726,7 +2729,7 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
|
|
|
|
if (!dm_task_run(task))
|
2013-08-28 16:13:40 +00:00
|
|
|
goto err;
|
|
|
|
|
|
|
|
- const char *dev_name = dm_task_get_name (task);
|
|
|
|
+ dev_name = dm_task_get_name (task);
|
|
|
|
size_t name_len = strlen (dev_name);
|
|
|
|
vol_name = zasprintf ("%s%s%d",
|
|
|
|
dev_name,
|
2014-03-25 00:09:24 +00:00
|
|
|
@@ -2735,6 +2738,11 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
|
2013-08-28 16:13:40 +00:00
|
|
|
if (vol_name == NULL)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
+ dev_uuid = dm_task_get_uuid (task);
|
|
|
|
+ if (dev_uuid && (strlen(dev_uuid) > 0)
|
|
|
|
+ && !(vol_uuid = zasprintf ("part%d-%s", part->num, dev_uuid)))
|
|
|
|
+ goto err;
|
|
|
|
+
|
|
|
|
/* Caution: dm_task_destroy frees dev_name. */
|
|
|
|
dm_task_destroy (task);
|
|
|
|
task = NULL;
|
2014-03-25 00:09:24 +00:00
|
|
|
@@ -2747,6 +2755,8 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
|
2013-08-28 16:13:40 +00:00
|
|
|
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))
|
2014-03-25 00:09:24 +00:00
|
|
|
@@ -2755,6 +2765,7 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
|
2013-08-28 16:13:40 +00:00
|
|
|
dm_task_update_nodes ();
|
|
|
|
dm_task_destroy (task);
|
|
|
|
free (params);
|
|
|
|
+ free (vol_uuid);
|
|
|
|
free (vol_name);
|
|
|
|
return 1;
|
|
|
|
} else {
|
2014-03-25 00:09:24 +00:00
|
|
|
@@ -2765,6 +2776,7 @@ err:
|
2013-08-28 16:13:40 +00:00
|
|
|
if (task)
|
|
|
|
dm_task_destroy (task);
|
|
|
|
free (params);
|
|
|
|
+ free (vol_uuid);
|
|
|
|
free (vol_name);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
--
|
2014-03-25 00:09:24 +00:00
|
|
|
1.8.5.3
|
2013-08-28 16:13:40 +00:00
|
|
|
|