From: Frederick Grose Date: Sun, 27 Nov 2022 18:52:27 +0000 (-0500) Subject: fix(load_fstype): avoid false positive searchs X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10cf8e46f43a7a2094e4d861c1296db6af0e0fa1;p=thirdparty%2Fdracut.git fix(load_fstype): avoid false positive searchs Refactor to avoid substring matches and to speed processing. Also avoid xtracing. --- diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh index 218cb13b9..14f20d78a 100755 --- a/modules.d/99base/dracut-lib.sh +++ b/modules.d/99base/dracut-lib.sh @@ -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" }