If we're passed an argument, then treat it as a single NOMATCH event

to parse rather than searching for all events. Pass with new -p arg to
devmatch. devmatch will use that one event rather than walking the
entire tree.

kldload will stop at the first failure. So we need to loop.  Also,
symbolic links may confused kldload into trying (and failing) to load
multiple modules at once, so guard against that.

Noticed by: hps (with similar patch)
Sponsored by: Netflix
This commit is contained in:
imp 2018-02-17 06:57:21 +00:00
parent 1ebd4793ad
commit 9ae5cff01b

View File

@ -37,17 +37,26 @@ desc="Use devmatch(8) to load kernel modules"
start_cmd="${name}_start"
stop_cmd=':'
[ -n "$2" ] && one_nomatch="-p '$2'"
devmatch_start()
{
local x
x=$(devmatch | sort -u)
x=$(devmatch ${one_nomatch} | sort -u)
[ -n "$x" ] || return
# While kldload can accept multiple modules
# on the line at once, we loop here in case
# there's some weird error with one of them.
# We also optimize against the false positives
# or drivers that have symbolic links that
# confuse devmatch by running it -n.
echo "Autoloading modules: ${x}"
kldload ${x}
for m in ${x}; do
kldload -n ${m}
done
}
load_rc_config $name