parted/parted-1.9.0-new-lvm-rh525095.patch
Hans de Goede ce6563fae4 - Allow partitioning of loopback devices (#546622)
- Add libparted function to query maximum partition length and start
    addresses for a given disk (#533417)
- Add per disk flags functions from upstream, this is the way upstream has
    implemented the disable cylinder alignment functionality
- Add --align cmdline option to specify how to align new partitions see the
    parted man page for details (#361951)
- Make the default alignment for new partitions optimal (#361951)
- When cylinder alignment is disabled, allow use of the last (incomplete)
    cylinder of the disk (#533328)
- Don't crash when printing partition tables in Russian (#543029)
- Make parted work correctly with new lvm (#525095)
2009-12-18 09:42:14 +00:00

123 lines
4.3 KiB
Diff

--- 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 (&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);
+
+ if (asprintf (&vol_name, "%sp%d", dev_name, part->num) == -1)
goto err;
- if (!params)
+ dm_task_destroy (task);
+ task = NULL;
+
+ 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);
--- 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;