|
|
AddConfigHandler GentooModulesOptions | AddConfigHandler GentooModulesOptions |
AddConfigHelp "GentooModulesAutoload <boolean>" "Try to load default modules after resuming (from /etc/modules.autoload)" | AddConfigHelp "GentooModulesAutoload <boolean>" "Try to load default modules after resuming (from /etc/modules.autoload)" |
| |
GentooModulesAutoload() { |
# Necessary helpers to parse/work with /etc/modules.autoload.d/kernel-2.? |
[ x"$MODULES_GENTOO_AUTOLOAD" = "x1" ] || return 0 |
KV_major() { |
|
test -z "$1" && return 1 |
|
|
|
local KV="$@" |
|
echo "${KV%%.*}" |
|
} |
|
|
|
KV_minor() { |
|
test -z "$1" && return 1 |
|
|
|
local KV="$@" |
|
KV="${KV#*.}" |
|
echo "${KV%%.*}" |
|
} |
|
|
|
KV_micro() { |
|
test -z "$1" && return 1 |
|
|
|
local KV="$@" |
|
KV="${KV#*.*.}" |
|
r=`echo "$KV" | sed -n 's/^\([0-9]\+\)[^0-9].*$/\1/p'` |
|
#vecho 1 "in KV_micro KV=$KV r=$r @=" "$@" " ................" |
|
echo $r |
|
} |
|
|
|
get_KV() { |
|
test -z "${_RC_GET_KV_CACHE}" && _RC_GET_KV_CACHE=`uname -r` |
|
|
|
echo "$(KV_to_int "${_RC_GET_KV_CACHE}")" |
| |
if [ ! -f /sbin/functions.sh ] ; then |
return $? |
vecho 1 "/sbin/functions.sh not found - not running Gentoo? gentoo-modules disabled." |
} |
return 1 |
|
|
KV_to_int() { |
|
test -z "$1" && return 1 |
|
|
|
local KV_int=$(( `KV_major "$1"` * 65536 + `KV_minor "$1"` * 256 )) |
|
KV_int=$(( `KV_micro "$1"` + $KV_int )) |
|
|
|
# We make version 2.2.0 the minimum version we will handle as |
|
# a sanity check ... if its less, we fail ... |
|
|
|
if [ $KV_int -ge 131584 ]; then |
|
echo "${KV_int}" |
|
return 0 |
fi | fi |
| |
. /sbin/functions.sh |
return 1 |
|
} |
|
|
|
GentooModulesAutoload() { |
|
test "$MODULES_GENTOO_AUTOLOAD" = "1" || return 0 |
|
|
# taken from gentoo's /etc/init.d/modules | # taken from gentoo's /etc/init.d/modules |
if [ -f /etc/modules.autoload ] && [ ! -L /etc/modules.autoload ] ; then | if [ -f /etc/modules.autoload ] && [ ! -L /etc/modules.autoload ] ; then |
modules_autoload_file= /etc/modules.autoload | modules_autoload_file= /etc/modules.autoload |
|
|
local KV_MINOR="`KV_minor "${KV}"`" | local KV_MINOR="`KV_minor "${KV}"`" |
| |
# New support for /etc/modules.autoload/kernel-$KV | # New support for /etc/modules.autoload/kernel-$KV |
if [ "$(get_KV)" -ge "$(KV_to_int '2.5.48')" ] && \ |
if [ "$( get_KV )" -ge "$( KV_to_int '2.5.48' )" ] && \ |
[ -f /etc/modules.autoload.d/kernel-"${KV_MAJOR}.${KV_MINOR}" ] |
[ -f /etc/modules.autoload.d/kernel-"${KV_MAJOR}.${KV_MINOR}" ] ; then |
then |
|
modules_autoload_file="/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}" | modules_autoload_file="/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}" |
elif [ ! -f /etc/modules.autoload.d/kernel-"${KV_MAJOR}.${KV_MINOR}" ] |
elif [ ! -f /etc/modules.autoload.d/kernel-"${KV_MAJOR}.${KV_MINOR}" ] ; then |
then |
|
ewarn "Missing /etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}" | ewarn "Missing /etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}" |
modules_autoload_file="/etc/modules.autoload.d/kernel-2.4" | modules_autoload_file="/etc/modules.autoload.d/kernel-2.4" |
else | else |
|
|
return 0 | return 0 |
} | } |
| |
|
|
GentooModulesOptions() { | GentooModulesOptions() { |
case $1 in | case $1 in |
gentoomodulesautoload) | gentoomodulesautoload) |