[Parted-commits] GNU Parted Official Repository: Changes to 'master'
Jim Meyering
meyering at alioth.debian.org
Tue Jun 10 12:21:00 UTC 2008
include/parted/device.h | 1 -
include/parted/linux.h | 1 +
libparted/arch/linux.c | 15 +++++++++------
3 files changed, 10 insertions(+), 7 deletions(-)
New commits:
commit 29b66500d17d18f6b2ad03a9ae4b68313d6eb4c5
Author: Guido Guenther <agx at sigxcpu.org>
Date: Fri Jun 6 15:33:55 2008 +0200
move new dmtype member from PedDevice to LinuxSpecific,
since this is a Linux-only feature.
* include/parted/device.h (struct _PedDevice) [dmtype]: Remove member.
* include/parted/linux.h (struct _LinuxSpecific) [dmtype]: Add member.
* libparted/arch/linux.c (_dm_maptype, linux_new, linux_destroy): Update uses.
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, ¶ms);
- 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);
}
More information about the Parted-commits
mailing list