[PATCH parted 2/3] linux: Use devicemapper task name instead of device node name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use devicemapper task name instead of device node name as basename for
devicemapper disk partitions.

This is needed for upcoming lvm changes where the /dev/mapper/foobar files are
becoming symlinks, so we will end up opening /dev/dm-#, and naming our
partitions dm-#p1, dm-#p2, instead of foobarp1, foobarp2, etc.
---
 libparted/arch/linux.c |   34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index a564ad7..3ca938a 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2393,36 +2393,38 @@ err:
 static int
 _dm_add_partition (PedDisk* disk, PedPartition* part)
 {
-        struct stat     dev_stat;
         struct dm_task* task = NULL;
         int             rc;
         char*           vol_name = NULL;
-        char*           dev_name = NULL;
+        const char*     dev_name = NULL;
         char*           params = NULL;
+        LinuxSpecific*  arch_specific = LINUX_SPECIFIC (disk->dev);
 
         if (!_has_partitions(disk))
                 return 0;
 
-        dev_name = _device_get_part_path (disk->dev, part->num);
-        if (!dev_name)
-                return 0;
+        /* Get map name from devicemapper */
+        task = dm_task_create(DM_DEVICE_INFO);
+        if (!task)
+                goto err;
 
-        vol_name = strrchr (dev_name, '/');
-        if (vol_name && *vol_name && *(++vol_name))
-                vol_name = strdup (vol_name);
-        else
-                vol_name = strdup (dev_name);
-        if (!vol_name)
-                return 0;
+        if (!dm_task_set_major_minor(task, arch_specific->major,
+                                     arch_specific->minor, 0))
+                goto err;
 
-        if (!_device_stat (disk->dev, &dev_stat))
+        rc = dm_task_run(task);
+        if (rc < 0)
                 goto err;
 
-        if (asprintf (&params, "%d:%d %lld", major (dev_stat.st_rdev),
-                      minor (dev_stat.st_rdev), part->geom.start) == -1)
+        dev_name = dm_task_get_name(task);
+        dm_task_destroy (task);
+        task = NULL;
+
+        if (asprintf (&vol_name, "%sp%d", dev_name, part->num) == -1)
                 goto err;
 
-        if (!params)
+        if (asprintf (&params, "%d:%d %lld", arch_specific->major,
+                      arch_specific->minor, part->geom.start) == -1)
                 goto err;
 
         task = dm_task_create (DM_DEVICE_CREATE);
-- 
1.6.5.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux