Patchwork [2/2] udev-extraconf: Don't mount root filesystem under /media

login
register
mail settings
Submitter Andy Ross
Date Sept. 18, 2012, 9:38 p.m.
Message ID <1348004325-30668-3-git-send-email-andy.ross@windriver.com>
Download mbox | patch
Permalink /patch/36853/
State Accepted
Commit e281bb3e35ca7ffabaa6742c126fd6f6079c000f
Headers show

Comments

Andy Ross - Sept. 18, 2012, 9:38 p.m.
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(-)
Saul Wold - Sept. 18, 2012, 10:25 p.m.
On 09/18/2012 02:38 PM, Andy Ross wrote:
> 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.
>
How much bigger does this make the busybox image?

Sau!

> 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 \
>
Andy Ross - Sept. 18, 2012, 10:33 p.m.
On 09/18/2012 03:25 PM, Saul Wold wrote:
> How much bigger does this make the busybox image?

These binaries are manually stripped and not prelinked, but probably
close enough:

-rwxr-xr-x. 1 andy andy 557312 Sep 18 15:30 busybox-r0
-rwxr-xr-x. 1 andy andy 561696 Sep 18 15:30 busybox-r1

So 4k or 0.8%, basically.

Andy
Randy MacLeod - Oct. 11, 2012, 8:28 p.m.
On 12-09-18 06:33 PM, Andy Ross wrote:
> On 09/18/2012 03:25 PM, Saul Wold wrote:
>> How much bigger does this make the busybox image?
>
> These binaries are manually stripped and not prelinked, but probably
> close enough:
>
> -rwxr-xr-x. 1 andy andy 557312 Sep 18 15:30 busybox-r0
> -rwxr-xr-x. 1 andy andy 561696 Sep 18 15:30 busybox-r1
>
> So 4k or 0.8%, basically.
>
> Andy
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
>
>

Any news on this being added? I know there's a 1.3 release to get out
so I'm just wondering if we should expect silence then
a flurry of merges after 1.3 is declared in the couple of weeks.

Thanks,

Patch

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 \