From 530c285ccff7ea21fc4eb960631206b86743f2e1 Mon Sep 17 00:00:00 2001 From: "Gao,Yan" Date: Mon, 2 Dec 2024 11:08:14 +0100 Subject: [PATCH 1/2] Refactor: tests: ability to specify a libaio name ... with -DLIBAIO_NAME for instance via CFLAGS This also ensures that the corresponding library name is shown in case of dlopen() error together with more detail from dlerror(). --- tests/sbd-testbed.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/sbd-testbed.c b/tests/sbd-testbed.c index 02844a7..3a4b4dc 100644 --- a/tests/sbd-testbed.c +++ b/tests/sbd-testbed.c @@ -56,6 +56,17 @@ g_unix_fd_add(gint fd, } #endif +#define LIBAIO_DOQUOTE(name) #name +#define LIBAIO_QUOTE(name) LIBAIO_DOQUOTE(name) + +#define LIBAIO_DEFAULT LIBAIO_QUOTE(libaio.so) + +#ifndef LIBAIO_NAME + #define LIBAIO_QUOTED LIBAIO_DEFAULT +#else + #define LIBAIO_QUOTED LIBAIO_QUOTE(LIBAIO_NAME) +#endif + typedef int (*orig_open_f_type)(const char *pathname, int flags, ...); typedef int (*orig_ioctl_f_type)(int fd, unsigned long int request, ...); typedef ssize_t (*orig_write_f_type)(int fd, const void *buf, size_t count); @@ -144,6 +155,7 @@ init (void) const char *value; int i; char *token, *str, *str_orig; + const char *libaio = LIBAIO_QUOTED; is_init = 1; @@ -154,9 +166,13 @@ init (void) orig_fopen = (orig_fopen_f_type)dlsym_fatal(RTLD_NEXT,"fopen"); orig_fclose = (orig_fclose_f_type)dlsym_fatal(RTLD_NEXT,"fclose"); - handle = dlopen("libaio.so", RTLD_NOW); + if (libaio == NULL || libaio[0] == '\0') { + libaio = LIBAIO_DEFAULT; + } + + handle = dlopen(libaio, RTLD_NOW); if (!handle) { - fprintf(stderr, "Failed opening libaio.so.1\n"); + fprintf(stderr, "Failed opening %s (%s)\n", libaio, dlerror()); exit(1); } orig_io_setup = (orig_io_setup_f_type)dlsym_fatal(handle,"io_setup"); From 12dbb6938254450859fbc17cbabeefebff8346c6 Mon Sep 17 00:00:00 2001 From: "Gao,Yan" Date: Thu, 5 Dec 2024 20:48:59 +0100 Subject: [PATCH 2/2] Build: spec: try finding and using libaio.so.x library name ... i.e. the one with the major version number such as libaio.so.1, to likely avoid requiring libaio-devel for the generic symbolic link libaio.so. --- sbd.spec | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sbd.spec b/sbd.spec index 0291598..4dd192f 100644 --- a/sbd.spec +++ b/sbd.spec @@ -47,6 +47,14 @@ # by setting below to an explicit 'yes' or 'no'. %global sync_resource_startup_sysconfig "" +# Try finding and using libaio.so.x library name i.e. the one with the major +# version number such as libaio.so.1 +%global libaio_name %(readlink -f %{_libdir}/libaio.so | xargs basename | cut -d "." -f 1-3) + +%if "%{libaio_name}" != "" && "%{libaio_name}" != "libaio.so" +%global specify_libaio 1 +%endif + Name: sbd Summary: Storage-based death License: GPL-2.0-or-later @@ -97,6 +105,10 @@ Available rpmbuild rebuild options: Summary: Storage-based death environment for regression tests License: GPL-2.0-or-later Group: System Environment/Daemons +%if ! 0%{?specify_libaio} +# Requires libaio-devel for the generic symbolic link libaio.so +Requires: libaio-devel +%endif %description tests This package provides an environment + testscripts for @@ -110,6 +122,11 @@ regression-testing sbd. %build ./autogen.sh export CFLAGS="$RPM_OPT_FLAGS -Wall -Werror" + +%if 0%{?specify_libaio} +export CFLAGS="${CFLAGS} -DLIBAIO_NAME=%{libaio_name}" +%endif + %configure --with-watchdog-timeout-default=%{watchdog_timeout_default} \ --with-sync-resource-startup-default=%{?with_sync_resource_startup_default:yes}%{!?with_sync_resource_startup_default:no} \ --with-sync-resource-startup-sysconfig=%{sync_resource_startup_sysconfig} \