Blame SOURCES/0005-swap-status-on-dm.patch

b3f87c
From 3d75598da3fda5344934fe9cd86297856f340909 Mon Sep 17 00:00:00 2001
b3f87c
From: Vojtech Trefny <vtrefny@redhat.com>
b3f87c
Date: Tue, 12 Feb 2019 12:21:03 +0100
b3f87c
Subject: [PATCH] Fix checking swap status on lvm/md
b3f87c
b3f87c
'bd_utils_resolve_device' returns already resolved part, there is
b3f87c
no '../' to remove.
b3f87c
b3f87c
Resolves: rhbz#1649815
b3f87c
---
b3f87c
 src/plugins/swap.c | 11 ++---------
b3f87c
 1 file changed, 2 insertions(+), 9 deletions(-)
b3f87c
b3f87c
diff --git a/src/plugins/swap.c b/src/plugins/swap.c
b3f87c
index 28db6f3..c8cdb57 100644
b3f87c
--- a/src/plugins/swap.c
b3f87c
+++ b/src/plugins/swap.c
b3f87c
@@ -400,7 +400,6 @@ gboolean bd_swap_swapoff (const gchar *device, GError **error) {
b3f87c
 gboolean bd_swap_swapstatus (const gchar *device, GError **error) {
b3f87c
     gchar *file_content;
b3f87c
     gchar *real_device = NULL;
b3f87c
-    gchar *dev_path = NULL;
b3f87c
     gsize length;
b3f87c
     gchar *next_line;
b3f87c
     gboolean success;
b3f87c
@@ -414,19 +413,15 @@ gboolean bd_swap_swapstatus (const gchar *device, GError **error) {
b3f87c
     /* get the real device node for device-mapper devices since the ones
b3f87c
        with meaningful names are just dev_paths */
b3f87c
     if (g_str_has_prefix (device, "/dev/mapper/") || g_str_has_prefix (device, "/dev/md/")) {
b3f87c
-        dev_path = bd_utils_resolve_device (device, error);
b3f87c
-        if (!dev_path) {
b3f87c
+        real_device = bd_utils_resolve_device (device, error);
b3f87c
+        if (!real_device) {
b3f87c
             /* the device doesn't exist and thus is not an active swap */
b3f87c
             g_clear_error (error);
b3f87c
             return FALSE;
b3f87c
         }
b3f87c
-
b3f87c
-        /* the dev_path starts with "../" */
b3f87c
-        real_device = g_strdup_printf ("/dev/%s", dev_path + 3);
b3f87c
     }
b3f87c
 
b3f87c
     if (g_str_has_prefix (file_content, real_device ? real_device : device)) {
b3f87c
-        g_free (dev_path);
b3f87c
         g_free (real_device);
b3f87c
         g_free (file_content);
b3f87c
         return TRUE;
b3f87c
@@ -435,7 +430,6 @@ gboolean bd_swap_swapstatus (const gchar *device, GError **error) {
b3f87c
     next_line = (strchr (file_content, '\n') + 1);
b3f87c
     while (next_line && ((gsize)(next_line - file_content) < length)) {
b3f87c
         if (g_str_has_prefix (next_line, real_device ? real_device : device)) {
b3f87c
-            g_free (dev_path);
b3f87c
             g_free (real_device);
b3f87c
             g_free (file_content);
b3f87c
             return TRUE;
b3f87c
@@ -444,7 +438,6 @@ gboolean bd_swap_swapstatus (const gchar *device, GError **error) {
b3f87c
         next_line = (strchr (next_line, '\n') + 1);
b3f87c
     }
b3f87c
 
b3f87c
-    g_free (dev_path);
b3f87c
     g_free (real_device);
b3f87c
     g_free (file_content);
b3f87c
     return FALSE;
b3f87c
-- 
b3f87c
2.20.1
b3f87c