[oe-commits] Richard Tollerton : udev-cache: Update cache tarball atomically
git at git.openembedded.org
git at git.openembedded.org
Sat Aug 23 12:31:17 UTC 2014
Module: openembedded-core.git
Branch: master-next
Commit: 79291347a28291ce0eb4a44662cb98c53f509743
URL: http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=79291347a28291ce0eb4a44662cb98c53f509743
Author: Richard Tollerton <rich.tollerton at ni.com>
Date: Fri Aug 22 16:30:47 2014 -0500
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 at ni.com>
Signed-off-by: Ben Shelton <ben.shelton at ni.com>
Acked-by: Gratian Crisan <gratian.crisan at ni.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
meta/recipes-core/udev/udev/udev-cache | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/meta/recipes-core/udev/udev/udev-cache b/meta/recipes-core/udev/udev/udev-cache
index db5a513..c08cef2 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
More information about the Openembedded-commits
mailing list