aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Erculiani <lxnay@sabayon.org>2013-04-23 16:21:53 +0100
committerFabio Erculiani <lxnay@sabayon.org>2013-04-25 08:19:54 +0100
commit3a054014e880e5b1ff28e3d87767c45a073da6b5 (patch)
tree4877dc457a0757cf84c96748821ac2fc749a1d7a
parentAdd rootflags to switches we understand (diff)
downloadgenkernel-3a054014e880e5b1ff28e3d87767c45a073da6b5.tar.gz
genkernel-3a054014e880e5b1ff28e3d87767c45a073da6b5.tar.bz2
genkernel-3a054014e880e5b1ff28e3d87767c45a073da6b5.zip
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.
-rwxr-xr-xdefaults/initrd.defaults8
-rwxr-xr-xdefaults/initrd.scripts35
-rwxr-xr-xdefaults/modprobe147
-rwxr-xr-xgen_initramfs.sh25
4 files changed, 36 insertions, 179 deletions
diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
index 90f73f4..8ff5510 100755
--- a/defaults/initrd.defaults
+++ b/defaults/initrd.defaults
@@ -58,13 +58,7 @@ fi
QUIET='1'
ROOT_LINKS='bin sbin lib lib32 lib64 boot usr opt emul'
ROOT_TREES='etc root home var'
-INSMOD='insmod'
-if [ "${KMAJOR}" -ge 3 ] || [ "${KMAJOR}" -eq 2 -a "${KMINOR}" -gt '4' ]
-then
- KSUFF='.ko'
-else
- KSUFF='.o'
-fi
+KSUFF='.ko'
REAL_ROOT=''
CONSOLE='/dev/console'
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 2e8e744..7ec5c94 100755
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -2,10 +2,6 @@
. /etc/initrd.defaults
-backup() {
- echo -ne "\033[0G\033[0K"
-}
-
modules_load() {
for module in $*
do
@@ -17,30 +13,37 @@ modules_load() {
modules_scan() {
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}
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
then
echo -e "${BOLD} ::${NORMAL} Skipping ${x}..."
- elif [ "${MLOAD}" = "${MLIST}" ] # == No change == No specified no-load
+ elif [ "${MLOAD}" = "${MLIST}" ]
then
- [ -n "${DEBUG}" ] && echo -ne "${BOLD} ::${NORMAL} Checking for ${x}..."
- # find -name does not work since the return status is always zero
- if find /lib/modules/${KV} | grep /"${x}${KSUFF}" >/dev/null 2>&1
- then
- echo -ne "${BOLD} ::${NORMAL} Scanning for ${x}..."
- modprobe ${x} -n
- backup
- echo -ne "${NORMAL}"
+ if [ -n "${DEBUG}" ]; then
+ echo -ne "${BOLD} ::${NORMAL} "
+ echo -ne "Scanning for ${x}..."
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
echo -e "${BOLD} ::${NORMAL} Skipping ${x}..."
fi
done
+ [ -n "${MODS}" ] && echo
}
uppercase(){
diff --git a/defaults/modprobe b/defaults/modprobe
deleted file mode 100755
index 6bbe7e4..0000000
--- a/defaults/modprobe
+++ /dev/null
@@ -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
diff --git a/gen_initramfs.sh b/gen_initramfs.sh
index af6dff6..784c0cc 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -120,12 +120,26 @@ append_busybox() {
chmod +x "${TEMP}/initramfs-busybox-temp/usr/share/udhcpc/default.script"
# Set up a few default symlinks
- for i in ${BUSYBOX_APPLETS:-[ ash sh mount uname echo cut cat}; do
- rm -f ${TEMP}/initramfs-busybox-temp/bin/$i > /dev/null
+ local default_applets="[ ash sh mount uname echo cut cat"
+ 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 ||
gen_die "Busybox error: could not link ${i}!"
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/"
log_future_cpio_content
find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
@@ -705,12 +719,6 @@ append_auxilary() {
done
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
then
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/etc/initrd.scripts"
chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
- chmod +x "${TEMP}/initramfs-aux-temp/sbin/modprobe"
if isTrue ${NETBOOT}
then