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