Blame SOURCES/0001-dracut.sh-workaround-broken-read-from-proc-modules.patch

5b232a
From 14af2ab39994576bda1d2a6b9c7980f08473e784 Mon Sep 17 00:00:00 2001
5b232a
From: Lukas Nykryn <lnykryn@redhat.com>
5b232a
Date: Mon, 11 Jun 2018 11:07:59 +0200
5b232a
Subject: [PATCH] dracut.sh: workaround broken read from /proc/modules
5b232a
5b232a
RHEL-only (upstream is using libkmod)
5b232a
Resolves: #1578222
5b232a
---
5b232a
 dracut.sh | 21 +++++++++++++++++----
5b232a
 1 file changed, 17 insertions(+), 4 deletions(-)
5b232a
5b232a
diff --git a/dracut.sh b/dracut.sh
5b232a
index 873274c..9dadece 100755
5b232a
--- a/dracut.sh
5b232a
+++ b/dracut.sh
5b232a
@@ -1145,10 +1145,23 @@ if [[ $hostonly ]]; then
5b232a
 
5b232a
     # check /proc/modules
5b232a
     declare -A host_modules
5b232a
-    while read m rest; do
5b232a
-        [ -z "$m" ] && continue
5b232a
-        host_modules["$m"]=1
5b232a
-    done 
5b232a
+    declare new_module_found=1
5b232a
+    declare tmpmodules=$(mktemp --tmpdir="$TMPDIR/" -t proc_modules.XXXXXX)
5b232a
+    while [[ $new_module_found ]]; do
5b232a
+        new_module_found=
5b232a
+        sleep 0.1
5b232a
+        #reading from procfs can be broken, so copy the file elsewhere
5b232a
+        cp -f /proc/modules "$tmpmodules"
5b232a
+        while read m rest; do
5b232a
+            [ -z "$m" ] && continue
5b232a
+            [[ ${host_modules["$m"]} ]] && continue
5b232a
+            host_modules["$m"]=1
5b232a
+            new_module_found=1
5b232a
+        done < "$tmpmodules"
5b232a
+    done
5b232a
+    rm "$tmpmodules"
5b232a
+    unset new_module_found
5b232a
+    unset tmpmodules
5b232a
 fi
5b232a
 
5b232a
 unset m
5b232a
-- 
5b232a
2.14.4
5b232a