# trim traling slash, code expects it not to be there
udev_root=${udev_root%/}
-make_extra_nodes () {
+create_static_nodes() {
+ /sbin/kmod static-nodes --format=tmpfiles | \
+ while read type file mode uid gid age dev ; do
+ case $type in
+ d|D)
+ mkdir -p --mode=$mode $file
+ ;;
+ *)
+ oldIFS=$IFS
+ IFS=":"
+ set -- $dev
+ maj=$1
+ min=$2
+ IFS=$oldIFS
+ mknod --mode=$mode $file $type $maj $min
+ ;;
+ esac
+ [ $uid = "-" ] || chown $uid $file
+ [ $gid = "-" ] || chgrp $gid $file
+ done
+}
+
+make_extra_nodes() {
grep '^[^#]' /etc/udev/links.conf | \
while read type name arg1; do
[ "$type" -a "$name" -a ! -e "$udev_root/$name" -a ! -L "/dev/$name" ] ||continue
}' /proc/mounts
}
+show "Starting udev"; busy
+
export ACTION=add
prog=udev
ret=0
-show "Starting udev"
-busy
# mount the devtmpfs on $udev_root, if not already done
awk "\$2 == \"$udev_root\" && \$3 == \"devtmpfs\" { exit 1 }" /proc/mounts && {
kill_udevd > "$udev_root/null" 2>&1
+# Create required static device nodes for the current kernel
+create_static_nodes
+
# Start udevd daemon
-$udevd --daemon
-ret=$(( $ret + $? ))
+$udevd --daemon; rc=$?
+test $rc -eq 0 && ok || fail
+ret=$(( $ret + $rc ))
# Making extra nodes
-make_extra_nodes
-ret=$(( $ret + $? ))
+show "Setup extra nodes"; busy
+make_extra_nodes; rc=$?
+test $rc -eq 0 && ok || fail
+ret=$(( $ret + $rc ))
-if [ -f "/sys/class/tty/console/uevent" ]; then
+if [ -f /sys/class/tty/console/uevent ]; then
# Setting default hotplug handler
set_hotplug_handler
ret=$(( $ret + $? ))
# retrigger all events
- /sbin/udevadm trigger --type=subsystems --action=add
- ret=$(( $ret + $? ))
- /sbin/udevadm trigger --type=devices --action=add
- ret=$(( $ret + $? ))
+ show "Retrigger subsystems events"; busy
+ /sbin/udevadm trigger --type=subsystems --action=add; rc=$?
+ test $rc -eq 0 && ok || fail
+ ret=$(( $ret + $rc ))
+
+ show "Retrigger devices events"; busy
+ /sbin/udevadm trigger --type=devices --action=add; rc=$?
+ test $rc -eq 0 && ok || fail
+ ret=$(( $ret + $rc ))
# wait for the events to finish
- /sbin/udevadm settle
- ret=$(( $ret + $? ))
+ show "udevadm settle"; busy
+ /sbin/udevadm settle; rc=$?
+ test $rc -eq 0 && ok || fail
+ ret=$(( $ret + $rc ))
else
echo "Kernel too old for this udev version"
fi
-ret=$(( $ret + $? ))
-[ $ret -eq 0 ] && ok || fail
-exit 0
+exit $ret