* [PATCH 0/2] udev-extraconf: Don't mount root filesystem under /media @ 2012-09-18 21:38 Andy Ross 2012-09-18 21:38 ` [PATCH 1/2] busybox: add /usr/bin/stat applet Andy Ross 0 siblings, 1 reply; 6+ messages in thread From: Andy Ross @ 2012-09-18 21:38 UTC (permalink / raw) To: openembedded-core When you boot an image with a kernel-mounted root filesystem (e.g. "root=/dev/sda1" or the like), the root filesystem also appears as a read-write filesystem under /media. The fix has two parts: 2. Modify the mount.sh hook to test the root filesystem device number instead of the name (which won't match "/dev/root"). 1. ...but that breaks on images which use busybox and lack coreutils, because there is no stat binary. Add this to the busybox defconfig, and patch it to live in /usr/bin instead of /bin to match the coreutils path. Andy ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] busybox: add /usr/bin/stat applet 2012-09-18 21:38 [PATCH 0/2] udev-extraconf: Don't mount root filesystem under /media Andy Ross @ 2012-09-18 21:38 ` Andy Ross 2012-09-18 21:38 ` [PATCH 2/2] udev-extraconf: Don't mount root filesystem under /media Andy Ross 0 siblings, 1 reply; 6+ messages in thread From: Andy Ross @ 2012-09-18 21:38 UTC (permalink / raw) To: openembedded-core The busybox defconfig lacks a stat tool, the functionality of which cannot be reproduced in a way accessible to a shell script running in a minimal configuration. Enable, and modify the installation path to /usr/bin/stat to match the coreutils tool for proper alternatives handling. Signed-off-by: Andy Ross <andy.ross@windriver.com> --- meta/recipes-core/busybox/busybox-1.20.2/defconfig | 4 ++-- .../busybox/busybox-1.20.2/stat-usr-bin.patch | 21 +++++++++++++++++++++ meta/recipes-core/busybox/busybox_1.20.2.bb | 5 +++-- 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 meta/recipes-core/busybox/busybox-1.20.2/stat-usr-bin.patch diff --git a/meta/recipes-core/busybox/busybox-1.20.2/defconfig b/meta/recipes-core/busybox/busybox-1.20.2/defconfig index dff07f1..b39234f 100644 --- a/meta/recipes-core/busybox/busybox-1.20.2/defconfig +++ b/meta/recipes-core/busybox/busybox-1.20.2/defconfig @@ -270,8 +270,8 @@ CONFIG_SORT=y CONFIG_FEATURE_SORT_BIG=y # CONFIG_SPLIT is not set # CONFIG_FEATURE_SPLIT_FANCY is not set -# CONFIG_STAT is not set -# CONFIG_FEATURE_STAT_FORMAT is not set +CONFIG_STAT=y +CONFIG_FEATURE_STAT_FORMAT=y CONFIG_STTY=y # CONFIG_SUM is not set CONFIG_SYNC=y diff --git a/meta/recipes-core/busybox/busybox-1.20.2/stat-usr-bin.patch b/meta/recipes-core/busybox/busybox-1.20.2/stat-usr-bin.patch new file mode 100644 index 0000000..4049324 --- /dev/null +++ b/meta/recipes-core/busybox/busybox-1.20.2/stat-usr-bin.patch @@ -0,0 +1,21 @@ +busybox: move /bin/stat to /usr/bin/stat to match coreutils + +The coreutils stat binary lives in /usr/bin, fix busybox to use the same path so +they can be properly tracked by alternatives. + +Upstream-Status: Inappropriate [embedded] +Signed-off-by: Andy Ross <andy.ross@windriver.com> + +diff --git a/include/applets.src.h b/include/applets.src.h +index 0d33bfc..30ae3ad 100644 +--- a/include/applets.src.h ++++ b/include/applets.src.h +@@ -340,7 +340,7 @@ IF_SOFTLIMIT(APPLET_ODDNAME(softlimit, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, soft + IF_SORT(APPLET_NOEXEC(sort, sort, BB_DIR_USR_BIN, BB_SUID_DROP, sort)) + IF_SPLIT(APPLET(split, BB_DIR_USR_BIN, BB_SUID_DROP)) + IF_START_STOP_DAEMON(APPLET_ODDNAME(start-stop-daemon, start_stop_daemon, BB_DIR_SBIN, BB_SUID_DROP, start_stop_daemon)) +-IF_STAT(APPLET(stat, BB_DIR_BIN, BB_SUID_DROP)) ++IF_STAT(APPLET(stat, BB_DIR_USR_BIN, BB_SUID_DROP)) + IF_STRINGS(APPLET(strings, BB_DIR_USR_BIN, BB_SUID_DROP)) + IF_STTY(APPLET(stty, BB_DIR_BIN, BB_SUID_DROP)) + /* Needs to be run by root or be suid root - needs to change uid and gid: */ diff --git a/meta/recipes-core/busybox/busybox_1.20.2.bb b/meta/recipes-core/busybox/busybox_1.20.2.bb index ced04d2..2251383 100644 --- a/meta/recipes-core/busybox/busybox_1.20.2.bb +++ b/meta/recipes-core/busybox/busybox_1.20.2.bb @@ -1,5 +1,5 @@ require busybox.inc -PR = "r0" +PR = "r1" SRC_URI = "http://www.busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \ file://B921600.patch \ @@ -26,7 +26,8 @@ SRC_URI = "http://www.busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \ file://defconfig \ file://busybox-mkfs-minix-tests_bigendian.patch \ file://fix-for-spurious-testsuite-failure.patch \ - file://busybox-1.20.2-kernel_ver.patch" + file://busybox-1.20.2-kernel_ver.patch \ + file://stat-usr-bin.patch" SRC_URI[tarball.md5sum] = "e025414bc6cd79579cc7a32a45d3ae1c" SRC_URI[tarball.sha256sum] = "eb13ff01dae5618ead2ef6f92ba879e9e0390f9583bd545d8789d27cf39b6882" -- 1.7.11.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] udev-extraconf: Don't mount root filesystem under /media 2012-09-18 21:38 ` [PATCH 1/2] busybox: add /usr/bin/stat applet Andy Ross @ 2012-09-18 21:38 ` Andy Ross 2012-09-18 22:25 ` Saul Wold 0 siblings, 1 reply; 6+ messages in thread From: Andy Ross @ 2012-09-18 21:38 UTC (permalink / raw) To: openembedded-core 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 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] udev-extraconf: Don't mount root filesystem under /media 2012-09-18 21:38 ` [PATCH 2/2] udev-extraconf: Don't mount root filesystem under /media Andy Ross @ 2012-09-18 22:25 ` Saul Wold 2012-09-18 22:33 ` Andy Ross 0 siblings, 1 reply; 6+ messages in thread From: Saul Wold @ 2012-09-18 22:25 UTC (permalink / raw) To: Andy Ross; +Cc: openembedded-core 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 \ > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] udev-extraconf: Don't mount root filesystem under /media 2012-09-18 22:25 ` Saul Wold @ 2012-09-18 22:33 ` Andy Ross 2012-10-11 20:28 ` Randy MacLeod 0 siblings, 1 reply; 6+ messages in thread From: Andy Ross @ 2012-09-18 22:33 UTC (permalink / raw) To: Saul Wold; +Cc: openembedded-core 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] udev-extraconf: Don't mount root filesystem under /media 2012-09-18 22:33 ` Andy Ross @ 2012-10-11 20:28 ` Randy MacLeod 0 siblings, 0 replies; 6+ messages in thread From: Randy MacLeod @ 2012-10-11 20:28 UTC (permalink / raw) To: openembedded-core 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, -- # Randy MacLeod. SMTS, Linux, Wind River Direct: 613.963.1350 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-10-11 23:14 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 ` [PATCH 2/2] udev-extraconf: Don't mount root filesystem under /media Andy Ross 2012-09-18 22:25 ` Saul Wold 2012-09-18 22:33 ` Andy Ross 2012-10-11 20:28 ` Randy MacLeod
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox