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