Patchwork udev: Don't remount root filesystem under /media

login
register
mail settings
Submitter Andy Ross
Date Aug. 10, 2012, 7 p.m.
Message ID <1344625255-15337-1-git-send-email-andy.ross@windriver.com>
Download mbox | patch
Permalink /patch/34279/
State New
Headers show

Comments

Andy Ross - Aug. 10, 2012, 7 p.m.
The existing logic to avoid mounting already-mounted filesystems
breaks for a kernel-mounted root, which appears as /dev/root in
/proc/mounts.  The effect is that an image booted with
e.g. "root=/dev/mmcblk0p1" will find its root filesystem remount rw
under /media/mmcblk0p1 at boot.

Signed-off-by: Andy Ross <andy.ross@windriver.com>
---
 meta/recipes-core/udev/udev/mount.sh | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Patch

diff --git a/meta/recipes-core/udev/udev/mount.sh b/meta/recipes-core/udev/udev/mount.sh
index c13b8bb..61d14a3 100644
--- a/meta/recipes-core/udev/udev/mount.sh
+++ b/meta/recipes-core/udev/udev/mount.sh
@@ -49,9 +49,15 @@  if [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ]; then
 	elif [ -x $MOUNT ]; then
     		$MOUNT $DEVNAME 2> /dev/null
 	fi
-	
-	# If the device isn't mounted at this point, it isn't configured in fstab
-	grep -q "^$DEVNAME " /proc/mounts || automount
+
+	# If the device isn't mounted at this point, it isn't
+	# configured in fstab (note the root filesystem shows up as
+	# /dev/root in /proc/mounts, so parse the command line for
+	# that case)
+	root=`sed 's/\(^\|.* \)root=\([^ ]*\).*/\2/' /proc/cmdline`
+	if [ "$root" != "$DEVNAME" ]; then
+		grep -q "^$DEVNAME " /proc/mounts || automount
+	fi
 fi