summaryrefslogtreecommitdiff
blob: 5d2ecf9539f6d9f4b9833cd8308205cdf1a5088a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
Index: init.d/halt.sh
===================================================================
--- init.d/halt.sh	(revision 1600)
+++ init.d/halt.sh	(working copy)
@@ -13,66 +13,9 @@
 	/sbin/pam_console_apply -r
 fi
 
-# We need to properly terminate devfsd to save the permissions
-if [[ -n $(ps --no-heading -C 'devfsd') ]]; then
-	ebegin "Stopping devfsd"
-	killall -15 devfsd &>/dev/null
-	eend $?
-elif [[ ! -e /dev/.devfsd && -e /dev/.udev && -z ${CDBOOT} && \
-        ${RC_DEVICE_TARBALL} == "yes" ]] && \
-		touch /lib/udev-state/devices.tar.bz2 2>/dev/null
-then
-	ebegin "Saving device nodes"
-	# Handle our temp files
-	devices_udev=$(mktemp /tmp/devices.udev.XXXXXX)
-	devices_real=$(mktemp /tmp/devices.real.XXXXXX)
-	devices_totar=$(mktemp /tmp/devices.totar.XXXXXX)
-	device_tarball=$(mktemp /tmp/devices-XXXXXX)
-	
-	if [[ -z ${devices_udev} || -z ${devices_real} || \
-	      -z ${device_tarball} ]]; then
-		eend 1 "Could not create temporary files!"
-	else
-		cd /dev
-		# Find all devices
-		find . -xdev -type b -or -type c -or -type l | cut -d/ -f2- > \
-			"${devices_real}"
-		# Figure out what udev created
-		eval $(grep '^[[:space:]]*udev_db=' /etc/udev/udev.conf)
-		if [[ -d ${udev_db} ]]; then
-			# New udev_db is clear text ...
-			udevinfo=$(cat "${udev_db}"/*)
-		else
-			# Old one is not ...
-			udevinfo=$(udevinfo -d)
-		fi
-		# This basically strips 'S:' and 'N:' from the db output, and then
-		# print all the nodes/symlinks udev created ...
-		echo "${udevinfo}" | gawk '
-			/^(N|S):.+/ {
-				sub(/^(N|S):/, "")
-				split($0, nodes)
-				for (x in nodes)
-					print nodes[x]
-			}' > "${devices_udev}"
-		# These ones we also do not want in there
-		for x in MAKEDEV core fd initctl pts shm stderr stdin stdout; do
-			echo "${x}" >> "${devices_udev}"
-		done
-		fgrep -x -v -f "${devices_udev}" < "${devices_real}" > "${devices_totar}"
-		# Now only tarball those not created by udev if we have any
-		if [[ -s ${devices_totar} ]]; then
-			try tar --one-file-system -jcpf "${device_tarball}" -T "${devices_totar}"
-			try mv -f "${device_tarball}" /lib/udev-state/devices.tar.bz2
-		else
-			rm -f /lib/udev-state/devices.tar.bz2
-		fi
-		eend 0
-	fi
+stop_addon devfs
+stop_addon udev
 
-	rm -f "${devices_udev}" "${devices_real}" "${devices_totar}" "${device_tarball}"
-fi
-
 # Try to unmount all tmpfs filesystems not in use, else a deadlock may
 # occure, bug #13599.
 umount -at tmpfs &>/dev/null
Index: sbin/rc
===================================================================
--- sbin/rc	(revision 1600)
+++ sbin/rc	(working copy)
@@ -74,21 +74,6 @@
 	return 0
 }
 
-udev_version() {
-	local version=0
-
-	if [ -x "/sbin/udev" ]
-	then
-		version=$(/sbin/udev -V)
-		# We need it without a leading '0', else bash do the wrong thing
-		version="${version##0}"
-		# Older udev's will print nothing
-		[ -z "${version}" ] && version=0
-	fi
-
-	echo "${version}"
-}
-
 # void noblock_read(var)
 #
 #   reads a line of input into var like regular read
@@ -152,31 +137,6 @@
 	done
 }
 
-populate_udev() {
-	# Now populate /dev
-	/sbin/udevstart
-
-	# Not provided by sysfs but needed
-	ln -snf /proc/self/fd /dev/fd
-	ln -snf fd/0 /dev/stdin
-	ln -snf fd/1 /dev/stdout
-	ln -snf fd/2 /dev/stderr
-	[ -e /proc/kcore ] && ln -snf /proc/kcore /dev/core
-
-	# Create nodes that udev can't
-	[ -x /sbin/dmsetup ] && /sbin/dmsetup mknodes &>/dev/null
-	[ -x /sbin/lvm ] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null
-	[ -x /sbin/evms_activate ] && /sbin/evms_activate -q &>/dev/null
-
-	# Create problematic directories
-	mkdir -p /dev/{pts,shm}
-
-	# Same thing as /dev/.devfsd
-	touch /dev/.udev
-
-	return 0
-}
-
 get_critical_services() {
 	local x=
 	CRITICAL_SERVICES=
@@ -308,96 +268,29 @@
 		fi
 
 		# Actually start setting up /dev now
-		if [[ ${udev} = "yes" ]] ; then
-			# Setup temporary storage for /dev
-			ebegin "Mounting /dev for udev"
-			if [[ ${RC_USE_FSTAB} = "yes" ]] ; then
-				mntcmd=$(get_mount_fstab /dev)
-			else
-				unset mntcmd
-			fi
-			if [[ -n ${mntcmd} ]] ; then
-				try mount -n ${mntcmd}
-			else
-				if egrep -qs tmpfs /proc/filesystems ; then
-					mntcmd="tmpfs"
-				else
-					mntcmd="ramfs"
-				fi
-				# many video drivers require exec access in /dev #92921
-				try mount -n -t ${mntcmd} udev /dev -o exec,nosuid,mode=0755
-			fi
-			eend $?
+		if [[ ${udev} == "yes" ]] ; then
+			start_addon udev
 
-			# Selinux lovin; /selinux should be mounted by selinux-patched init
-			if [[ -x /sbin/restorecon ]] && [[ -c /selinux/null ]] ; then
-				restorecon /dev &> /selinux/null
-			fi
-
-			# Actually get udev rolling
-			ebegin "Configuring system to use udev"
-			if [[ ${RC_DEVICE_TARBALL} = "yes" ]] && [[ -s /lib/udev-state/devices.tar.bz2 ]]
-			then
-				einfo "  Populating /dev with device nodes ..."
-				try tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev
-			fi
-			populate_udev
-
-			# Setup hotplugging (if possible)
-			if [ -e /proc/sys/kernel/hotplug ] ; then
-				if [ "$(udev_version)" -ge "48" ] ; then
-					einfo "  Setting /sbin/udevsend as hotplug agent ..."
-					echo "/sbin/udevsend" > /proc/sys/kernel/hotplug
-				elif [ -x /sbin/hotplug ] ; then
-					einfo "  Using /sbin/hotplug as hotplug agent ..."
-				else
-					einfo "  Setting /sbin/udev as hotplug agent ..."
-					echo "/sbin/udev" > /proc/sys/kernel/hotplug
-				fi
-			fi
-			eend 0
-
 		# With devfs, /dev can be mounted by the kernel ...
-		elif [ "${devfs}" = "yes" ]
-		then
-			mymounts="$(awk '($2 == "devfs") { print "yes"; exit 0 }' /proc/filesystems)"
-			# Is devfs support compiled in?
-			if [ "${mymounts}" = "yes" ]
-			then
-				if [ "${devfs_automounted}" = "no" ]
-				then
-					ebegin "Mounting devfs at /dev"
-					try mount -n -t devfs devfs /dev
-					eend $?
-				else
-					ebegin "Kernel automatically mounted devfs at /dev"
-					eend 0
-				fi
-				ebegin "Starting devfsd"
-				/sbin/devfsd /dev >/dev/null
-				eend $? "Could not start /sbin/devfsd"
-			else
-				devfs="no"
-			fi
+		elif [[ ${devfs} == "yes" ]] ; then
+			start_addon devfs
 
 			# Did the user want udev in the config file but for 
 			# some reason, udev support didnt work out ?
-			if [ "${fellback_to_devfs}" = "yes" ]
-			then
+			if [[ ${fellback_to_devfs} == "yes" ]] ; then
 				ewarn "You wanted udev but support for it was not available!"
 				ewarn "Please review your system after it's booted!"
 			fi
 		fi
 
 		# OK, if we got here, things are probably not right :)
-		if [ "${devfs}" = "no" ] && [ "${udev}" = "no" ]
-		then
+		if [[ ${devfs} == "no" && ${udev} == "no" ]] ; then
 			clear
 			echo
 			einfo "The Gentoo Linux system initialization scripts have detected that"
-			einfo "your system does not support DEVFS or UDEV.  Since Gentoo Linux"
-			einfo "has been designed with these dynamic /dev managers in mind, it is"
-			einfo "highly suggested that you build support for it into your kernel."
+			einfo "your system does not support UDEV.  Since Gentoo Linux has been"
+			einfo "designed with dynamic /dev in mind, it is highly suggested that you"
+			einfo "emerge sys-fs/udev and configure your system to use it."
 			einfo "Please read the Gentoo Handbook for more information!"
 			echo
 			einfo "    http://www.gentoo.org/doc/en/handbook/"