GNU bug report logs - #15352
[PATCH 04/19] libparted: preserve the uuid on dm partitions (#832145)

Previous Next

Package: parted;

Reported by: "Brian C. Lane" <bcl <at> redhat.com>

Date: Wed, 11 Sep 2013 20:17:02 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 15352 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-parted <at> gnu.org:
bug#15352; Package parted. (Wed, 11 Sep 2013 20:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Brian C. Lane" <bcl <at> redhat.com>:
New bug report received and forwarded. Copy sent to bug-parted <at> gnu.org. (Wed, 11 Sep 2013 20:17:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Brian C. Lane" <bcl <at> redhat.com>
To: bug-parted <at> gnu.org
Subject: [PATCH 04/19] libparted: preserve the uuid on dm partitions (#832145)
Date: Wed, 11 Sep 2013 12:24:54 -0700
From: "Brian C. Lane" <bcl <at> redhat.com>

* 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
index 1c5faa5..375be83 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2711,9 +2711,12 @@ static int
 _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);
@@ -2727,7 +2730,7 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
         if (!dm_task_run (task))
                 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,
@@ -2736,6 +2739,11 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
         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;
@@ -2748,6 +2756,8 @@ _dm_add_partition (PedDisk* disk, const 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))
@@ -2756,6 +2766,7 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
                 dm_task_update_nodes ();
                 dm_task_destroy (task);
                 free (params);
+                free (vol_uuid);
                 free (vol_name);
                 return 1;
         } else {
@@ -2766,6 +2777,7 @@ err:
         if (task)
                 dm_task_destroy (task);
         free (params);
+        free (vol_uuid);
         free (vol_name);
         return 0;
 }
-- 
1.8.3.1





This bug report was last modified 11 years and 284 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.