Subject: parted-3.2 build failure

From: Chris Clayton <[email-masked]>
Date: Tue, 29 Jul 2014 22:41:56 +0100

Hi.

I'm getting the following errors trying to build parted-3.2:

arch/linux.c: In function 'dm_canonical_path':
arch/linux.c:2313:16: warning: implicit declaration of function 'dm_task_create' [-Wimplicit-function-declaration]
         struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
                ^
arch/linux.c:2313:48: error: 'DM_DEVICE_INFO' undeclared (first use in this function)
         struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
                                                ^
arch/linux.c:2313:48: note: each undeclared identifier is reported only once for each function it appears in
arch/linux.c:2316:9: warning: implicit declaration of function 'dm_task_set_major_minor' [-Wimplicit-function-declaration]
         if (!dm_task_set_major_minor (task, arch_specific->major,
         ^
arch/linux.c:2319:9: warning: implicit declaration of function 'dm_task_run' [-Wimplicit-function-declaration]
         if (!dm_task_run(task))
         ^
arch/linux.c:2321:9: warning: implicit declaration of function 'dm_task_get_name' [-Wimplicit-function-declaration]
         char *dev_name = zasprintf ("/dev/mapper/%s", dm_task_get_name (task));
         ^
arch/linux.c:2324:9: warning: implicit declaration of function 'dm_task_destroy' [-Wimplicit-function-declaration]
         dm_task_destroy (task);
         ^
arch/linux.c: In function '_disk_sync_part_table':
arch/linux.c:2949:33: error: '_dm_add_partition' undeclared (first use in this function)
                 add_partition = _dm_add_partition;
                                 ^
arch/linux.c:2950:36: error: '_dm_remove_partition' undeclared (first use in this function)
                 remove_partition = _dm_remove_partition;
                                    ^
arch/linux.c:2951:36: error: '_dm_resize_partition' undeclared (first use in this function)
                 resize_partition = _dm_resize_partition;
                                    ^
arch/linux.c:2952:50: error: '_dm_get_partition_start_and_length' undeclared (first use in this function)
                 get_partition_start_and_length = _dm_get_partition_start_and_length;
                                                  ^
I am passing --disable-device-mapper to configure, but the code causing the errors is not guarded by #ifdef
ENABLE_DEVICE_MAPPER.

The attached patch allows the build to succeed. I think the resultant code is functionally correct, but I'm sure you
will check that :-)

Regards.

Chris
--- parted-3.2/libparted/arch/linux.c.device-mapper	2014-06-15 20:15:54.000000000 +0100
+++ parted-3.2/libparted/arch/linux.c	2014-07-29 22:27:54.487430030 +0100
@@ -2307,6 +2307,7 @@ zasprintf (const char *format, ...)
 static char *
 dm_canonical_path (PedDevice const *dev)
 {
+#ifdef ENABLE_DEVICE_MAPPER
         LinuxSpecific const *arch_specific = LINUX_SPECIFIC (dev);
 
         /* Get map name from devicemapper */
@@ -2324,6 +2325,7 @@ dm_canonical_path (PedDevice const *dev)
         dm_task_destroy (task);
         return dev_name;
 err:
+#endif
         return NULL;
 }
 
@@ -2944,13 +2946,14 @@ _disk_sync_part_table (PedDisk* disk)
                                                unsigned long long *start,
                                                unsigned long long *length);
 
-
+#ifdef ENABLE_DEVICE_MAPPER
         if (disk->dev->type == PED_DEVICE_DM) {
                 add_partition = _dm_add_partition;
                 remove_partition = _dm_remove_partition;
                 resize_partition = _dm_resize_partition;
                 get_partition_start_and_length = _dm_get_partition_start_and_length;
         } else {
+#endif
                 add_partition = _blkpg_add_partition;
                 remove_partition = _blkpg_remove_partition;
 #ifdef BLKPG_RESIZE_PARTITION
@@ -2959,7 +2962,9 @@ _disk_sync_part_table (PedDisk* disk)
                 resize_partition = NULL;
 #endif
                 get_partition_start_and_length = _kernel_get_partition_start_and_length;
+#ifdef ENABLE_DEVICE_MAPPER
         }
+#endif
 
         /* lpn = largest partition number.
          * for remove pass, use greater of device or label limit */