]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(load_fstype): avoid false positive searchs
authorFrederick Grose <fgrose@sugarlabs.org>
Sun, 27 Nov 2022 18:52:27 +0000 (13:52 -0500)
committerLaszlo Gombos <laszlo.gombos@gmail.com>
Fri, 30 Dec 2022 14:13:00 +0000 (09:13 -0500)
Refactor to avoid substring matches
  and to speed processing.
Also avoid xtracing.

modules.d/99base/dracut-lib.sh

index 218cb13b911fbd6c0ca5e71222844477a73c7f17..14f20d78ab464adc383ebac09c15cabe80a201fa 100755 (executable)
@@ -1140,5 +1140,10 @@ remove_hostonly_files() {
 # returns OK if kernel_module is loaded
 # modprobe fails if /lib/modules is not available (--no-kernel use case)
 load_fstype() {
-    strstr "$(cat /proc/filesystems)" "${2:-$1}" || modprobe "$1"
+    local - fs _fs="${2:-$1}"
+    set +x
+    while read -r d fs || [ "$d" ]; do
+        [ "${fs:-$d}" = "$_fs" ] && return 0
+    done < /proc/filesystems
+    modprobe "$1"
 }