systemd/modules_on_boot.patch

89 lines
3.4 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-37/src/modules-load.c
===================================================================
--- systemd-37.orig/src/modules-load.c
+++ systemd-37/src/modules-load.c
@@ -36,6 +36,9 @@ int main(int argc, char *argv[]) {
char **arguments = NULL;
unsigned n_arguments = 0, n_allocated = 0;
char **files, **fn;
+#if defined(TARGET_SUSE)
+ char *modules_on_boot = NULL;
+#endif
if (argc > 1) {
log_error("This program takes no argument.");
@@ -126,6 +129,42 @@ int main(int argc, char *argv[]) {
}
strv_free(files);
+#if defined(TARGET_SUSE)
+ 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));
+ }
+ if (modules_on_boot) {
+ char **modules = strv_split(modules_on_boot,WHITESPACE);
+ char **module;
+ if (modules) {
+ STRV_FOREACH(module, modules) {
+ if (n_arguments >= n_allocated) {
+ char **a;
+ unsigned m;
+
+ m = MAX(16U, n_arguments*2);
+
+ if (!(a = realloc(arguments, sizeof(char*) * (m+1)))) {
+ log_error("Failed to increase module array size.");
+ free(*module);
+ r = EXIT_FAILURE;
+ continue;
+ }
+
+ arguments = a;
+ n_allocated = m;
+ }
+ log_debug("adding module: %s\n", *module);
+ arguments[n_arguments++] = strdup(*module);
+ }
+ }
+ strv_free(modules);
+ }
+#endif
+
finish:
if (n_arguments > 3) {
@@ -138,6 +177,9 @@ finish:
}
strv_free(arguments);
+#if defined(TARGET_SUSE)
+ free(modules_on_boot);
+#endif
return r;
}
Index: systemd-37/units/systemd-modules-load.service.in
===================================================================
--- systemd-37.orig/units/systemd-modules-load.service.in
+++ systemd-37/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