diff options
author | Richard Tollerton <rich.tollerton@ni.com> | 2014-08-22 16:30:47 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-08-23 23:01:34 +0100 |
commit | 5dbf43fe32a1cf259f9379a7d2c008260eabf3ac (patch) | |
tree | 702284a6b5ecf668582ed8184825c494ebbdcbaf /meta | |
parent | fe2f51571f97e2cceae974f6a18782025e080c32 (diff) | |
download | openembedded-core-5dbf43fe32a1cf259f9379a7d2c008260eabf3ac.tar.gz openembedded-core-5dbf43fe32a1cf259f9379a7d2c008260eabf3ac.tar.bz2 openembedded-core-5dbf43fe32a1cf259f9379a7d2c008260eabf3ac.zip |
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.
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>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/recipes-core/udev/udev/udev-cache | 4 |
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 [ -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 |