aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--recipes-core/udev/udev/init63
-rw-r--r--recipes-core/udev/udev/udev-cache32
2 files changed, 66 insertions, 29 deletions
diff --git a/recipes-core/udev/udev/init b/recipes-core/udev/udev/init
index e88bddf..a96638f 100644
--- a/recipes-core/udev/udev/init
+++ b/recipes-core/udev/udev/init
@@ -14,7 +14,9 @@ export TZ=/etc/localtime
[ -d /sys/class ] || exit 1
[ -r /proc/mounts ] || exit 1
[ -x @UDEVD@ ] || exit 1
-[ -f /etc/default/udev-cache ] && . /etc/default/udev-cache
+if [ "$use_udev_cache" != "" ]; then
+ [ -f /etc/default/udev-cache ] && . /etc/default/udev-cache
+fi
[ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf
[ -f /etc/default/rcS ] && . /etc/default/rcS
@@ -60,35 +62,38 @@ case "$1" in
# Cache handling.
# A list of files which are used as a criteria to judge whether the udev cache could be reused.
CMP_FILE_LIST="/proc/version /proc/cmdline /proc/devices /proc/atags"
- if [ "$DEVCACHE" != "" ]; then
- if [ -e $DEVCACHE ]; then
- readfiles $CMP_FILE_LIST
- NEWDATA="$READDATA"
- readfiles /etc/udev/cache.data
- OLDDATA="$READDATA"
- if [ "$OLDDATA" = "$NEWDATA" ]; then
- (cd /; tar xf $DEVCACHE > /dev/null 2>&1)
- not_first_boot=1
- [ "$VERBOSE" != "no" ] && echo "udev: using cache file $DEVCACHE"
- [ -e /dev/shm/udev.cache ] && rm -f /dev/shm/udev.cache
- else
- # Output detailed reason why the cached /dev is not used
- if [ "$VERBOSE" != "no" ]; then
- echo "udev: udev cache not used"
- echo "udev: we use $CMP_FILE_LIST as criteria to judge whether the cache /dev could be resued"
- echo "udev: olddata: $OLDDATA"
- echo "udev: newdata: $NEWDATA"
- fi
- echo "$NEWDATA" > /dev/shm/udev.cache
- fi
- else
- if [ "$ROOTFS_READ_ONLY" != "yes" ]; then
- # If rootfs is not read-only, it's possible that a new udev cache would be generated;
- # otherwise, we do not bother to read files.
+ if [ "$use_udev_cache" != "" ]; then
+ if [ "$DEVCACHE" != "" ]; then
+ if [ -e $DEVCACHE ]; then
readfiles $CMP_FILE_LIST
- echo "$READDATA" > /dev/shm/udev.cache
+ NEWDATA="$READDATA"
+ readfiles /etc/udev/cache.data
+ OLDDATA="$READDATA"
+ if [ "$OLDDATA" = "$NEWDATA" ]; then
+ tar --directory=/ -xf $DEVCACHE > /dev/null 2>&1
+ not_first_boot=1
+ [ "$VERBOSE" != "no" ] && echo "udev: using cache file $DEVCACHE"
+ [ -e /dev/shm/udev.cache ] && rm -f /dev/shm/udev.cache
+ else
+ # Output detailed reason why the cached /dev is not used
+ if [ "$VERBOSE" != "no" ]; then
+ echo "udev: udev cache not used"
+ echo "udev: we use $CMP_FILE_LIST as criteria to judge whether the cache /dev could be resued"
+ echo "udev: olddata: $OLDDATA"
+ echo "udev: newdata: $NEWDATA"
+ fi
+ echo "$NEWDATA" > /dev/shm/udev.cache
+ fi
+ /usr/sbin/setenforce 1
+ else
+ if [ "$ROOTFS_READ_ONLY" != "yes" ]; then
+ # If rootfs is not read-only, it's possible that a new udev cache would be generated;
+ # otherwise, we do not bother to read files.
+ readfiles $CMP_FILE_LIST
+ echo "$READDATA" > /dev/shm/udev.cache
+ fi
fi
- fi
+ fi
fi
# make_extra_nodes
@@ -101,7 +106,7 @@ case "$1" in
/usr/bin/udevadm control --env=STARTUP=1
if [ "$not_first_boot" != "" ];then
/usr/bin/udevadm trigger --action=add --subsystem-nomatch=tty --subsystem-nomatch=mem --subsystem-nomatch=vc --subsystem-nomatch=vtconsole --subsystem-nomatch=misc --subsystem-nomatch=dcon --subsystem-nomatch=pci_bus --subsystem-nomatch=graphics --subsystem-nomatch=backlight --subsystem-nomatch=video4linux --subsystem-nomatch=platform
- (/usr/bin/udevadm settle --timeout=3; /usr/bin/udevadm control --env=STARTUP=)&
+ (/usr/bin/udevadm settle --timeout=10; /usr/bin/udevadm control --env=STARTUP=)&
else
/usr/bin/udevadm trigger --action=add
/usr/bin/udevadm settle
diff --git a/recipes-core/udev/udev/udev-cache b/recipes-core/udev/udev/udev-cache
new file mode 100644
index 0000000..6898577
--- /dev/null
+++ b/recipes-core/udev/udev/udev-cache
@@ -0,0 +1,32 @@
+#!/bin/sh -e
+
+### BEGIN INIT INFO
+# Provides: udev-cache
+# Required-Start: mountall
+# Required-Stop:
+# Default-Start: S
+# Default-Stop:
+# Short-Description: cache /dev to speedup the udev next boot
+### END INIT INFO
+
+export TZ=/etc/localtime
+
+[ -r /proc/mounts ] || exit 1
+[ -x @UDEVD@ ] || exit 1
+[ -d /sys/class ] || exit 1
+
+[ -f /etc/default/rcS ] && . /etc/default/rcS
+[ -f /etc/default/udev-cache ] && . /etc/default/udev-cache
+
+if [ "$ROOTFS_READ_ONLY" = "yes" ]; then
+ [ "$VERBOSE" != "no" ] && echo "udev-cache: read-only rootfs, skip generating udev-cache"
+ exit 0
+fi
+
+if [ "$DEVCACHE" != "" -a -e /dev/shm/udev.cache ]; then
+ echo "Populating dev cache"
+ tar --directory=/ --selinux --xattrs -cf "$DEVCACHE" dev
+ mv /dev/shm/udev.cache /etc/udev/cache.data
+fi
+
+exit 0