summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/initscripts
diff options
context:
space:
mode:
authorChen Qi <Qi.Chen@windriver.com>2013-08-26 14:43:55 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-08-26 13:19:36 +0100
commit86ac10995fd08226f82d87e23fda5d4898c3190f (patch)
tree5da87d2e9d43b57579d4956ca79a56e531fdb690 /meta/recipes-core/initscripts
parent1565a0c5a3f245703e280ca90cf11d3f9374788a (diff)
downloadopenembedded-core-contrib-86ac10995fd08226f82d87e23fda5d4898c3190f.tar.gz
openembedded-core-contrib-86ac10995fd08226f82d87e23fda5d4898c3190f.tar.bz2
openembedded-core-contrib-86ac10995fd08226f82d87e23fda5d4898c3190f.zip
read-only-rootfs-hook.sh: check before bind mounting /var/lib
It's possible that /var/lib is on a separate writable partition. In such situation, we should not bind mount /var/lib with tmpfs, becasue it's already writable. This patch fixes this problem by checking whether /var/lib is already on a writable partition. [YOCTO #4888] Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/initscripts')
-rw-r--r--meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh33
1 files changed, 29 insertions, 4 deletions
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh b/meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh
index 9cf0921670..1a0328d63e 100644
--- a/meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh
@@ -4,10 +4,35 @@
[ "$ROOTFS_READ_ONLY" = "no" ] && exit 0
+is_on_read_only_partition () {
+ DIRECTORY=$1
+ dir=`readlink -f $DIRECTORY`
+ while true; do
+ if [ ! -d "$dir" ]; then
+ echo "ERROR: $dir is not a directory"
+ exit 1
+ else
+ for flag in `awk -v dir=$dir '{ if ($2 == dir) { print "FOUND"; split($4,FLAGS,",") } }; \
+ END { for (f in FLAGS) print FLAGS[f] }' < /proc/mounts`; do
+ [ "$flag" = "FOUND" ] && partition="read-write"
+ [ "$flag" = "ro" ] && { partition="read-only"; break; }
+ done
+ if [ "$dir" = "/" -o -n "$partition" ]; then
+ break
+ else
+ dir=`dirname $dir`
+ fi
+ fi
+ done
+ [ "$partition" = "read-only" ] && echo "yes" || echo "no"
+}
+
if [ "$1" = "start" ] ; then
- grep -q "tmpfs /var/volatile" /proc/mounts || mount /var/volatile
- mkdir -p /var/volatile/lib
- cp -a /var/lib/* /var/volatile/lib
- mount --bind /var/volatile/lib /var/lib
+ if [ `is_on_read_only_partition /var/lib` = "yes" ]; then
+ grep -q "tmpfs /var/volatile" /proc/mounts || mount /var/volatile
+ mkdir -p /var/volatile/lib
+ cp -a /var/lib/* /var/volatile/lib
+ mount --bind /var/volatile/lib /var/lib
+ fi
fi