From: "Alexander E. Patrakov" <patrakov@ums.usu.ru>
To: linux-hotplug@vger.kernel.org
Subject: hotplug and "rw" on kernel command line
Date: Sun, 30 May 2004 14:01:58 +0000 [thread overview]
Message-ID: <40B9E956.2000608@ums.usu.ru> (raw)
[-- Attachment #1: Type: text/plain, Size: 1891 bytes --]
This is a trouble report forwarded from a Linux From Scratch CVS HEAD user.
=====================================================
[Bug 842] New: udev bootscript can fail to run udevstart if hotplug
is installed.
In the LFS-specific udev bootscript, a check is made to see if
/dev/.udev.tdb exists, and if it does the remainder of the script is not
run. This was added to handle the situation where an initrd or initramfs
had already run udevstart and created the "extra" nodes, so the script
would not generate errors.
However, now that hotplug is in the unstable book, there is a problem:
if the root filesystem is mounted read-write when the kernel mounts it
(the first mount) AND a hotplug event occurs before this script runs
(small window), then udev will get run by the hotplug scripts and this
file will get created. The result is that when the script runs it does
not do what is needed.
=====================================================
I understand that this is mostly LFS-specific, and the report can be in
fact treated as invalid since we don't officially support the "rw" flag
on the kernel command line, but I have a question.
Is this normal that a hotplug event somehow managed to fire up in that
small time window? The udev initscript is the second one that actually
runs in LFS, and it just mounts ramfs on /dev, calls udevstart and
creates extra nodes in /dev like /dev/fd symlink. The first initscript
is called mountkernfs and it just mounts /proc, /sys and probably
/proc/bus/usb. Both bootscripts are attached. You see that none of them
does things that can lead to a hotplug event, so the source of that
bogus event is a mystery for me.
Another question is: how are other distros supposed to deal with such
unexpected hotplug events, when the root filesystem is mounted read-only
and /usr is not mounted at all?
--
Alexander E. Patrakov
[-- Attachment #2: functions --]
[-- Type: text/plain, Size: 6589 bytes --]
#!/bin/sh
# Begin $rc_base/init.d/functions - Run Level Control Functions
# Based on functions script from LFS-3.1 and earlier.
# Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
# With code based on Matthias Benkmann's simpleinit-msb @
# http://winterdrache.de/linux/newboot/index.html
# Number of seconds between term signal and kill signal when stopping processes
KILLDELAY=3
umask 022
export PATH="/bin:/usr/bin:/sbin:/usr/sbin"
# Width of the Screen
COLUMNS=$(stty size)
COLUMNS=${COLUMNS##* }
# When using remote connections, such as a serial port, stty size returns 0
if [ "$COLUMNS" = "0" ]; then COLUMNS=80; fi
# Measurements for positioning result messages
COL=$(($COLUMNS - 10))
WCOL=$(($COLUMNS - 30))
# Set Cursur Position Commands, used via echo -e
SET_COL="\\033[${COL}G"
SET_WCOL="\\033[${WCOL}G"
CURS_UP="\\033[A"
# Set color commands, used via echo -e
NORMAL="\\033[0;39m"
SUCCESS="\\033[1;32m"
WARNING="\\033[1;33m"
FAILURE="\\033[1;31m"
echo_ok()
{
echo -e "$CURS_UP$SET_COL"["$SUCCESS"" OK ""$NORMAL"]
}
echo_failure()
{
echo -e "$CURS_UP$SET_COL"["$FAILURE"FAILED"$NORMAL"]
}
echo_warning()
{
echo -e "$CURS_UP$SET_WCOL$@$SET_COL"["$WARNING" WARN "$NORMAL"]
}
# $i is inherited by the rc script
print_error_msg()
{
echo -e -n $FAILURE
echo
echo "You should not be reading this error message. It means"
echo "that an unforseen error took place in $i,"
echo "which exited with a return value of $error_value"
echo
echo "If you're able to track this error down to a bug in one"
echo "of the files provided by the LFS book, please be so kind"
echo "to inform us at lfs-dev@linuxfromscratch.org"
echo -e -n $NORMAL
echo
echo
echo "Press Enter to continue..."
read ENTER
}
# $i is inherited by the rc script
check_script_status()
{
if [ ! -f $i ]
then
echo "$i is not a valid symlink"
continue
fi
if [ ! -x $i ]
then
echo "$i is not executable, skipping"
continue
fi
}
evaluate_retval()
{
error_value=$?
if [ $error_value = 0 ]
then
print_status success
else
print_status failure
sleep 5
fi
return 0
#return $error_value
}
print_status()
{
if [ $# = 0 ]
then
echo "Usage: $0 {success|warning|failure}"
return 1
fi
case "$1" in
success)
echo_ok
;;
warning)
case "$2" in
running)
echo_warning "Already running"
;;
not_running)
echo_warning "Not running"
;;
esac
;;
failure)
echo_failure
;;
esac
}
# Returns all of the pid #'s for $1 process
getpids()
{
base=${1##*/}
local lpids=""
local pid
pidlist=""
lpids=$(pidof $base)
for pid in $lpids
do
if [ $pid -ne $$ ] && [ $pid -ne $PPID ]
then
pidlist="$pidlist $pid"
fi
done
}
# Starts a program if it is currently not running
loadproc()
{
if [ $# = 0 ]
then
echo "Usage: loadproc {program}"
exit 1
fi
if [ -n "$PIDFILE" -a -r "$PIDFILE" ]; then
pidlist=`cat $PIDFILE`
else
getpids $1
fi
if [ -z "$pidlist" ]
then
"$@"
evaluate_retval
else
print_status warning running
fi
}
# Stops a process if it is running
killproc()
{
if [ $# = 0 ]
then
echo "Usage: killproc {program} [signal]"
exit 1
fi
if [ -z "$2" ]; then
signal=TERM
fallback=KILL
else
signal=${2##-}
signal=${signal##SIG}
fallback=""
fi
if [ -n "$PIDFILE" -a -r "$PIDFILE" ]; then
pidlist=`cat $PIDFILE`
else
getpids $1
fi
if [ -n "$pidlist" ]; then
local i=0
for pid in $pidlist
do
kill -$signal $pid 2>/dev/null
while [ $i -lt $KILLDELAY ]; do
kill -0 $pid 2>/dev/null || break
sleep 1
i=$(($i+1))
done
if [ -n "$fallback" ]; then
kill -$fallback $pid 2>/dev/null
fi
done
getpids $1
base=${1##*/}
if [ -n "$pidlist" ]; then
failure=1
else
failure=0
if [ ! -z $PIDFILE ]; then
rm -f $PIDFILE
else
rm -f /var/run/$base.pid
fi
fi
(exit $failure)
evaluate_retval
else
print_status warning not_running
fi
}
reloadproc()
{
if [ $# = 0 ]
then
echo "Usage: reloadproc {program} [signal]"
exit 1
fi
if [ -z "$2" ]; then
signal=HUP
else
signal=${2##-}
signal=${signal##SIG}
fi
getpids $1
if [ -n "$pidlist" ]
then
failure=0
for pid in $pidlist
do
kill -$signal $pid || failure=1
done
(exit $failure)
evaluate_retval
else
print_status warning not_running
fi
}
statusproc()
{
if [ $# = 0 ]
then
echo "Usage: statusproc {program}"
exit 1
fi
base=${1##*/}
getpids $base
if [ -n "$pidlist" ]
then
echo "$base is running with Process ID(s) $pidlist"
else
if [ -s /var/run/$base.pid ]
then
echo "$1 is not running but /var/run/$base.pid exists"
return 1
else
echo "$1 is not running"
fi
fi
}
# End $rc_base/init.d/functions
[-- Attachment #3: mountkernfs --]
[-- Type: text/plain, Size: 746 bytes --]
#!/bin/sh
# Begin $rc_base/init.d/mountkernfs
# Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
. /etc/sysconfig/rc
. $rc_functions
case "$1" in
start)
if [ ! -e /proc/mounts ]; then
echo "Mounting proc file system..."
mount -n /proc
evaluate_retval
fi
# This should be mounted on a 2.6 kernel.
if grep -q '[[:space:]]sysfs' /proc/filesystems; then
if [ -d /sys -a ! -d /sys/block ]; then
echo "Mounting sysfs file system..."
mount -n /sys
evaluate_retval
fi
fi
if grep -q '[[:space:]]usbfs' /proc/filesystems; then
echo "Mounting USB filesystem"
mount -n /proc/bus/usb
evaluate_retval
fi
;;
*)
echo "Usage $0 {start}"
exit 1
;;
esac
# End $rc_base/init.d/mountkernfs
[-- Attachment #4: udev --]
[-- Type: text/plain, Size: 1767 bytes --]
#!/bin/sh
# Begin $rc_base/init.d/udev - Udev cold-plugging script
# Written by Zack Winkles - winkie@linuxfromscratch.org
. /etc/sysconfig/rc
. $rc_functions
# Assure that sysfs is mounted and that udev is present.
[ -d /sys/block -a -x /sbin/udev ] || exit 0
# Create some things that sysfs does not, and should not export for us. Feel
# free to add devices to this list.
make_extra_nodes() {
ln -s /proc/self/fd /dev/fd
ln -s /proc/self/fd/0 /dev/stdin
ln -s /proc/self/fd/1 /dev/stdout
ln -s /proc/self/fd/2 /dev/stderr
ln -s /proc/kcore /dev/core
mkdir /dev/pts
mkdir /dev/shm
}
case "$1" in
start)
# When the hotplug package isn't installed, make sure that udev
# still gets hotplug events.
if [ ! -x /sbin/hotplug ]; then
echo /sbin/udev > /proc/sys/kernel/hotplug
fi
# Don't attempt to populate the /dev directory when something
# else has already set it up.
[ -f /dev/.udev.tdb ] && exit 0
echo "Populating /dev with device nodes..."
# Mount a temporary file system over /dev, so that any devices
# made or removed during this boot don't affect the next one.
# The reason we don't write to mtab is because we don't ever
# want /dev to be unavailable (such as by `umount -a').
mount -n -t ramfs ramfs /dev
# Populate /dev with all the devices that are already available,
# and save it's status so we can report failures.
udevstart || failed=1
# Now, create some required files/directories/devices that sysfs
# doesn't export for us.
make_extra_nodes
# When reporting the status, base it on the success or failure
# of the `udevstart' command, since that's the most important.
(exit $failed)
evaluate_retval
;;
*)
echo "Usage $0 {start}"
exit 1
;;
esac
# End $rc_base/init.d/udev
next reply other threads:[~2004-05-30 14:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-30 14:01 Alexander E. Patrakov [this message]
2004-05-31 19:28 ` hotplug and "rw" on kernel command line Kevin P. Fleming
2004-06-01 8:59 ` Alex Galakhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=40B9E956.2000608@ums.usu.ru \
--to=patrakov@ums.usu.ru \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).