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