Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 1 | Upstream-Status: Backport |
| 2 | Signed-off-by: Ross Burton <ross.burton@intel.com> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 4 | From da3f129710929abe9a403901fa7d168355b0e95a Mon Sep 17 00:00:00 2001 |
| 5 | From: Felix Janda <felix.janda@posteo.de> |
| 6 | Date: Sun, 3 May 2015 10:33:15 +0200 |
| 7 | Subject: [PATCH] libparted/arch/linux.c: Compile without ENABLE_DEVICE_MAPPER |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 9 | Signed-off-by: Brian C. Lane <bcl@redhat.com> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10 | --- |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 11 | libparted/arch/linux.c | 21 +++++++++++++++++---- |
| 12 | 1 file changed, 17 insertions(+), 4 deletions(-) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13 | |
| 14 | diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 15 | index a15854f..7f12f58 100644 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16 | --- a/libparted/arch/linux.c |
| 17 | +++ b/libparted/arch/linux.c |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 18 | @@ -2305,6 +2305,7 @@ zasprintf (const char *format, ...) |
| 19 | return r < 0 ? NULL : resultp; |
| 20 | } |
| 21 | |
| 22 | +#ifdef ENABLE_DEVICE_MAPPER |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 23 | static char * |
| 24 | dm_canonical_path (PedDevice const *dev) |
| 25 | { |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 26 | @@ -2327,14 +2328,21 @@ dm_canonical_path (PedDevice const *dev) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 27 | err: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 28 | return NULL; |
| 29 | } |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 30 | +#endif |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 31 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 32 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 63 | unsigned long long *length); |
| 64 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 65 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 66 | +#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 Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 80 | 2.11.0 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 81 | |