Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Andy Ross <andy.ross@windriver.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 2/2] udev-extraconf: Don't mount root filesystem under /media
Date: Tue, 18 Sep 2012 14:38:45 -0700	[thread overview]
Message-ID: <1348004325-30668-3-git-send-email-andy.ross@windriver.com> (raw)
In-Reply-To: <1348004325-30668-2-git-send-email-andy.ross@windriver.com>

The mount.sh handler attempts to prevent already-mounted filesystems
from being mounted as dynamic/removable "/media".  But it misses the
case where the kernel has mounted the root filesystem (e.g. with
"root=/dev/sda1").  In that situation, /proc/mounts has a device name
of "/dev/root" instead of the proper $DEVNAME string exposed by udev.
So we must also test the root filesystem device number vs. the
$MAJOR/$MINOR udev tells us.

Signed-off-by: Andy Ross <andy.ross@windriver.com>
---
 meta/recipes-core/udev/udev-extraconf/mount.sh | 8 ++++++--
 meta/recipes-core/udev/udev-extraconf_1.0.bb   | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/meta/recipes-core/udev/udev-extraconf/mount.sh b/meta/recipes-core/udev/udev-extraconf/mount.sh
index 2eb9aff..99c76b2 100644
--- a/meta/recipes-core/udev/udev-extraconf/mount.sh
+++ b/meta/recipes-core/udev/udev-extraconf/mount.sh
@@ -49,8 +49,12 @@ if [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ]; 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 can show up as
+	# /dev/root in /proc/mounts, so check the device number too)
+	if expr $MAJOR "*" 256 + $MINOR != `stat -c %d /`; then
+		grep -q "^$DEVNAME " /proc/mounts || automount
+	fi
 fi
 
 
diff --git a/meta/recipes-core/udev/udev-extraconf_1.0.bb b/meta/recipes-core/udev/udev-extraconf_1.0.bb
index 9995899..2c4a4f1 100644
--- a/meta/recipes-core/udev/udev-extraconf_1.0.bb
+++ b/meta/recipes-core/udev/udev-extraconf_1.0.bb
@@ -6,7 +6,7 @@ LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3
 
 inherit allarch
 
-PR = "r6"
+PR = "r7"
 
 SRC_URI = " \
        file://automount.rules \
-- 
1.7.11.4




  reply	other threads:[~2012-09-18 21:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-18 21:38 [PATCH 0/2] udev-extraconf: Don't mount root filesystem under /media Andy Ross
2012-09-18 21:38 ` [PATCH 1/2] busybox: add /usr/bin/stat applet Andy Ross
2012-09-18 21:38   ` Andy Ross [this message]
2012-09-18 22:25     ` [PATCH 2/2] udev-extraconf: Don't mount root filesystem under /media Saul Wold
2012-09-18 22:33       ` Andy Ross
2012-10-11 20:28         ` Randy MacLeod

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1348004325-30668-3-git-send-email-andy.ross@windriver.com \
    --to=andy.ross@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox