diff options
Diffstat (limited to 'meta/recipes-core/udev/udev/udev-cache')
-rw-r--r-- | meta/recipes-core/udev/udev/udev-cache | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/meta/recipes-core/udev/udev/udev-cache b/meta/recipes-core/udev/udev/udev-cache index 497d257397..df97000dde 100644 --- a/meta/recipes-core/udev/udev/udev-cache +++ b/meta/recipes-core/udev/udev/udev-cache @@ -19,6 +19,22 @@ export TZ=/etc/localtime DEVCACHE_TMP="/dev/shm/udev-cache-tmp.tar" SYSCONF_CACHED="/etc/udev/cache.data" SYSCONF_TMP="/dev/shm/udev.cache" +DEVCACHE_REGEN="/dev/shm/udev-regen" # create to request cache regen + +# 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" +[ -f /proc/atags ] && CMP_FILE_LIST="$CMP_FILE_LIST /proc/atags" + +# List of files whose metadata (size/mtime/name) will be included in cached +# system state. +META_FILE_LIST="lib/udev/rules.d/* etc/udev/rules.d/*" + +# Command to compute system configuration. +sysconf_cmd () { + cat -- $CMP_FILE_LIST + stat -c '%s %Y %n' -- $META_FILE_LIST | awk -F/ '{print $1 " " $NF;}' +} + [ -f /etc/default/udev-cache ] && . /etc/default/udev-cache if [ "$ROOTFS_READ_ONLY" = "yes" ]; then @@ -26,13 +42,28 @@ if [ "$ROOTFS_READ_ONLY" = "yes" ]; then exit 0 fi -if [ "$DEVCACHE" != "" -a -e "$SYSCONF_TMP" ]; then - echo "Populating dev cache" +[ "$DEVCACHE" != "" ] || exit 0 +[ "${VERBOSE}" == "no" ] || echo -n "udev-cache: checking for ${DEVCACHE_REGEN}... " +if ! [ -e "$DEVCACHE_REGEN" ]; then + [ "${VERBOSE}" == "no" ] || echo "not found." + exit 0 +fi +[ "${VERBOSE}" == "no" ] || echo "found." +echo "Populating dev cache" + +( + set -e + trap 'echo "udev-cache: update failed!"' EXIT + udevadm control --stop-exec-queue + sysconf_cmd > "$SYSCONF_TMP" find /dev -xdev \( -type b -o -type c -o -type l \) | cut -c 2- \ | xargs tar cf "${DEVCACHE_TMP}" -T- gzip < "${DEVCACHE_TMP}" > "$DEVCACHE" rm -f "${DEVCACHE_TMP}" mv "$SYSCONF_TMP" "$SYSCONF_CACHED" -fi + udevadm control --start-exec-queue + rm -f "$DEVCACHE_REGEN" + trap - EXIT +) & exit 0 |