dracut: add --force-add option

This patch adds a new option --force-add, which
can force dracut to load some module when -H
is specified.

Signed-off-by: Amerigo Wang <amwang@redhat.com>
master
Amerigo Wang 2011-08-01 10:01:23 +08:00 committed by Harald Hoyer
parent 0c7112fcff
commit 31f1c02dda
3 changed files with 35 additions and 6 deletions

8
dracut
View File

@ -195,6 +195,7 @@ verbosity_mod_l=0
while (($# > 0)); do while (($# > 0)); do
case ${1%%=*} in case ${1%%=*} in
-a|--add) push_arg add_dracutmodules_l "$@" || shift;; -a|--add) push_arg add_dracutmodules_l "$@" || shift;;
--force-add) push_arg force_add_dracutmodules_l "$@" || shift;;
--add-drivers) push_arg add_drivers_l "$@" || shift;; --add-drivers) push_arg add_drivers_l "$@" || shift;;
-m|--modules) push_arg dracutmodules_l "$@" || shift;; -m|--modules) push_arg dracutmodules_l "$@" || shift;;
-o|--omit) push_arg omit_dracutmodules_l "$@" || shift;; -o|--omit) push_arg omit_dracutmodules_l "$@" || shift;;
@ -301,6 +302,13 @@ if (( ${#add_dracutmodules_l[@]} )); then
done done
fi fi


if (( ${#force_add_dracutmodules_l[@]} )); then
while pop force_add_dracutmodules_l val; do
force_add_dracutmodules+=" $val "
done
fi


if (( ${#add_drivers_l[@]} )); then if (( ${#add_drivers_l[@]} )); then
while pop add_drivers_l val; do while pop add_drivers_l val; do
add_drivers+=" $val " add_drivers+=" $val "

View File

@ -606,21 +606,27 @@ inst_opt_decompress() {
module_check() { module_check() {
local _moddir=$(echo ${dracutbasedir}/modules.d/??${1}) local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
local _ret local _ret
local _forced=0
local _hostonly=$hostonly
[ $# -eq 2 ] && _forced=$2
[[ -d $_moddir ]] || return 1 [[ -d $_moddir ]] || return 1
if [[ ! -f $_moddir/module-setup.sh ]]; then if [[ ! -f $_moddir/module-setup.sh ]]; then
# if we do not have a check script, we are unconditionally included # if we do not have a check script, we are unconditionally included
[[ -x $_moddir/check ]] || return 0 [[ -x $_moddir/check ]] || return 0
[ $_forced -ne 0 ] && unset hostonly
$_moddir/check $hostonly $_moddir/check $hostonly
return $? _ret=$?
else else
unset check depends install installkernel unset check depends install installkernel
. $_moddir/module-setup.sh . $_moddir/module-setup.sh
is_func check || return 0 is_func check || return 0
check [ $_forced -ne 0 ] && unset hostonly
check $hostonly
_ret=$? _ret=$?
unset check depends install installkernel unset check depends install installkernel
return $_ret
fi fi
hostonly=$_hostonly
return $_ret
} }


module_depends() { module_depends() {
@ -695,8 +701,12 @@ check_module() {


strstr " $omit_dracutmodules " " $_mod " && return 1 strstr " $omit_dracutmodules " " $_mod " && return 1


if strstr " $dracutmodules $add_dracutmodules " " $_mod "; then if strstr " $dracutmodules $add_dracutmodules $force_add_dracutmodules" " $_mod "; then
module_check $_mod; ret=$? if strstr " $force_add_dracutmodules" " $_mod"; then
module_check $_mod 1; ret=$?
else
module_check $_mod 0; ret=$?
fi
# explicit module, so also accept ret=255 # explicit module, so also accept ret=255
[[ $ret = 0 || $ret = 255 ]] || return 1 [[ $ret = 0 || $ret = 255 ]] || return 1
else else
@ -714,6 +724,8 @@ check_module() {
# handle deps as if they were manually added # handle deps as if they were manually added
strstr " $add_dracutmodules " " $_moddep " || \ strstr " $add_dracutmodules " " $_moddep " || \
add_dracutmodules+=" $_moddep " add_dracutmodules+=" $_moddep "
strstr " $force_add_dracutmodules " " $_moddep " || \
force_add_dracutmodules+=" $_moddep "
# if a module we depend on fail, fail also # if a module we depend on fail, fail also
check_module $_moddep || return 1 check_module $_moddep || return 1
done done
@ -735,7 +747,7 @@ check_module_dir() {
done done


# Report any missing dracut modules, the user has specified # Report any missing dracut modules, the user has specified
_modcheck=$add_dracutmodules _modcheck="$add_dracutmodules $force_add_dracutmodules"
[[ $dracutmodules != all ]] && _modcheck="$m $dracutmodules" [[ $dracutmodules != all ]] && _modcheck="$m $dracutmodules"
for _mod in $_modcheck; do for _mod in $_modcheck; do
strstr "$mods_to_load" "$_mod" && continue strstr "$mods_to_load" "$_mod" && continue

View File

@ -136,6 +136,15 @@ Modules are located in
<para>add a space-separated list of dracut modules to the default set of modules. This parameter can be specified multiple times.</para> <para>add a space-separated list of dracut modules to the default set of modules. This parameter can be specified multiple times.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>
<option>--force-add&nbsp;<replaceable>&lt;list of dracut modules&gt;</replaceable></option>
</term>
<listitem>
<para>force to add a space-separated list of dracut modules to the default set of modules, when -H is specified. This parameter can be specified multiple times.</para>
</listitem>
</varlistentry>

<varlistentry> <varlistentry>
<term> <term>
<option>-d</option> <option>-d</option>