Hi Otavio, Just to make merging easier: This is the git tree as mentioned on debian-boot. http://git.debian.org/git/users/agx/parted1.8.git I additionally attach the patch to this mail so we have it in the BTS. -- Guido
>From bd2038e2f1efd0528e6a69aaf7fbedabcd531407 Mon Sep 17 00:00:00 2001 From: Guido Guenther <[EMAIL PROTECTED]> Date: Thu, 7 Aug 2008 12:11:36 +0200 Subject: [PATCH] linux device-mapper map type detection
detect the type of the device map and add it to the displayed type information. This is also included in upstream parted. --- include/parted/linux.h | 1 + libparted/arch/linux.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 1 deletions(-) diff --git a/include/parted/linux.h b/include/parted/linux.h index 05a2f0e..1b0d8f8 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 9876956..14baa69 100644 --- a/libparted/arch/linux.c +++ b/libparted/arch/linux.c @@ -301,6 +301,44 @@ _is_sx8_major (int major) #ifdef ENABLE_DEVICE_MAPPER static int +_dm_maptype (PedDevice* dev) +{ + LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev); + struct dm_task *dmt; + void *next = NULL; + uint64_t start, length; + char *target_type = NULL; + char *params; + int r = -1; + const char* dev_dir = getenv ("DM_DEV_DIR"); + + if (dev_dir && *dev_dir && !dm_set_dev_dir(dev_dir)) + return r; + + if (!(dmt = dm_task_create(DM_DEVICE_TABLE))) + return r; + + if (!dm_task_set_name(dmt, dev->path)) + goto bad; + + dm_task_no_open_count(dmt); + + if (!dm_task_run(dmt)) + goto bad; + + next = dm_get_next_target(dmt, next, &start, &length, + &target_type, ¶ms); + + arch_specific->dmtype = strdup(target_type); + if (arch_specific->dmtype == NULL) + goto bad; + r = 0; +bad: + dm_task_destroy(dmt); + return r; +} + +static int readFD (int fd, char **buf) { char* p; @@ -488,6 +526,12 @@ _device_probe_type (PedDevice* dev) #ifdef ENABLE_DEVICE_MAPPER } else if (_is_dm_major(dev_major)) { dev->type = PED_DEVICE_DM; + if (_dm_maptype(dev)) { + LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev); + + arch_specific = LINUX_SPECIFIC (dev); + arch_specific->dmtype = strdup("unknown"); + } #endif } else if (dev_major == XVD_MAJOR && (dev_minor % 0x10 == 0)) { dev->type = PED_DEVICE_XVD; @@ -1105,6 +1149,8 @@ static PedDevice* linux_new (const char* path) { PedDevice* dev; + char* type; + LinuxSpecific* arch_specific; PED_ASSERT (path != NULL, return NULL); @@ -1120,6 +1166,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; @@ -1188,7 +1236,11 @@ linux_new (const char* path) #ifdef ENABLE_DEVICE_MAPPER case PED_DEVICE_DM: - if (!init_generic (dev, _("Linux device-mapper"))) + if (arch_specific->dmtype == NULL + || asprintf(&type, _("Linux device-mapper (%s)"), + arch_specific->dmtype) == -1) + goto error_free_arch_specific; + if (!init_generic (dev, type)) goto error_free_arch_specific; break; #endif @@ -1227,6 +1279,9 @@ linux_destroy (PedDevice* dev) ped_free (dev->arch_specific); ped_free (dev->path); ped_free (dev->model); +#ifdef ENABLE_DEVICE_MAPPER + ped_free (((LinuxSpecific*)dev->arch_specific)->dmtype); +#endif ped_free (dev); } -- 1.5.6.3
>From bb51c236d88605d114f062b5f1484be4ff56c37f Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Guido=20G=C3=BCnther?= <[EMAIL PROTECTED]> Date: Tue, 10 Jun 2008 18:35:41 +0200 Subject: [PATCH] Return the correct partition names for 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 14baa69..3d84373 100644 --- a/libparted/arch/linux.c +++ b/libparted/arch/linux.c @@ -2015,6 +2015,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) @@ -2027,6 +2028,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.6.3