3b5284
From 73242b75af92bc86c26cfbe2954b7ecb9aaaf765 Mon Sep 17 00:00:00 2001
3b5284
From: Harald Hoyer <harald@redhat.com>
3b5284
Date: Tue, 4 Dec 2018 10:02:45 +0100
3b5284
Subject: [PATCH] install/dracut-install.c: install module dependencies of
3b5284
 dependencies
3b5284
3b5284
(cherry picked from commit c38f9e980c1ee03151dd1c6602907c6228b78d30)
3b5284
3b5284
Resolves: #1846343
3b5284
---
3b5284
 install/dracut-install.c | 28 +++++++++++++++++++++++++---
3b5284
 1 file changed, 25 insertions(+), 3 deletions(-)
3b5284
3b5284
diff --git a/install/dracut-install.c b/install/dracut-install.c
3b5284
index 88bca1d4..253ae194 100644
3b5284
--- a/install/dracut-install.c
3b5284
+++ b/install/dracut-install.c
3b5284
@@ -84,6 +84,11 @@ static bool arg_mod_filter_noname = false;
3b5284
 static int dracut_install(const char *src, const char *dst, bool isdir, bool resolvedeps, bool hashdst);
3b5284
 
3b5284
 
3b5284
+static inline void kmod_module_unrefp(struct kmod_module **p) {
3b5284
+        if (*p)
3b5284
+                kmod_module_unref(*p);
3b5284
+}
3b5284
+#define _cleanup_kmod_module_unref_ _cleanup_(kmod_module_unrefp)
3b5284
 
3b5284
 static inline void kmod_module_unref_listp(struct kmod_list **p) {
3b5284
         if (*p)
3b5284
@@ -1234,28 +1239,45 @@ static bool check_module_path(const char *path)
3b5284
 static int install_dependent_modules(struct kmod_list *modlist)
3b5284
 {
3b5284
         struct kmod_list *itr;
3b5284
-        struct kmod_module *mod;
3b5284
         const char *path = NULL;
3b5284
         const char *name = NULL;
3b5284
         int ret = 0;
3b5284
 
3b5284
         kmod_list_foreach(itr, modlist) {
3b5284
+		_cleanup_kmod_module_unref_ struct kmod_module *mod = NULL;
3b5284
                 mod = kmod_module_get_module(itr);
3b5284
                 path = kmod_module_get_path(mod);
3b5284
 
3b5284
+		if (check_hashmap(items_failed, path))
3b5284
+			return -1;
3b5284
+
3b5284
+		if (check_hashmap(items, path)) {
3b5284
+			continue;
3b5284
+		}
3b5284
+
3b5284
                 name = kmod_module_get_name(mod);
3b5284
+
3b5284
                 if ((path == NULL) || (arg_mod_filter_noname && (regexec(&mod_filter_noname, name, 0, NULL, 0) == 0))) {
3b5284
-                        kmod_module_unref(mod);
3b5284
                         continue;
3b5284
                 }
3b5284
+
3b5284
                 ret = dracut_install(path, &path[kerneldirlen], false, false, true);
3b5284
                 if (ret == 0) {
3b5284
+			_cleanup_kmod_module_unref_list_ struct kmod_list *modlist = NULL;
3b5284
+			_cleanup_kmod_module_unref_list_ struct kmod_list *modpre = NULL;
3b5284
+			_cleanup_kmod_module_unref_list_ struct kmod_list *modpost = NULL;
3b5284
                         log_debug("dracut_install '%s' '%s' OK", path, &path[kerneldirlen]);
3b5284
                         install_firmware(mod);
3b5284
+			modlist = kmod_module_get_dependencies(mod);
3b5284
+			ret = install_dependent_modules(modlist);
3b5284
+			if (ret == 0) {
3b5284
+				ret = kmod_module_get_softdeps(mod, &modpre, &modpost);
3b5284
+				if (ret == 0)
3b5284
+					ret = install_dependent_modules(modpre);
3b5284
+			}
3b5284
                 } else {
3b5284
                         log_error("dracut_install '%s' '%s' ERROR", path, &path[kerneldirlen]);
3b5284
                 }
3b5284
-                kmod_module_unref(mod);
3b5284
         }
3b5284
 
3b5284
         return ret;
3b5284