source: udev/boot.udev@ 03b5f90

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 03b5f90 was 7e161ea, checked in by Jim Gifford <clfs@…>, 19 years ago

r833@server (orig r831): jim | 2005-12-05 10:42:24 -0800
Added: udev package for Cross-LFS. Work in Progress

  • Property mode set to 100755
File size: 2.3 KB
RevLine 
[7e161ea]1#!/bin/sh
2########################################################################
3# Begin $rc_base/init.d/udev
4#
5# Description : Udev Boot Script
6#
7# Authors : Based on Open Suse Udev Rules
8# kay.sievers@suse.de
9#
10# Adapted to : Jim Gifford
11# LFS
12#
13# Version : 00.00
14#
15# Notes :
16#
17########################################################################
18
19. /etc/sysconfig/rc
20. ${rc_functions}
21
22PATH="/sbin:/bin"
23DAEMON=/sbin/udevd
24udevd_args="--daemon"
25
26function trigger_device_events() {
27 # generate events with the sysfs trigger
28 list=$(echo /sys/bus/*/devices/*/uevent)
29 list="$list $(echo /sys/class/*/*/uevent)"
30 list="$list $(echo /sys/block/*/uevent /sys/block/*/*/uevent)"
31 for i in $list; do
32 case "$i" in
33 */device/uevent)
34 # skip followed device symlinks
35 continue
36 ;;
37
38 */class/mem/*|*/class/tty/*)
39 first="$first $i"
40 ;;
41
42 */block/md*)
43 last="$last $i"
44 ;;
45
46 */*)
47 default="$default $i"
48 ;;
49 esac
50 done
51
52 # trigger the sorted events
53 for i in $first $default $last; do
54 echo "add" > "$i"
55 done
56}
57
58case "$1" in
59 start)
60
61 # disable hotplug helper, udevd listens to netlink
62 echo "" > /proc/sys/kernel/hotplug
63
64 # start udevd
65 boot_mesg "Starting udevd"
66 loadproc $DAEMON $udevd_args
67
68 # cleanup some stuff
69 rm -rf /events/*
70
71 # unlikely, but we may be faster than the first event
72 mkdir -p /dev/.udev/queue
73
74 # configure all devices
75 trigger_device_events
76
77 # until we know how to do better, we wait for all events to finish
78 loop=0
79 while test -d /dev/.udev/queue; do
80 sleep 0.1;
81 test "$loop" -gt 300 && break
82 loop=$(($loop + 1))
83 done
84 ;;
85
86 stop)
87 boot_mesg "Stopping udevd:"
88 echo "/sbin/hotplug" > /proc/sys/kernel/hotplug
89 killproc $DAEMON
90 ;;
91
92 restart)
93 ${0} stop
94 sleep 1
95 ${0} start
96 ;;
97
98 status)
99 statusproc /sbin/udevd
100 ;;
101
102 reload)
103 boot_mesg "Reloading udev rules:"
104 udevcontrol reload_rules
105 cp --preserve=all --recursive --update /lib/udev/devices/* /dev
106 evaluate_retval
107 ;;
108
109 force-reload)
110 boot_mesg "Updating all available device nodes in /dev: "
111 udevcontrol reload_rules
112 rm -rf /dev/.udev /dev/disk
113 cp --preserve=all --recursive --update /lib/udev/devices/* /dev
114 trigger_device_events
115 evaluate_retval
116 ;;
117 *)
118 echo "Usage: $0 {start|stop|restart|status|reload|force-reload}"
119 exit 1
120 ;;
121esac
Note: See TracBrowser for help on using the repository browser.