diff options
Diffstat (limited to 'src/udev')
-rw-r--r-- | src/udev/meson.build | 2 | ||||
-rw-r--r-- | src/udev/udev-builtin-kmod.c | 27 |
2 files changed, 15 insertions, 14 deletions
diff --git a/src/udev/meson.build b/src/udev/meson.build index e5b52ab642..3535551e74 100644 --- a/src/udev/meson.build +++ b/src/udev/meson.build @@ -114,7 +114,7 @@ libudevd_core = static_library( include_directories : includes + include_directories('net'), link_with : udev_link_with, dependencies : [libblkid, - libkmod, + libkmod_cflags, userspace], build_by_default : false) diff --git a/src/udev/udev-builtin-kmod.c b/src/udev/udev-builtin-kmod.c index 6d37af88a3..f4aa4802c9 100644 --- a/src/udev/udev-builtin-kmod.c +++ b/src/udev/udev-builtin-kmod.c @@ -18,10 +18,6 @@ static struct kmod_ctx *ctx = NULL; -_printf_(6,0) static void udev_kmod_log(void *data, int priority, const char *file, int line, const char *fn, const char *format, va_list args) { - log_internalv(priority, 0, file, line, fn, format, args); -} - static int builtin_kmod(UdevEvent *event, int argc, char *argv[]) { sd_device *dev = ASSERT_PTR(ASSERT_PTR(event)->dev); int r; @@ -44,7 +40,7 @@ static int builtin_kmod(UdevEvent *event, int argc, char *argv[]) { r = sd_device_get_property_value(dev, "MODALIAS", &modalias); if (r < 0) - return log_device_warning_errno(dev, r, "Failed to read property \"MODALIAS\"."); + return log_device_warning_errno(dev, r, "Failed to read property \"MODALIAS\": %m"); (void) module_load_and_warn(ctx, modalias, /* verbose = */ false); } else @@ -56,23 +52,28 @@ static int builtin_kmod(UdevEvent *event, int argc, char *argv[]) { /* called at udev startup and reload */ static int builtin_kmod_init(void) { + int r; + if (ctx) return 0; - ctx = kmod_new(NULL, NULL); - if (!ctx) - return -ENOMEM; - log_debug("Loading kernel module index."); - kmod_set_log_fn(ctx, udev_kmod_log, NULL); - kmod_load_resources(ctx); + + r = module_setup_context(&ctx); + if (r < 0) + return log_error_errno(r, "Failed to initialize libkmod context: %m"); + return 0; } /* called on udev shutdown and reload request */ static void builtin_kmod_exit(void) { log_debug("Unload kernel module index."); - ctx = kmod_unref(ctx); + + if (!ctx) + return; + + ctx = sym_kmod_unref(ctx); } /* called every couple of seconds during event activity; 'true' if config has changed */ @@ -80,7 +81,7 @@ static bool builtin_kmod_should_reload(void) { if (!ctx) return false; - if (kmod_validate_resources(ctx) != KMOD_RESOURCES_OK) { + if (sym_kmod_validate_resources(ctx) != KMOD_RESOURCES_OK) { log_debug("Kernel module index needs reloading."); return true; } |