]> git.ipfire.org Git - ipfire-2.x.git/blob - config/mkinitcpio/start_udev
Die IDE/SCSI/SATA/USB-Erkennung erstellt nun schoene Ramdisks :D
[ipfire-2.x.git] / config / mkinitcpio / start_udev
1 #! /bin/sh
2 #
3 # start_udev
4 # script to initialize /dev by using udev.
5 #
6 # Modified for Archlinux by Tobias Powalowski <tpowa@archlinux.org>
7 #
8 # Inspired by:
9 #
10 # Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com>
11 #
12 # Released under the GPL v2 only.
13 #
14 # This needs to be run at the earliest possible point in the boot
15 # process.
16 #
17 # Based on the udev init.d script
18 #
19 # Thanks go out to the Gentoo developers for proving
20 # that this is possible to do.
21 #
22 # Yes, it's very verbose, feel free to turn off all of the echo calls,
23 # they were there to make me feel better that everything was working
24 # properly during development...
25
26 prog=udev
27 sysfs_dir=/sys
28 bin=/sbin/udev
29 udevd=/sbin/udevd
30 udev_root="/dev"
31
32 trigger_device_events ()
33 {
34 /sbin/udevtrigger
35 }
36
37 wait_for_queue ()
38 {
39 # disabled because it hangs network boot
40 #loop=20
41 #while ! [ "$loop" -gt 0 -a -d /dev/.udev/queue ]; do
42 # sleep 0.1;
43 # loop=$(($loop - 1))
44 #done
45 /sbin/udevsettle
46 }
47
48 make_extra_nodes ()
49 {
50 # there are a few things that sysfs does not export for us.
51 # these things go here (and remember to remove them in
52 # remove_extra_nodes()
53 #
54 # Thanks to Gentoo for the initial list of these.
55 ln -sf /proc/self/fd $udev_root/fd
56 ln -sf /proc/self/fd/0 $udev_root/stdin
57 ln -sf /proc/self/fd/1 $udev_root/stdout
58 ln -sf /proc/self/fd/2 $udev_root/stderr
59 ln -sf /proc/kcore $udev_root/core
60 }
61
62 udev_init ()
63 {
64 # don't use udev if sysfs is not mounted.
65 if [ ! -d $sysfs_dir/block ]; then
66 exit 1
67 fi
68
69 #echo "mounting... ramfs at $udev_root"
70 mount -t ramfs none $udev_root
71
72 # propogate /udev from /sys
73 #echo "Creating initial udev device nodes:"
74
75 #echo "making extra nodes"
76 make_extra_nodes
77
78 # check if udevd is already running
79 #echo "start udev daemon"
80 /sbin/udevd --daemon
81
82 case "$(uname -r)" in
83 2.6.[0-9]|2.6.[0-9][!0-9]*) ;;
84 *) if [ -f "/sys/class/tty/console/uevent" ]; then
85 #echo "Kernel >= 2.6.15 and supports uevents"
86 # trigger the sorted events
87 echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug
88 # catch events that are real fast
89 mkdir -p /dev/.udev/queue
90 else
91 # for older kernels without uevents will be removed when udevstart dies in udev
92 echo "Kernel does not support uevents, you need a kernel >= 2.6.15!"
93 exit 1
94 fi
95 ;;
96 esac
97 }
98
99 udev_uevents ()
100 {
101 # configure all devices
102 trigger_device_events
103 # until we know how to do better, just wait for _all_ events to finish
104 wait_for_queue
105 }
106
107 if [ $# -eq 0 ]; then
108 udev_init
109 udev_uevents
110 fi
111
112 [ "$1" = "init" ] && udev_init
113 [ "$1" = "uevents" ] && udev_uevents
114
115 exit 0