New: Added auto-mount for USB and SD Card (mdev) (for 2011.05)
https://bugs.busybox.net/show_bug.cgi?id=3811
Summary: Added auto-mount for USB and SD Card (mdev) (for
2011.05)
Product: buildroot
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P5
Component: Other
AssignedTo: unassigned at buildroot.uclibc.org
ReportedBy: tkazmierczak at eurofunk.com
CC: buildroot at uclibc.org
Estimated Hours: 0.0
Works great for me :)
package/busybox/S10mdev +1 -0
@@ -6,6 +6,7 @@ case "$1" in start) echo "Starting mdev..." + /bin/echo /sbin/mdev > /proc/sys/kernel/hotplug /sbin/mdev -s ;; stop)
package/busybox/automount.sh new file +34 -0
@@ -0,0 +1,34 @@ +#! /bin/sh + +if [ "$1" == "" ]; then + exit 1 +fi + +mounted=`mount | grep $1 | wc -l` + +# mounted, assume we umount +if [ $mounted -ge 1 ]; then + if ! umount "/dev/$1"; then + exit 1 + fi + + if ! rmdir "/media/$1"; then + exit 1 + fi +# not mounted, lets mount under /media +else + if ! mkdir -p "/media/$1"; then + exit 1 + fi + + if ! mount -o sync "/dev/$1" "/media/$1"; then + # failed to mount, clean up mountpoint + if ! rmdir "/media/$1"; then + exit 1 + fi + exit 1 + fi +fi + +exit 0 +
package/busybox/busybox.mk +2 -0
@@ -32,6 +32,8 @@ endif ifeq ($(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV),y) define BUSYBOX_INSTALL_MDEV_SCRIPT install -m 0755 package/busybox/S10mdev $(TARGET_DIR)/etc/init.d + install -m 0755 package/busybox/mdev.conf $(TARGET_DIR)/etc + install -m 0755 package/busybox/automount.sh $(TARGET_DIR)/sbin endef define BUSYBOX_SET_MDEV $(call KCONFIG_ENABLE_OPT,CONFIG_MDEV,$(BUSYBOX_BUILD_CONFIG))
package/busybox/mdev.conf new file +2 -0
@@ -0,0 +1,2 @@ +sd[a-z][0-9]* 0:0 0660 *(/sbin/automount.sh $MDEV) +mmcblk[0-9]p[0-9] 0:0 0660 *(/sbin/automount.sh $MDEV)
Signature · 3 lines
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
Dnia 2011-06-01, ?ro o godzinie 13:28 +0000, bugzilla at busybox.net pisze:
Quoted 18 lines
https://bugs.busybox.net/show_bug.cgi?id=3811
Summary: Added auto-mount for USB and SD Card (mdev) (for
2011.05)
Product: buildroot
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P5
Component: Other
AssignedTo: unassigned at buildroot.uclibc.org
ReportedBy: tkazmierczak at eurofunk.com
CC: buildroot at uclibc.org
Estimated Hours: 0.0
Quoted 1 line
Works great for me :)
Great! Thats exactly what I need :) Will try to test it this month. Thanks!
Signature · 4 lines
Patryk "LeadMan" Benderz Linux Registered User #377521 () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments
Some comments on your automount.sh changes:
Quoted 1 line
+#!
/bin/sh
No space after #!
Quoted 1 line
+mounted=
mount | grep $1 | wc -l
mounted=$(grep -c "^/dev/$1 " /proc/mounts)
$() is clearer than ``.
Less processes is better than more.
Use a full pattern so you don't accidently match sda against /dev/sda1 or other sub-matches (sda1 vs sda11).
package/busybox/automount.sh line 13
Quoted 5 lines
package/busybox/automount.sh new file +5
-0+# mounted, assume we umount +if [ $mounted -ge 1 ]; then + if ! umount "/dev/$1"; then + exit 1 + fi
If something is mounted more than once, you unmount it only once. So why it it necessary to know how many times it is mounted?
if grep -qs "^/dev/$1 " /proc/mounts ; then
is simplier and more idiomatic. You can then get rid of mounted=... above.
package/busybox/automount.sh line 22
Quoted 9 lines
package/busybox/automount.sh new file +9
-0+ + if ! rmdir "/media/$1"; then + exit 1 + fi +# not mounted, lets mount under /media +else + if ! mkdir -p "/media/$1"; then + exit 1 + fi
Why remove the directory, only to re-create it again?
package/busybox/automount.sh line 29
Quoted 7 lines
package/busybox/automount.sh new file +7
-0+ + if ! mount -o sync "/dev/$1" "/media/$1"; then + # failed to mount, clean up mountpoint + if ! rmdir "/media/$1"; then + exit 1 + fi + exit 1
Why test the result of rmdir if you are just going to exit 1 anyway?
rmdir "/media/$1"
exit 1
Quoted 13 lines
package/busybox/automount.sh new file +5
-0+ fi +fi + +exit 0 +package/busybox/busybox.mk +0
-0@@ -32,6 +32,8 @@ endif ifeq ($(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV),y)define
BUSYBOX_INSTALL_MDEV_SCRIPTinstall -m 0755 package/busybox/S10mdev $(TARGET_DIR)/etc/init.d
package/busybox/busybox.mk endif · line 36
Quoted 2 lines
package/busybox/busybox.mk +2
-0+ install -m 0755 package/busybox/mdev.conf $(TARGET_DIR)/etc + install -m 0755 package/busybox/automount.sh $(TARGET_DIR)/sbin
Since automount.sh is a helper program for mdev, not a general-purpose program, it should probably live in /lib/mdev and not /sbin.
Quoted 11 lines
endef
defineBUSYBOX_SET_MDEV$(call KCONFIG_ENABLE_OPT,CONFIG_MDEV,$(BUSYBOX_BUILD_CONFIG))package/busybox/mdev.conf new file +2
-0@@ -0,0 +1,2 @@ +sd[a-z][0-9]* 0:0 0660 *(/sbin/automount.sh $MDEV) +mmcblk[0-9]p[0-9] 0:0 0660 *(/sbin/automount.sh $MDEV)
[Buildroot] [Bug 3811] Added auto-mount for USB and SD Card (mdev) (for 2011.05)
In reply to bugzilla at busybox.nethttps://bugs.busybox.net/show_bug.cgi?id=3811
--- Comment #1 from Thomas De Schampheleire <[email protected]> 2014-02-08 20:53:25 UTC --- In my opinion, this script/proposal is very project-specific and does not need
to be part of mainline buildroot. What is the opinion of other buildroot
developers?
If you agree, I would propose to close this bug as Resolved/Wontfix.
Signature · 3 lines
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
[Buildroot] [Bug 3811] Added auto-mount for USB and SD Card (mdev) (for 2011.05)
In reply to bugzilla at busybox.nethttps://bugs.busybox.net/show_bug.cgi?id=3811
Thomas De Schampheleire <[email protected]> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |WONTFIX--- Comment #2 from Thomas De Schampheleire <[email protected]> 2014-02-10 17:56:42 UTC --- Other buildroot developers agree that this patch is very project specific and
should not be applied to mainline buildroot.
Please consider using a post-build script or rootfs overlay to achieve the same effect. See the buildroot manual for more information:
http://buildroot.uclibc.org/downloads/manual/manual.html#_customization
Signature · 3 lines
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.