[Parted-commits] GNU Parted Official Repository: Changes to 'next'
Jim Meyering
meyering at alioth.debian.org
Fri Nov 6 18:20:17 UTC 2009
libparted/arch/linux.c | 54 ++++++++++++++++++++++++------------------------
libparted/arch/linux.h | 2 +
libparted/labels/dasd.c | 1
3 files changed, 30 insertions(+), 27 deletions(-)
New commits:
commit 92bf03342267b32a645a7f911e9df40fea660f9b
Author: Hans de Goede <hdegoede at redhat.com>
Date: Fri Nov 6 17:50:52 2009 +0100
dasd: fix unused variable warning
* libparted/labels/dasd.c (dasd_get_partition_alignment): Fix unused
variable warning.
diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index eda2709..6bf0a06 100644
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -741,7 +741,6 @@ dasd_get_max_supported_partition_count (const PedDisk* disk, int *max_n)
static PedAlignment*
dasd_get_partition_alignment(const PedDisk *disk)
{
- DasdDiskSpecific* disk_specific = disk->disk_specific;
LinuxSpecific *arch_specific = LINUX_SPECIFIC(disk->dev);
PedSector sector_size =
arch_specific->real_sector_size / disk->dev->sector_size;
commit f1d6be60ba8a3d2a14cdeb8308045c0aaddec8f4
Author: Hans de Goede <hdegoede at redhat.com>
Date: Fri Nov 6 17:50:51 2009 +0100
linux: use cached major minor instead of statting the device again
* libparted/arch/linux.c (_dm_remove_parts): Use cached major/minor
numbers.
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 10f8597..f7e6a5e 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2340,22 +2340,20 @@ err:
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)
commit 162ac17e40ed35d216d755cb8b51434b971a64a9
Author: Hans de Goede <hdegoede at redhat.com>
Date: Fri Nov 6 17:50:50 2009 +0100
linux: use devicemapper task name instead of device node name
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.
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index c87a7ca..10f8597 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2400,36 +2400,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 (¶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);
+ dm_task_destroy (task);
+ task = NULL;
+
+ if (asprintf (&vol_name, "%sp%d", dev_name, part->num) == -1)
goto err;
- if (!params)
+ 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);
@@ -2439,7 +2441,7 @@ _dm_add_partition (PedDisk* disk, PedPartition* part)
dm_task_set_name (task, vol_name);
dm_task_add_target (task, 0, part->geom.length,
"linear", params);
- rc = dm_task_run(task);
+ rc = dm_task_run (task);
if (rc >= 0) {
//printf("0 %ld linear %s\n", part->geom.length, params);
dm_task_update_nodes();
commit 3eb1d427e31d94855fd012692d6f415cac3971d1
Author: Hans de Goede <hdegoede at redhat.com>
Date: Fri Nov 6 17:50:49 2009 +0100
linux: use major / minor to specify device mapper device in dm_task
Use major / minor to specify device mapper device instead of
dm_task_set_name. 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 dm-# is not a valid dm_task name.
This is only needed in this one place, as in the other places where we
use dm_task_set_name, the name we use was returned by libdevicemapper
itself in an earlier function call.
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 52d8fa8..c87a7ca 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -420,7 +420,8 @@ _dm_maptype (PedDevice *dev)
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);
@@ -502,6 +503,7 @@ _device_probe_type (PedDevice* dev)
struct stat dev_stat;
int dev_major;
int dev_minor;
+ LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
if (!_device_stat (dev, &dev_stat))
return 0;
@@ -511,8 +513,8 @@ _device_probe_type (PedDevice* dev)
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;
diff --git a/libparted/arch/linux.h b/libparted/arch/linux.h
index 391859b..7036886 100644
--- a/libparted/arch/linux.h
+++ b/libparted/arch/linux.h
@@ -28,6 +28,8 @@ typedef struct _LinuxSpecific LinuxSpecific;
struct _LinuxSpecific {
int fd;
+ int major;
+ int minor;
char* dmtype; /**< device map target type */
#if defined __s390__ || defined __s390x__
unsigned int real_sector_size;
More information about the Parted-commits
mailing list