summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/udev/eudev/udev-cache
diff options
context:
space:
mode:
authorAlejandro Hernandez <alejandro.hernandez@linux.intel.com>2016-03-01 02:52:47 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-02 22:39:43 +0000
commit3e5e540513665105b963262c2eaf33f197a0a36c (patch)
tree3ce445ae80c50cd303040a810ae478e0fdf1080d /meta/recipes-core/udev/eudev/udev-cache
parent674e55f4169de8080b8453f951a4f68fc4b3fcd8 (diff)
downloadpoky-3e5e540513665105b963262c2eaf33f197a0a36c.tar.gz
eudev: Replaces udev with eudev for compatibility when using sysvinit on newer kernels
udev has started to fail on new kernels (4.4), due to being deprecated in favor of systemd's udev implementation. To maintain a sysvinit alternative we also need to provide an alternative to udev. Eudev is a fork of systemds udev, this new eudev recipe provides upstream udev 220 funcitonality. - Removes patches that dont apply anymore - ToDo: eudev-ptest? [YOCTO #8998] (From OE-Core rev: a22797f7c37a865420837b5c29b270f73ee4c6ce) Signed-off-by: Alejandro Hernandez <alejandro.hernandez@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/udev/eudev/udev-cache')
-rw-r--r--meta/recipes-core/udev/eudev/udev-cache75
1 files changed, 75 insertions, 0 deletions
diff --git a/meta/recipes-core/udev/eudev/udev-cache b/meta/recipes-core/udev/eudev/udev-cache
new file mode 100644
index 0000000000..dcfff1cb45
--- /dev/null
+++ b/meta/recipes-core/udev/eudev/udev-cache
@@ -0,0 +1,75 @@
1#!/bin/sh -e
2
3### BEGIN INIT INFO
4# Provides: udev-cache
5# Required-Start: mountall
6# Required-Stop:
7# Default-Start: S
8# Default-Stop:
9# Short-Description: cache /dev to speedup the udev next boot
10### END INIT INFO
11
12export TZ=/etc/localtime
13
14[ -r /proc/mounts ] || exit 1
15[ -x @UDEVD@ ] || exit 1
16[ -d /sys/class ] || exit 1
17
18[ -f /etc/default/rcS ] && . /etc/default/rcS
19DEVCACHE_TMP="/dev/shm/udev-cache-tmp.tar"
20SYSCONF_CACHED="/etc/udev/cache.data"
21SYSCONF_TMP="/dev/shm/udev.cache"
22DEVCACHE_REGEN="/dev/shm/udev-regen" # create to request cache regen
23
24# A list of files which are used as a criteria to judge whether the udev cache could be reused.
25CMP_FILE_LIST="/proc/version /proc/cmdline /proc/devices"
26[ -f /proc/atags ] && CMP_FILE_LIST="$CMP_FILE_LIST /proc/atags"
27
28# List of files whose metadata (size/mtime/name) will be included in cached
29# system state.
30META_FILE_LIST="lib/udev/rules.d/* etc/udev/rules.d/*"
31
32# Command to compute system configuration.
33sysconf_cmd () {
34 cat -- $CMP_FILE_LIST
35 stat -c '%s %Y %n' -- $META_FILE_LIST | awk -F/ '{print $1 " " $NF;}'
36}
37
38[ -f /etc/default/udev-cache ] && . /etc/default/udev-cache
39
40if [ "$ROOTFS_READ_ONLY" = "yes" ]; then
41 [ "$VERBOSE" != "no" ] && echo "udev-cache: read-only rootfs, skip generating udev-cache"
42 exit 0
43fi
44
45[ "$DEVCACHE" != "" ] || exit 0
46[ "${VERBOSE}" == "no" ] || echo -n "udev-cache: checking for ${DEVCACHE_REGEN}... "
47if ! [ -e "$DEVCACHE_REGEN" ]; then
48 [ "${VERBOSE}" == "no" ] || echo "not found."
49 exit 0
50fi
51[ "${VERBOSE}" == "no" ] || echo "found."
52echo "Populating dev cache"
53
54err_cleanup () {
55 echo "udev-cache: update failed!"
56 udevadm control --start-exec-queue
57 rm -f -- "$SYSCONF_TMP" "$DEVCACHE_TMP" "$DEVCACHE" "$SYSCONF_CACHED"
58}
59
60(
61 set -e
62 trap 'err_cleanup' EXIT
63 udevadm control --stop-exec-queue
64 sysconf_cmd > "$SYSCONF_TMP"
65 find /dev -xdev \( -type b -o -type c -o -type l \) | cut -c 2- \
66 | xargs tar cf "${DEVCACHE_TMP}"
67 gzip < "${DEVCACHE_TMP}" > "$DEVCACHE"
68 rm -f "${DEVCACHE_TMP}"
69 mv "$SYSCONF_TMP" "$SYSCONF_CACHED"
70 udevadm control --start-exec-queue
71 rm -f "$DEVCACHE_REGEN"
72 trap - EXIT
73) &
74
75exit 0