blob: 8c4d2ae66d18e383f9fa6fd932f3bad8b6a7ff5d [file] [log] [blame]
Brad Bishop15ae2502019-06-18 21:44:24 -04001Upstream-Status: Backport
2Signed-off-by: Ross Burton <ross.burton@intel.com>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05003
Brad Bishop15ae2502019-06-18 21:44:24 -04004From da3f129710929abe9a403901fa7d168355b0e95a Mon Sep 17 00:00:00 2001
5From: Felix Janda <felix.janda@posteo.de>
6Date: Sun, 3 May 2015 10:33:15 +0200
7Subject: [PATCH] libparted/arch/linux.c: Compile without ENABLE_DEVICE_MAPPER
Patrick Williamsc124f4f2015-09-15 14:41:29 -05008
Brad Bishop15ae2502019-06-18 21:44:24 -04009Signed-off-by: Brian C. Lane <bcl@redhat.com>
Patrick Williamsc124f4f2015-09-15 14:41:29 -050010---
Brad Bishop15ae2502019-06-18 21:44:24 -040011 libparted/arch/linux.c | 21 +++++++++++++++++----
12 1 file changed, 17 insertions(+), 4 deletions(-)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050013
14diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
Brad Bishop15ae2502019-06-18 21:44:24 -040015index a15854f..7f12f58 100644
Patrick Williamsc124f4f2015-09-15 14:41:29 -050016--- a/libparted/arch/linux.c
17+++ b/libparted/arch/linux.c
Brad Bishop15ae2502019-06-18 21:44:24 -040018@@ -2305,6 +2305,7 @@ zasprintf (const char *format, ...)
19 return r < 0 ? NULL : resultp;
20 }
21
22+#ifdef ENABLE_DEVICE_MAPPER
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023 static char *
24 dm_canonical_path (PedDevice const *dev)
25 {
Brad Bishop15ae2502019-06-18 21:44:24 -040026@@ -2327,14 +2328,21 @@ dm_canonical_path (PedDevice const *dev)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027 err:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028 return NULL;
29 }
Brad Bishop15ae2502019-06-18 21:44:24 -040030+#endif
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031
Brad Bishop15ae2502019-06-18 21:44:24 -040032 static char*
33 _device_get_part_path (PedDevice const *dev, int num)
34 {
35- char *devpath = (dev->type == PED_DEVICE_DM
36- ? dm_canonical_path (dev) : dev->path);
37- size_t path_len = strlen (devpath);
38+ char *devpath;
39+ size_t path_len;
40 char *result;
41+#ifdef ENABLE_DEVICE_MAPPER
42+ devpath = (dev->type == PED_DEVICE_DM
43+ ? dm_canonical_path (dev) : dev->path);
44+#else
45+ devpath = dev->path;
46+#endif
47+ path_len = strlen (devpath);
48 /* Check for devfs-style /disc => /partN transformation
49 unconditionally; the system might be using udev with devfs rules,
50 and if not the test is harmless. */
51@@ -2350,8 +2358,10 @@ _device_get_part_path (PedDevice const *dev, int num)
52 ? "p" : "");
53 result = zasprintf ("%s%s%d", devpath, p, num);
54 }
55+#ifdef ENABLE_DEVICE_MAPPER
56 if (dev->type == PED_DEVICE_DM)
57 free (devpath);
58+#endif
59 return result;
60 }
61
62@@ -2946,12 +2956,15 @@ _disk_sync_part_table (PedDisk* disk)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063 unsigned long long *length);
64
Brad Bishop15ae2502019-06-18 21:44:24 -040065
Patrick Williamsc124f4f2015-09-15 14:41:29 -050066+#ifdef ENABLE_DEVICE_MAPPER
67 if (disk->dev->type == PED_DEVICE_DM) {
68 add_partition = _dm_add_partition;
69 remove_partition = _dm_remove_partition;
70 resize_partition = _dm_resize_partition;
71 get_partition_start_and_length = _dm_get_partition_start_and_length;
72- } else {
73+ } else
74+#endif
75+ {
76 add_partition = _blkpg_add_partition;
77 remove_partition = _blkpg_remove_partition;
78 #ifdef BLKPG_RESIZE_PARTITION
79--
Brad Bishop15ae2502019-06-18 21:44:24 -0400802.11.0
Patrick Williamsc124f4f2015-09-15 14:41:29 -050081