This also switches all these notes to be defined via SD_ELF_NOTE_DLOPEN_ANCHORED(). Consequently, any notes added within unreachable or unused functions will be automatically garbage-collected by the linker (--gc-sections) instead of bloating the final binary. E.g. unused p11-kit library dependency is now dropped from systemd-repart.standalone binary. Before: ``` $ systemd-analyze dlopen-metadata build/systemd-repart.standalone FEATURE DESCRIPTION SONAME PRIORITY cryptsetup Support for disk encryption, integrity, and authentication libcryptsetup.so.12 recommended blkid Support for block device identification libblkid.so.1 required libcrypto Support for cryptographic operations libcrypto.so.4 libcrypto.so.3 recommended mount Support for mount enumeration libmount.so.1 required fdisk Support for reading and writing partition tables libfdisk.so.1 required blkid Support for block device identification libblkid.so.1 recommended libcrypto Support for cryptographic operations libcrypto.so.4 libcrypto.so.3 suggested cryptsetup Support for disk encryption, integrity, and authentication libcryptsetup.so.12 suggested fdisk Support for reading and writing partition tables libfdisk.so.1 suggested idn Support for internationalized domain names libidn2.so.0 suggested mount Support for mount enumeration libmount.so.1 recommended selinux Support for SELinux libselinux.so.1 recommended tpm Support for TPM libtss2-esys.so.0 suggested tpm Support for TPM libtss2-rc.so.0 suggested tpm Support for TPM libtss2-mu.so.0 suggested tpm Support for TPM libtss2-tcti-device.so.0 suggested p11-kit Support for PKCS11 hardware tokens libp11-kit.so.0 suggested ``` After: ``` $ systemd-analyze dlopen-metadata build/systemd-repart.standalone FEATURE DESCRIPTION SONAME PRIORITY cryptsetup Support for disk encryption, integrity, and authentication libcryptsetup.so.12 recommended blkid Support for block device identification libblkid.so.1 required libcrypto Support for cryptographic operations libcrypto.so.4 libcrypto.so.3 recommended mount Support for mount enumeration libmount.so.1 required fdisk Support for reading and writing partition tables libfdisk.so.1 required blkid Support for block device identification libblkid.so.1 recommended libcrypto Support for cryptographic operations libcrypto.so.4 libcrypto.so.3 suggested cryptsetup Support for disk encryption, integrity, and authentication libcryptsetup.so.12 suggested fdisk Support for reading and writing partition tables libfdisk.so.1 suggested mount Support for mount enumeration libmount.so.1 recommended selinux Support for SELinux libselinux.so.1 recommended tpm Support for TPM libtss2-esys.so.0 suggested tpm Support for TPM libtss2-rc.so.0 suggested tpm Support for TPM libtss2-mu.so.0 suggested tpm Support for TPM libtss2-tcti-device.so.0 suggested ```
98 lines
3.3 KiB
C
98 lines
3.3 KiB
C
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
#pragma once
|
|
|
|
#include "dlopen-note.h"
|
|
#include "shared-forward.h"
|
|
|
|
#if HAVE_LIBMOUNT
|
|
#ifndef SYSTEMD_CFLAGS_MARKER_LIBMOUNT
|
|
# error "missing libmount_cflags in meson dependency."
|
|
#endif
|
|
|
|
/* This needs to be after sys/mount.h */
|
|
#include <libmount.h> /* IWYU pragma: export */
|
|
|
|
#include "dlfcn-util.h"
|
|
|
|
extern DLSYM_PROTOTYPE(mnt_free_iter);
|
|
extern DLSYM_PROTOTYPE(mnt_free_table);
|
|
extern DLSYM_PROTOTYPE(mnt_fs_get_fs_options);
|
|
extern DLSYM_PROTOTYPE(mnt_fs_get_fstype);
|
|
extern DLSYM_PROTOTYPE(mnt_fs_get_id);
|
|
extern DLSYM_PROTOTYPE(mnt_fs_get_option);
|
|
extern DLSYM_PROTOTYPE(mnt_fs_get_options);
|
|
extern DLSYM_PROTOTYPE(mnt_fs_get_passno);
|
|
extern DLSYM_PROTOTYPE(mnt_fs_get_propagation);
|
|
extern DLSYM_PROTOTYPE(mnt_fs_get_source);
|
|
extern DLSYM_PROTOTYPE(mnt_fs_get_target);
|
|
extern DLSYM_PROTOTYPE(mnt_fs_get_vfs_options);
|
|
extern DLSYM_PROTOTYPE(mnt_get_builtin_optmap);
|
|
extern DLSYM_PROTOTYPE(mnt_init_debug);
|
|
extern DLSYM_PROTOTYPE(mnt_monitor_enable_kernel);
|
|
extern DLSYM_PROTOTYPE(mnt_monitor_enable_userspace);
|
|
extern DLSYM_PROTOTYPE(mnt_monitor_get_fd);
|
|
extern DLSYM_PROTOTYPE(mnt_monitor_next_change);
|
|
extern DLSYM_PROTOTYPE(mnt_new_iter);
|
|
extern DLSYM_PROTOTYPE(mnt_new_monitor);
|
|
extern DLSYM_PROTOTYPE(mnt_new_table);
|
|
extern DLSYM_PROTOTYPE(mnt_optstr_get_flags);
|
|
extern DLSYM_PROTOTYPE(mnt_table_find_devno);
|
|
extern DLSYM_PROTOTYPE(mnt_table_find_target);
|
|
extern DLSYM_PROTOTYPE(mnt_table_next_child_fs);
|
|
extern DLSYM_PROTOTYPE(mnt_table_next_fs);
|
|
extern DLSYM_PROTOTYPE(mnt_table_parse_file);
|
|
extern DLSYM_PROTOTYPE(mnt_table_parse_mtab);
|
|
extern DLSYM_PROTOTYPE(mnt_table_parse_stream);
|
|
extern DLSYM_PROTOTYPE(mnt_table_parse_swaps);
|
|
extern DLSYM_PROTOTYPE(mnt_unref_monitor);
|
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct libmnt_table*, sym_mnt_free_table, mnt_free_tablep, NULL);
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct libmnt_iter*, sym_mnt_free_iter, mnt_free_iterp, NULL);
|
|
|
|
int libmount_parse_full(
|
|
const char *path,
|
|
FILE *source,
|
|
int direction,
|
|
struct libmnt_table **ret_table,
|
|
struct libmnt_iter **ret_iter);
|
|
|
|
static inline int libmount_parse_mountinfo(
|
|
FILE *source,
|
|
struct libmnt_table **ret_table,
|
|
struct libmnt_iter **ret_iter) {
|
|
|
|
return libmount_parse_full("/proc/self/mountinfo", source, MNT_ITER_FORWARD, ret_table, ret_iter);
|
|
}
|
|
|
|
static inline int libmount_parse_with_utab(
|
|
struct libmnt_table **ret_table,
|
|
struct libmnt_iter **ret_iter) {
|
|
|
|
return libmount_parse_full(NULL, NULL, MNT_ITER_FORWARD, ret_table, ret_iter);
|
|
}
|
|
|
|
int libmount_parse_fstab(struct libmnt_table **ret_table, struct libmnt_iter **ret_iter);
|
|
|
|
int libmount_is_leaf(
|
|
struct libmnt_table *table,
|
|
struct libmnt_fs *fs);
|
|
|
|
#else
|
|
|
|
struct libmnt_monitor;
|
|
|
|
static inline void* sym_mnt_unref_monitor(struct libmnt_monitor *p) {
|
|
assert(p == NULL);
|
|
return NULL;
|
|
}
|
|
|
|
#endif
|
|
|
|
int dlopen_libmount(int log_level);
|
|
|
|
#define DLOPEN_LIBMOUNT(log_level, priority) \
|
|
({ \
|
|
LIBMOUNT_NOTE(priority); \
|
|
dlopen_libmount(log_level); \
|
|
})
|