summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Tollerton <rich.tollerton@ni.com>2014-08-22 16:30:47 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-08-23 23:01:58 +0100
commitbd7fb7c3ca50b3eea2d173487f24b3006470f6df (patch)
tree242a0eece02bb6029e2011c014a33735c463670b
parent8d59fca331c982d9de35eed5ad6a86ade45531c4 (diff)
downloadpoky-bd7fb7c3ca50b3eea2d173487f24b3006470f6df.tar.gz
udev-cache: Update cache tarball atomically
Overwriting the tarball in-place could cause a partial write, if the system stops at an inopportune time. This is mitigated by first writing to a temporary file, then moving that file on top of the final location. (From OE-Core rev: 5dbf43fe32a1cf259f9379a7d2c008260eabf3ac) Signed-off-by: Richard Tollerton <rich.tollerton@ni.com> Signed-off-by: Ben Shelton <ben.shelton@ni.com> Acked-by: Gratian Crisan <gratian.crisan@ni.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-core/udev/udev/udev-cache4
1 files changed, 3 insertions, 1 deletions
diff --git a/meta/recipes-core/udev/udev/udev-cache b/meta/recipes-core/udev/udev/udev-cache
index db5a513e14..c08cef2eed 100644
--- a/meta/recipes-core/udev/udev/udev-cache
+++ b/meta/recipes-core/udev/udev/udev-cache
@@ -16,6 +16,7 @@ export TZ=/etc/localtime
16[ -d /sys/class ] || exit 1 16[ -d /sys/class ] || exit 1
17 17
18[ -f /etc/default/rcS ] && . /etc/default/rcS 18[ -f /etc/default/rcS ] && . /etc/default/rcS
19DEVCACHE_TMP="/dev/shm/udev-cache-tmp.tar"
19[ -f /etc/default/udev-cache ] && . /etc/default/udev-cache 20[ -f /etc/default/udev-cache ] && . /etc/default/udev-cache
20 21
21if [ "$ROOTFS_READ_ONLY" = "yes" ]; then 22if [ "$ROOTFS_READ_ONLY" = "yes" ]; then
@@ -25,7 +26,8 @@ fi
25 26
26if [ "$DEVCACHE" != "" -a -e /dev/shm/udev.cache ]; then 27if [ "$DEVCACHE" != "" -a -e /dev/shm/udev.cache ]; then
27 echo "Populating dev cache" 28 echo "Populating dev cache"
28 (cd /; tar cf "$DEVCACHE" dev) 29 (cd /; tar cf "${DEVCACHE_TMP}" dev)
30 mv -f "${DEVCACHE_TMP}" "$DEVCACHE"
29 mv /dev/shm/udev.cache /etc/udev/cache.data 31 mv /dev/shm/udev.cache /etc/udev/cache.data
30fi 32fi
31 33