summaryrefslogtreecommitdiffstats
path: root/functions
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2013-09-22 00:47:53 +0200
committerDave Reisner <dreisner@archlinux.org>2013-09-24 17:12:20 +0200
commit59c79bda956ccb309d21adfb5afcc19df77a8e0b (patch)
tree8816266cbeeb6cd64fc4c380edefe01518f69bef /functions
parentc1e8eb0e130a1f8e9dd8253478a0a626b4f441cc (diff)
downloadmkinitcpio-59c79bda956ccb309d21adfb5afcc19df77a8e0b.tar.gz
mkinitcpio-59c79bda956ccb309d21adfb5afcc19df77a8e0b.tar.xz
autodetect: read modaliases from uevent files
As suggested by Harald Hoyer, this is more accurate for the sake of following where udev gets its modaliases from. In some rare cases, it may even be more complete than scraping the raw modalias files. Also, introduce a wrapper around modprobe so that the options passed are never ommitted, or wrongly specified. In this case, a subtle bug with the -r flag is fixed due to using the wrong variable with modprobe's -d flag. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'functions')
-rw-r--r--functions12
1 files changed, 7 insertions, 5 deletions
diff --git a/functions b/functions
index 4f231b1..f0dce80 100644
--- a/functions
+++ b/functions
@@ -251,16 +251,18 @@ list_hookpoints() {
in_array run_cleanuphook "${funcs[@]}" && msg2 "cleanup hook"
}
+modprobe() {
+ command modprobe -d "$_optmoduleroot" -S "$KERNELVERSION" "$@"
+}
+
auto_modules() {
# Perform auto detection of modules via sysfs.
local mods=
- IFS=$'\n' read -rd '' -a mods < \
- <(find /sys/devices -name modalias -exec sort -u {} + |
- # delimit each input by a newline, expanded in place
- xargs -d $'\n' modprobe -d "$MODULEROOT" -qaRS "$KERNELVERSION" |
- sort -u)
+ mapfile -t mods < <(find /sys/devices -name uevent \
+ -exec sort -u {} + | awk -F= '$1 == "MODALIAS" && !_[$0]++')
+ mapfile -t mods < <(modprobe -qaR "${mods[@]#MODALIAS=}")
(( ${#mods[*]} )) && printf "%s\n" "${mods[@]//-/_}"
}