Blame SOURCES/parted-3.1-libparted-preserve-the-uuid-on-dm-partitions.patch

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