[oe] [RFC Patch] initscripts-1.0 checkroot: fix rootfs identification

Brian Bloniarz phunge0 at hotmail.com
Thu Jul 2 13:59:28 UTC 2009


Hi Phil, I had a question about the checkroot script from initscripts-1.0.

>ROOTFSDEV="/dev/root"
>if ! grep -q "^$ROOTFSDEV\w" /proc/mounts; then
>  ROOTFSDEV="rootfs"
>fi
>if [ x$(grep "^$ROOTFSDEV\w" /proc/mounts | awk '{print $4}') = "xrw" ]; then
>	echo "Root filesystem already read-write, not remounting"
>	exit 0
>fi

If this code is intended to look for the rootfs dev, I don't think \w (word
character) is right. grep "^/dev/root\w" doesn't match "/dev/root", it matches
stuff like "/dev/rootf". Was this intended?  It looks like this change was from
8f5f3f87a526b585717f3064a8db5a2e6ae849ec: "initscripts: tweak mtab reading in
checkroot.sh so that r/w ramdisk works on epia"

The following patch greps for \> instead (end of word). I also changed it
so that it doesn't hardcode the assumption that the rootfs is about to
be remounted read-write, in case the fstab has the root as RO.

Thanks for all your hard work on OpenEmbedded. Let me know if this sounds OK,
I'll resubmit with a changelog & Signed-off-by.

Thanks,
Brian Bloniarz

diff --git a/recipes/initscripts/initscripts-1.0/checkroot b/recipes/initscripts/initscripts-1.0/checkroot
index e5aa9aa..7ad00d0 100755
--- a/recipes/initscripts/initscripts-1.0/checkroot
+++ b/recipes/initscripts/initscripts-1.0/checkroot
@@ -182,6 +182,15 @@ else
   fi
 fi
 
+ROOTFSDEV="/dev/root"
+if ! grep -q "^$ROOTFSDEV\>" /proc/mounts; then
+  ROOTFSDEV="rootfs"
+fi
+if [ x$(grep "^$ROOTFSDEV\>" /proc/mounts | awk '{print $4}') = "x$rootmode" ]; then
+	echo "Root filesystem already $rootmode, not remounting"
+	exit 0
+fi
+
 #
 #	If the root filesystem was not marked as read-only in /etc/fstab,
 #	remount the rootfs rw but do not try to change mtab because it
@@ -189,15 +198,6 @@ fi
 #	and finally write the new mtab.
 #	This part is only needed if the rootfs was mounted ro.
 #
-ROOTFSDEV="/dev/root"
-if ! grep -q "^$ROOTFSDEV\w" /proc/mounts; then
-  ROOTFSDEV="rootfs"
-fi
-if [ x$(grep "^$ROOTFSDEV\w" /proc/mounts | awk '{print $4}') = "xrw" ]; then
-	echo "Root filesystem already read-write, not remounting"
-	exit 0
-fi
-
 echo "Remounting root file system..."
 mount -n -o remount,$rootmode /
 if test "$rootmode" = rw




More information about the Openembedded-devel mailing list