diff --git a/0000-swap-error-codes.patch b/0000-swap-error-codes.patch deleted file mode 100644 index b95ed837ffaf0c262d9b934c6d292f7438685f16..0000000000000000000000000000000000000000 --- a/0000-swap-error-codes.patch +++ /dev/null @@ -1,407 +0,0 @@ -From 22171c66d11597deee5726ed57e06f3b76fef7aa Mon Sep 17 00:00:00 2001 -From: Vojtech Trefny -Date: Mon, 1 Oct 2018 16:06:42 +0200 -Subject: [PATCH 1/2] Use libblkid to check swap status before swapon - -libblkid probe is more reliable than our custom check. ---- - configure.ac | 2 +- - src/plugins/Makefile.am | 4 +- - src/plugins/swap.c | 149 ++++++++++++++++++++++++++++++++-------- - 3 files changed, 124 insertions(+), 31 deletions(-) - -diff --git a/configure.ac b/configure.ac -index 4890136..be641b3 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -227,7 +227,7 @@ AS_IF([test "x$with_fs" != "xno"], - AC_SUBST([PARTED_FS_CFLAGS], [])])], - []) - --AS_IF([test "x$with_fs" != "xno" -o "x$with_crypto" != "xno"], -+AS_IF([test "x$with_fs" != "xno" -o "x$with_crypto" != "xno" -o "x$with_swap" != "xno"], - [LIBBLOCKDEV_PKG_CHECK_MODULES([BLKID], [blkid >= 2.23.0]) - # older versions of libblkid don't support BLKID_SUBLKS_BADCSUM so let's just - # define it as 0 (neutral value for bit combinations of flags) -diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am -index 5b41822..fd15efb 100644 ---- a/src/plugins/Makefile.am -+++ b/src/plugins/Makefile.am -@@ -149,8 +149,8 @@ libbd_nvdimm_la_SOURCES = nvdimm.c nvdimm.h check_deps.c check_deps.h - endif - - if WITH_SWAP --libbd_swap_la_CFLAGS = $(GLIB_CFLAGS) -Wall -Wextra -Werror --libbd_swap_la_LIBADD = ${builddir}/../utils/libbd_utils.la $(GLIB_LIBS) -+libbd_swap_la_CFLAGS = $(GLIB_CFLAGS) $(BLKID_CFLAGS) -Wall -Wextra -Werror -+libbd_swap_la_LIBADD = ${builddir}/../utils/libbd_utils.la $(GLIB_LIBS) $(BLKID_LIBS) - libbd_swap_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 2:0:0 -Wl,--no-undefined - libbd_swap_la_CPPFLAGS = -I${builddir}/../../include/ - libbd_swap_la_SOURCES = swap.c swap.h check_deps.c check_deps.h -diff --git a/src/plugins/swap.c b/src/plugins/swap.c -index bc52637..bfe653f 100644 ---- a/src/plugins/swap.c -+++ b/src/plugins/swap.c -@@ -21,6 +21,8 @@ - #include - #include - #include -+#include -+#include - #include - - #include "swap.h" -@@ -179,13 +181,14 @@ gboolean bd_swap_mkswap (const gchar *device, const gchar *label, const BDExtraA - * Tech category: %BD_SWAP_TECH_SWAP-%BD_SWAP_TECH_MODE_ACTIVATE_DEACTIVATE - */ - gboolean bd_swap_swapon (const gchar *device, gint priority, GError **error) { -- GIOChannel *dev_file = NULL; -- GIOStatus io_status = G_IO_STATUS_ERROR; -- GError *tmp_error = NULL; -- gsize num_read = 0; -- gchar dev_status[11]; -- dev_status[10] = '\0'; -- gint page_size; -+ blkid_probe probe = NULL; -+ gint fd = 0; -+ gint status = 0; -+ guint n_try = 0; -+ const gchar *value = NULL; -+ gint64 status_len = 0; -+ gint64 swap_pagesize = 0; -+ gint64 sys_pagesize = 0; - gint flags = 0; - gint ret = 0; - guint64 progress_id = 0; -@@ -198,53 +201,143 @@ gboolean bd_swap_swapon (const gchar *device, gint priority, GError **error) { - - bd_utils_report_progress (progress_id, 0, "Analysing the swap device"); - /* check the device if it is an activatable swap */ -- dev_file = g_io_channel_new_file (device, "r", error); -- if (!dev_file) { -- /* error is already populated */ -+ probe = blkid_new_probe (); -+ if (!probe) { -+ g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_UNKNOWN_STATE, -+ "Failed to create a new probe"); - bd_utils_report_finished (progress_id, (*error)->message); - return FALSE; - } - -- page_size = getpagesize (); -- page_size = MAX (2048, page_size); -- io_status = g_io_channel_seek_position (dev_file, page_size - 10, G_SEEK_SET, &tmp_error); -- if (io_status != G_IO_STATUS_NORMAL) { -+ fd = open (device, O_RDONLY|O_CLOEXEC); -+ if (fd == -1) { - g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_UNKNOWN_STATE, -- "Failed to determine device's state: %s", tmp_error->message); -- g_clear_error (&tmp_error); -- g_io_channel_shutdown (dev_file, FALSE, &tmp_error); -+ "Failed to open the device '%s'", device); - bd_utils_report_finished (progress_id, (*error)->message); -+ blkid_free_probe (probe); - return FALSE; - } - -- io_status = g_io_channel_read_chars (dev_file, dev_status, 10, &num_read, &tmp_error); -- if ((io_status != G_IO_STATUS_NORMAL) || (num_read != 10)) { -+ /* we may need to try mutliple times with some delays in case the device is -+ busy at the very moment */ -+ for (n_try=5, status=-1; (status != 0) && (n_try > 0); n_try--) { -+ status = blkid_probe_set_device (probe, fd, 0, 0); -+ if (status != 0) -+ g_usleep (100 * 1000); /* microseconds */ -+ } -+ if (status != 0) { - g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_UNKNOWN_STATE, -- "Failed to determine device's state: %s", tmp_error->message); -- g_clear_error (&tmp_error); -- g_io_channel_shutdown (dev_file, FALSE, &tmp_error); -- g_clear_error (&tmp_error); -+ "Failed to create a probe for the device '%s'", device); - bd_utils_report_finished (progress_id, (*error)->message); -+ blkid_free_probe (probe); -+ close (fd); - return FALSE; - } - -- g_io_channel_shutdown (dev_file, FALSE, &tmp_error); -- g_clear_error (&tmp_error); -+ blkid_probe_enable_superblocks (probe, 1); -+ blkid_probe_set_superblocks_flags (probe, BLKID_SUBLKS_TYPE | BLKID_SUBLKS_MAGIC); - -- if (g_str_has_prefix (dev_status, "SWAP-SPACE")) { -+ /* we may need to try mutliple times with some delays in case the device is -+ busy at the very moment */ -+ for (n_try=5, status=-1; !(status == 0 || status == 1) && (n_try > 0); n_try--) { -+ status = blkid_do_safeprobe (probe); -+ if (status < 0) -+ g_usleep (100 * 1000); /* microseconds */ -+ } -+ if (status < 0) { -+ /* -1 or -2 = error during probing*/ -+ g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_UNKNOWN_STATE, -+ "Failed to probe the device '%s'", device); -+ bd_utils_report_finished (progress_id, (*error)->message); -+ blkid_free_probe (probe); -+ close (fd); -+ return FALSE; -+ } else if (status == 1) { -+ /* 1 = nothing detected */ -+ g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_UNKNOWN_STATE, -+ "No superblock detected on the device '%s'", device); -+ bd_utils_report_finished (progress_id, (*error)->message); -+ blkid_free_probe (probe); -+ close (fd); -+ return FALSE; -+ } -+ -+ status = blkid_probe_lookup_value (probe, "TYPE", &value, NULL); -+ if (status != 0) { -+ g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_UNKNOWN_STATE, -+ "Failed to get format type for the device '%s'", device); -+ bd_utils_report_finished (progress_id, (*error)->message); -+ blkid_free_probe (probe); -+ close (fd); -+ return FALSE; -+ } -+ -+ if (g_strcmp0 (value, "swap") != 0) { -+ g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_UNKNOWN_STATE, -+ "Device '%s' is not formatted as swap", device); -+ bd_utils_report_finished (progress_id, (*error)->message); -+ blkid_free_probe (probe); -+ close (fd); -+ return FALSE; -+ } -+ -+ status = blkid_probe_lookup_value (probe, "SBMAGIC", &value, NULL); -+ if (status != 0) { -+ g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_UNKNOWN_STATE, -+ "Failed to get swap status on the device '%s'", device); -+ bd_utils_report_finished (progress_id, (*error)->message); -+ blkid_free_probe (probe); -+ close (fd); -+ return FALSE; -+ } -+ -+ if (g_strcmp0 (value, "SWAP-SPACE") == 0) { - g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_ACTIVATE, - "Old swap format, cannot activate."); - bd_utils_report_finished (progress_id, (*error)->message); -+ blkid_free_probe (probe); -+ close (fd); - return FALSE; -- } else if (g_str_has_prefix (dev_status, "S1SUSPEND") || g_str_has_prefix (dev_status, "S2SUSPEND")) { -+ } else if (g_strcmp0 (value, "S1SUSPEND") == 0 || g_strcmp0 (value, "S2SUSPEND") == 0) { - g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_ACTIVATE, - "Suspended system on the swap device, cannot activate."); - bd_utils_report_finished (progress_id, (*error)->message); -+ blkid_free_probe (probe); -+ close (fd); - return FALSE; -- } else if (!g_str_has_prefix (dev_status, "SWAPSPACE2")) { -+ } else if (g_strcmp0 (value, "SWAPSPACE2") != 0) { - g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_ACTIVATE, - "Unknown swap space format, cannot activate."); - bd_utils_report_finished (progress_id, (*error)->message); -+ blkid_free_probe (probe); -+ close (fd); -+ return FALSE; -+ } -+ -+ status_len = (gint64) strlen (value); -+ -+ status = blkid_probe_lookup_value (probe, "SBMAGIC_OFFSET", &value, NULL); -+ if (status != 0 || !value) { -+ g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_UNKNOWN_STATE, -+ "Failed to get swap status on the device '%s'", device); -+ bd_utils_report_finished (progress_id, (*error)->message); -+ blkid_free_probe (probe); -+ close (fd); -+ return FALSE; -+ } -+ -+ swap_pagesize = status_len + g_ascii_strtoll (value, (char **)NULL, 10); -+ -+ blkid_free_probe (probe); -+ close (fd); -+ -+ sys_pagesize = getpagesize (); -+ -+ if (swap_pagesize != sys_pagesize) { -+ g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_UNKNOWN_STATE, -+ "Swap format pagesize (%"G_GINT64_FORMAT") and system pagesize (%"G_GINT64_FORMAT") don't match", -+ swap_pagesize, sys_pagesize); -+ bd_utils_report_finished (progress_id, (*error)->message); - return FALSE; - } - --- -2.17.1 - - -From bef564b7525fc97dc1f4e4383768bd8f22f4f0b5 Mon Sep 17 00:00:00 2001 -From: Vojtech Trefny -Date: Thu, 4 Oct 2018 08:07:55 +0200 -Subject: [PATCH 2/2] Add error codes and Python exceptions for swapon fails - -We need to be able to tell why swapon failed so our users can -decide what to do. ---- - src/lib/plugin_apis/swap.api | 4 ++++ - src/plugins/swap.c | 10 +++++----- - src/plugins/swap.h | 4 ++++ - src/python/gi/overrides/BlockDev.py | 19 +++++++++++++++++-- - tests/swap_test.py | 13 +++++++++++++ - 5 files changed, 43 insertions(+), 7 deletions(-) - -diff --git a/src/lib/plugin_apis/swap.api b/src/lib/plugin_apis/swap.api -index d0906fe..3fcc0e5 100644 ---- a/src/lib/plugin_apis/swap.api -+++ b/src/lib/plugin_apis/swap.api -@@ -10,6 +10,10 @@ typedef enum { - BD_SWAP_ERROR_UNKNOWN_STATE, - BD_SWAP_ERROR_ACTIVATE, - BD_SWAP_ERROR_TECH_UNAVAIL, -+ BD_SWAP_ERROR_ACTIVATE_OLD, -+ BD_SWAP_ERROR_ACTIVATE_SUSPEND, -+ BD_SWAP_ERROR_ACTIVATE_UNKNOWN, -+ BD_SWAP_ERROR_ACTIVATE_PAGESIZE, - } BDSwapError; - - typedef enum { -diff --git a/src/plugins/swap.c b/src/plugins/swap.c -index bfe653f..28db6f3 100644 ---- a/src/plugins/swap.c -+++ b/src/plugins/swap.c -@@ -292,21 +292,21 @@ gboolean bd_swap_swapon (const gchar *device, gint priority, GError **error) { - } - - if (g_strcmp0 (value, "SWAP-SPACE") == 0) { -- g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_ACTIVATE, -+ g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_ACTIVATE_OLD, - "Old swap format, cannot activate."); - bd_utils_report_finished (progress_id, (*error)->message); - blkid_free_probe (probe); - close (fd); - return FALSE; - } else if (g_strcmp0 (value, "S1SUSPEND") == 0 || g_strcmp0 (value, "S2SUSPEND") == 0) { -- g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_ACTIVATE, -+ g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_ACTIVATE_SUSPEND, - "Suspended system on the swap device, cannot activate."); - bd_utils_report_finished (progress_id, (*error)->message); - blkid_free_probe (probe); - close (fd); - return FALSE; - } else if (g_strcmp0 (value, "SWAPSPACE2") != 0) { -- g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_ACTIVATE, -+ g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_ACTIVATE_UNKNOWN, - "Unknown swap space format, cannot activate."); - bd_utils_report_finished (progress_id, (*error)->message); - blkid_free_probe (probe); -@@ -318,7 +318,7 @@ gboolean bd_swap_swapon (const gchar *device, gint priority, GError **error) { - - status = blkid_probe_lookup_value (probe, "SBMAGIC_OFFSET", &value, NULL); - if (status != 0 || !value) { -- g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_UNKNOWN_STATE, -+ g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_ACTIVATE_PAGESIZE, - "Failed to get swap status on the device '%s'", device); - bd_utils_report_finished (progress_id, (*error)->message); - blkid_free_probe (probe); -@@ -334,7 +334,7 @@ gboolean bd_swap_swapon (const gchar *device, gint priority, GError **error) { - sys_pagesize = getpagesize (); - - if (swap_pagesize != sys_pagesize) { -- g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_UNKNOWN_STATE, -+ g_set_error (error, BD_SWAP_ERROR, BD_SWAP_ERROR_ACTIVATE_PAGESIZE, - "Swap format pagesize (%"G_GINT64_FORMAT") and system pagesize (%"G_GINT64_FORMAT") don't match", - swap_pagesize, sys_pagesize); - bd_utils_report_finished (progress_id, (*error)->message); -diff --git a/src/plugins/swap.h b/src/plugins/swap.h -index a01c873..9947bad 100644 ---- a/src/plugins/swap.h -+++ b/src/plugins/swap.h -@@ -12,6 +12,10 @@ typedef enum { - BD_SWAP_ERROR_UNKNOWN_STATE, - BD_SWAP_ERROR_ACTIVATE, - BD_SWAP_ERROR_TECH_UNAVAIL, -+ BD_SWAP_ERROR_ACTIVATE_OLD, -+ BD_SWAP_ERROR_ACTIVATE_SUSPEND, -+ BD_SWAP_ERROR_ACTIVATE_UNKNOWN, -+ BD_SWAP_ERROR_ACTIVATE_PAGESIZE, - } BDSwapError; - - typedef enum { -diff --git a/src/python/gi/overrides/BlockDev.py b/src/python/gi/overrides/BlockDev.py -index c2ef2f4..e608887 100644 ---- a/src/python/gi/overrides/BlockDev.py -+++ b/src/python/gi/overrides/BlockDev.py -@@ -1031,7 +1031,17 @@ __all__.append("MpathError") - - class SwapError(BlockDevError): - pass --__all__.append("SwapError") -+class SwapActivateError(SwapError): -+ pass -+class SwapOldError(SwapActivateError): -+ pass -+class SwapSuspendError(SwapActivateError): -+ pass -+class SwapUnknownError(SwapActivateError): -+ pass -+class SwapPagesizeError(SwapActivateError): -+ pass -+__all__.extend(("SwapError", "SwapActivateError", "SwapOldError", "SwapSuspendError", "SwapUnknownError", "SwapPagesizeError")) - - class KbdError(BlockDevError): - pass -@@ -1070,6 +1080,11 @@ __all__.append("BlockDevNotImplementedError") - not_implemented_rule = XRule(GLib.Error, re.compile(r".*The function '.*' called, but not implemented!"), None, BlockDevNotImplementedError) - - fs_nofs_rule = XRule(GLib.Error, None, 3, FSNoFSError) -+swap_activate_rule = XRule(GLib.Error, None, 1, SwapActivateError) -+swap_old_rule = XRule(GLib.Error, None, 3, SwapOldError) -+swap_suspend_rule = XRule(GLib.Error, None, 4, SwapSuspendError) -+swap_unknown_rule = XRule(GLib.Error, None, 5, SwapUnknownError) -+swap_pagesize_rule = XRule(GLib.Error, None, 6, SwapPagesizeError) - - btrfs = ErrorProxy("btrfs", BlockDev, [(GLib.Error, BtrfsError)], [not_implemented_rule]) - __all__.append("btrfs") -@@ -1092,7 +1107,7 @@ __all__.append("md") - mpath = ErrorProxy("mpath", BlockDev, [(GLib.Error, MpathError)], [not_implemented_rule]) - __all__.append("mpath") - --swap = ErrorProxy("swap", BlockDev, [(GLib.Error, SwapError)], [not_implemented_rule]) -+swap = ErrorProxy("swap", BlockDev, [(GLib.Error, SwapError)], [not_implemented_rule, swap_activate_rule, swap_old_rule, swap_suspend_rule, swap_unknown_rule, swap_pagesize_rule]) - __all__.append("swap") - - kbd = ErrorProxy("kbd", BlockDev, [(GLib.Error, KbdError)], [not_implemented_rule]) -diff --git a/tests/swap_test.py b/tests/swap_test.py -index 05d0c19..395fdf5 100644 ---- a/tests/swap_test.py -+++ b/tests/swap_test.py -@@ -97,6 +97,19 @@ class SwapTestCase(SwapTest): - _ret, out, _err = run_command("blkid -ovalue -sLABEL -p %s" % self.loop_dev) - self.assertEqual(out, "BlockDevSwap") - -+ def test_swapon_pagesize(self): -+ """Verify that activating swap with different pagesize fails""" -+ -+ # create swap with 64k pagesize -+ ret, out, err = run_command("mkswap --pagesize 65536 %s" % self.loop_dev) -+ if ret != 0: -+ self.fail("Failed to prepare swap for pagesize test: %s %s" % (out, err)) -+ -+ # activation should fail because swap has different pagesize -+ with self.assertRaises(BlockDev.SwapPagesizeError): -+ BlockDev.swap.swapon(self.loop_dev) -+ -+ - class SwapUnloadTest(SwapTest): - def setUp(self): - # make sure the library is initialized with all plugins loaded for other --- -2.17.1 - diff --git a/0001-lvm-Add-missing-attribute-to-bd_lvm_pvdata_copy-in-L.patch b/0001-lvm-Add-missing-attribute-to-bd_lvm_pvdata_copy-in-L.patch new file mode 100644 index 0000000000000000000000000000000000000000..05c376cf1735e07df3822215e33d6cda56834875 --- /dev/null +++ b/0001-lvm-Add-missing-attribute-to-bd_lvm_pvdata_copy-in-L.patch @@ -0,0 +1,25 @@ +From 93b0a8881790097e2b4c3116fe9af38f237fb8cc Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 2 Jun 2020 16:15:18 +0200 +Subject: [PATCH 167/193] lvm: Add missing attribute to bd_lvm_pvdata_copy in + LVM DBUs plugin + +--- + src/plugins/lvm-dbus.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c +index 222597b..454fc78 100644 +--- a/src/plugins/lvm-dbus.c ++++ b/src/plugins/lvm-dbus.c +@@ -100,6 +100,7 @@ BDLVMPVdata* bd_lvm_pvdata_copy (BDLVMPVdata *data) { + new_data->pv_name = g_strdup (data->pv_name); + new_data->pv_uuid = g_strdup (data->pv_uuid); + new_data->pv_free = data->pv_free; ++ new_data->pv_size = data->pv_size; + new_data->pe_start = data->pe_start; + new_data->vg_name = g_strdup (data->vg_name); + new_data->vg_uuid = g_strdup (data->vg_uuid); +-- +1.8.3.1 + diff --git a/0002-module.c-Fix-error-message-when-loading-module-witho.patch b/0002-module.c-Fix-error-message-when-loading-module-witho.patch new file mode 100644 index 0000000000000000000000000000000000000000..773bde9323f1656f67cb4de4f67cece0e79a4f6e --- /dev/null +++ b/0002-module.c-Fix-error-message-when-loading-module-witho.patch @@ -0,0 +1,37 @@ +From be58ebe20fd9fdfc2db7bdd99a55eff835cef23a Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Wed, 10 Jun 2020 14:31:15 +0200 +Subject: [PATCH 184/193] module.c: Fix error message when loading module + without options + +Lets avoid error messages like "Failed to load the module 'kvdo' +with options '(null)'". +--- + src/utils/module.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +diff --git a/src/utils/module.c b/src/utils/module.c +index 988f603..eb3f765 100644 +--- a/src/utils/module.c ++++ b/src/utils/module.c +@@ -167,9 +167,14 @@ gboolean bd_utils_load_kernel_module (const gchar *module_name, const gchar *opt + ret = kmod_module_probe_insert_module (mod, KMOD_PROBE_FAIL_ON_LOADED, + options, NULL, NULL, NULL); + if (ret < 0) { +- g_set_error (error, BD_UTILS_MODULE_ERROR, BD_UTILS_MODULE_ERROR_FAIL, +- "Failed to load the module '%s' with options '%s': %s", +- module_name, options, strerror_l (-ret, c_locale)); ++ if (options) ++ g_set_error (error, BD_UTILS_MODULE_ERROR, BD_UTILS_MODULE_ERROR_FAIL, ++ "Failed to load the module '%s' with options '%s': %s", ++ module_name, options, strerror_l (-ret, c_locale)); ++ else ++ g_set_error (error, BD_UTILS_MODULE_ERROR, BD_UTILS_MODULE_ERROR_FAIL, ++ "Failed to load the module '%s': %s", ++ module_name, strerror_l (-ret, c_locale)); + kmod_module_unref (mod); + kmod_unref (ctx); + freelocale (c_locale); +-- +1.8.3.1 + diff --git a/0003-exec-Fix-setting-locale-for-util-calls.patch b/0003-exec-Fix-setting-locale-for-util-calls.patch new file mode 100644 index 0000000000000000000000000000000000000000..b536fc23e66717ff6ad95d46642173155d497d4d --- /dev/null +++ b/0003-exec-Fix-setting-locale-for-util-calls.patch @@ -0,0 +1,119 @@ +From f1b6e752d8836d23ebcdf6833b96e09678bda2c9 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Wed, 10 Jun 2020 17:03:28 +0200 +Subject: [PATCH 185/193] exec: Fix setting locale for util calls + +This actually fixes two issue. The _utils_exec_and_report_progress +function didn't set the LC_ALL=C environment variable to make sure +we get output in English. And also we shouldn't use setenv in the +GSpawnChildSetupFunc, it's actually example of what not to do in +g_spawn_async documentation. This fix uses g_environ_setenv and +passes the new environment to the g_spawn call. +--- + src/utils/exec.c | 26 +++++++++++++++++--------- + tests/utils_test.py | 7 +++++++ + 2 files changed, 24 insertions(+), 9 deletions(-) + +diff --git a/src/utils/exec.c b/src/utils/exec.c +index 9293930..37bd960 100644 +--- a/src/utils/exec.c ++++ b/src/utils/exec.c +@@ -140,11 +140,6 @@ static void log_done (guint64 task_id, gint exit_code) { + return; + } + +-static void set_c_locale(gpointer user_data __attribute__((unused))) { +- if (setenv ("LC_ALL", "C", 1) != 0) +- g_warning ("Failed to set LC_ALL=C for a child process!"); +-} +- + /** + * bd_utils_exec_and_report_error: + * @argv: (array zero-terminated=1): the argv array for the call +@@ -194,6 +189,8 @@ gboolean bd_utils_exec_and_report_status_error (const gchar **argv, const BDExtr + const BDExtraArg **extra_p = NULL; + gint exit_status = 0; + guint i = 0; ++ gchar **old_env = NULL; ++ gchar **new_env = NULL; + + if (extra) { + args_len = g_strv_length ((gchar **) argv); +@@ -219,16 +216,20 @@ gboolean bd_utils_exec_and_report_status_error (const gchar **argv, const BDExtr + args[i] = NULL; + } + ++ old_env = g_get_environ (); ++ new_env = g_environ_setenv (old_env, "LC_ALL", "C", TRUE); ++ + task_id = log_running (args ? args : argv); +- success = g_spawn_sync (NULL, args ? (gchar **) args : (gchar **) argv, NULL, G_SPAWN_SEARCH_PATH, +- (GSpawnChildSetupFunc) set_c_locale, NULL, +- &stdout_data, &stderr_data, &exit_status, error); ++ success = g_spawn_sync (NULL, args ? (gchar **) args : (gchar **) argv, new_env, G_SPAWN_SEARCH_PATH, ++ NULL, NULL, &stdout_data, &stderr_data, &exit_status, error); + if (!success) { + /* error is already populated from the call */ ++ g_strfreev (new_env); + g_free (stdout_data); + g_free (stderr_data); + return FALSE; + } ++ g_strfreev (new_env); + + /* g_spawn_sync set the status in the same way waitpid() does, we need + to get the process exit code manually (this is similar to calling +@@ -297,6 +298,8 @@ static gboolean _utils_exec_and_report_progress (const gchar **argv, const BDExt + gboolean err_done = FALSE; + GString *stdout_data = g_string_new (NULL); + GString *stderr_data = g_string_new (NULL); ++ gchar **old_env = NULL; ++ gchar **new_env = NULL; + + /* TODO: share this code between functions */ + if (extra) { +@@ -325,7 +328,10 @@ static gboolean _utils_exec_and_report_progress (const gchar **argv, const BDExt + + task_id = log_running (args ? args : argv); + +- ret = g_spawn_async_with_pipes (NULL, args ? (gchar**) args : (gchar**) argv, NULL, ++ old_env = g_get_environ (); ++ new_env = g_environ_setenv (old_env, "LC_ALL", "C", TRUE); ++ ++ ret = g_spawn_async_with_pipes (NULL, args ? (gchar**) args : (gchar**) argv, new_env, + G_SPAWN_DEFAULT|G_SPAWN_SEARCH_PATH|G_SPAWN_DO_NOT_REAP_CHILD, + NULL, NULL, &pid, NULL, &out_fd, &err_fd, error); + +@@ -333,9 +339,11 @@ static gboolean _utils_exec_and_report_progress (const gchar **argv, const BDExt + /* error is already populated */ + g_string_free (stdout_data, TRUE); + g_string_free (stderr_data, TRUE); ++ g_strfreev (new_env); + g_free (args); + return FALSE; + } ++ g_strfreev (new_env); + + args_str = g_strjoinv (" ", args ? (gchar **) args : (gchar **) argv); + msg = g_strdup_printf ("Started '%s'", args_str); +diff --git a/tests/utils_test.py b/tests/utils_test.py +index 4bec3db..2bec5ed 100644 +--- a/tests/utils_test.py ++++ b/tests/utils_test.py +@@ -170,6 +170,13 @@ class UtilsExecLoggingTest(UtilsTestCase): + # exit code != 0 + self.assertTrue(BlockDev.utils_check_util_version("libblockdev-fake-util-fail", "1.1", "version", "Version:\\s(.*)")) + ++ @tag_test(TestTags.NOSTORAGE, TestTags.CORE) ++ def test_exec_locale(self): ++ """Verify that setting locale for exec functions works as expected""" ++ ++ succ, out = BlockDev.utils_exec_and_capture_output(["locale"]) ++ self.assertTrue(succ) ++ self.assertIn("LC_ALL=C", out) + + class UtilsDevUtilsTestCase(UtilsTestCase): + @tag_test(TestTags.NOSTORAGE, TestTags.CORE) +-- +1.8.3.1 + diff --git a/0004-lvm-Fix-checking-for-LVM-VDO-dependencies.patch b/0004-lvm-Fix-checking-for-LVM-VDO-dependencies.patch new file mode 100644 index 0000000000000000000000000000000000000000..cfc55efa853cb9c2b91629476c02386b85e16b38 --- /dev/null +++ b/0004-lvm-Fix-checking-for-LVM-VDO-dependencies.patch @@ -0,0 +1,28 @@ +From dff4f13d20e7371cd55df7aab7a1800c41e3d39b Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Mon, 29 Jun 2020 14:40:57 +0200 +Subject: [PATCH 188/193] lvm: Fix checking for LVM VDO dependencies + +We also need to check for the LVM tools availability when checking +for BD_LVM_TECH_VDO availability. +--- + src/plugins/lvm.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c +index 32ad55c..2bd7782 100644 +--- a/src/plugins/lvm.c ++++ b/src/plugins/lvm.c +@@ -329,7 +329,8 @@ gboolean bd_lvm_is_tech_avail (BDLVMTech tech, guint64 mode, GError **error) { + return TRUE; + case BD_LVM_TECH_VDO: + return check_features (&avail_features, FEATURES_VDO_MASK, features, FEATURES_LAST, &deps_check_lock, error) && +- check_module_deps (&avail_module_deps, MODULE_DEPS_VDO_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error); ++ check_module_deps (&avail_module_deps, MODULE_DEPS_VDO_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error) && ++ check_deps (&avail_deps, DEPS_LVM_MASK, deps, DEPS_LAST, &deps_check_lock, error); + default: + /* everything is supported by this implementation of the plugin */ + return check_deps (&avail_deps, DEPS_LVM_MASK, deps, DEPS_LAST, &deps_check_lock, error); +-- +1.8.3.1 + diff --git a/0005-lvm-dbus-Fix-memory-leak-in-bd_lvm_cache_attach.patch b/0005-lvm-dbus-Fix-memory-leak-in-bd_lvm_cache_attach.patch new file mode 100644 index 0000000000000000000000000000000000000000..7eda3b243e8d1f3c1066a40a387790f1a51d983f --- /dev/null +++ b/0005-lvm-dbus-Fix-memory-leak-in-bd_lvm_cache_attach.patch @@ -0,0 +1,25 @@ +From c9e76261bc52cf2360ee7f43dcdfedfa7149b30e Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 30 Jun 2020 16:05:47 +0200 +Subject: [PATCH 189/193] lvm-dbus: Fix memory leak in bd_lvm_cache_attach + +--- + src/plugins/lvm-dbus.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c +index fa19d1a..327969d 100644 +--- a/src/plugins/lvm-dbus.c ++++ b/src/plugins/lvm-dbus.c +@@ -3274,6 +3274,8 @@ gboolean bd_lvm_cache_attach (const gchar *vg_name, const gchar *data_lv, const + lv_id = g_strdup_printf ("%s/%s", vg_name, cache_pool_lv); + + call_lvm_obj_method_sync (lv_id, CACHE_POOL_INTF, "CacheLv", params, NULL, extra, TRUE, error); ++ g_free (lv_id); ++ g_free (lv_obj_path); + return ((*error) == NULL); + } + +-- +1.8.3.1 + diff --git a/0006-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch b/0006-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch new file mode 100644 index 0000000000000000000000000000000000000000..fe1c9d12afc41a9dbbae9e6ad74e5012facef4e6 --- /dev/null +++ b/0006-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch @@ -0,0 +1,24 @@ +From d9e8b2d43c84a664aa6a9b498047a865a1a38225 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 30 Jun 2020 16:06:01 +0200 +Subject: [PATCH 190/193] lvm: Fix memory leak bd_lvm_cache_create_cached_lv + +--- + src/plugins/lvm.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c +index 0aae9ac..bec7656 100644 +--- a/src/plugins/lvm.c ++++ b/src/plugins/lvm.c +@@ -2475,6 +2475,7 @@ gboolean bd_lvm_cache_create_cached_lv (const gchar *vg_name, const gchar *lv_na + + success = bd_lvm_lvcreate (vg_name, lv_name, data_size, NULL, slow_pvs, NULL, error); + if (!success) { ++ g_free (name); + g_prefix_error (error, "Failed to create the data LV: "); + bd_utils_report_finished (progress_id, (*error)->message); + return FALSE; +-- +1.8.3.1 + diff --git a/0007-fs-Fix-return-values-in-bd_fs_ntfs_get_info.patch b/0007-fs-Fix-return-values-in-bd_fs_ntfs_get_info.patch new file mode 100644 index 0000000000000000000000000000000000000000..0f7f8ea739eec37d020ef9c858205a5bed658b1f --- /dev/null +++ b/0007-fs-Fix-return-values-in-bd_fs_ntfs_get_info.patch @@ -0,0 +1,52 @@ +From 90b119f3026af68e2478450c7a71ed0fe68a9cbc Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 11 Aug 2020 18:00:57 +0200 +Subject: [PATCH 07/15] fs: Fix return values in bd_fs_ntfs_get_info + +--- + src/plugins/fs/ntfs.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/plugins/fs/ntfs.c b/src/plugins/fs/ntfs.c +index fdd959a..b406f41 100644 +--- a/src/plugins/fs/ntfs.c ++++ b/src/plugins/fs/ntfs.c +@@ -253,7 +253,7 @@ BDFSNtfsInfo* bd_fs_ntfs_get_info (const gchar *device, GError **error) { + g_autofree gchar* mountpoint = NULL; + + if (!check_deps (&avail_deps, DEPS_NTFSCLUSTER_MASK, deps, DEPS_LAST, &deps_check_lock, error)) +- return FALSE; ++ return NULL; + + mountpoint = bd_fs_get_mountpoint (device, error); + if (mountpoint != NULL) { +@@ -270,7 +270,7 @@ BDFSNtfsInfo* bd_fs_ntfs_get_info (const gchar *device, GError **error) { + success = bd_utils_exec_and_capture_output (args, NULL, &output, error); + if (!success) + /* error is already populated */ +- return FALSE; ++ return NULL; + + ret = g_new0 (BDFSNtfsInfo, 1); + lines = g_strsplit (output, "\n", 0); +@@ -283,7 +283,7 @@ BDFSNtfsInfo* bd_fs_ntfs_get_info (const gchar *device, GError **error) { + g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse NTFS file system information"); + g_strfreev (lines); + bd_fs_ntfs_info_free (ret); +- return FALSE; ++ return NULL; + } + + /* extract data from something like this: "bytes per volume : 998240256" */ +@@ -297,7 +297,7 @@ BDFSNtfsInfo* bd_fs_ntfs_get_info (const gchar *device, GError **error) { + g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse NTFS file system information"); + g_strfreev (lines); + bd_fs_ntfs_info_free (ret); +- return FALSE; ++ return NULL; + } + + /* extract data from something like this: "bytes of free space : 992759808" */ +-- +1.8.3.1 + diff --git a/0008-fs-Fix-return-values-in-bd_fs_xfs_get_info.patch b/0008-fs-Fix-return-values-in-bd_fs_xfs_get_info.patch new file mode 100644 index 0000000000000000000000000000000000000000..165f074093ec3f9b4b1ad0626c567347d11fbc93 --- /dev/null +++ b/0008-fs-Fix-return-values-in-bd_fs_xfs_get_info.patch @@ -0,0 +1,52 @@ +From 63f5df1992b15c1d6a442f2d392fa3b92ecf7b92 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 11 Aug 2020 18:04:58 +0200 +Subject: [PATCH 08/15] fs: Fix return values in bd_fs_xfs_get_info + +--- + src/plugins/fs/xfs.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/plugins/fs/xfs.c b/src/plugins/fs/xfs.c +index b8b4bbe..d28ce72 100644 +--- a/src/plugins/fs/xfs.c ++++ b/src/plugins/fs/xfs.c +@@ -274,7 +274,7 @@ BDFSXfsInfo* bd_fs_xfs_get_info (const gchar *device, GError **error) { + if (!success) { + /* error is already populated */ + bd_fs_xfs_info_free (ret); +- return FALSE; ++ return NULL; + } + + lines = g_strsplit (output, "\n", 0); +@@ -288,7 +288,7 @@ BDFSXfsInfo* bd_fs_xfs_get_info (const gchar *device, GError **error) { + g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse xfs file system information"); + g_strfreev (lines); + bd_fs_xfs_info_free (ret); +- return FALSE; ++ return NULL; + } + + /* extract data from something like this: "data = bsize=4096 blocks=262400, imaxpct=25" */ +@@ -305,7 +305,7 @@ BDFSXfsInfo* bd_fs_xfs_get_info (const gchar *device, GError **error) { + g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse xfs file system information"); + g_strfreev (lines); + bd_fs_xfs_info_free (ret); +- return FALSE; ++ return NULL; + } + while (isdigit (*val_start) || isspace(*val_start)) + val_start++; +@@ -318,7 +318,7 @@ BDFSXfsInfo* bd_fs_xfs_get_info (const gchar *device, GError **error) { + g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse xfs file system information"); + g_strfreev (lines); + bd_fs_xfs_info_free (ret); +- return FALSE; ++ return NULL; + } + g_strfreev (lines); + +-- +1.8.3.1 + diff --git a/0009-dm-Fix-comparing-DM-RAID-member-devices-UUID.patch b/0009-dm-Fix-comparing-DM-RAID-member-devices-UUID.patch new file mode 100644 index 0000000000000000000000000000000000000000..6a2f7d76c1d9cb11565ec63aeb6b351c476d7ddb --- /dev/null +++ b/0009-dm-Fix-comparing-DM-RAID-member-devices-UUID.patch @@ -0,0 +1,30 @@ +From 332c90019613797a2a634020f288a81a09b8b985 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 18 Aug 2020 09:44:29 +0200 +Subject: [PATCH 09/15] dm: Fix comparing DM RAID member devices UUID + +There is no "UUID" property in UDev we must use the "ID_FS_UUID" +one. +This comparison works only because most DM RAID members don't have +UUID so the check is skipped, but it fails for DDF RAID members +which have a special GUID/UUID in UDev database. +--- + src/plugins/dm.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/plugins/dm.c b/src/plugins/dm.c +index fb4e50b..93a47f4 100644 +--- a/src/plugins/dm.c ++++ b/src/plugins/dm.c +@@ -481,7 +481,7 @@ static gboolean raid_dev_matches_spec (struct raid_dev *raid_dev, const gchar *n + + context = udev_new (); + device = udev_device_new_from_subsystem_sysname (context, "block", dev_name); +- dev_uuid = udev_device_get_property_value (device, "UUID"); ++ dev_uuid = udev_device_get_property_value (device, "ID_FS_UUID"); + major_str = udev_device_get_property_value (device, "MAJOR"); + minor_str = udev_device_get_property_value (device, "MINOR"); + +-- +1.8.3.1 + diff --git a/0010-dm-Fix-memory-leak-in-the-DM-plugin-and-DM-logging-r.patch b/0010-dm-Fix-memory-leak-in-the-DM-plugin-and-DM-logging-r.patch new file mode 100644 index 0000000000000000000000000000000000000000..562d85dc8ef8863e30592a721ae79cac3bc50cdd --- /dev/null +++ b/0010-dm-Fix-memory-leak-in-the-DM-plugin-and-DM-logging-r.patch @@ -0,0 +1,30 @@ +From 6c0ae13b509975e67c65d690d388afccc78a0b63 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Fri, 25 Sep 2020 14:23:24 +0200 +Subject: [PATCH 10/15] dm: Fix memory leak in the DM plugin and DM logging + redirect function + +conflict: + 1. there is no dm_logging.c in v2.24 + +Signed-off-by: Vojtech Trefny +Signed-off-by: Zhiqiang Liu +--- + src/plugins/dm.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/plugins/dm.c b/src/plugins/dm.c +index 93a47f4..e8f0f4e 100644 +--- a/src/plugins/dm.c ++++ b/src/plugins/dm.c +@@ -246,6 +246,7 @@ gchar* bd_dm_name_from_node (const gchar *dm_node, GError **error) { + + if (!success) { + /* errror is already populated */ ++ g_free (ret); + return NULL; + } + +-- +1.8.3.1 + diff --git a/0011-fs-Fix-memory-leak.patch b/0011-fs-Fix-memory-leak.patch new file mode 100644 index 0000000000000000000000000000000000000000..4ada5431823021e543fee99bcaa17ee7584aa970 --- /dev/null +++ b/0011-fs-Fix-memory-leak.patch @@ -0,0 +1,29 @@ +From 11e899c9f7256cd549e6a0a5ef607925b15cdb7a Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Fri, 25 Sep 2020 14:24:14 +0200 +Subject: [PATCH 11/15] fs: Fix memory leak + +Conflict: +1. due to context differences, we have adapted the patch. + +Signed-off-by: Vojtech Trefny +Signed-off-by: Zhiqiang Liu +--- + src/plugins/fs/mount.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/plugins/fs/mount.c b/src/plugins/fs/mount.c +index 43d64e8..98110aa 100644 +--- a/src/plugins/fs/mount.c ++++ b/src/plugins/fs/mount.c +@@ -541,6 +541,7 @@ static gboolean run_as_user (MountFunc func, MountArgs *args, uid_t run_as_uid, + "Unknoen error while reading error."); + g_io_channel_unref (channel); + close (pipefd[0]); ++ g_free(error_msg); + return FALSE; + } + +-- +1.8.3.1 + diff --git a/0012-kbd-Fix-memory-leak.patch b/0012-kbd-Fix-memory-leak.patch new file mode 100644 index 0000000000000000000000000000000000000000..ae7f52bcc422f3271b6eaccee062ba12077d329a --- /dev/null +++ b/0012-kbd-Fix-memory-leak.patch @@ -0,0 +1,24 @@ +From bc7fddbe15f21eba45d55b3d9a9feaabf954a309 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Fri, 25 Sep 2020 14:26:24 +0200 +Subject: [PATCH 12/15] kbd: Fix memory leak + +--- + src/plugins/kbd.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/plugins/kbd.c b/src/plugins/kbd.c +index a2908ec..41593be 100644 +--- a/src/plugins/kbd.c ++++ b/src/plugins/kbd.c +@@ -1254,6 +1254,7 @@ static gboolean get_cache_size_used (const gchar *cache_dev_sys, guint64 *size, + g_io_channel_unref (file); + + if (!found) { ++ g_free (line); + g_set_error (error, BD_KBD_ERROR, BD_KBD_ERROR_BCACHE_INVAL, + "Failed to get cache usage data"); + return FALSE; +-- +1.8.3.1 + diff --git a/0013-lvm-dbus-Fix-memory-leak.patch b/0013-lvm-dbus-Fix-memory-leak.patch new file mode 100644 index 0000000000000000000000000000000000000000..fff88be1b773c15f7b517322c2fce6f510b7ada4 --- /dev/null +++ b/0013-lvm-dbus-Fix-memory-leak.patch @@ -0,0 +1,24 @@ +From 696dd84099cc2144b7c6b530933bed01b5fbaac4 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Fri, 25 Sep 2020 14:26:37 +0200 +Subject: [PATCH 13/15] lvm-dbus: Fix memory leak + +--- + src/plugins/lvm-dbus.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c +index b0efe7a..bf60141 100644 +--- a/src/plugins/lvm-dbus.c ++++ b/src/plugins/lvm-dbus.c +@@ -2978,6 +2978,7 @@ gboolean bd_lvm_cache_detach (const gchar *vg_name, const gchar *cached_lv, gboo + lv_id = g_strdup_printf ("%s/%s", vg_name, cached_lv); + call_lvm_obj_method_sync (lv_id, CACHED_LV_INTF, "DetachCachePool", params, NULL, extra, TRUE, error); + g_free (lv_id); ++ g_free (cache_pool_name); + return ((*error) == NULL); + } + +-- +1.8.3.1 + diff --git a/0014-mdraid-Fix-memory-leak.patch b/0014-mdraid-Fix-memory-leak.patch new file mode 100644 index 0000000000000000000000000000000000000000..399fc30caf55f9c40167e26f60856af2379674ba --- /dev/null +++ b/0014-mdraid-Fix-memory-leak.patch @@ -0,0 +1,24 @@ +From d60f654d4547febf7c6ce5353a403ca0df60450c Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Fri, 25 Sep 2020 14:27:22 +0200 +Subject: [PATCH 14/15] mdraid: Fix memory leak + +--- + src/plugins/mdraid.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c +index 74af744..b97bc64 100644 +--- a/src/plugins/mdraid.c ++++ b/src/plugins/mdraid.c +@@ -1332,6 +1332,7 @@ gchar* bd_md_name_from_node (const gchar *node, GError **error) { + continue; + } + node_name = g_path_get_basename (dev_path); ++ g_free (dev_path); + if (g_strcmp0 (node_name, node) == 0) { + found = TRUE; + name = g_path_get_basename (*path_p); +-- +1.8.3.1 + diff --git a/0015-swap-Fix-memory-leak.patch b/0015-swap-Fix-memory-leak.patch new file mode 100644 index 0000000000000000000000000000000000000000..099c7ec2da2194af66b8775afa85b37f27d28668 --- /dev/null +++ b/0015-swap-Fix-memory-leak.patch @@ -0,0 +1,24 @@ +From 58e7484228fcfbffc439a9d5131a221dd9e35d5f Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Fri, 25 Sep 2020 14:27:54 +0200 +Subject: [PATCH 15/15] swap: Fix memory leak + +--- + src/plugins/swap.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/plugins/swap.c b/src/plugins/swap.c +index 102780a..115f8fc 100644 +--- a/src/plugins/swap.c ++++ b/src/plugins/swap.c +@@ -417,6 +417,7 @@ gboolean bd_swap_swapstatus (const gchar *device, GError **error) { + if (!real_device) { + /* the device doesn't exist and thus is not an active swap */ + g_clear_error (error); ++ g_free (file_content); + return FALSE; + } + } +-- +1.8.3.1 + diff --git a/0016-vdo-Do-not-use-g_memdup-in-bd_vdo_stats_copy.patch b/0016-vdo-Do-not-use-g_memdup-in-bd_vdo_stats_copy.patch new file mode 100644 index 0000000000000000000000000000000000000000..dc9fdd3075f247d7bdad235ab4929a404ef73628 --- /dev/null +++ b/0016-vdo-Do-not-use-g_memdup-in-bd_vdo_stats_copy.patch @@ -0,0 +1,101 @@ +From 5528baef6ccc835a06c45f9db34a2c9c3f2dd940 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 16 Mar 2021 12:05:37 +0100 +Subject: [PATCH] vdo: Do not use g_memdup in bd_vdo_stats_copy + +g_memdup is deprecated and the replacement g_memdup2 is not yet +available so lets just do the copy manually. + +Signed-off-by: Vojtech Trefny +--- + src/lib/plugin_apis/vdo.api | 17 ++++++++++++++++- + src/lib/plugin_apis/vdo.c | 17 ++++++++++++++++- + src/plugins/vdo.c | 17 ++++++++++++++++- + 3 files changed, 48 insertions(+), 3 deletions(-) + +diff --git a/src/lib/plugin_apis/vdo.api b/src/lib/plugin_apis/vdo.api +index 936f8e0..312de4e 100644 +--- a/src/lib/plugin_apis/vdo.api ++++ b/src/lib/plugin_apis/vdo.api +@@ -170,7 +170,22 @@ void bd_vdo_stats_free (BDVDOStats *stats) { + * Deprecated: 2.24: Use LVM-VDO integration instead. + */ + BDVDOStats* bd_vdo_stats_copy (BDVDOStats *stats) { +- return g_memdup (stats, sizeof (BDVDOStats)); ++ if (stats == NULL) ++ return NULL; ++ ++ BDVDOStats *new_stats = g_new0 (BDVDOStats, 1); ++ ++ new_stats->block_size = stats->block_size; ++ new_stats->logical_block_size = stats->logical_block_size; ++ new_stats->physical_blocks = stats->physical_blocks; ++ new_stats->data_blocks_used = stats->data_blocks_used; ++ new_stats->overhead_blocks_used = stats->overhead_blocks_used; ++ new_stats->logical_blocks_used = stats->logical_blocks_used; ++ new_stats->used_percent = stats->used_percent; ++ new_stats->saving_percent = stats->saving_percent; ++ new_stats->write_amplification_ratio = stats->write_amplification_ratio; ++ ++ return new_stats; + } + + GType bd_vdo_stats_get_type () { +diff --git a/src/lib/plugin_apis/vdo.c b/src/lib/plugin_apis/vdo.c +index 40563ee..3e23bbc 100644 +--- a/src/lib/plugin_apis/vdo.c ++++ b/src/lib/plugin_apis/vdo.c +@@ -106,7 +106,22 @@ void bd_vdo_stats_free (BDVDOStats *stats) { + * Deprecated: 2.24: Use LVM-VDO integration instead. + */ + BDVDOStats* bd_vdo_stats_copy (BDVDOStats *stats) { +- return g_memdup (stats, sizeof (BDVDOStats)); ++ if (stats == NULL) ++ return NULL; ++ ++ BDVDOStats *new_stats = g_new0 (BDVDOStats, 1); ++ ++ new_stats->block_size = stats->block_size; ++ new_stats->logical_block_size = stats->logical_block_size; ++ new_stats->physical_blocks = stats->physical_blocks; ++ new_stats->data_blocks_used = stats->data_blocks_used; ++ new_stats->overhead_blocks_used = stats->overhead_blocks_used; ++ new_stats->logical_blocks_used = stats->logical_blocks_used; ++ new_stats->used_percent = stats->used_percent; ++ new_stats->saving_percent = stats->saving_percent; ++ new_stats->write_amplification_ratio = stats->write_amplification_ratio; ++ ++ return new_stats; + } + + GType bd_vdo_stats_get_type () { +diff --git a/src/plugins/vdo.c b/src/plugins/vdo.c +index 2352394..a9eb54a 100644 +--- a/src/plugins/vdo.c ++++ b/src/plugins/vdo.c +@@ -81,7 +81,22 @@ void bd_vdo_stats_free (BDVDOStats *stats) { + } + + BDVDOStats* bd_vdo_stats_copy (BDVDOStats *stats) { +- return g_memdup (stats, sizeof (BDVDOStats)); ++ if (stats == NULL) ++ return NULL; ++ ++ BDVDOStats *new_stats = g_new0 (BDVDOStats, 1); ++ ++ new_stats->block_size = stats->block_size; ++ new_stats->logical_block_size = stats->logical_block_size; ++ new_stats->physical_blocks = stats->physical_blocks; ++ new_stats->data_blocks_used = stats->data_blocks_used; ++ new_stats->overhead_blocks_used = stats->overhead_blocks_used; ++ new_stats->logical_blocks_used = stats->logical_blocks_used; ++ new_stats->used_percent = stats->used_percent; ++ new_stats->saving_percent = stats->saving_percent; ++ new_stats->write_amplification_ratio = stats->write_amplification_ratio; ++ ++ return new_stats; + } + + +-- +2.27.0 diff --git a/libblockdev-2.20.tar.gz b/libblockdev-2.20.tar.gz deleted file mode 100644 index f28c49df63d638731175457cfaa8b79f7b7cbafa..0000000000000000000000000000000000000000 Binary files a/libblockdev-2.20.tar.gz and /dev/null differ diff --git a/libblockdev-2.24.tar.gz b/libblockdev-2.24.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..1adbf0a45e7dc4f90cd0bf586f9d0eef642af1db Binary files /dev/null and b/libblockdev-2.24.tar.gz differ diff --git a/libblockdev.spec b/libblockdev.spec index 0e34070cd0f485203110ecf81f36b46e498904f3..b84e60fabef31716c6937eda9b54eda128f039ec 100644 --- a/libblockdev.spec +++ b/libblockdev.spec @@ -1,52 +1,71 @@ +# dmraid is deprecated +%define configure_opts --without-dmraid + Name: libblockdev -Version: 2.20 -Release: 4 +Version: 2.24 +Release: 9 Summary: libblockdev is a C library supporting GObject introspection for manipulation of block devices License: LGPLv2+ URL: https://github.com/storaged-project/libblockdev Source0: https://github.com/storaged-project/libblockdev/releases/download/%{version}-1/%{name}-%{version}.tar.gz -Patch0000: 0000-swap-error-codes.patch - -BuildRequires: git glib2-devel libyaml-devel libbytesize-devel parted-devel libuuid-devel ndctl-devel device-mapper-devel -BuildRequires: device-mapper-devel dmraid-devel systemd-devel nss-devel volume_key-devel >= 0.3.9-7 libblkid-devel libmount-devel +Patch1: 0001-lvm-Add-missing-attribute-to-bd_lvm_pvdata_copy-in-L.patch +Patch2: 0002-module.c-Fix-error-message-when-loading-module-witho.patch +Patch3: 0003-exec-Fix-setting-locale-for-util-calls.patch +Patch4: 0004-lvm-Fix-checking-for-LVM-VDO-dependencies.patch +Patch5: 0005-lvm-dbus-Fix-memory-leak-in-bd_lvm_cache_attach.patch +Patch6: 0006-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch +Patch7: 0007-fs-Fix-return-values-in-bd_fs_ntfs_get_info.patch +Patch8: 0008-fs-Fix-return-values-in-bd_fs_xfs_get_info.patch +Patch9: 0009-dm-Fix-comparing-DM-RAID-member-devices-UUID.patch +Patch10: 0010-dm-Fix-memory-leak-in-the-DM-plugin-and-DM-logging-r.patch +Patch11: 0011-fs-Fix-memory-leak.patch +Patch12: 0012-kbd-Fix-memory-leak.patch +Patch13: 0013-lvm-dbus-Fix-memory-leak.patch +Patch14: 0014-mdraid-Fix-memory-leak.patch +Patch15: 0015-swap-Fix-memory-leak.patch +Patch16: 0016-vdo-Do-not-use-g_memdup-in-bd_vdo_stats_copy.patch + +BuildRequires: glib2-devel libyaml-devel libbytesize-devel parted-devel libuuid-devel ndctl-devel device-mapper-devel +BuildRequires: device-mapper-devel systemd-devel nss-devel volume_key-devel >= 0.3.9-7 libblkid-devel libmount-devel BuildRequires: cryptsetup-devel kmod-devel libxslt glib2-doc gtk-doc python2-devel python3-devel gobject-introspection-devel -Requires: btrfs-progs device-mapper dmraid device-mapper-multipath lvm2 mdadm +BuildRequires: autoconf-archive +Requires: btrfs-progs device-mapper device-mapper-multipath lvm2 mdadm Requires: device-mapper-persistent-data lvm2-dbusd >= 2.02.156 ndctl gdisk util-linux Recommends: vdo kmod-kvdo Provides: %{name}-utils%{?_isa} %{name}-utils -Obsoletes: %{name}-utils +Obsoletes: %{name}-utils < %{version} Provides: %{name}-btrfs%{?_isa} %{name}-btrfs -Obsoletes: %{name}-btrfs +Obsoletes: %{name}-btrfs < %{version} Provides: %{name}-crypto%{?_isa} %{name}-crypto -Obsoletes: %{name}-crypto +Obsoletes: %{name}-crypto < %{version} Provides: %{name}-dm%{?_isa} %{name}-dm -Obsoletes: %{name}-dm +Obsoletes: %{name}-dm < %{version} Provides: %{name}-fs%{?_isa} %{name}-fs -Obsoletes: %{name}-fs +Obsoletes: %{name}-fs < %{version} Provides: %{name}-kbd%{?_isa} %{name}-kbd -Obsoletes: %{name}-kbd +Obsoletes: %{name}-kbd < %{version} Provides: %{name}-vdo%{?_isa} %{name}-vdo -Obsoletes: %{name}-vdo +Obsoletes: %{name}-vdo < %{version} Provides: %{name}-loop%{?_isa} %{name}-loop -Obsoletes: %{name}-loop +Obsoletes: %{name}-loop < %{version} Provides: %{name}-lvm%{?_isa} %{name}-lvm -Obsoletes: %{name}-lvm +Obsoletes: %{name}-lvm < %{version} Provides: %{name}-lvm-dbus%{?_isa} %{name}-lvm-dbus -Obsoletes: %{name}-lvm-dbus +Obsoletes: %{name}-lvm-dbus < %{version} Provides: %{name}-mdraid%{?_isa} %{name}-mdraid -Obsoletes: %{name}-mdraid +Obsoletes: %{name}-mdraid < %{version} Provides: %{name}-mpath%{?_isa} %{name}-mpath -Obsoletes: %{name}-mpath +Obsoletes: %{name}-mpath < %{version} Provides: %{name}-nvdimm%{?_isa} %{name}-nvdimm -Obsoletes: %{name}-nvdimm +Obsoletes: %{name}-nvdimm < %{version} Provides: %{name}-part%{?_isa} %{name}-part -Obsoletes: %{name}-part +Obsoletes: %{name}-part < %{version} Provides: %{name}-swap%{?_isa} %{name}-swap -Obsoletes: %{name}-swap +Obsoletes: %{name}-swap < %{version} Provides: %{name}-plugins-all%{?_isa} %{name}-plugins-all -Obsoletes: %{name}-plugins-all +Obsoletes: %{name}-plugins-all < %{version} %description libblockdev is a C library supporting GObject introspection for manipulation of block devices. @@ -56,38 +75,38 @@ possibly with multiple implementations (e.g. using LVM CLI or the new LVM DBus A %package devel Summary: Libraries and header files for libblockdev Requires: %{name}%{?_isa} = %{version}-%{release} -Requires: glib2-devel device-mapper-devel xfsprogs dosfstools dmraid-devel systemd-devel +Requires: glib2-devel device-mapper-devel xfsprogs dosfstools systemd-devel Provides: %{name}-btrfs-devel%{?_isa} %{name}-btrfs-devel -Obsoletes: %{name}-btrfs-devel +Obsoletes: %{name}-btrfs-devel < %{version} Provides: %{name}-crypto-devel%{?_isa} %{name}-crypto-devel -Obsoletes: %{name}-crypto-devel +Obsoletes: %{name}-crypto-devel < %{version} Provides: %{name}-dm-devel%{?_isa} %{name}-dm-devel -Obsoletes: %{name}-dm-devel +Obsoletes: %{name}-dm-devel < %{version} Provides: %{name}-fs-devel%{?_isa} %{name}-fs-devel -Obsoletes: %{name}-fs-devel +Obsoletes: %{name}-fs-devel < %{version} Provides: %{name}-kbd-devel%{?_isa} %{name}-kbd-devel -Obsoletes: %{name}-kbd-devel +Obsoletes: %{name}-kbd-devel < %{version} Provides: %{name}-loop-devel%{?_isa} %{name}-loop-devel -Obsoletes: %{name}-loop-devel +Obsoletes: %{name}-loop-devel < %{version} Provides: %{name}-lvm-devel%{?_isa} %{name}-lvm-devel -Obsoletes: %{name}-lvm-devel +Obsoletes: %{name}-lvm-devel < %{version} Provides: %{name}-lvm-dbus-devel%{?_isa} %{name}-lvm-dbus-devel -Obsoletes: %{name}-lvm-dbus-devel +Obsoletes: %{name}-lvm-dbus-devel < %{version} Provides: %{name}-mdraid-devel%{?_isa} %{name}-mdraid-devel -Obsoletes: %{name}-mdraid-devel +Obsoletes: %{name}-mdraid-devel < %{version} Provides: %{name}-mpath-devel%{?_isa} %{name}-mpath-devel -Obsoletes: %{name}-mpath-devel +Obsoletes: %{name}-mpath-devel < %{version} Provides: %{name}-nvdimm-devel%{?_isa} %{name}-nvdimm-devel -Obsoletes: %{name}-nvdimm-devel +Obsoletes: %{name}-nvdimm-devel < %{version} Provides: %{name}-part-devel%{?_isa} %{name}-part-devel -Obsoletes: %{name}-part-devel +Obsoletes: %{name}-part-devel < %{version} Provides: %{name}-swap-devel%{?_isa} %{name}-swap-devel -Obsoletes: %{name}-swap-devel +Obsoletes: %{name}-swap-devel < %{version} Provides: %{name}-vdo-devel%{?_isa} %{name}-vdo-devel -Obsoletes: %{name}-vdo-devel +Obsoletes: %{name}-vdo-devel < %{version} Provides: %{name}-utils-devel%{?_isa} %{name}-utils-devel -Obsoletes: %{name}-utils-devel +Obsoletes: %{name}-utils-devel < %{version} %description devel Libraries and header files for a set for utils(libblockdev,libblockdev-btrfs,libblockdev-crypto, @@ -95,6 +114,16 @@ libblockdev-dm,libblockdev-fs,libblockdev-kbd,libblockdev-loop,libblockdev-lvm, libblockdev-lvm-dbus,libblockdev-mdraid,libblockdev-mpath,libblockdev-nvdimm,libblockdev-part, libblockdev-swap,libblockdev-utils,libblockdev-vdo +%package tools +Summary: Various nice tools based on libblockdev +Requires: %{name} +Requires: %{name}-lvm +BuildRequires: libbytesize-devel +Recommends: %{name}-lvm-dbus + +%description tools +Various nice storage-related tools based on libblockdev. + %package -n python2-blockdev Summary: Python2 bindings for libblockdev Requires: %{name}%{?_isa} = %{version}-%{release} @@ -114,7 +143,7 @@ Requires: python3-gobject-base Python3 bindings for libblockdev %prep -%autosetup -n %{name}-%{version} -p1 -Sgit +%autosetup -n %{name}-%{version} -p1 %build autoreconf -ivf @@ -147,6 +176,9 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm} %dir %{_includedir}/blockdev %{_includedir}/blockdev/* +%files tools +%{_bindir}/lvm-cache-stats + %files -n python2-blockdev %{python2_sitearch}/gi/overrides/* @@ -155,5 +187,29 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm} %changelog +* Wed Jun 25 2025 kouwenqi - 2.24-9 +- fix changelog display confusion issue + +* Tue Sep 28 2021 Wenchao Hao - 2.24-8 +- NOP:nothing but to make it able to sync between differnt branches + +* Fri Jul 30 2021 chenyanpanHW - 2.24-7 +- DESC: delete -Sgit from autosetup, and delete BuildRequires git + +* Thu Nov 26 2020 yanglongkang - 2.24-6 +- fix build fail caused by deprecated-declarations + +* Sat Oct 31 2020 Zhiqiang Liu - 2.24-5 +- backport upstream patches-epoch2 to fix serveral problems + +* Fri Jul 31 2020 Ruijun Ge - 2.24-3 +- backport upstream patches + +* Thu Jul 30 2020 Lixiaokeng - 2.24-2 +- remove require of dmraid + +* Wed Jul 29 2020 Zhiqiang Liu - 2.24-1 +- update to 2.24 version + * Mon Sep 16 2019 wubo - 2.20.4 - Package init