diff options
author | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
---|---|---|
committer | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
commit | c527fd1f14c27855a37f2e8ac5346ce8d940ced2 (patch) | |
tree | bb002c1fdf011c41dbd2f0927bed23ecb5f83c97 /meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh | |
download | poky-daisy-140929.tar.gz |
initial commit for Enea Linux 4.0-140929daisy-140929
Migrated from the internal git server on the daisy-enea-point-release branch
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh')
-rw-r--r-- | meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh | 38 |
1 files changed, 38 insertions, 0 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 new file mode 100644 index 0000000000..1a0328d63e --- /dev/null +++ b/meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh | |||
@@ -0,0 +1,38 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | . /etc/default/rcS | ||
4 | |||
5 | [ "$ROOTFS_READ_ONLY" = "no" ] && exit 0 | ||
6 | |||
7 | is_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 | |||
30 | if [ "$1" = "start" ] ; then | ||
31 | if [ `is_on_read_only_partition /var/lib` = "yes" ]; then | ||
32 | grep -q "tmpfs /var/volatile" /proc/mounts || mount /var/volatile | ||
33 | mkdir -p /var/volatile/lib | ||
34 | cp -a /var/lib/* /var/volatile/lib | ||
35 | mount --bind /var/volatile/lib /var/lib | ||
36 | fi | ||
37 | fi | ||
38 | |||