systemd/modules_on_boot.patch

96 lines
4.2 KiB
Diff
Raw Normal View History

From 051e407e1af70e779c092c81733a98832c29d6b4 Mon Sep 17 00:00:00 2001
From: Frederic Crozat <fcrozat@suse.com>
Date: Wed, 12 Oct 2011 15:18:29 +0200
Subject: [PATCH] module-load: handle SUSE /etc/sysconfig/kernel module list
---
src/modules-load.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
Index: systemd-44/src/modules-load.c
===================================================================
--- systemd-44.orig/src/modules-load.c
+++ systemd-44/src/modules-load.c
@@ -44,6 +44,9 @@ static void systemd_kmod_log(void *data,
int main(int argc, char *argv[]) {
int r = EXIT_FAILURE;
char **files, **fn;
+#if defined(TARGET_SUSE)
+ char *modules_on_boot = NULL;
+#endif
struct kmod_ctx *ctx;
const int probe_flags = KMOD_PROBE_APPLY_BLACKLIST|KMOD_PROBE_IGNORE_LOADED;
@@ -141,9 +144,59 @@ int main(int argc, char *argv[]) {
fclose(f);
}
+#if defined(TARGET_SUSE)
+ log_debug("apply: /etc/sysconfig/kernel MODULES_LOADED_ON_BOOT");
+ if ((r = parse_env_file("/etc/sysconfig/kernel", NEWLINE,
+ "MODULES_LOADED_ON_BOOT", &modules_on_boot,
+ NULL)) < 0) {
+ if (r != -ENOENT)
+ log_warning("Failed to read /etc/sysconfig/kernel: %s", strerror(-r));
+ } else
+ r = EXIT_SUCCESS;
+ if (modules_on_boot) {
+ char **modules = strv_split(modules_on_boot,WHITESPACE);
+ char **module;
+ struct kmod_list *itr, *modlist = NULL;
+ int err;
+
+ if (modules) {
+ STRV_FOREACH(module, modules) {
+ err = kmod_module_new_from_lookup(ctx, *module, &modlist);
+ if (err < 0) {
+ log_error("Failed to lookup alias '%s'", *module);
+ r = EXIT_FAILURE;
+ continue;
+ }
+ kmod_list_foreach(itr, modlist) {
+ struct kmod_module *mod = kmod_module_get_module(itr);
+ 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 {
+ log_error("Failed to insert '%s': %s", kmod_module_get_name(mod),
+ strerror(-err));
+ r = EXIT_FAILURE;
+ }
+
+ kmod_module_unref(mod);
+ }
+ kmod_module_unref_list(modlist);
+ modlist = NULL;
+ }
+ }
+ strv_free(modules);
+ }
+#endif
finish:
strv_free(files);
+#if defined(TARGET_SUSE)
+ free(modules_on_boot);
+#endif
kmod_unref(ctx);
return r;
Index: systemd-44/units/systemd-modules-load.service.in
===================================================================
--- systemd-44.orig/units/systemd-modules-load.service.in
+++ systemd-44/units/systemd-modules-load.service.in
@@ -11,6 +11,7 @@ DefaultDependencies=no
Conflicts=shutdown.target
After=systemd-readahead-collect.service systemd-readahead-replay.service
Before=sysinit.target shutdown.target
+ConditionPathExists=|/etc/sysconfig/kernel
ConditionDirectoryNotEmpty=|/lib/modules-load.d
ConditionDirectoryNotEmpty=|/usr/lib/modules-load.d
ConditionDirectoryNotEmpty=|/usr/local/lib/modules-load.d