Lines 1-45
Link Here
|
1 |
# Copyright 1999-2005 Gentoo Foundation |
1 |
# Copyright 1999-2005 Gentoo Foundation |
2 |
# Distributed under the terms of the GNU General Public License v2 |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
|
3 |
|
4 |
udev_version() { |
|
|
5 |
local version=0 |
6 |
|
7 |
if [[ -x /sbin/udev ]] ; then |
8 |
version=$(/sbin/udev -V) |
9 |
# We need it without a leading '0', else bash do the wrong thing |
10 |
version=${version##0} |
11 |
# Older udev's will print nothing |
12 |
[[ -z ${version} ]] && version=0 |
13 |
fi |
14 |
|
15 |
echo "${version}" |
16 |
} |
17 |
|
18 |
|
19 |
populate_udev() { |
4 |
populate_udev() { |
20 |
# populate /dev with devices already found by the kernel |
5 |
# populate /dev with devices already found by the kernel |
21 |
if [ "$(get_KV)" -gt "$(KV_to_int '2.6.14')" ] ; then |
6 |
if [ "$(get_KV)" -gt "$(KV_to_int '2.6.14')" ] ; then |
22 |
ebegin "Populating /dev with existing devices through uevents" |
7 |
ebegin "Populating /dev with existing devices through uevents" |
23 |
udevtrigger |
8 |
local opts= |
24 |
eend 0 |
9 |
[[ ${RC_COLDPLUG} != "yes" ]] && opts="--no-scan-bus" |
|
|
10 |
/sbin/udevtrigger ${opts} |
11 |
eend $? |
25 |
else |
12 |
else |
26 |
ebegin "Populating /dev with existing devices with udevstart" |
13 |
ebegin "Populating /dev with existing devices with udevstart" |
27 |
/sbin/udevstart |
14 |
/sbin/udevstart |
28 |
eend 0 |
15 |
eend $? |
29 |
fi |
16 |
fi |
30 |
|
17 |
|
31 |
# loop until everything is finished |
18 |
# loop until everything is finished |
32 |
# there's gotta be a better way... |
19 |
# there's gotta be a better way... |
33 |
ebegin "Letting udev process events" |
20 |
ebegin "Letting udev process events" |
34 |
udevsettle |
21 |
/sbin/udevsettle --timeout=60 |
35 |
# loop=0 |
22 |
eend $? |
36 |
# while test -d /dev/.udev/queue; do |
|
|
37 |
# sleep 0.1; |
38 |
# test "$loop" -gt 300 && break |
39 |
# loop=$(($loop + 1)) |
40 |
# done |
41 |
#einfo "loop = $loop" |
42 |
eend 0 |
43 |
|
23 |
|
44 |
return 0 |
24 |
return 0 |
45 |
} |
25 |
} |
Lines 65-71
Link Here
|
65 |
eend 0 |
45 |
eend 0 |
66 |
} |
46 |
} |
67 |
|
47 |
|
68 |
|
|
|
69 |
main() { |
48 |
main() { |
70 |
# Setup temporary storage for /dev |
49 |
# Setup temporary storage for /dev |
71 |
ebegin "Mounting /dev for udev" |
50 |
ebegin "Mounting /dev for udev" |
Lines 77-83
Link Here
|
77 |
if [[ -n ${mntcmd} ]] ; then |
56 |
if [[ -n ${mntcmd} ]] ; then |
78 |
try mount -n ${mntcmd} |
57 |
try mount -n ${mntcmd} |
79 |
else |
58 |
else |
80 |
if egrep -qs tmpfs /proc/filesystems ; then |
59 |
# This is bash only, but saves on using grep |
|
|
60 |
if [[ $(</proc/filesystems)$'\n' =~ '[[:space:]]tmpfs'$'\n' ]] ; then |
81 |
mntcmd="tmpfs" |
61 |
mntcmd="tmpfs" |
82 |
else |
62 |
else |
83 |
mntcmd="ramfs" |
63 |
mntcmd="ramfs" |
Lines 108-129
Link Here
|
108 |
seed_dev |
88 |
seed_dev |
109 |
|
89 |
|
110 |
# Setup hotplugging (if possible) |
90 |
# Setup hotplugging (if possible) |
111 |
ebegin "Setting up proper hotplug agent" |
|
|
112 |
if [[ -e /proc/sys/kernel/hotplug ]] ; then |
91 |
if [[ -e /proc/sys/kernel/hotplug ]] ; then |
113 |
if [ "$(get_KV)" -gt "$(KV_to_int '2.6.14')" ] ; then |
92 |
ebegin "Setting up proper hotplug agent" |
114 |
einfo " Using netlink for hotplug events..." |
93 |
eindent |
|
|
94 |
if [[ $(get_KV) -gt $(KV_to_int '2.6.14') ]] ; then |
95 |
einfo "Using netlink for hotplug events..." |
115 |
echo "" > /proc/sys/kernel/hotplug |
96 |
echo "" > /proc/sys/kernel/hotplug |
116 |
elif [[ $(udev_version) -ge "48" ]] ; then |
|
|
117 |
einfo " Setting /sbin/udevsend as hotplug agent ..." |
118 |
echo "/sbin/udevsend" > /proc/sys/kernel/hotplug |
119 |
elif [[ -x /sbin/hotplug ]] ; then |
120 |
einfo " Using /sbin/hotplug as hotplug agent ..." |
121 |
else |
97 |
else |
122 |
einfo " Setting /sbin/udev as hotplug agent ..." |
98 |
einfo "Setting /sbin/udevsend as hotplug agent ..." |
123 |
echo "/sbin/udev" > /proc/sys/kernel/hotplug |
99 |
echo "/sbin/udevsend" > /proc/sys/kernel/hotplug |
124 |
fi |
100 |
fi |
|
|
101 |
eoutdent |
102 |
eend 0 |
125 |
fi |
103 |
fi |
126 |
eend 0 |
|
|
127 |
|
104 |
|
128 |
ebegin "Starting udevd" |
105 |
ebegin "Starting udevd" |
129 |
/sbin/udevd --daemon |
106 |
/sbin/udevd --daemon |
Lines 144-148
Link Here
|
144 |
|
121 |
|
145 |
main |
122 |
main |
146 |
|
123 |
|
147 |
|
|
|
148 |
# vim:ts=4 |
124 |
# vim:ts=4 |