2010/6/9 Amadeusz Żołnowski <aidecoe@xxxxxxxxxxxx>: > modprobe included in version prior to 3.7 of module-init-tools doesn't > have -d | --dirname option which allows to give a prefix other than > '/' for kernel modules path. Dracut assumes existence of that > option and uses it even with default '/'. The patch passes -d option > only if it's different from default and also checks module-init-tools > version if user changes the prefix by --kmoddir Dracut option. > --- > dracut | 8 +++++++- > dracut-functions | 44 ++++++++++++++++++++++++++++++++++++++++++-- > 2 files changed, 49 insertions(+), 3 deletions(-) > > diff --git a/dracut b/dracut > index 35be7eb..139d0e0 100755 > --- a/dracut > +++ b/dracut > @@ -183,7 +183,13 @@ esac > abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile" > > srcmods="/lib/modules/$kernel/" > -[[ $drivers_dir ]] && srcmods="$drivers_dir" > +[[ $drivers_dir ]] && { > + if verlt $(modprobe --version | cut -d' ' -f3) 3.7; then > + derror 'To use --kmoddir option module-init-tools >= 3.7 is required.' > + exit 1 > + fi > + srcmods="$drivers_dir" > +} > export srcmods > > if [[ -f $outfile && ! $force ]]; then > diff --git a/dracut-functions b/dracut-functions > index a76cc22..fbac282 100755 > --- a/dracut-functions > +++ b/dracut-functions > @@ -24,6 +24,39 @@ IF_dynamic="" > # Generic substring function. If $2 is in $1, return 0. > strstr() { [[ $1 =~ $2 ]]; } > > +# Version comparision function. Returns result similar to C strcmp, > +# but instead of -1 is 2. Function assumes version scheme like does > +# Linux kernel. > +vercmp() { > + local n1 n2 i=1 > + > + while true > + do > + n1=$(echo $1 | cut -d'.' -f$i) > + n2=$(echo $2 | cut -d'.' -f$i) Ugh, no. We are using bash, no need for that sort of hackery. Just split the passed version strings into arrays using parameter expansion, like so: n1=(${1//./ }) n2=(${2//./ }) > + [[ ! $n1 && ! $n2 ]] && return 0 > + [[ $n1 -lt $n2 ]] && return 2 > + [[ $n1 -gt $n2 ]] && return 1 > + > + ((i++)) > + done and then do the whole thing in an arithmetic for loop: for ((i=0; ;i++)); do [[ ${n1[i]} && ! ${n2[i]} ]] && return 1 [[ ! ${n1[i]} && ${n2[i]} ]] && return 2 [[ ${n1[i]} && ${n2[i]} || return 0 ((${n1[i]} > ${n2[i]})) && return 1 ((${n1[i]} < ${n2[i]})) && return 2 done > +} > + > +# Variation of version comparision function. If $1 >= $2, return 0. > +verge() { > + vercmp $1 $2 > + > + [[ $? = 0 || $? = 1 ]] > +} > + > +# Variation of version comparision function. If $1 < $2, return 0. > +verlt() { > + vercmp $1 $2 > + > + [[ $? = 2 ]] > +} > + > # Log initrd creation. > if ! [[ $dracutlogfile ]]; then > [[ $dracutbasedir = /usr/share/dracut ]] && \ > @@ -487,7 +520,7 @@ filter_kernel_modules () ( > # install kernel modules along with all their dependencies. > instmods() { > [[ $no_kernel = yes ]] && return > - local mod mpargs modpath modname cmd > + local mod mpargs modpath modname cmd moddirname > while (($# > 0)); do > mod=${1%.ko*} > case $mod in > @@ -519,10 +552,17 @@ instmods() { > ! echo $add_drivers | grep -qe "\<${mod}\>" && { > shift; continue; > } > + > + # We use '-d' option in modprobe only if modules prefix path > + # differs from default '/'. This allows us to use Dracut with > + # old version of modprobe which doesn't have '-d' option. > + moddirname=${srcmods%%/lib/modules/*} > + [[ -n ${moddirname} ]] && moddirname="-d ${moddirname}/" > + > # ok, load the module, all its dependencies, and any firmware > # it may require > for_each_kmod_dep install_kmod_with_fw $mod \ > - --set-version $kernel -d ${srcmods%%/lib/modules/*}/ > + --set-version $kernel ${moddirname} > ;; > esac > shift > -- > 1.7.1 > -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html