diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-07-06 11:57:54 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-07-16 13:08:40 +0200 |
commit | 3cb9b42af3b205fba176ebf51ce0e07739698278 (patch) | |
tree | b24f91e42049627ac27ebdbf635bfcc23ec75262 /src/modules-load | |
parent | core/kmod-setup: restore comments (diff) | |
download | systemd-3cb9b42af3b205fba176ebf51ce0e07739698278.tar.xz systemd-3cb9b42af3b205fba176ebf51ce0e07739698278.zip |
Move module-util.h to src/shared/ and load_module() to libshared
Unfortunately this needs libshared to link to libkmod. Before it was linked
into systemd-udevd, udevadm, and systemd each seperately. On most systems this
doesn't make much difference, because at least systemd would be installed, but
it might not be in small chroots. It is a small library, so I hope this is not
a big issue.
Diffstat (limited to 'src/modules-load')
-rw-r--r-- | src/modules-load/modules-load.c | 63 |
1 files changed, 2 insertions, 61 deletions
diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c index c49a6b7a76..b3a4e818b6 100644 --- a/src/modules-load/modules-load.c +++ b/src/modules-load/modules-load.c @@ -59,65 +59,6 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat return 0; } -static int load_module(struct kmod_ctx *ctx, const char *m) { - const int probe_flags = KMOD_PROBE_APPLY_BLACKLIST; - struct kmod_list *itr; - _cleanup_(kmod_module_unref_listp) struct kmod_list *modlist = NULL; - int r = 0; - - log_debug("load: %s", m); - - r = kmod_module_new_from_lookup(ctx, m, &modlist); - if (r < 0) - return log_error_errno(r, "Failed to lookup alias '%s': %m", m); - - if (!modlist) { - log_error("Failed to find module '%s'", m); - return -ENOENT; - } - - kmod_list_foreach(itr, modlist) { - _cleanup_(kmod_module_unrefp) struct kmod_module *mod = NULL; - int state, err; - - mod = kmod_module_get_module(itr); - state = kmod_module_get_initstate(mod); - - switch (state) { - case KMOD_MODULE_BUILTIN: - log_info("Module '%s' is builtin", kmod_module_get_name(mod)); - break; - - case KMOD_MODULE_LIVE: - log_debug("Module '%s' is already loaded", kmod_module_get_name(mod)); - break; - - default: - err = kmod_module_probe_insert_module(mod, probe_flags, - NULL, NULL, NULL, NULL); - - if (err == 0) - log_info("Inserted module '%s'", kmod_module_get_name(mod)); - else if (err == KMOD_PROBE_APPLY_BLACKLIST) - log_info("Module '%s' is blacklisted", kmod_module_get_name(mod)); - else { - assert(err < 0); - - log_full_errno(err == ENODEV ? LOG_NOTICE : - err == ENOENT ? LOG_WARNING : - LOG_ERR, - err, - "Failed to insert '%s': %m", - kmod_module_get_name(mod)); - if (!IN_SET(err, ENODEV, ENOENT)) - r = err; - } - } - } - - return r; -} - static int apply_file(struct kmod_ctx *ctx, const char *path, bool ignore_enoent) { _cleanup_fclose_ FILE *f = NULL; int r; @@ -151,7 +92,7 @@ static int apply_file(struct kmod_ctx *ctx, const char *path, bool ignore_enoent if (strchr(COMMENTS "\n", *l)) continue; - k = load_module(ctx, l); + k = module_load_and_warn(ctx, l); if (k < 0 && r == 0) r = k; } @@ -248,7 +189,7 @@ int main(int argc, char *argv[]) { char **fn, **i; STRV_FOREACH(i, arg_proc_cmdline_modules) { - k = load_module(ctx, *i); + k = module_load_and_warn(ctx, *i); if (k < 0 && r == 0) r = k; } |