--- parted-1.9.0.orig/libparted/arch/linux.c 2009-12-18 09:35:22.000000000 +0100 +++ parted-1.9.0/libparted/arch/linux.c 2009-12-18 09:57:37.000000000 +0100 @@ -430,7 +430,8 @@ if (!(dmt = dm_task_create(DM_DEVICE_TABLE))) return r; - if (!dm_task_set_name(dmt, dev->path)) + if (!dm_task_set_major_minor(dmt, arch_specific->major, + arch_specific->minor, 0)) goto bad; dm_task_no_open_count(dmt); @@ -513,6 +514,7 @@ struct stat dev_stat; int dev_major; int dev_minor; + LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev); if (!_device_stat (dev, &dev_stat)) return 0; @@ -522,8 +524,8 @@ return 1; } - dev_major = major (dev_stat.st_rdev); - dev_minor = minor (dev_stat.st_rdev); + arch_specific->major = dev_major = major (dev_stat.st_rdev); + arch_specific->minor = dev_minor = minor (dev_stat.st_rdev); if (SCSI_BLK_MAJOR (dev_major) && (dev_minor % 0x10 == 0)) { dev->type = PED_DEVICE_SCSI; @@ -2305,22 +2307,20 @@ static int _dm_remove_parts (PedDevice* dev) { - struct stat dev_stat; struct dm_task* task = NULL; struct dm_info* info = alloca(sizeof *info); struct dm_names* names = NULL; unsigned int next = 0; int rc; - - if (!_device_stat (dev, &dev_stat)) - goto err; + LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev); task = dm_task_create(DM_DEVICE_LIST); if (!task) goto err; - dm_task_set_major (task, major (dev_stat.st_rdev)); - dm_task_set_minor (task, minor (dev_stat.st_rdev)); + if (!dm_task_set_major_minor (task, arch_specific->major, + arch_specific->minor, 0)) + goto err; rc = dm_task_run(task); if (rc < 0) @@ -2365,33 +2365,36 @@ 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); - 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 (¶ms, "%d:%d %lld", major (dev_stat.st_rdev), - minor (dev_stat.st_rdev), part->geom.start) == -1) + dev_name = dm_task_get_name (task); + + if (asprintf (&vol_name, "%sp%d", dev_name, part->num) == -1) goto err; - if (!params) + dm_task_destroy (task); + task = NULL; + + if (asprintf (¶ms, "%d:%d %lld", arch_specific->major, + arch_specific->minor, part->geom.start) == -1) goto err; task = dm_task_create (DM_DEVICE_CREATE); --- parted-1.9.0.orig/libparted/arch/linux.h 2009-12-18 09:35:22.000000000 +0100 +++ parted-1.9.0/libparted/arch/linux.h 2009-12-18 09:44:26.000000000 +0100 @@ -28,6 +28,8 @@ struct _LinuxSpecific { int fd; + int major; + int minor; char* dmtype; /**< device map target type */ #if defined(__s390__) || defined(__s390x__) unsigned int real_sector_size;