Patchwork [v2,10/12] udev-cache: invalidate on rules.d changes

login
register
mail settings
Submitter Richard Tollerton
Date Aug. 22, 2014, 9:30 p.m.
Message ID <6b39f0e8a7e0d8f904828fe21cc73f09e4f2dd47.1408742574.git.rich.tollerton@ni.com>
Download mbox | patch
Permalink /patch/78831/
State New
Headers show

Comments

Richard Tollerton - Aug. 22, 2014, 9:30 p.m.
Presently, the cache is not regenerated if udev rules are modified,
which may cause the cache to preserve an old configuration. To fix,
include the size, mtime, and filename of all udev rules in the system
configuration.

This change requires `stat`. If busybox supplies stat,
CONFIG_FEATURE_STAT_FORMAT must be enabled.

Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
---
 meta/recipes-core/udev/udev/init       | 5 +++++
 meta/recipes-core/udev/udev/udev-cache | 5 +++++
 2 files changed, 10 insertions(+)

Patch

diff --git a/meta/recipes-core/udev/udev/init b/meta/recipes-core/udev/udev/init
index 10cbf56..c44dc2d 100644
--- a/meta/recipes-core/udev/udev/init
+++ b/meta/recipes-core/udev/udev/init
@@ -22,9 +22,14 @@  DEVCACHE_REGEN="/dev/shm/udev-regen" # create to request cache regen
 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 -L -c '%s %Y %n' -- $META_FILE_LIST | awk -F/ '{print $1 " " $NF;}'
 }
 [ -f /etc/default/udev-cache ] && . /etc/default/udev-cache
 [ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf
diff --git a/meta/recipes-core/udev/udev/udev-cache b/meta/recipes-core/udev/udev/udev-cache
index 5a1bc78..c499676 100644
--- a/meta/recipes-core/udev/udev/udev-cache
+++ b/meta/recipes-core/udev/udev/udev-cache
@@ -25,9 +25,14 @@  DEVCACHE_REGEN="/dev/shm/udev-regen" # create to request cache regen
 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 -L -c '%s %Y %n' -- $META_FILE_LIST | awk -F/ '{print $1 " " $NF;}'
 }
 [ -f /etc/default/udev-cache ] && . /etc/default/udev-cache