source: udev/udev @ c044e1b

clfs-1.2clfs-2.1clfs-3.0.0-systemdclfs-3.0.0-sysvinitsystemdsysvinit
Last change on this file since c044e1b was c044e1b, checked in by Jim Gifford <clfs@…>, 18 years ago

r1002@server (orig r1000): jim | 2006-01-04 17:11:14 -0800

r1271@server: jim | 2006-01-04 16:39:41 -0800
Added creating of /dev and copying of files


  • Property mode set to 100755
File size: 2.6 KB
Line 
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
22trigger_device_events() {
23        # generate events with the sysfs trigger
24        list=$(echo /sys/bus/*/devices/*/uevent)
25        list="$list $(echo /sys/class/*/*/uevent)"
26        list="$list $(echo /sys/block/*/uevent /sys/block/*/*/uevent)"
27        for i in $list; do
28            case "$i" in
29                */device/uevent|*\**)
30                    # skip followed device symlinks
31                    continue
32                    ;;
33
34                */class/mem/*|*/class/tty/*)
35                    first="$first $i"
36                    ;;
37
38                */block/md*)
39                    last="$last $i"
40                    ;;
41
42                */*)
43                    default="$default $i"
44                    ;;
45            esac
46        done
47
48        # trigger the sorted events
49        for i in $first $default $last; do
50            echo "add" > "$i"
51        done
52}
53
54case "$1" in
55    start)
56        echo "Creating /dev in tmpfs..."
57        mount -n -t tmpfs tmpfs /dev -o mode=755
58
59        echo "Copying static entries..."
60        cp -ar /lib/udev/devices/* /dev
61
62        echo "Executing udevstart..."
63        udevstart
64
65        # disable hotplug helper, udevd listens to netlink
66        echo "" > /proc/sys/kernel/hotplug
67
68        # start udevd
69        boot_mesg "Starting udevd..."
70        loadproc /sbin/udevd --daemon
71
72        # cleanup some stuff
73        rm -f /var/run/sysconfig/network
74        rm -rf /events/*
75
76        # start coldplugging
77        boot_mesg "Performing Coldplugging..."
78
79        # unlikely, but we may be faster than the first event
80        mkdir -p /dev/.udev/queue
81
82        # configure all devices
83        trigger_device_events
84
85        # until we know how to do better, just wait for _all_ events to finish
86        loop=300
87        while test -d /dev/.udev/queue; do
88            sleep 0.1;
89            test "$loop" -gt 0 || break
90            loop=$(($loop - 1))
91        done
92
93        echo_ok
94        ;;
95
96    stop)
97        boot_mesg "Stopping udevd..."
98        echo "/sbin/hotplug" > /proc/sys/kernel/hotplug
99        killproc /sbin/udevd
100        ;;
101
102    restart)
103        boot_mesg "Restarting udevd..."
104        killproc /sbin/udevd
105        loadproc /sbin/udevd --daemon
106        evaluate_retval
107        ;;
108
109    status)
110        statusproc /sbin/udevd
111        ;;
112
113    reload)
114        boot_mesg "Reloading udev rules..."
115        udevcontrol reload_rules
116        cp --preserve=all --recursive --update /lib/udev/devices/* /dev
117        evaluate_retval
118        ;;
119
120    force-reload)
121        boot_mesg "Updating all available device nodes in /dev..."
122        udevcontrol reload_rules
123        rm -rf /dev/.udev /dev/disk
124        cp --preserve=all --recursive --update /lib/udev/devices/* /dev
125        trigger_device_events
126        evaluate_retval
127        ;;
128
129    *)
130        echo "Usage: $0 {start|stop|restart|status|reload|force-reload}"
131        exit 1
132        ;;
133esac
Note: See TracBrowser for help on using the repository browser.