[PATCH] move dmtype from PedDevice to LinuxSpecific
Guido Guenther
agx at sigxcpu.org
Fri Jun 6 13:33:55 UTC 2008
since this is a Linux only feature
---
include/parted/device.h | 1 -
include/parted/linux.h | 1 +
libparted/arch/linux.c | 15 +++++++++------
3 files changed, 10 insertions(+), 7 deletions(-)
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);
}
--
1.5.5.3
--YiEDa0DAkWCtVeE4--
More information about the parted-devel
mailing list