On Fri, Jun 06, 2008 at 10:59:45AM +0200, Jim Meyering wrote:
> Guido Günther <[EMAIL PROTECTED]> wrote:
> > On Fri, Jun 06, 2008 at 09:00:14AM +0200, Jim Meyering wrote:
> > While looking at the code I wonder if we should move the whole dmtype
> > into LinuxSpecific (since it is)? Let me know and I post a patch.
> 
> Good idea, but best to wait until after I push,
> since otherwise our changes will surely conflict.
Patch that moves dmtype into LinuxSpecific attached.

> I'm including below the changes I expect to push today,
> (this includes yours) though a few of my smaller c-sets are
> probably going to be reordered and squashed.
Thanks a lot!
 -- Guido
>From 297c1888c7185e2eee8ecbd8d2ced99c6892824f Mon Sep 17 00:00:00 2001
From: Guido Guenther <[EMAIL PROTECTED]>
Date: Fri, 6 Jun 2008 15:33:55 +0200
Subject: [PATCH] move dmtype from PedDevice to LinuxSpecific

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, &params);
 
-        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

_______________________________________________
parted-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/parted-devel

Reply via email to