]>
Commit | Line | Data |
---|---|---|
05149ed5 AM |
1 | #!/bin/sh |
2 | # | |
3 | # start_udev | |
4 | # | |
5 | # script to initialize /dev by using udev. | |
6 | # | |
7 | # Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com> | |
8 | # | |
9 | # Released under the GPL v2 only. | |
10 | # | |
11 | # This needs to be run at the earliest possible point in the boot | |
12 | # process. | |
13 | # | |
14 | # Based on the udev init.d script | |
15 | # | |
16 | # Thanks go out to the Gentoo developers for proving | |
17 | # that this is possible to do. | |
18 | # | |
19 | # Yes, it's very verbose, feel free to turn off all of the echo calls, | |
20 | # they were there to make me feel better that everything was working | |
21 | # properly during development... | |
22 | # | |
23 | # don't use udev if sysfs is not mounted. | |
24 | [ ! -d $sysfs_dir/class ] || exit 1 | |
25 | [ -r /proc/mounts ] || exit 1 | |
26 | [ -x /sbin/udev ] || exit 1 | |
27 | [ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf | |
28 | ||
29 | ||
30 | . /etc/init.d/functions | |
31 | ||
32 | prog=udev | |
33 | sysfs_dir=/sys | |
34 | bin=/sbin/udev | |
35 | udevd=/sbin/udevd | |
36 | MAKEDEV="/sbin/MAKEDEV" | |
37 | ||
38 | make_extra_nodes () { | |
39 | ln -snf /proc/self/fd $udev_root/fd | |
40 | ln -snf /proc/self/fd/0 $udev_root/stdin | |
41 | ln -snf /proc/self/fd/1 $udev_root/stdout | |
42 | ln -snf /proc/self/fd/2 $udev_root/stderr | |
43 | ln -snf /proc/kcore $udev_root/core | |
44 | ||
45 | [ -d $udev_root/pts ] || (mkdir $udev_root/pts;chmod 0755 $udev_root/pts) | |
46 | [ -d $udev_root/shm ] || (mkdir $udev_root/shm;chmod 0755 $udev_root/shm) | |
47 | ||
48 | if [ -x $MAKEDEV ]; then | |
49 | $MAKEDEV -x $( | |
50 | for i in 0 1 2 3 4 5 6 7; do echo fd$i; done | |
51 | for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do | |
52 | echo cpu/$i/microcode; | |
53 | done; | |
54 | for i in 0 1 2 3 4 5 6 7; do echo loop$i; done | |
55 | for i in 0 1 2 3; do echo lp$i; echo par$i;done | |
56 | echo net/tun ppp; | |
57 | ); | |
58 | [ -a /dev/MAKEDEV ] || ln -s $MAKEDEV /dev/MAKEDEV; | |
59 | fi | |
60 | } | |
61 | ||
62 | mount_udev() { | |
63 | mount -n -o fscontext=system_u:object_r:device_t,mode=0755 \ | |
64 | -t tmpfs none "$udev_root" | |
65 | return $? | |
66 | } | |
67 | ||
68 | ||
69 | grep -q " ${udev_root%/} " /proc/mounts || { | |
70 | STRING=$"Mounting... tmpfs at $udev_root: " | |
71 | echo -n "$STRING "; | |
72 | mount_udev && success $"$STRING" || failure $"$STRING"; | |
73 | } | |
74 | ||
75 | ||
76 | STRING=$"Making extra nodes: " | |
77 | echo -n "$STRING " | |
78 | make_extra_nodes && success $"$STRING" || failure $"$STRING" | |
79 | echo | |
80 | ||
81 | export ACTION=add | |
82 | export UDEV_NO_SLEEP=1 | |
83 | STRING=$"Starting udev: " | |
84 | # propagate $udev_root from /sys | |
85 | echo -n "$STRING " | |
86 | rm -f $udev_root/.udev.tdb | |
87 | /sbin/udevstart && success $"$STRING" || failure $"$STRING" | |
88 | echo | |
89 | ||
90 | exit 0 |