You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.5 KiB
71 lines
2.5 KiB
From e2b9f9051c8d9905b15af0f7fa79c85502370b25 Mon Sep 17 00:00:00 2001 |
|
From: Brian C. Lane <bcl@redhat.com> |
|
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 file changed, 11 insertions(+) |
|
|
|
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c |
|
index 37ddb5f..2c410a0 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 ("part%d-%s", part->num, dev_uuid))) |
|
+ 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.11.4 |
|
|
|
|