fdisk-util: load libfdisk via dlopen

Convert fdisk-util to the dlopen pattern used by other optional shared
libraries in libshared. Declare the libfdisk API entry points with
DLSYM_PROTOTYPE, resolve them in a dlopen_fdisk() helper, and call the
sym_* wrappers from the homework, sysupdate and repart binaries that
use them.

With this in place fdisk-util can live in libshared itself, linked only
against libfdisk's headers (via libfdisk_cflags). The libshared_fdisk
convenience library and the libfdisk link dependency on systemd-homework,
systemd-sysupdate, systemd-repart and systemd-repart.standalone go away.

Also add a dlopen_fdisk() check to test-dlopen-so.
This commit is contained in:
Daan De Meyer
2026-04-21 07:53:53 +02:00
committed by Daan De Meyer
parent db3bfa0c4c
commit a066396fbc
13 changed files with 441 additions and 217 deletions
+1
View File
@@ -301,6 +301,7 @@ executables += [
'sources' : files('test-dlopen-so.c'),
'dependencies' : [
libblkid_cflags,
libfdisk_cflags,
libkmod_cflags,
libmount_cflags,
libp11kit_cflags,
+2
View File
@@ -8,6 +8,7 @@
#include "cryptsetup-util.h"
#include "curl-util.h"
#include "elf-util.h"
#include "fdisk-util.h"
#include "gcrypt-util.h"
#include "idn-util.h"
#include "libarchive-util.h"
@@ -49,6 +50,7 @@ static int run(int argc, char **argv) {
ASSERT_DLOPEN(dlopen_curl, HAVE_LIBCURL);
ASSERT_DLOPEN(dlopen_dw, HAVE_ELFUTILS);
ASSERT_DLOPEN(dlopen_elf, HAVE_ELFUTILS);
ASSERT_DLOPEN(dlopen_fdisk, HAVE_LIBFDISK);
ASSERT_DLOPEN(dlopen_gcrypt, HAVE_GCRYPT);
ASSERT_DLOPEN(dlopen_idn, HAVE_LIBIDN2);
ASSERT_DLOPEN(dlopen_libacl, HAVE_ACL);