slowusb: ease the code in order to reduce entropy, one place for one thing.

There were several places where a mixture of sdelay and "sleep 10"
were called without worrying too much, resulting in slower boot
time, mainly. This commit should fix the mess and make some order
in the slowusb saga.
cleanup-cruft
Fabio Erculiani 14 years ago
parent fcdece1b0e
commit 51e0b14044

@ -410,17 +410,23 @@ setup_hotplug() {
fi fi
} }
check_slowusb() { setup_slowusb() {
# slowusb already set?
if [ "${DO_slowusb}" = "1" ]
then
return
fi
local usb_storage_dir="/sys/bus/usb/drivers/usb-storage" local usb_storage_dir="/sys/bus/usb/drivers/usb-storage"
if [ ! -d "${usb_storage_dir}" ] if [ ! -d "${usb_storage_dir}" ]
then then
# no automated slowusb required. no usb-storage devices attached.
return return
fi fi
[ "${DO_slowusb}" ] || \
for x in "${usb_storage_dir}"/* for x in "${usb_storage_dir}"/*
do do
[ -d "${x}" ] && [ "${x}" != "${usb_storage_dir}/module" ] \ [ -d "${x}" ] && [ "${x}" != "${usb_storage_dir}/module" ] \
&& { FORCE_slowusb="1" ; break ; } && { DO_slowusb="1" ; break ; }
done done
} }
@ -428,13 +434,8 @@ start_dev_mgr() {
if [ "${KV_2_6_OR_GREATER}" ] if [ "${KV_2_6_OR_GREATER}" ]
then then
cd /sys cd /sys
[ "${DO_slowusb}" ] && sdelay
check_slowusb
[ "${FORCE_slowusb}" ] && sdelay
good_msg 'Activating mdev' good_msg 'Activating mdev'
runmdev runmdev
[ "${DO_slowusb}" ] || \
[ "${FORCE_slowusb}" ] && sdelay
cd / cd /
fi fi
} }
@ -881,12 +882,12 @@ startLUKS() {
sdelay() { sdelay() {
# Sleep a specific number of seconds if SDELAY is set otherwise only sleep # Sleep a specific number of seconds if SDELAY is set otherwise only sleep
# 1 second # 3 seconds, which is a much better default than 1 second (previous default)
if [ -n "${SDELAY}" ] if [ "${SDELAY}" ]
then then
sleep ${SDELAY} sleep ${SDELAY}
else else
sleep 1 sleep 3
fi fi
} }

@ -289,6 +289,11 @@ fi
# Delay if needed for USB hardware # Delay if needed for USB hardware
sdelay sdelay
# Setup slow USB bits
setup_slowusb
# if doslowusb is passed, pause other 10 seconds
[ "${DO_slowusb}" ] && sleep 10
# Start device manager # Start device manager
start_dev_mgr start_dev_mgr
@ -675,10 +680,6 @@ then
fi fi
done done
if [ "${DO_slowusb}" ] || [ "${FORCE_slowusb}" ]
then
sleep 10
fi
mkdir initramfs proc tmp sys 2>/dev/null mkdir initramfs proc tmp sys 2>/dev/null
chmod 1777 tmp chmod 1777 tmp
@ -694,11 +695,6 @@ then
# Let Init scripts know that we booted from CD # Let Init scripts know that we booted from CD
export CDBOOT export CDBOOT
CDBOOT=1 CDBOOT=1
check_slowusb
if [ "${DO_slowusb}" ] || [ "${FORCE_slowusb}" ]
then
sleep 10
fi
else else
if [ "${USE_UNIONFS_NORMAL}" = '1' ] if [ "${USE_UNIONFS_NORMAL}" = '1' ]
then then

Loading…
Cancel
Save