Ticket #1769: udev

File udev, 2.7 KB (added by alexander@…, 18 years ago)

Modified udev script

Line 
1#!/bin/sh
2########################################################################
3# Begin $rc_base/init.d/udev
4#
5# Description : Udev cold-plugging script
6#
7# Authors : Zack Winkles, Alexander E. Patrakov
8#
9# Version : 00.02
10#
11# Notes :
12#
13########################################################################
14
15. /etc/sysconfig/rc
16. ${rc_functions}
17
18case "${1}" in
19 start)
20 boot_mesg "Populating /dev with device nodes..."
21 if ! grep -q '[[:space:]]sysfs' /proc/mounts; then
22 echo_failure
23 boot_mesg -n "FAILURE:\n\nUnable to create" ${FAILURE}
24 boot_mesg -n " devices without a SysFS filesystem"
25 boot_mesg -n "\n\nAfter you press Enter, this system"
26 boot_mesg -n " will be halted and powered off."
27 boot_mesg -n "\n\nPress Enter to continue..." ${INFO}
28 boot_mesg "" ${NORMAL}
29 read ENTER
30 /etc/rc.d/init.d/halt stop
31 fi
32
33 # Mount a temporary file system over /dev, so that any devices
34 # made or removed during this boot don't affect the next one.
35 # The reason we don't write to mtab is because we don't ever
36 # want /dev to be unavailable (such as by `umount -a').
37 mount -n -t tmpfs tmpfs /dev -o mode=755
38 if [ ${?} != 0 ]; then
39 echo_failure
40 boot_mesg -n "FAILURE:\n\nCannot mount a tmpfs" ${FAILURE}
41 boot_mesg -n " onto /dev, this system will be halted."
42 boot_mesg -n "\n\nAfter you press Enter, this system"
43 boot_mesg -n " will be halted and powered off."
44 boot_mesg -n "\n\nPress Enter to continue..." ${INFO}
45 boot_mesg "" ${NORMAL}
46 read ENTER
47 /etc/rc.d/init.d/halt stop
48 fi
49
50 # Udev handles uevents itself, so we don't need to have
51 # the kernel call out to any binary in response to them
52 echo > /proc/sys/kernel/hotplug
53
54 # Copy static device nodes to /dev
55 cp -a /lib/udev/devices/* /dev
56
57 # Start the udev daemon to continually watch for, and act on,
58 # uevents
59 /sbin/udevd --daemon
60
61 # Now traverse /sys in order to "coldplug" devices that have
62 # already been discovered
63 /sbin/udevtrigger
64
65 # Now wait for udevd to process the uevents we triggered
66 /sbin/udevsettle
67 failed="${?}"
68 > /dev/bug
69 sleep 6
70 if test -s /dev/bug; then
71 mv /dev/bug /dev/bugreport
72 failed="2"
73 else
74 rm -f /dev/bug
75 fi
76 (exit "${failed}")
77 evaluate_retval
78
79 if [ "${failed}" -eq "2" ]; then
80 boot_mesg "Some uevents escaped from the \"udevsettle\" program" ${FAILURE}
81 boot_mesg "This is a bug either in the kernel or in the program itself."
82 boot_mesg "Please mail the /dev/bugreport file to lfs-dev@linuxfromscratch.org."
83 boot_mesg "Otherwise, the next version of LFS may be unbootable on your system!"
84 echo_failure
85 sleep 10
86 exit 1
87 fi
88
89 ;;
90
91 *)
92 echo "Usage ${0} {start}"
93 exit 1
94 ;;
95esac
96
97# End $rc_base/init.d/udev