diff --git a/0002-Check-also-for-aliases-in-bd_utils_have_kernel_module.patch b/0002-Check-also-for-aliases-in-bd_utils_have_kernel_module.patch new file mode 100644 index 0000000..d48bd85 --- /dev/null +++ b/0002-Check-also-for-aliases-in-bd_utils_have_kernel_module.patch @@ -0,0 +1,86 @@ +From 91c22078e9d369d266c044f949b65ebd611f31b0 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 21 May 2024 15:42:29 +0200 +Subject: [PATCH] utils: Check also for aliases in bd_utils_have_kernel_module + +We want to return true for ext2/3 which are now supported by ext4 +module. +--- + src/utils/module.c | 12 +++++++++++- + tests/utils_test.py | 22 ++++++++++++++++++++++ + 2 files changed, 33 insertions(+), 1 deletion(-) + +diff --git a/src/utils/module.c b/src/utils/module.c +index 66d02343..71d53b46 100644 +--- a/src/utils/module.c ++++ b/src/utils/module.c +@@ -85,6 +85,7 @@ gboolean bd_utils_have_kernel_module (const gchar *module_name, GError **error) + gint ret = 0; + struct kmod_ctx *ctx = NULL; + struct kmod_module *mod = NULL; ++ struct kmod_list *list = NULL; + gchar *null_config = NULL; + const gchar *path = NULL; + gboolean have_path = FALSE; +@@ -100,21 +101,30 @@ gboolean bd_utils_have_kernel_module (const gchar *module_name, GError **error) + } + set_kmod_logging (ctx); + +- ret = kmod_module_new_from_name (ctx, module_name, &mod); ++ ret = kmod_module_new_from_lookup (ctx, module_name, &list); + if (ret < 0) { + g_set_error (error, BD_UTILS_MODULE_ERROR, BD_UTILS_MODULE_ERROR_FAIL, + "Failed to get the module: %s", strerror_l (-ret, c_locale)); + kmod_unref (ctx); ++ kmod_module_unref_list (list); ++ freelocale (c_locale); ++ return FALSE; ++ } ++ ++ if (list == NULL) { ++ kmod_unref (ctx); + freelocale (c_locale); + return FALSE; + } + ++ mod = kmod_module_get_module (list); + path = kmod_module_get_path (mod); + have_path = (path != NULL) && (g_strcmp0 (path, "") != 0); + if (!have_path) { + builtin = kmod_module_get_initstate (mod) == KMOD_MODULE_BUILTIN; + } + kmod_module_unref (mod); ++ kmod_module_unref_list (list); + kmod_unref (ctx); + freelocale (c_locale); + +diff --git a/tests/utils_test.py b/tests/utils_test.py +index d656d309..372228f8 100644 +--- a/tests/utils_test.py ++++ b/tests/utils_test.py +@@ -484,3 +484,25 @@ def test_initialization(self): + self.assertEqual(ver.major, ver2.major) + self.assertEqual(ver.minor, ver2.minor) + self.assertEqual(ver.micro, ver2.micro) ++ ++ ++class UtilsKernelModuleTest(UtilsTestCase): ++ @tag_test(TestTags.NOSTORAGE, TestTags.CORE) ++ def test_have_kernel_module(self): ++ """ Test checking for kernel modules """ ++ ++ have = BlockDev.utils_have_kernel_module("definitely-not-existing-kernel-module") ++ self.assertFalse(have) ++ ++ # loop should be everywhere, right? ++ have = BlockDev.utils_have_kernel_module("loop") ++ self.assertTrue(have) ++ ++ # lets check some filesystems support and compare with 'modprobe' results ++ for fs in ("ext2", "ext3", "ext4", "xfs", "btrfs"): ++ have_fs = BlockDev.utils_have_kernel_module(fs) ++ ret, _out, _err = run_command("modprobe --dry-run %s" % fs) ++ if ret == 0: ++ self.assertTrue(have_fs) ++ else: ++ self.assertFalse(have_fs) diff --git a/libblockdev.spec b/libblockdev.spec index 7723949..4fe73a1 100644 --- a/libblockdev.spec +++ b/libblockdev.spec @@ -78,13 +78,14 @@ Name: libblockdev Version: 3.1.0 -Release: 3%{?dist} +Release: 4%{?dist} Summary: A library for low-level manipulation with block devices License: LGPL-2.1-or-later URL: https://github.com/storaged-project/libblockdev Source0: https://github.com/storaged-project/libblockdev/releases/download/%{version}-%{release}/%{name}-%{version}.tar.gz Patch0: 0001-misc-RHEL-10-beta-backport.patch +Patch1: 0002-Check-also-for-aliases-in-bd_utils_have_kernel_module.patch BuildRequires: make BuildRequires: glib2-devel @@ -853,6 +854,10 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm} %files plugins-all %changelog +* Thu May 30 2024 Vojtech Trefny - 3.1.0-4 +- Check also for aliases in bd_utils_have_kernel_module + Resolves: RHEL-37249 + * Tue May 14 2024 Vojtech Trefny - 3.1.0-3 - Fix creating MD RAID arrays without specifying bitmap localtion Resolves: RHEL-31379