7689d7
#!/bin/sh +x
93a897
# Kernel build can have many thousands of modules.
93a897
# kmod.prov is run for every one of them.
93a897
# Try to make this script run as fast as we can.
93a897
# For example, use shell string ops instead of external programs
93a897
# where possible.
7689d7
7689d7
IFS=$'\n'
7689d7
93a897
read -r fname || exit
7689d7
93a897
# Only process files from .../lib/modules/... subtree
93a897
[ "${fname#*/lib/modules/*}" != "$fname" ] || exit 0
93a897
93a897
kmod=${fname##*/}  # like basename, but faster
93a897
93a897
if [ "$kmod" = "modules.builtin" ]; then
93a897
        for j in $(cat -- "$fname"); do
93a897
                echo "kmod(${j##*/})"
93a897
        done
93a897
        exit 0
93a897
fi
93a897
93a897
kmod=${kmod%.gz}
93a897
kmod=${kmod%.xz}
93a897
if [ "${kmod%.ko}" != "$kmod" ]; then
93a897
        echo "kmod($kmod)"
93a897
fi