* udev on Fedore 5
@ 2006-08-03 5:14 Piet Delaney
2006-08-03 8:39 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Piet Delaney @ 2006-08-03 5:14 UTC (permalink / raw)
To: linux-hotplug
I wasn't able to login to your Fedora 5 (10.10.111.220).
I tried my AMD hammer at home (hammer.piet.net) and looked
at the Fedora 5 udev scripts. I can't see what the gento
/sbin/start_udev might be doing to boost Performance so much
and didn't see the udev daemon stuff we saw on your system.
Perhaps it's probing the modules to pre-awaken them. I'm not
using modules, so I doubt it would have an effect.
--------------------------------------------------------------
/sbin/start_udev
--------------------------------------------------------------
#!/bin/sh
#
# start_udev
#
# script to initialize /dev by using udev.
#
# Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com>
#
# Released under the GPL v2 only.
#
# This needs to be run at the earliest possible point in the boot
# process.
#
# Based on the udev init.d script
#
# Thanks go out to the Gentoo developers for proving
# that this is possible to do.
#
# Yes, it's very verbose, feel free to turn off all of the echo calls,
# they were there to make me feel better that everything was working
# properly during development...
#
# don't use udev if sysfs is not mounted.
sysfs_dir=/sys
[ -d $sysfs_dir/class ] || exit 1
[ -r /proc/mounts ] || exit 1
[ -x /sbin/udev ] || exit 1
[ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf
. /etc/init.d/functions
prog=udev
bin=/sbin/udev
udevd=/sbin/udevd
MAKEDEV="/sbin/MAKEDEV"
xargs_simple () {
if [ "$1" = "-n" ]; then
shift
MAXNR="$1"
shift
else
MAXNR\x100
fi
NR=$MAXNR
ARGS=""
[ -z "$1" ] && set echo
while read line; do
if [ $NR -gt 0 ]; then
ARGS="$ARGS $line"
NR=$[$NR - 1]
else
"$@" $ARGS
NR=$MAXNR
ARGS="$line"
fi
done
if [ -n "$ARGS" ]; then
"$@" $ARGS
fi
}
make_extra_nodes () {
ln -snf /proc/self/fd $udev_root/fd
ln -snf /proc/self/fd/0 $udev_root/stdin
ln -snf /proc/self/fd/1 $udev_root/stdout
ln -snf /proc/self/fd/2 $udev_root/stderr
ln -snf /proc/kcore $udev_root/core
[ -d $udev_root/pts ] || mkdir -m 0755 $udev_root/pts
[ -d $udev_root/shm ] || mkdir -m 0755 $udev_root/shm
[ -a /dev/MAKEDEV ] || ln -s $MAKEDEV /dev/MAKEDEV;
if [ -x $MAKEDEV ]; then
for i in /etc/udev/makedev.d/*.nodes; do
if [ -f "$i" ]; then
cat "$i" | sed -e 's,#.*,,g' | \
xargs_simple -n 100 $MAKEDEV -x
fi
done
fi
pushd /etc/udev/devices &> "$udev_root/null"
set *
if [ "$1" != "*" ]; then
cp -ar "$@" $udev_root/
pushd "$udev_root" &> "$udev_root/null"
[ -x /sbin/restorecon ] && /sbin/restorecon "$@"
popd &> "$udev_root/null"
fi
popd &> "$udev_root/null"
}
# we cannot use /usr/bin/find here
find_d () {
where=$1
what=$2
found=""
for f in $where/*; do
if [ -d "$f" -a ! -L "$f" ]; then
if [ "$f" != "${f%%$what}" ];then
# make sure we are at the path end
# we have no dirname and basename
rest="${f#*$what}"
[ "${rest##*/}" = "$rest" ] &&
found="$found $f"
fi
found="$found $(find_d $f $what)"
fi
done
echo "$found"
}
# we cannot use /usr/bin/find here
find_f () {
where=$1
what=$2
found=""
for f in $where/*; do
if [ -d "$f" -a ! -L "$f" ]; then
found="$found $(find_f $f $what)"
elif [ -e "$f" ]; then
[ "$where/" = "${f%$what}" ] && found="$found
$f"
fi
done
[ -n "$found" ] && echo "$found"
}
kill_udevd() {
if [ -x /sbin/pidof ]; then
pid=`/sbin/pidof -x udevd`
[ -n "$pid" ] && kill $pid
fi
}
# call hotplug with the scsi devices
scsi_replay () {
HOTPLUG=$(cat /proc/sys/kernel/hotplug)
[ -z "$HOTPLUG" ] && return 1
scsi_hosts=$(find_d /sys/devices host\*)
SEQNUM=1
for host in $scsi_hosts;do
[ -d $host ] || continue
devs=$(find_f $host type)
for dev in $devs;do
[ -f $dev ] || continue
export SEQNUM
DEVPATH=${dev%/type}
DEVPATH=${DEVPATH#/sys}
export DEVPATH
export ACTIONd
$HOTPLUG scsi_device
SEQNUM=$[$SEQNUM + 1]
$HOTPLUG scsi
SEQNUM=$[$SEQNUM + 1]
done
done
return 0
}
164,1 60%
ide_scan() {
if [ ! -d /proc/ide ]; then
return 1
fi
for i in /proc/ide/*/media; do
read media < "$i"
case "$media" in
disk)
module=ide-disk
;;
cdrom)
module=ide-cd
;;
tape)
module=ide-tape
;;
floppy)
module=ide-floppy
;;
*)
module=ide-generic
;;
esac
/sbin/modprobe $module
done
return 0
}
export ACTIONd
prog=udev
ret=0
STRING=$"Starting $prog: "
# propagate $udev_root from /sys
echo -n "$STRING "
# mount the tmpfs on ${udev_root%/}, if not already done
LANG=C awk "\$2 = \"${udev_root%/}\" && \$3 = \"tmpfs\" { exit
1 }" /proc/mounts && {
if LANG=C fgrep -q "none ${udev_root%/}/pts " /proc/mounts; then
PTSDIR=$(mktemp -d)
mount --move $udev_root/pts "$PTSDIR"
fi
if LANG=C fgrep -q "none ${udev_root%/}/shm " /proc/mounts; then
SHMDIR=$(mktemp -d)
mount --move $udev_root/shm "$SHMDIR"
fi
mount -n -o mode\a55 -t tmpfs none "$udev_root"
mkdir -m 0755 $udev_root/pts
mkdir -m 0755 $udev_root/shm
if [ -n "$PTSDIR" ]; then
mount --move "$PTSDIR" $udev_root/pts
rmdir "$PTSDIR"
fi
if [ -n "$SHMDIR" ]; then
mount --move "$SHMDIR" $udev_root/shm
rmdir "$SHMDIR"
fi
ret=$[$ret + $?]
}
rm -fr "$udev_db"
make_extra_nodes
kill_udevd > "$udev_root/null" 2>&1
scsi_replay > "$udev_root/null" 2>&1
ret=$[$ret + $?]
ide_scan > "$udev_root/null" 2>&1
/sbin/udevstart
ret=$[$ret + $?]
[ $ret -eq 0 ] && success $"$STRING" || failure $"$STRING"
echo
exit 0
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: udev on Fedore 5
2006-08-03 5:14 udev on Fedore 5 Piet Delaney
@ 2006-08-03 8:39 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2006-08-03 8:39 UTC (permalink / raw)
To: linux-hotplug
On Wed, Aug 02, 2006 at 10:14:46PM -0700, Piet Delaney wrote:
> I wasn't able to login to your Fedora 5 (10.10.111.220).
> I tried my AMD hammer at home (hammer.piet.net) and looked
> at the Fedora 5 udev scripts. I can't see what the gento
> /sbin/start_udev might be doing to boost Performance so much
> and didn't see the udev daemon stuff we saw on your system.
> Perhaps it's probing the modules to pre-awaken them. I'm not
> using modules, so I doubt it would have an effect.
The gentoo script for startup is attached below. It picks it's startup
logic depending on the kernel version running.
Hope this helps,
greg k-h
------------------
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
udev_version() {
local version=0
if [[ -x /sbin/udev ]] ; then
version=$(/sbin/udev -V)
# We need it without a leading '0', else bash do the wrong thing
version=${version##0}
# Older udev's will print nothing
[[ -z ${version} ]] && version=0
fi
echo "${version}"
}
# This works for 2.6.15 kernels or greater
trigger_events() {
list=""
# if you want real coldplug (with all modules being loaded for all
# devices in the system), uncomment out the next line.
#list="$list $(echo /sys/bus/*/devices/*/uevent)"
list="$list $(echo /sys/class/*/*/uevent)"
list="$list $(echo /sys/block/*/uevent /sys/block/*/*/uevent)"
for i in $list; do
case "$i" in
*/device/uevent)
# skip followed device symlinks
continue
;;
*/class/mem/*|*/class/tty/*)
first="$first $i"
;;
*/block/md*)
last="$last $i"
;;
*/*)
default="$default $i"
;;
esac
done
# trigger the sorted events
for i in $first $default $last; do
echo "add" > "$i"
done
}
populate_udev() {
# populate /dev with devices already found by the kernel
if [ "$(get_KV)" -gt "$(KV_to_int '2.6.14')" ] ; then
ebegin "Populating /dev with existing devices through uevents"
udevtrigger
eend 0
else
ebegin "Populating /dev with existing devices with udevstart"
/sbin/udevstart
eend 0
fi
# loop until everything is finished
# there's gotta be a better way...
ebegin "Letting udev process events"
loop=0
while test -d /dev/.udev/queue; do
sleep 0.1;
test "$loop" -gt 300 && break
loop=$(($loop + 1))
done
#einfo "loop = $loop"
eend 0
return 0
}
seed_dev() {
# Seed /dev with some things that we know we need
ebegin "Seeding /dev with needed nodes"
# copy over any persistant things
if [[ -d /lib/udev/devices ]] ; then
cp --preserve=all --recursive --update /lib/udev/devices/* /dev
fi
# Not provided by sysfs but needed
ln -snf /proc/self/fd /dev/fd
ln -snf fd/0 /dev/stdin
ln -snf fd/1 /dev/stdout
ln -snf fd/2 /dev/stderr
[[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core
# Create problematic directories
mkdir -p /dev/{pts,shm}
eend 0
}
main() {
# Setup temporary storage for /dev
ebegin "Mounting /dev for udev"
if [[ ${RC_USE_FSTAB} = "yes" ]] ; then
mntcmd=$(get_mount_fstab /dev)
else
unset mntcmd
fi
if [[ -n ${mntcmd} ]] ; then
try mount -n ${mntcmd}
else
if egrep -qs tmpfs /proc/filesystems ; then
mntcmd="tmpfs"
else
mntcmd="ramfs"
fi
# many video drivers require exec access in /dev #92921
try mount -n -t ${mntcmd} udev /dev -o exec,nosuid,mode\a55
fi
eend $?
# Create a file so that our rc system knows it's still in sysinit.
# Existance means init scripts will not directly run.
# rc will remove the file when done with sysinit.
touch /dev/.rcsysinit
# Selinux lovin; /selinux should be mounted by selinux-patched init
if [[ -x /sbin/restorecon && -c /selinux/null ]] ; then
restorecon /dev &> /selinux/null
fi
# Actually get udev rolling
if [[ ${RC_DEVICE_TARBALL} = "yes" && \
-s /lib/udev-state/devices.tar.bz2 ]] ; then
ebegin "Populating /dev with saved device nodes"
try tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev
eend $?
fi
seed_dev
# Setup hotplugging (if possible)
ebegin "Setting up proper hotplug agent"
if [[ -e /proc/sys/kernel/hotplug ]] ; then
if [ "$(get_KV)" -gt "$(KV_to_int '2.6.14')" ] ; then
einfo " Using netlink for hotplug events..."
echo "" > /proc/sys/kernel/hotplug
elif [[ $(udev_version) -ge "48" ]] ; then
einfo " Setting /sbin/udevsend as hotplug agent ..."
echo "/sbin/udevsend" > /proc/sys/kernel/hotplug
elif [[ -x /sbin/hotplug ]] ; then
einfo " Using /sbin/hotplug as hotplug agent ..."
else
einfo " Setting /sbin/udev as hotplug agent ..."
echo "/sbin/udev" > /proc/sys/kernel/hotplug
fi
fi
eend 0
ebegin "Starting udevd"
/sbin/udevd --daemon
eend $?
populate_udev
# Create nodes that udev can't
ebegin "Finalizing udev configuration"
[[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null
[[ -x /sbin/lvm ]] && \
/sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null
# Running evms_activate on a LiveCD causes lots of headaches
[[ -z ${CDBOOT} ]] && [[ -x /sbin/evms_activate ]] && \
/sbin/evms_activate -q &>/dev/null
eend 0
}
main
# vim:ts=4
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-08-03 8:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-03 5:14 udev on Fedore 5 Piet Delaney
2006-08-03 8:39 ` Greg KH
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).