r7429 - in branches/udev_update/bootscripts: . lfs/init.d

dj at linuxfromscratch.org dj at linuxfromscratch.org
Mon Mar 13 19:55:40 PST 2006


Author: dj
Date: 2006-03-13 20:55:39 -0700 (Mon, 13 Mar 2006)
New Revision: 7429

Modified:
   branches/udev_update/bootscripts/Makefile
   branches/udev_update/bootscripts/lfs/init.d/udev
Log:
udpated udev script and removed hotplug from install target

Modified: branches/udev_update/bootscripts/Makefile
===================================================================
--- branches/udev_update/bootscripts/Makefile	2006-03-14 03:46:03 UTC (rev 7428)
+++ branches/udev_update/bootscripts/Makefile	2006-03-14 03:55:39 UTC (rev 7429)
@@ -27,7 +27,6 @@
 	install -m ${CONFMODE} lfs/init.d/functions ${EXTDIR}/rc.d/init.d/
 	install -m ${MODE} lfs/init.d/halt          ${EXTDIR}/rc.d/init.d/
 	install -m ${MODE} lfs/init.d/console       ${EXTDIR}/rc.d/init.d/
-	install -m ${MODE} lfs/init.d/hotplug       ${EXTDIR}/rc.d/init.d/
 	install -m ${MODE} lfs/init.d/localnet      ${EXTDIR}/rc.d/init.d/
 	install -m ${MODE} lfs/init.d/modules       ${EXTDIR}/rc.d/init.d/
 	install -m ${MODE} lfs/init.d/mountfs       ${EXTDIR}/rc.d/init.d/
@@ -44,7 +43,6 @@
 	install -m ${MODE} lfs/init.d/udev          ${EXTDIR}/rc.d/init.d/
 	ln -sf ../init.d/network     ${EXTDIR}/rc.d/rc0.d/K80network
 	ln -sf ../init.d/sysklogd   ${EXTDIR}/rc.d/rc0.d/K90sysklogd
-	ln -sf ../init.d/hotplug     ${EXTDIR}/rc.d/rc0.d/S50hotplug
 	ln -sf ../init.d/sendsignals ${EXTDIR}/rc.d/rc0.d/S60sendsignals
 	ln -sf ../init.d/mountfs     ${EXTDIR}/rc.d/rc0.d/S70mountfs
 	ln -sf ../init.d/swap        ${EXTDIR}/rc.d/rc0.d/S80swap
@@ -62,7 +60,6 @@
 	ln -sf ../init.d/network     ${EXTDIR}/rc.d/rc5.d/S20network
 	ln -sf ../init.d/network     ${EXTDIR}/rc.d/rc6.d/K80network
 	ln -sf ../init.d/sysklogd   ${EXTDIR}/rc.d/rc6.d/K90sysklogd
-	ln -sf ../init.d/hotplug     ${EXTDIR}/rc.d/rc6.d/S50hotplug
 	ln -sf ../init.d/sendsignals ${EXTDIR}/rc.d/rc6.d/S60sendsignals
 	ln -sf ../init.d/mountfs     ${EXTDIR}/rc.d/rc6.d/S70mountfs
 	ln -sf ../init.d/swap        ${EXTDIR}/rc.d/rc6.d/S80swap
@@ -75,7 +72,6 @@
 	ln -sf ../init.d/checkfs     ${EXTDIR}/rc.d/rcsysinit.d/S30checkfs
 	ln -sf ../init.d/mountfs     ${EXTDIR}/rc.d/rcsysinit.d/S40mountfs
 	ln -sf ../init.d/cleanfs     ${EXTDIR}/rc.d/rcsysinit.d/S50cleanfs
-	ln -sf ../init.d/hotplug     ${EXTDIR}/rc.d/rcsysinit.d/S55hotplug
 	ln -sf ../init.d/setclock    ${EXTDIR}/rc.d/rcsysinit.d/S60setclock
 	ln -sf ../init.d/console     ${EXTDIR}/rc.d/rcsysinit.d/S70console
 	ln -sf ../init.d/localnet    ${EXTDIR}/rc.d/rcsysinit.d/S80localnet

Modified: branches/udev_update/bootscripts/lfs/init.d/udev
===================================================================
--- branches/udev_update/bootscripts/lfs/init.d/udev	2006-03-14 03:46:03 UTC (rev 7428)
+++ branches/udev_update/bootscripts/lfs/init.d/udev	2006-03-14 03:55:39 UTC (rev 7429)
@@ -15,16 +15,36 @@
 . /etc/sysconfig/rc
 . ${rc_functions}
 
-# 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
+walk_sysfs() {
+	# generate events with the sysfs trigger
+	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
 }
 
 case "${1}" in
@@ -61,20 +81,23 @@
 			/etc/rc.d/init.d/halt stop
 		fi
 
-		# Assign udevsend to get hotplug events. udevsend can manage the whole
-		# hotplug handling by taking over the kernel spawned event process
-		echo /sbin/udevsend > /proc/sys/kernel/hotplug
+		# Udev handles hotplug events itself, so we don't need to have
+		# the kernel call out to any binary in response to hotplug
+		# events
+		> /proc/sys/kernel/hotplug
 
-		# Populate /dev with all the devices that are already available,
-		# and save it's status so we can report failures.
-		udevstart || failed=1
+		# Copy static device nodes to /dev
+		cp -ar /lib/udev/devices/* /dev
 
-		# Now, create some required files/directories/devices that sysfs
-		# doesn't export for us.
-		make_extra_nodes
+		# Start the udev daemon to continually watch for, and act on,
+		# hotplug events
+		/sbin/udevd --daemon
+		evaluate_retval
 
-		# When reporting the status, base it on the success or failure
-		# of the `udevstart' command, since that's the most important.
+		# Now traverse /sys in order to "coldplug" devices that have
+		# already been discovered
+		walk_sysfs
+
 		(exit ${failed})
 		evaluate_retval
 		;;




More information about the lfs-book mailing list