Magellan Linux

Annotation of /tags/udev-185-r4/udev.rc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1289 - (hide annotations) (download)
Mon Feb 28 20:10:49 2011 UTC (13 years, 2 months ago) by niro
Original Path: trunk/udev/udev.rc
File size: 4251 byte(s)
-updated rules to match udev-166
-added udev-qemu-usb.rules.magellan
-use rc_print and rc_echo
1 niro 1058 #!/bin/bash
2 niro 1087 # $Header: /root/magellan-cvs/src/udev/udev.rc,v 1.2 2010-08-18 00:57:31 niro Exp $
3 niro 1058
4     udev_version()
5     {
6     local version=0
7    
8     if [[ -x /sbin/udev ]]
9     then
10     version=$(/sbin/udev -V)
11     # We need it without a leading '0', else bash do the wrong thing
12     version=${version##0}
13     # Older udev's will print nothing
14     [[ -z ${version} ]] && version=0
15     elif [[ -x /sbin/udevd ]]
16     then
17     version=$(/sbin/udevd --version)
18     version=${version##0}
19     [[ -z ${version} ]] && version=0
20     fi
21    
22     echo "${version}"
23     }
24    
25     populate_udev()
26     {
27     local opts
28    
29     # tell modprobe.sh to be verbose to $CONSOLE
30     echo CONSOLE=${CONSOLE} > /dev/.udev_populate
31    
32     # populate /dev with devices already found by the kernel
33 niro 1289 rc_print " Populating /dev with existing devices through uevents ..."
34 niro 1058 if [[ ${RC_COLDPLUG} = yes ]]
35     then
36     /sbin/udevadm trigger
37     else
38     # do not run any init-scripts
39     /sbin/udevadm control --env do_not_run_plug_service=1
40    
41     # only create device nodes
42     /sbin/udevadm trigger --attr-match=dev
43    
44     # run persistent-net stuff
45     /sbin/udevadm trigger --subsystem-match=net
46     fi
47     evaluate_retval
48    
49     # loop until everything is finished
50 niro 1289 rc_print " Letting udev process events ..."
51 niro 1058 /sbin/udevadm settle --timeout=60
52     evaluate_retval
53    
54     # unset this variable
55     /sbin/udevadm control --env do_not_run_plug_service=
56    
57     rm -f /dev/.udev_populate
58     return 0
59     }
60    
61     seed_dev()
62     {
63     # seed /dev with some things that we know we need
64 niro 1289 rc_print " Seeding /dev with needed nodes ..."
65 niro 1058 (
66     [ ! -c /dev/console ] && mknod /dev/console c 5 1
67     [ ! -c /dev/tty1 ] && mknod /dev/tty1 c 4 1
68     [ ! -c /dev/null ] && mknod /dev/null c 1 3
69    
70     # create kmsg too, so udev can add its start-message to dmesg
71     [ -c /dev/kmsg ] || mknod -m 660 /dev/kmsg c 1 11
72    
73     # copy over any persistant things
74     if [[ -d /lib/udev/devices ]]
75     then
76     cp -RPp /lib/udev/devices/* /dev 2>/dev/null
77     fi
78    
79     # not provided by sysfs but needed
80     ln -snf /proc/self/fd /dev/fd
81     ln -snf fd/0 /dev/stdin
82     ln -snf fd/1 /dev/stdout
83     ln -snf fd/2 /dev/stderr
84     [[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core
85    
86     # create problematic directories
87     mkdir -p /dev/pts /dev/shm
88     )
89     evaluate_retval
90     }
91    
92     # main function
93     start_devicemanager()
94     {
95     # check if /dev/console exists outside tmpfs
96     [ -c /dev/console ] ; need_redirect=$?
97    
98     # create a ramdisk for populating udev
99 niro 1289 rc_print "Mounting udev at /dev ..."
100 niro 1058 # many video drivers needed exec access
101     fstype=ramfs
102     # tmpfs was suggested by Greg Kroah-Hartman
103     kernel_supports_fs tmpfs && fstype=tmpfs
104     # mount devtmpfs if supported
105     kernel_supports_fs devtmpfs && fstype=devtmpfs
106     mount -n -t ${fstype} udev /dev -o exec,nosuid,mode=0755,size=10M
107     evaluate_retval
108    
109     # if a device tarball exists load it and if it is activated
110 niro 1289 rc_print "Configurating system to use udev ..."
111 niro 1058 if [[ ${RC_DEVICE_TARBALL} = yes ]]
112     then
113 niro 1289 rc_print " Populating /dev with saved device nodes ..."
114 niro 1058 tar -jxpf /lib/udev/state/devices.tar.bz2 -C /dev
115     evaluate_retval
116     fi
117    
118     # other eeded device nodes with udev
119     seed_dev
120    
121     if [ -e /proc/sys/kernel/hotplug ]
122     then
123 niro 1289 rc_print " Using netlink for hotplug events ..."
124 niro 1058 echo "" > /proc/sys/kernel/hotplug
125     evaluate_retval
126     else
127 niro 1289 rc_print ${COLYELLOW}" Kernel was not compiled with hotplug support !"
128 niro 1058 print_status failure
129     fi
130    
131     # load unix domain sockets if built as module
132     if [ -e /proc/modules ]
133     then
134     modprobe -q unix 2>/dev/null
135     fi
136    
137 niro 1289 rc_print " Starting udevd daemon ..."
138 niro 1058 if [ ${need_redirect} -eq 1 ]
139     then
140     # we need to open fds 0 1 2
141     start-stop-daemon --start --exec /sbin/udevd -- --daemon </dev/console >/dev/console 2>/dev/console
142     else
143     start-stop-daemon --start --exec /sbin/udevd -- --daemon
144     fi
145     evaluate_retval
146    
147     # write root_link rule
148     /lib/udev/write_root_link_rule
149     # populate udev device nodes
150     populate_udev
151    
152     # create nodes that udev can't
153 niro 1289 rc_print " Finializing udev configuration ..."
154 niro 1058 [[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null
155     [[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null
156     [[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null
157     print_status success
158    
159     # same thing as /dev/.devfsd
160     touch /dev/.udev
161     }
162    
163     stop_devicemanager()
164     {
165 niro 1289 rc_print "Stopping udevd daemon ..."
166 niro 1058 start-stop-daemon --stop --exec /sbin/udevd
167     evaluate_retval
168     }