summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core
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:42 +0100
commit1dff47b097615771bc144f14c31ea137aa562c70 (patch)
tree6bf9a4655736a4bf8be4c73c811cefce01554bfc /meta/recipes-core
parente6e44cf9c10116b9bd2260eb344031d9b897f669 (diff)
downloadpoky-1dff47b097615771bc144f14c31ea137aa562c70.tar.gz
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] (From OE-Core rev: 86ac10995fd08226f82d87e23fda5d4898c3190f) Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core')
-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 @@
4 4
5[ "$ROOTFS_READ_ONLY" = "no" ] && exit 0 5[ "$ROOTFS_READ_ONLY" = "no" ] && exit 0
6 6
7is_on_read_only_partition () {
8 DIRECTORY=$1
9 dir=`readlink -f $DIRECTORY`
10 while true; do
11 if [ ! -d "$dir" ]; then
12 echo "ERROR: $dir is not a directory"
13 exit 1
14 else
15 for flag in `awk -v dir=$dir '{ if ($2 == dir) { print "FOUND"; split($4,FLAGS,",") } }; \
16 END { for (f in FLAGS) print FLAGS[f] }' < /proc/mounts`; do
17 [ "$flag" = "FOUND" ] && partition="read-write"
18 [ "$flag" = "ro" ] && { partition="read-only"; break; }
19 done
20 if [ "$dir" = "/" -o -n "$partition" ]; then
21 break
22 else
23 dir=`dirname $dir`
24 fi
25 fi
26 done
27 [ "$partition" = "read-only" ] && echo "yes" || echo "no"
28}
29
7if [ "$1" = "start" ] ; then 30if [ "$1" = "start" ] ; then
8 grep -q "tmpfs /var/volatile" /proc/mounts || mount /var/volatile 31 if [ `is_on_read_only_partition /var/lib` = "yes" ]; then
9 mkdir -p /var/volatile/lib 32 grep -q "tmpfs /var/volatile" /proc/mounts || mount /var/volatile
10 cp -a /var/lib/* /var/volatile/lib 33 mkdir -p /var/volatile/lib
11 mount --bind /var/volatile/lib /var/lib 34 cp -a /var/lib/* /var/volatile/lib
35 mount --bind /var/volatile/lib /var/lib
36 fi
12fi 37fi
13 38