[OE-core] [PATCH 1/2] checkroot.sh: check for conflicting configurations

Qi.Chen at windriver.com Qi.Chen at windriver.com
Mon Aug 26 06:43:54 UTC 2013


From: Chen Qi <Qi.Chen at windriver.com>

In our current boot scripts, two ways are used to determine whether
the rootfs is read-only or not. One by checking the READ_ONLY_ROOTFS
value in /etc/default/rcS, the other by checking the /etc/fstab entry.

>From a normal Linux user's point of view, the way of checking the
/etc/fstab entry is preferred. However, as there are several boot scripts
that need to know whether rootfs is read-only or not, checking /etc/fstab
in each script brings too much overhead. Thus, these boot scripts
use the READ_ONLY_ROOTFS value in /etc/default/rcS.

In normal use cases, there would be no problem, as both /etc/default/rcS and
the /etc/fstab are modified at rootfs time. However, if the user changes
the mount option for rootfs in /etc/fstab to read-write, and he/she forgets
to change the value in /etc/default/rcS, there would be unexpected results.
For example, the udev-cache would still be disabled.

So at a minimal, a check for conflicting configurations between /etc/fstab
and /etc/default/rcS should be added in checkroot.sh so that there would be
reasonable warnings if users have configured the system in a non-consistent
way.

[YOCTO #4880]

Signed-off-by: Chen Qi <Qi.Chen at windriver.com>
---
 .../initscripts/initscripts-1.0/checkroot.sh       |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/meta/recipes-core/initscripts/initscripts-1.0/checkroot.sh b/meta/recipes-core/initscripts/initscripts-1.0/checkroot.sh
index cf84cfa..dfee2af 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/checkroot.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/checkroot.sh
@@ -54,6 +54,16 @@ do
 done
 exec 0>&9 9>&-
 
+# Check for conflicting configurations
+if [ "$rootmode" = "ro" -a "$ROOTFS_READ_ONLY" = "no" ] || \
+	[ "$rootmode" = "rw" -a "$ROOTFS_READ_ONLY" = "yes" ]; then
+	echo ""
+	echo "WARN: conflicting configurations in /etc/fstab and /etc/default/rcS"
+	echo "      regarding the writability of rootfs. Please fix one of them."
+	echo ""
+fi
+
+
 #
 # Activate the swap device(s) in /etc/fstab. This needs to be done
 # before fsck, since fsck can be quite memory-hungry.
-- 
1.7.9.5




More information about the Openembedded-core mailing list