path: root/meta
diff options
authorRandy Witt <randy.e.witt@linux.intel.com>2015-03-24 10:26:36 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-03-24 17:52:43 +0000
commitb574ac6f3c9e07f0054ed4261bc1f83583c29c53 (patch)
tree8555fa8ccb2697b06e3431d21d3cc91c0c3c211f /meta
parent98230d2d049c742c349f35b256b13afbc3d26235 (diff)
image.bbclass: Empty /var/volatile if it is a mount point
If /var/volatile is a mount point it shouldn't contain any files before mount time. If files are there, they will no longer be able to be accessed once the tmpfs gets mounted at /var/volatile. This problem can be seen for instance when systemd creates /var/volatile/log/journal as part of its package installation. It then assumes the journal is persistent even though /var/volatile/log/journal goes away shortly thereafter. This change makes sure that there are no files in /var/volatile if it is to be used as a mount point. [Yocto #7388] Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
1 files changed, 18 insertions, 0 deletions
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index cd1783770b..03cbbf7a91 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -181,6 +181,8 @@ POSTINST_LOGFILE ?= "${localstatedir}/log/postinstall.log"
SYSTEMD_DEFAULT_TARGET ?= '${@bb.utils.contains("IMAGE_FEATURES", "x11-base", "graphical.target", "multi-user.target", d)}'
ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("DISTRO_FEATURES", "systemd", "set_systemd_default_target; ", "", d)}'
+ROOTFS_POSTPROCESS_COMMAND += 'empty_var_volatile;'
# some default locales
IMAGE_LINGUAS ?= "de-de fr-fr en-gb"
@@ -377,6 +379,22 @@ set_systemd_default_target () {
+# If /var/volatile is not empty, we have seen problems where programs such as the
+# journal make assumptions based on the contents of /var/volatile. The journal
+# would then write to /var/volatile before it was mounted, thus hiding the
+# items previously written.
+# This change is to attempt to fix those types of issues in a way that doesn't
+# affect users that may not be using /var/volatile.
+empty_var_volatile () {
+ if [ -e ${IMAGE_ROOTFS}/etc/fstab ]; then
+ match=`awk '$1 !~ "#" && $2 ~ /\/var\/volatile/{print $2}' ${IMAGE_ROOTFS}/etc/fstab 2> /dev/null`
+ if [ -n "$match" ]; then
+ find ${IMAGE_ROOTFS}/var/volatile -mindepth 1 -delete
+ fi
+ fi
# Turn any symbolic /sbin/init link into a file
remove_init_link () {
if [ -h ${IMAGE_ROOTFS}/sbin/init ]; then