initscripts: Create the volatiles cache atomically.
authorJames Limbouris <james@digitalmatter.com.au>
Wed, 29 Feb 2012 01:13:46 +0000 (09:13 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 2 Mar 2012 15:22:54 +0000 (15:22 +0000)
If a machine loses power while building the volatiles cache, it will
continue to operate with an incomplete set of volatiles. Fix this by
updating atomically.

(From OE-Core rev: a60432ff4588390f5f955a6da234298e958546e6)

Signed-off-by: James Limbouris <james@digitalmatter.com.au>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
meta/recipes-core/initscripts/initscripts_1.0.bb

index 1813fd1..4a99aff 100755 (executable)
@@ -22,7 +22,7 @@ create_file() {
        chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/tty0 2>&1; 
        chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 " 
 
-       test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache
+       test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build
 
        [ -e "$1" ] && {
          [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
@@ -37,7 +37,7 @@ mk_dir() {
        chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/tty0 2>&1; 
        chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 "
 
-       test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache
+       test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build
        
        [ -e "$1" ] && {
          [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
@@ -49,7 +49,7 @@ mk_dir() {
 link_file() {
        EXEC="test -e \"$2\" -o -L $2 || ln -s \"$1\" \"$2\" >/dev/tty0 2>&1" 
 
-       test "$VOLATILE_ENABLE_CACHE" = yes && echo "   $EXEC" >> /etc/volatile.cache
+       test "$VOLATILE_ENABLE_CACHE" = yes && echo "   $EXEC" >> /etc/volatile.cache.build
        
        [ -e "$2" ] && {
          echo "Cannot create link over existing -${TNAME}-." >&2
@@ -185,10 +185,12 @@ if test -e /etc/volatile.cache -a "$VOLATILE_ENABLE_CACHE" = "yes" -a "x$1" != "
 then
        sh /etc/volatile.cache
 else   
-       rm -f /etc/volatile.cache
+       rm -f /etc/volatile.cache /etc/volatile.cache.build
        for file in `ls -1 "${CFGDIR}" | sort`; do
                apply_cfgfile "${CFGDIR}/${file}"
        done
+
+       [ -e /etc/volatile.cache.build ] && sync && mv /etc/volatile.cache.build /etc/volatile.cache
 fi
 
 if test -f /etc/ld.so.cache -a ! -f /var/run/ld.so.cache
index 68701ce..f3dc852 100644 (file)
@@ -3,7 +3,7 @@ DESCRIPTION = "Initscripts provide the basic system startup initialization scrip
 SECTION = "base"
 LICENSE = "GPLv2"
 LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
-PR = "r132"
+PR = "r133"
 
 INHIBIT_DEFAULT_DEPS = "1"