[parted-devel] [PATCH 4/4] libparted: set dmraid partition uuid

Phillip Susi phillsusi at gmail.com
Sun Jan 8 17:39:02 UTC 2012


When dmraid creates the partition devices, it assigns them a UUID in the
form of "DMRAID-XXXXX".  When kpartx creates the partitions, it assigns
them a UUID of the form "partN-DMRAID-XXXX".  This patch has parted use
the kpartx style.
---
 NEWS                   |    6 ++++++
 libparted/arch/linux.c |    8 ++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/NEWS b/NEWS
index f616b72..4528fa4 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,12 @@ GNU parted NEWS                                    -*- outline -*-
   parted has improved support for partitionable loopback devices
 
 ** Bug fixes
+  libparted: set dmraid partition uuid.  When dmraid creates the
+  partition devices, it assigns them a UUID in the form of
+  "DMRAID-XXXXX".  When kpartx creates the partitions, it assigns
+  them a UUID of the form "partN-DMRAID-XXXX".  Parted will now
+  set the UUID and use the kpartx style.
+
   libparted: Don't fail to manipulate partitions on dmraid disks that
   have other partitions in use.
 
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 6d1b5e9..a75d7cd 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2842,6 +2842,8 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
         const char*     dev_name = NULL;
         char*           params = NULL;
         LinuxSpecific*  arch_specific = LINUX_SPECIFIC (disk->dev);
+        char*           dm_uuid = NULL;
+        int             uuid_len;
 
         /* Get map name from devicemapper */
         struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
@@ -2878,6 +2880,12 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
         dm_task_set_name (task, vol_name);
         dm_task_add_target (task, 0, part->geom.length,
                 "linear", params);
+        if (_is_dmraid_device (disk->dev->path)) {
+                uuid_len = (strlen (vol_name) + 8);
+                dm_uuid = (char*) ped_malloc (uuid_len);
+                snprintf (dm_uuid, uuid_len, "part%d-DMRAID-%s", part->num, vol_name);
+                dm_task_set_uuid (task, dm_uuid);
+        }
         if (dm_task_run (task)) {
                 //printf("0 %ld linear %s\n", part->geom.length, params);
                 dm_task_update_nodes();
-- 
1.7.5.4




More information about the parted-devel mailing list