Every dlopen_xxx() helper now takes an int log_level argument. It is passed through to dlopen_many_sym_or_warn() (which in turn propagates it to dlopen_verbose() for the library-not-installed case), and is used by the fallback stub when support for the library is not compiled in to emit a "<lib> support is not compiled in." message at the caller's level. Callers pass LOG_DEBUG when gracefully degrading, or a higher level when the failure should surface, and no longer need to log redundantly at the call site. As part of this, dlopen_bpf_full() (which already took a log_level) is merged into dlopen_bpf() rather than keeping both. The static inline fallbacks used to live in the headers, which required pulling log.h in from every header that declared a dlopen_xxx(). Move them into the .c files instead: the declaration is always outside the #if HAVE_XXX block, the impl sits outside the outer #if HAVE_XXX wrap with its own internal #if HAVE_XXX/#else/#endif, and apparmor-util.c, idn-util.c, libmount-util.c and pam-util.c are now always compiled so they can host their stubs.
54 lines
1.7 KiB
C
54 lines
1.7 KiB
C
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
#pragma once
|
|
|
|
#include "shared-forward.h"
|
|
|
|
#if HAVE_KMOD
|
|
|
|
#include <libkmod.h> /* IWYU pragma: export */
|
|
|
|
#include "dlfcn-util.h"
|
|
|
|
extern DLSYM_PROTOTYPE(kmod_list_next);
|
|
extern DLSYM_PROTOTYPE(kmod_load_resources);
|
|
extern DLSYM_PROTOTYPE(kmod_module_get_initstate);
|
|
extern DLSYM_PROTOTYPE(kmod_module_get_module);
|
|
extern DLSYM_PROTOTYPE(kmod_module_get_name);
|
|
extern DLSYM_PROTOTYPE(kmod_module_new_from_lookup);
|
|
extern DLSYM_PROTOTYPE(kmod_module_probe_insert_module);
|
|
extern DLSYM_PROTOTYPE(kmod_module_unref);
|
|
extern DLSYM_PROTOTYPE(kmod_module_unref_list);
|
|
extern DLSYM_PROTOTYPE(kmod_new);
|
|
extern DLSYM_PROTOTYPE(kmod_set_log_fn);
|
|
extern DLSYM_PROTOTYPE(kmod_unref);
|
|
extern DLSYM_PROTOTYPE(kmod_validate_resources);
|
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct kmod_ctx*, sym_kmod_unref, kmod_unrefp, NULL);
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct kmod_module*, sym_kmod_module_unref, kmod_module_unrefp, NULL);
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct kmod_list*, sym_kmod_module_unref_list, kmod_module_unref_listp, NULL);
|
|
|
|
#define sym_kmod_list_foreach(list_entry, first_entry) \
|
|
for (list_entry = first_entry; \
|
|
list_entry != NULL; \
|
|
list_entry = sym_kmod_list_next(first_entry, list_entry))
|
|
|
|
int module_load_and_warn(struct kmod_ctx *ctx, const char *module, bool verbose);
|
|
int module_setup_context(struct kmod_ctx **ret);
|
|
|
|
#else
|
|
|
|
struct kmod_ctx;
|
|
|
|
|
|
static inline int module_setup_context(struct kmod_ctx **ret) {
|
|
return -EOPNOTSUPP;
|
|
}
|
|
|
|
static inline int module_load_and_warn(struct kmod_ctx *ctx, const char *module, bool verbose) {
|
|
return -EOPNOTSUPP;
|
|
}
|
|
|
|
#endif
|
|
|
|
int dlopen_libkmod(int log_level);
|