]> code.ossystems Code Review - openembedded-core.git/commitdiff
udev-cache: Update cache tarball atomically
authorRichard Tollerton <rich.tollerton@ni.com>
Fri, 22 Aug 2014 21:30:47 +0000 (16:30 -0500)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 23 Aug 2014 22:01:34 +0000 (23:01 +0100)
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.

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>
meta/recipes-core/udev/udev/udev-cache

index db5a513e14a8083c39d15ef56a3a81644edd09db..c08cef2eed77fd64801e6ae62f31e602444682f6 100644 (file)
@@ -16,6 +16,7 @@ export TZ=/etc/localtime
 [ -d /sys/class ] || exit 1
 
 [ -f /etc/default/rcS ] && . /etc/default/rcS
+DEVCACHE_TMP="/dev/shm/udev-cache-tmp.tar"
 [ -f /etc/default/udev-cache ] && . /etc/default/udev-cache
 
 if [ "$ROOTFS_READ_ONLY" = "yes" ]; then
@@ -25,7 +26,8 @@ fi
 
 if [ "$DEVCACHE" != "" -a -e /dev/shm/udev.cache ]; then
        echo "Populating dev cache"
-       (cd /; tar cf "$DEVCACHE" dev)
+       (cd /; tar cf "${DEVCACHE_TMP}" dev)
+       mv -f "${DEVCACHE_TMP}" "$DEVCACHE"
        mv /dev/shm/udev.cache /etc/udev/cache.data
 fi