Patchwork [1/1] initscripts: update populate-volatile.sh

login
register
mail settings
Submitter Kang Kai
Date June 19, 2014, 7:31 a.m.
Message ID <33b60242a24e4a5b0f906dd2b00dcf147a324cb8.1403162980.git.kai.kang@windriver.com>
Download mbox | patch
Permalink /patch/74055/
State New
Headers show

Comments

Kang Kai - June 19, 2014, 7:31 a.m.
If a partition such as /tmp mounted on a volatile directory which create
by script populate-volatile.sh from initscripts, it will show errors.

In /var/log/boot, error message:

Thu Jun 19 05:39:09 2014: bootlogd.
Thu Jun 19 05:39:10 2014: rm: cannot remove '/tmp': Device or resource busy

Check volatile directories and if it is be mounted then don't force make
it as a link.

Signed-off-by: Kai Kang <kai.kang@windriver.com>
---
 .../initscripts/initscripts-1.0/populate-volatile.sh           | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Patch

diff --git a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
index e707b20..904037e 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
@@ -72,10 +72,12 @@  link_file() {
 	if [ -L \"$2\" ]; then
 		[ \"\$(readlink -f \"$2\")\" != \"\$(readlink -f \"$1\")\" ] && { rm -f \"$2\"; ln -sf \"$1\" \"$2\"; };
 	elif [ -d \"$2\" ]; then
-		cp -a $2/* $1 2>/dev/null;
-		cp -a $2/.[!.]* $1 2>/dev/null;
-		rm -rf \"$2\";
-		ln -sf \"$1\" \"$2\";
+		if awk '\$2 == \"$2\" {exit 1}' /proc/mounts; then
+			cp -a $2/* $1 2>/dev/null;
+			cp -a $2/.[!.]* $1 2>/dev/null;
+			rm -rf \"$2\";
+			ln -sf \"$1\" \"$2\";
+		fi
 	else
 		ln -sf \"$1\" \"$2\";
 	fi