summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/busybox/files
diff options
context:
space:
mode:
authormike.looijmans@topic.nl <mike.looijmans@topic.nl>2014-12-18 15:17:31 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-12-19 18:08:03 +0000
commit973c565a7eb6ee98b90fc5d243a9aca7d54307fe (patch)
treebc83593f400ecd008797dbea83e8d9b3cc07d9d8 /meta/recipes-core/busybox/files
parent6695f76a10d4176ceef65c88ca3e69a69a5049f0 (diff)
downloadpoky-973c565a7eb6ee98b90fc5d243a9aca7d54307fe.tar.gz
busybox-mdev: Support automatic mounting of block devices
Upon inserting a USB stick or similar device, mdev will run an automounter script that mounts valid partitions on /media/<device>. The script first checks /etc/fstab entries so that mounting on UUID or LABEL or using custom mount options is still possible. If /etc/fstab does not contain particular mount options, the script will create (and remove) the mountpoint automatically. The script also supports full disk partitions (devices without partition table). The following environments can be set in /etc/default/mdev: MDEV_AUTOMOUNT=n (Disables automounting completely) MDEV_AUTOMOUNT_ROOT=/media (Change the mount root location) Automatic mounting for a particular device can be disabled by creating a file "/dev/<device>.nomount". This is helpful in scripts that create partitions for example, and want to perform specific actions which require the device to remain unmounted. A more complex variation (using LABEL based mounts) on this script has been in use in OpenPLi for many years now, and I've used this one on many projects already, so it's about time to push this to mainline. (From OE-Core rev: 19073fb991b3e2d2304e55f94e30674adf375197) Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/busybox/files')
-rw-r--r--meta/recipes-core/busybox/files/mdev-mount.sh63
-rw-r--r--meta/recipes-core/busybox/files/mdev.conf3
2 files changed, 66 insertions, 0 deletions
diff --git a/meta/recipes-core/busybox/files/mdev-mount.sh b/meta/recipes-core/busybox/files/mdev-mount.sh
new file mode 100644
index 0000000000..d5d66d66fb
--- /dev/null
+++ b/meta/recipes-core/busybox/files/mdev-mount.sh
@@ -0,0 +1,63 @@
1#!/bin/sh
2MDEV_AUTOMOUNT=y
3MDEV_AUTOMOUNT_ROOT=/run/media
4[ -f /etc/default/mdev ] && . /etc/default/mdev
5if [ "${MDEV_AUTOMOUNT}" = "n" ] ; then
6 exit 0
7fi
8
9case "$ACTION" in
10 add|"")
11 ACTION="add"
12 # check if already mounted
13 if grep -q "^/dev/${MDEV} " /proc/mounts ; then
14 # Already mounted
15 exit 0
16 fi
17 DEVBASE=`expr substr $MDEV 1 3`
18 if [ "${DEVBASE}" == "mmc" ] ; then
19 DEVBASE=`expr substr $MDEV 1 7`
20 fi
21 # check for "please don't mount it" file
22 if [ -f "/dev/nomount.${DEVBASE}" ] ; then
23 # blocked
24 exit 0
25 fi
26 # check for full-disk partition
27 if [ "${DEVBASE}" == "${MDEV}" ] ; then
28 if [ -d /sys/block/${DEVBASE}/${DEVBASE}*1 ] ; then
29 # Partition detected, just quit
30 exit 0
31 fi
32 if [ ! -f /sys/block/${DEVBASE}/size ] ; then
33 # No size at all
34 exit 0
35 fi
36 if [ `cat /sys/block/${DEVBASE}/size` == 0 ] ; then
37 # empty device, bail out
38 exit 0
39 fi
40 fi
41 # first allow fstab to determine the mountpoint
42 if ! mount /dev/$MDEV > /dev/null 2>&1
43 then
44 MOUNTPOINT="${MDEV_AUTOMOUNT_ROOT}/$MDEV"
45 mkdir "$MOUNTPOINT"
46 mount -t auto /dev/$MDEV "$MOUNTPOINT"
47 fi
48 ;;
49 remove)
50 MOUNTPOINT=`grep "^/dev/$MDEV\s" /proc/mounts | cut -d' ' -f 2`
51 if [ ! -z "$MOUNTPOINT" ]
52 then
53 umount "$MOUNTPOINT"
54 rmdir "$MOUNTPOINT"
55 else
56 umount /dev/$MDEV
57 fi
58 ;;
59 *)
60 # Unexpected keyword
61 exit 1
62 ;;
63esac
diff --git a/meta/recipes-core/busybox/files/mdev.conf b/meta/recipes-core/busybox/files/mdev.conf
index 6dfd161fa0..17e93da7c3 100644
--- a/meta/recipes-core/busybox/files/mdev.conf
+++ b/meta/recipes-core/busybox/files/mdev.conf
@@ -37,3 +37,6 @@ input/mice 0:0 0660
37input/mouse.* 0:0 0660 37input/mouse.* 0:0 0660
38 38
39tun[0-9]* 0:0 0660 =net/ 39tun[0-9]* 0:0 0660 =net/
40
41[hs]d[a-z][0-9]? 0:0 660 */etc/mdev/mdev-mount.sh
42mmcblk[0-9].* 0:0 660 */etc/mdev/mdev-mount.sh