Drop our own /sbin/modprobe and use busybox built-in applet instead

Our modprobe is an ancient heritage from the past, probably dating to
a time where busybox's modprobe features were limited. There is no reason
at all to keep using our own version instead of the busybox one.
This commit also makes modules_scan 15% faster.
cleanup-cruft
Fabio Erculiani 12 years ago
parent e4ab952d63
commit 3a054014e8

@ -58,13 +58,7 @@ fi
QUIET='1' QUIET='1'
ROOT_LINKS='bin sbin lib lib32 lib64 boot usr opt emul' ROOT_LINKS='bin sbin lib lib32 lib64 boot usr opt emul'
ROOT_TREES='etc root home var' ROOT_TREES='etc root home var'
INSMOD='insmod' KSUFF='.ko'
if [ "${KMAJOR}" -ge 3 ] || [ "${KMAJOR}" -eq 2 -a "${KMINOR}" -gt '4' ]
then
KSUFF='.ko'
else
KSUFF='.o'
fi
REAL_ROOT='' REAL_ROOT=''
CONSOLE='/dev/console' CONSOLE='/dev/console'

@ -2,10 +2,6 @@
. /etc/initrd.defaults . /etc/initrd.defaults
backup() {
echo -ne "\033[0G\033[0K"
}
modules_load() { modules_load() {
for module in $* for module in $*
do do
@ -17,30 +13,37 @@ modules_load() {
modules_scan() { modules_scan() {
local MODS local MODS
[ -d "/etc/modules/${1}" ] || touch /etc/modules/${1} local loaded
MODS=$(cat /etc/modules/${1} 2>/dev/null)
[ -n "${MODS}" ] && echo -ne "${BOLD} ::${NORMAL} "
[ -n "${MODS}" ] && echo -ne "Loading from ${1}: "
[ -f "/etc/modules/${1}" ] && MODS=`cat /etc/modules/${1}`
for x in ${MODS} for x in ${MODS}
do do
MLOAD=`echo ${MLIST} | sed -e "s/.*${x}.*/${x}/"` MLOAD=$(echo ${MLIST} | sed -e "s/.*${x}.*/${x}/")
if [ "${MLOAD}" = "${x}" ] # Only module to no-load if [ "${MLOAD}" = "${x}" ] # Only module to no-load
then then
echo -e "${BOLD} ::${NORMAL} Skipping ${x}..." echo -e "${BOLD} ::${NORMAL} Skipping ${x}..."
elif [ "${MLOAD}" = "${MLIST}" ] # == No change == No specified no-load elif [ "${MLOAD}" = "${MLIST}" ]
then then
[ -n "${DEBUG}" ] && echo -ne "${BOLD} ::${NORMAL} Checking for ${x}..." if [ -n "${DEBUG}" ]; then
# find -name does not work since the return status is always zero echo -ne "${BOLD} ::${NORMAL} "
if find /lib/modules/${KV} | grep /"${x}${KSUFF}" >/dev/null 2>&1 echo -ne "Scanning for ${x}..."
then
echo -ne "${BOLD} ::${NORMAL} Scanning for ${x}..."
modprobe ${x} -n
backup
echo -ne "${NORMAL}"
fi fi
modprobe ${x} > /dev/null 2>&1
loaded=${?}
[ -n "${DEBUG}" -a "${loaded}" = "0" ] && \
echo "loaded"
[ -n "${DEBUG}" -a "${loaded}" != "0" ] && \
echo "not loaded"
[ -z "${DEBUG}" -a "${loaded}" = "0" ] && \
echo -en "${x} "
else else
echo -e "${BOLD} ::${NORMAL} Skipping ${x}..." echo -e "${BOLD} ::${NORMAL} Skipping ${x}..."
fi fi
done done
[ -n "${MODS}" ] && echo
} }
uppercase(){ uppercase(){

@ -1,147 +0,0 @@
#!/bin/ash
# Apparently, this is required for proper functionality with busybox 1.1.3
# Check out bug #197730 for more details.
. /etc/initrd.defaults
usage() {
echo 'Usage:'
echo ' modprobe moduleprefix'
echo
echo 'Example:'
echo ' modprobe eepro100'
echo
echo 'Note: Do not pass the suffix to modprobe!'
exit 1
}
# Pass module name to this function
modules_dep_list() {
if [ "$#" -lt '1' ]
then
echo 'modules_dep_list(): Improper usage!'
exit 1
fi
cat /lib/modules/${KV}/modules.dep | grep /"${1}${KSUFF}:" | cut -d':' -f2
}
# Pass module deps list
strip_mod_paths() {
local x
local ret
local myret
[ "$#" -lt '1' ] && return
for x in ${*}
do
ret=`basename ${x} | cut -d. -f1`
myret="${myret} ${ret}"
done
echo "${myret}"
}
LOADED_MODULES=''
is_module_already_loaded() {
local x
if [ "$#" != '1' ]
then
echo 'is_module_already_loaded(): Improper usage!'
fi
for x in ${LOADED_MODULES}
do
if [ "${x}" = "${1}" ]
then
# Yep, module is loaded
return 0
fi
done
return 1
}
real_mod_path() {
# Find -name is no good since the return status is always zero
find "/lib/modules/${KV}" | grep /"${1}${KSUFF}"
}
modprobe2() {
local x
local deps
local real_path
local modlist
local ret
local echoAppend
local echoFlags
if [ "$#" -lt '1' ]
then
usage
exit 1
fi
real_path=`real_mod_path ${1}`
if [ "${real_path}" = '' -o "${real_path}" = ' ' ]
then
[ "${2}" = '-n' ] && echo -n " -> $1"
echo ' module not found.'
exit 2
fi
modlist=`modules_dep_list ${1}`
if [ "${modlist}" != '' -a "${modlist}" != ' ' ]
then
deps=`strip_mod_paths ${modlist}`
else
deps=''
fi
# Make sure we don't do any endless loops!
LOADED_MODULES="${LOADED_MODULES} ${1}"
for x in ${deps}
do
if ! is_module_already_loaded ${x}
then
if [ "${x}" != '' -a "${x}" != ' ' ]
then
modprobe2 "${x}" -n
fi
else
filler=1
fi
done
# placing options into x
x="${real_path##*/}"
x="`cat "/etc/module_options/${x%.ko*}".* 2>/dev/null`"
${INSMOD} ${real_path} ${x} > /dev/null 2>&1
ret=$?
if [ ${ret} -eq 0 ]
then
echoAppend=' loaded.'
[ "${2}" = '-n' ] && echoFlags='-n' && echoAppend=', '
echo ${echoFlags} "${1}${echoAppend}"
fi
return $ret
}
if [ "$#" -lt '1' ]
then
usage
fi
[ -f '/modules.cache' ] || touch /modules.cache
for x in `cat /modules.cache`
do
LOADED_MODULES="${LOADED_MODULES} ${x}"
done
modprobe2 ${1}
modprobe_ret=$?
[ -f '/modules.cache' ] && rm -f /modules.cache > /dev/null 2>&1
for x in ${LOADED_MODULES}
do
echo $x >> /modules.cache
done
exit $modprobe_ret

@ -120,12 +120,26 @@ append_busybox() {
chmod +x "${TEMP}/initramfs-busybox-temp/usr/share/udhcpc/default.script" chmod +x "${TEMP}/initramfs-busybox-temp/usr/share/udhcpc/default.script"
# Set up a few default symlinks # Set up a few default symlinks
for i in ${BUSYBOX_APPLETS:-[ ash sh mount uname echo cut cat}; do local default_applets="[ ash sh mount uname echo cut cat"
rm -f ${TEMP}/initramfs-busybox-temp/bin/$i > /dev/null for i in ${BUSYBOX_APPLETS:-${default_applets}}; do
rm -f ${TEMP}/initramfs-busybox-temp/bin/$i
ln -s busybox ${TEMP}/initramfs-busybox-temp/bin/$i || ln -s busybox ${TEMP}/initramfs-busybox-temp/bin/$i ||
gen_die "Busybox error: could not link ${i}!" gen_die "Busybox error: could not link ${i}!"
done done
local mod_applets="sbin/modprobe sbin/insmod sbin/rmmod bin/lsmod"
local dir=
local name=
for i in ${mod_applets}; do
dir=$(dirname $i)
name=$(basename $i)
rm -f ${TEMP}/initramfs-busybox-temp/$dir/$name
mkdir -p ${TEMP}/initramfs-busybox-temp/$dir ||
gen_die "Busybox error: could not create dir: $dir"
ln -s ../bin/busybox ${TEMP}/initramfs-busybox-temp/$dir/$name ||
gen_die "Busybox error: could not link ${i}!"
done
cd "${TEMP}/initramfs-busybox-temp/" cd "${TEMP}/initramfs-busybox-temp/"
log_future_cpio_content log_future_cpio_content
find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \ find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
@ -705,12 +719,6 @@ append_auxilary() {
done done
echo '"' >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults" echo '"' >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
if [ -f "${GK_SHARE}/arch/${ARCH}/modprobe" ]
then
cp "${GK_SHARE}/arch/${ARCH}/modprobe" "${TEMP}/initramfs-aux-temp/sbin/modprobe"
else
cp "${GK_SHARE}/defaults/modprobe" "${TEMP}/initramfs-aux-temp/sbin/modprobe"
fi
if isTrue $CMD_DOKEYMAPAUTO if isTrue $CMD_DOKEYMAPAUTO
then then
echo 'MY_HWOPTS="${MY_HWOPTS} keymap"' >> ${TEMP}/initramfs-aux-temp/etc/initrd.defaults echo 'MY_HWOPTS="${MY_HWOPTS} keymap"' >> ${TEMP}/initramfs-aux-temp/etc/initrd.defaults
@ -728,7 +736,6 @@ append_auxilary() {
chmod +x "${TEMP}/initramfs-aux-temp/init" chmod +x "${TEMP}/initramfs-aux-temp/init"
chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.scripts" chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.scripts"
chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.defaults" chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
chmod +x "${TEMP}/initramfs-aux-temp/sbin/modprobe"
if isTrue ${NETBOOT} if isTrue ${NETBOOT}
then then

Loading…
Cancel
Save