]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: use the generic module_load() function
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 6 Jul 2018 10:41:50 +0000 (12:41 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 19 Jul 2018 16:28:21 +0000 (18:28 +0200)
This allows aliases to be used for the basic modules we load from pid1 before
udev is started. In #9501 the kernel renamed autofs4 to autofs, with "autofs4"
as alias, but we wouldn't load the module, because we didn't follow aliases.
The kernel change was reverted, but it's probably better to support aliases.

src/core/kmod-setup.c

index b8292e77fd67649b9fde0546f3808924b6f444c0..5feb9962ba1cad05d5b3d192d5048fb941f88e6c 100644 (file)
@@ -96,14 +96,11 @@ int kmod_setup(void) {
         };
         _cleanup_(kmod_unrefp) struct kmod_ctx *ctx = NULL;
         unsigned int i;
-        int r;
 
         if (have_effective_cap(CAP_SYS_MODULE) == 0)
                 return 0;
 
         for (i = 0; i < ELEMENTSOF(kmod_table); i++) {
-                _cleanup_(kmod_module_unrefp) struct kmod_module *mod = NULL;
-
                 if (kmod_table[i].path && access(kmod_table[i].path, F_OK) >= 0)
                         continue;
 
@@ -124,23 +121,7 @@ int kmod_setup(void) {
                         kmod_load_resources(ctx);
                 }
 
-                r = kmod_module_new_from_name(ctx, kmod_table[i].module, &mod);
-                if (r < 0) {
-                        log_error("Failed to lookup module '%s'", kmod_table[i].module);
-                        continue;
-                }
-
-                r = kmod_module_probe_insert_module(mod, KMOD_PROBE_APPLY_BLACKLIST, NULL, NULL, NULL, NULL);
-                if (r == 0)
-                        log_debug("Inserted module '%s'", kmod_module_get_name(mod));
-                else if (r == KMOD_PROBE_APPLY_BLACKLIST)
-                        log_info("Module '%s' is blacklisted", kmod_module_get_name(mod));
-                else {
-                        bool print_warning = kmod_table[i].warn_if_unavailable || (r < 0 && r != -ENOENT);
-
-                        log_full_errno(print_warning ? LOG_WARNING : LOG_DEBUG, r,
-                                       "Failed to insert module '%s': %m", kmod_module_get_name(mod));
-                }
+                (void) module_load_and_warn(ctx, kmod_table[i].module, kmod_table[i].warn_if_unavailable);
         }
 
 #endif