diff options
author | Dave Reisner <d@falconindy.com> | 2011-06-03 16:29:55 +0200 |
---|---|---|
committer | Dave Reisner <d@falconindy.com> | 2011-06-06 21:44:02 +0200 |
commit | 51d63c7556b5de04420dad4951c97199607f9b27 (patch) | |
tree | fedf7fbb0db37af7c4baae4eb96841f25a635f02 /functions | |
parent | bfee40e4d6080e218fc50a23d6a6111ccfb709dd (diff) | |
download | mkinitcpio-51d63c7556b5de04420dad4951c97199607f9b27.tar.gz mkinitcpio-51d63c7556b5de04420dad4951c97199607f9b27.tar.xz |
functions: refactor auto_modules
sort/uniq the modaliases files' contents, before passing _all_ of them
to modprobe -a. This cuts back on execution time as well as cleaning up
the resulting list of modules.
Signed-off-by: Dave Reisner <d@falconindy.com>
Diffstat (limited to 'functions')
-rw-r--r-- | functions | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -41,16 +41,13 @@ in_array() { auto_modules () { - aliases="$(find /sys/devices/ -name modalias -exec cat {} +)" - mods="" - for a in $aliases; do - m="$(modprobe --set-version ${KERNELVERSION} --resolve-alias "$a")" - [ -n "$m" ] && mods="$mods $m" - done + IFS=$'\n' read -rd '' -a mods < \ + <(find /sys/devices -name modalias -exec sort -zu {} + | + xargs -0 modprobe -aRS "$KERNELVERSION" | + sort -u) - echo "${mods}" | tr '-' '_' - [ -z "${mods}" ] && return 1 - return 0 + printf "%s\n" "${mods[@]//-/_}" + (( ${#mods[*]} )) } all_modules () |