Hi Otiavio,
from what I read on the debian-boot list a upload of parted 1.8 is about
to happen rather soon. Very cool! Now that most of the device mapper
code has been applied to parted SVN we only need the attached two
patches for multipath support. I hope Jim will apply the first one
rather soon, the second one is Debian specific and needed to get d-i to
work on multipath devices. I'd would be really nice to have this in beta3.
Cheers,
 -- Guido
>From 297c1888c7185e2eee8ecbd8d2ced99c6892824f Mon Sep 17 00:00:00 2001
From: Guido Guenther <[EMAIL PROTECTED]>
Date: Fri, 6 Jun 2008 15:33:55 +0200
Subject: [PATCH] move dmtype from PedDevice to LinuxSpecific

since this is a Linux only feature
---
 include/parted/device.h |    1 -
 include/parted/linux.h  |    1 +
 libparted/arch/linux.c  |   15 +++++++++------
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/include/parted/device.h b/include/parted/device.h
index 42d2593..fdfcb1f 100644
--- a/include/parted/device.h
+++ b/include/parted/device.h
@@ -72,7 +72,6 @@ struct _PedDevice {
 
         PedDeviceType   type;           /**< SCSI, IDE, etc.
                                              \deprecated \sa PedDeviceType */
-        char*		dmtype;         /**< device map target type */
         long long       sector_size;            /**< logical sector size */
         long long       phys_sector_size;       /**< physical sector size */
         PedSector       length;                 /**< device length (LBA) */
diff --git a/include/parted/linux.h b/include/parted/linux.h
index a496e53..1a4171d 100644
--- a/include/parted/linux.h
+++ b/include/parted/linux.h
@@ -32,6 +32,7 @@ typedef	struct _LinuxSpecific	LinuxSpecific;
 
 struct _LinuxSpecific {
 	int	fd;
+	char*	dmtype;         /**< device map target type */
 #if defined(__s390__) || defined(__s390x__)
 	unsigned int real_sector_size;
 	/* IBM internal dasd structure (i guess ;), required. */
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 57af6c7..4c9a2d3 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -304,6 +304,7 @@ _is_sx8_major (int major)
 static int
 _dm_maptype (PedDevice *dev)
 {
+        LinuxSpecific*  arch_specific = LINUX_SPECIFIC (dev);
         struct dm_task *dmt;
         void *next;
         uint64_t start, length;
@@ -329,8 +330,8 @@ _dm_maptype (PedDevice *dev)
         next = dm_get_next_target(dmt, NULL, &start, &length,
                                   &target_type, &params);
 
-        dev->dmtype = strdup(target_type);
-        if (dev->dmtype == NULL)
+        arch_specific->dmtype = strdup(target_type);
+        if (arch_specific->dmtype == NULL)
                 goto bad;
         r = 0;
 bad:
@@ -1150,6 +1151,7 @@ static PedDevice*
 linux_new (const char* path)
 {
         PedDevice*      dev;
+        LinuxSpecific*  arch_specific;
 
         PED_ASSERT (path != NULL, return NULL);
 
@@ -1157,7 +1159,6 @@ linux_new (const char* path)
         if (!dev)
                 goto error;
 
-        dev->dmtype = NULL;
         dev->path = strdup (path);
         if (!dev->path)
                 goto error_free_dev;
@@ -1166,6 +1167,8 @@ linux_new (const char* path)
                 = (LinuxSpecific*) ped_malloc (sizeof (LinuxSpecific));
         if (!dev->arch_specific)
                 goto error_free_path;
+        arch_specific = LINUX_SPECIFIC (dev);
+        arch_specific->dmtype = NULL;
 
         dev->open_count = 0;
         dev->read_only = 0;
@@ -1235,9 +1238,9 @@ linux_new (const char* path)
         case PED_DEVICE_DM:
                 {
                   char* type;
-                  if (dev->dmtype == NULL
+                  if (arch_specific->dmtype == NULL
                       || asprintf(&type, _("Linux device-mapper (%s)"),
-                                  dev->dmtype) == -1)
+                                  arch_specific->dmtype) == -1)
                         goto error_free_arch_specific;
                   bool ok = init_generic (dev, type);
                   free (type);
@@ -1277,10 +1280,10 @@ error:
 static void
 linux_destroy (PedDevice* dev)
 {
+        free (((LinuxSpecific*)dev->arch_specific)->dmtype);
         free (dev->arch_specific);
         free (dev->path);
         free (dev->model);
-        free (dev->dmtype);
         free (dev);
 }
 
-- 
1.5.5.3

>From edaffdb04a88d1011aed9dfe7518e97eb48920a9 Mon Sep 17 00:00:00 2001
From: Guido Guenther <[EMAIL PROTECTED]>
Date: Fri, 6 Jun 2008 15:58:06 +0200
Subject: [PATCH] Fix partition names on multipath devices

---
 libparted/arch/linux.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 4c9a2d3..3c07d51 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2014,6 +2014,7 @@ _device_get_part_path (PedDevice* dev, int num)
         int             path_len = strlen (dev->path);
         int             result_len = path_len + 16;
         char*           result;
+        LinuxSpecific*  arch_specific = LINUX_SPECIFIC (dev);
 
         result = (char*) ped_malloc (result_len);
         if (!result)
@@ -2026,6 +2027,13 @@ _device_get_part_path (PedDevice* dev, int num)
                 /* replace /disc with /path%d */
                 strcpy (result, dev->path);
                 snprintf (result + path_len - 5, 16, "/part%d", num);
+#ifdef ENABLE_DEVICE_MAPPER
+        } else if (dev->type == PED_DEVICE_DM && arch_specific->dmtype &&
+                   strcmp(arch_specific->dmtype, "multipath") == 0) {
+                /* This is what multipath-tools upstream and Debian uses, it's
+                 * a pure userpace (udev) decision! */
+                snprintf (result, result_len, "%s-part%d", dev->path, num);
+#endif
         } else if (dev->type == PED_DEVICE_DAC960
                         || dev->type == PED_DEVICE_CPQARRAY
                         || dev->type == PED_DEVICE_ATARAID
-- 
1.5.5.3

Reply via email to