removed obsolete kernel module functions and host_modules variable

module_is_host_only()
find_kernel_modules_by_path()
find_kernel_modules()
master
Harald Hoyer 2016-04-15 16:25:59 +02:00
parent eab32bda80
commit 3f60444ec1
3 changed files with 2 additions and 84 deletions

View File

@ -943,60 +943,6 @@ dracut_kernel_post() {

}

[[ "$kernel_current" ]] || export kernel_current=$(uname -r)

module_is_host_only() {
local _mod=$1
local _modenc a i _k _s _v _aliases
_mod=${_mod##*/}
_mod=${_mod%.ko*}
_modenc=${_mod//-/_}

[[ " $add_drivers " == *\ ${_mod}\ * ]] && return 0

# check if module is loaded
[[ ${host_modules["$_modenc"]} ]] && return 0

[[ "$kernel_current" ]] || export kernel_current=$(uname -r)

if [[ "$kernel_current" != "$kernel" ]]; then
# check if module is loadable on the current kernel
# 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

# just install the module, better safe than sorry
return 0
fi

return 1
}

find_kernel_modules_by_path () {
local _OLDIFS

[[ -f "$srcmods/modules.dep" ]] || return 0

_OLDIFS=$IFS
IFS=:
while read a rest || [ -n "$a" ]; do
[[ $a = */$1/* ]] || [[ $a = updates/* ]] || continue
printf "%s\n" "$srcmods/$a"
done < "$srcmods/modules.dep"
IFS=$_OLDIFS
return 0
}

find_kernel_modules () {
find_kernel_modules_by_path drivers
}

instmods() {
# instmods [-c [-s]] <kernel module> [<kernel module> ... ]
# instmods [-c [-s]] <kernel subsystem>

View File

@ -1101,8 +1101,6 @@ if (( ${#add_device_l[@]} )); then
push_host_devs "${add_device_l[@]}"
fi

declare -A host_modules

if [[ $hostonly ]]; then
# in hostonly mode, determine all devices, which have to be accessed
# and examine them for filesystem types
@ -1190,32 +1188,6 @@ if [[ $hostonly ]]; then
fi
done < /etc/fstab
fi

# check /proc/modules
while read m rest || [ -n "$m" ]; do
host_modules["$m"]=1
done </proc/modules

# Explanation of the following section:
# Since kernel 4.4, mpt3sas is a complete replacement for mpt2sas.
# mpt3sas has an alias to mpt2sas now, but since mpt3sas isn't loaded
# when generating the initrd from kernel < 4.4, it's not included.
# The other direction has the same issue:
# When generating the initrd from kernel >= 4.4, mpt2sas isn't loaded,
# so it's not included.
# Both ways result in an unbootable initrd.

# also add aliases of loaded modules
for mod in "${!host_modules[@]}"; do
aliases=$(modinfo -F alias "$mod" 2>&1)
for alias in $aliases; do
host_modules["$alias"]=1
done
# mod might be an alias in the target kernel, find the real module
mod_filename=$(modinfo -k "$kernel" "$mod" -F filename)
[ $? -ne 0 ] && continue
host_modules["$(basename -s .ko "$mod_filename")"]=1
done
fi

unset m
@ -1302,7 +1274,7 @@ export initdir dracutbasedir \
debug host_fs_types host_devs swap_devs sshkey add_fstab \
DRACUT_VERSION udevdir prefix filesystems drivers \
systemdutildir systemdsystemunitdir systemdsystemconfdir \
host_modules hostonly_cmdline loginstall \
hostonly_cmdline loginstall \
tmpfilesdir

mods_to_load=""

View File

@ -41,7 +41,7 @@ depends() {
# called by dracut
cmdline() {
for m in scsi_dh_alua scsi_dh_emc scsi_dh_rdac ; do
if module_is_host_only $m ; then
if grep -m 1 -q "$m" /proc/modules ; then
printf 'rd.driver.pre=%s ' "$m"
fi
done