mdev: Add auto-mounting support for USB and SD card
PATCH 1/1 mdev: Add auto-mounting support for USB and SD card
this will mount the device in /media as
/media/${MDEV}
--- fs/skeleton/etc/fstab | 1 + package/busybox/automount.sh | 33 +++++++++++++++++++++++++++++++++ package/busybox/busybox.mk | 3 +++ package/busybox/mdev.conf | 4 ++++ 4 files changed, 41 insertions(+), 0 deletions(-) create mode 100644 fs/skeleton/media/.empty create mode 100644 package/busybox/automount.sh
fs/skeleton/etc/fstab +1 -0
@@ -6,4 +6,5 @@ proc /proc proc defaults 0 0 devpts /dev/pts devpts defaults,gid=5,mode=620 0 0 tmpfs /dev/shm tmpfs mode=0777 0 0 tmpfs /tmp tmpfs defaults 0 0 +tmpfs /media tmpfs defaults 0 0 sysfs /sys sysfs defaults 0 0
fs/skeleton/media/.empty new file +0 -0
package/busybox/automount.sh new file +33 -0
@@ -0,0 +1,33 @@ +#!/bin/sh + +destdir=/media + +eumount() +{ + if grep -qs "^/dev/$1 " /proc/mounts ; then + umount "${destdir}/$1"; + fi + + [ -d "${destdir}/$1" ] && rmdir "${destdir}/$1" +} + +emount() +{ + mkdir -p "${destdir}/$1" || exit 1 + + if ! mount -t auto -o sync "/dev/$1" "${destdir}/$1"; then + # failed to mount, clean up mountpoint + rmdir "${destdir}/$1" + exit 1 + fi +} + +case "${ACTION}" in +add|"") + eumount ${MDEV} + emount ${MDEV} + ;; +remove) + eumount ${MDEV} + ;; +esac
package/busybox/busybox.mk +3 -0
@@ -37,6 +37,9 @@ define BUSYBOX_INSTALL_MDEV_CONF [ -f $(TARGET_DIR)/etc/mdev.conf ] || \ install -D -m 0644 package/busybox/mdev.conf \ $(TARGET_DIR)/etc/mdev.conf + [ -f $(TARGET_DIR)/etc/automount.sh ] || \ + install -D -m 0644 package/busybox/automount.sh \ + $(TARGET_DIR)/lib/mdev/automount.sh endef define BUSYBOX_SET_MDEV $(call KCONFIG_ENABLE_OPT,CONFIG_MDEV,$(BUSYBOX_BUILD_CONFIG))
package/busybox/mdev.conf +4 -0
@@ -33,3 +33,7 @@ event[0-9]+ root:root 640 =input/ mice root:root 640 =input/ mouse[0-9] root:root 640 =input/ ts[0-9] root:root 600 =input/ + +# block devices +sd[a-z][0-9]* root:root 0660 */lib/mdev/automount.sh +mmcblk[0-9]p[0-9] root:root 0660 */lib/mdev/automount.sh
Signature · 1 line
1.7.5.4
PATCH 1/1 mdev: Add auto-mounting support for USB and SD card
Quoted 2 lines · Jean-Christophe PLAGNIOL-VILLARD
this will mount the device in /media as
/media/${MDEV}
I'd make it an option, there are many scenarios where you don't want devices automounting media.
Regards.
PATCH 1/1 mdev: Add auto-mounting support for USB and SD card
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Gustavo" == Gustavo Zacarias <[email protected]> writes:
Gustavo> On Sat, 27 Aug 2011 06:26:22 +0200, Jean-Christophe PLAGNIOL-VILLARD
Quoted 2 lines · Gustavo> wrote:
Quoted 2 lines
this will mount the device in /media as
/media/${MDEV}
Gustavo> I'd make it an option, there are many scenarios where you don't want Gustavo> devices automounting media.
Gustavo> Regards.
Agreed, something like the usbmount package we have for udev.
Signature · 1 line
Bye, Peter Korsgaard