dracut-functions.sh: extend module_is_host_only()
If the currently running kernel is not present in the installer root, fall back to modalias checking.master
parent
d97d130da9
commit
3c4315fa13
|
|
@ -1473,23 +1473,41 @@ dracut_kernel_post() {
|
||||||
[[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && rm -fr -- "$DRACUT_KERNEL_LAZY_HASHDIR"
|
[[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && rm -fr -- "$DRACUT_KERNEL_LAZY_HASHDIR"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[ "$kernel_current" ]] || export kernel_current=$(uname -r)
|
||||||
|
|
||||||
module_is_host_only() {
|
module_is_host_only() {
|
||||||
local _mod=$1
|
local _mod=$1
|
||||||
|
local _modenc a i
|
||||||
_mod=${_mod##*/}
|
_mod=${_mod##*/}
|
||||||
_mod=${_mod%.ko}
|
_mod=${_mod%.ko}
|
||||||
|
_modenc=${_mod//-/_}
|
||||||
|
|
||||||
[[ " $add_drivers " == *\ ${_mod}\ * ]] && return 0
|
[[ " $add_drivers " == *\ ${_mod}\ * ]] && return 0
|
||||||
|
|
||||||
# check if module is loaded
|
# check if module is loaded
|
||||||
for i in /sys/module/${_mod//-/_}; do
|
[[ ${host_modules["$_modenc"]} ]] && return 0
|
||||||
[[ -d $i ]] && return 0
|
|
||||||
done
|
|
||||||
|
|
||||||
# check if module is loadable on the current kernel
|
[[ "$kernel_current" ]] || export kernel_current=$(uname -r)
|
||||||
# this covers the case, where a new module is introduced
|
|
||||||
# or a module was renamed
|
if [[ "$kernel_current" != "$kernel" ]]; then
|
||||||
# or a module changed from builtin to a module
|
# check if module is loadable on the current kernel
|
||||||
modinfo -F filename "$_mod" &>/dev/null || return 0
|
# this covers the case, where a new module is introduced
|
||||||
|
# or a module was renamed
|
||||||
|
# or a module changed from builtin to a module
|
||||||
|
if [[ -d /lib/modules/$kernel_current ]]; then
|
||||||
|
# if the modinfo can be parsed, but the module
|
||||||
|
# is not loaded, then we can safely return 1
|
||||||
|
modinfo -F filename "$_mod" &>/dev/null && return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Finally check all modalias, if we install for a kernel
|
||||||
|
# different from the current one
|
||||||
|
for a in $(modinfo -k $kernel -F alias $_mod 2>/dev/null); do
|
||||||
|
for i in "${!host_modalias[@]}"; do
|
||||||
|
[[ $i == $a ]] && return 0
|
||||||
|
done
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
|
||||||
20
dracut.sh
20
dracut.sh
|
|
@ -919,6 +919,23 @@ if [[ $hostonly ]]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# record all host modaliases
|
||||||
|
declare -A host_modalias
|
||||||
|
find /sys/devices/ -name modalias -print > "$initdir/.modalias"
|
||||||
|
while read m; do
|
||||||
|
host_modalias["$(<"$m")"]=1
|
||||||
|
done < "$initdir/.modalias"
|
||||||
|
rm -f -- "$initdir/.modalias"
|
||||||
|
|
||||||
|
# check /proc/modules
|
||||||
|
declare -A host_modules
|
||||||
|
while read m rest; do
|
||||||
|
host_modules["$m"]=1
|
||||||
|
done </proc/modules
|
||||||
|
|
||||||
|
unset m
|
||||||
|
unset rest
|
||||||
|
|
||||||
_get_fs_type() {
|
_get_fs_type() {
|
||||||
[[ $1 ]] || return
|
[[ $1 ]] || return
|
||||||
if [[ -b /dev/block/$1 ]] && ID_FS_TYPE=$(get_fs_env "/dev/block/$1"); then
|
if [[ -b /dev/block/$1 ]] && ID_FS_TYPE=$(get_fs_env "/dev/block/$1"); then
|
||||||
|
|
@ -989,7 +1006,8 @@ export initdir dracutbasedir dracutmodules \
|
||||||
stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
|
stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
|
||||||
debug host_fs_types host_devs sshkey add_fstab \
|
debug host_fs_types host_devs sshkey add_fstab \
|
||||||
DRACUT_VERSION udevdir prefix filesystems drivers \
|
DRACUT_VERSION udevdir prefix filesystems drivers \
|
||||||
systemdutildir systemdsystemunitdir systemdsystemconfdir
|
systemdutildir systemdsystemunitdir systemdsystemconfdir \
|
||||||
|
host_modalias host_modules
|
||||||
|
|
||||||
mods_to_load=""
|
mods_to_load=""
|
||||||
# check all our modules to see if they should be sourced.
|
# check all our modules to see if they should be sourced.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue