diff options
author | Martin Jansa <martin.jansa@gmail.com> | 2012-07-30 17:03:14 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-09-04 14:08:35 +0100 |
commit | 0cc01a67f1c0bf1bff491c9c644348d6be318a72 (patch) | |
tree | 2c090dc35a587707b0944162cd265a4c7574b4e9 /meta/recipes-core/udev/udev-extraconf/mount.sh | |
parent | c5003a45d9c54a7a6d1c78799b8c2e3962cf1e52 (diff) | |
download | poky-0cc01a67f1c0bf1bff491c9c644348d6be318a72.tar.gz |
udev-extraconf: Merge with udev-extra-rules from meta-oe
* Move parts of local.rules from udev to udev-extraconf
* Move mount.sh and network.sh to udev-extraconf along with rule fragments
* Add mount.blacklist to CONFFILES
* Change PV to 1.0 and bump PR to provide upgrade path from meta-oe's udev-extra-rules
including RREPLACE/RPROVIDES/RCONFLICTS trio
(From OE-Core rev: 0ca3a7823e97c4e4af6e89d852f98d29ed6193d7)
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/udev/udev-extraconf/mount.sh')
-rw-r--r-- | meta/recipes-core/udev/udev-extraconf/mount.sh | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/meta/recipes-core/udev/udev-extraconf/mount.sh b/meta/recipes-core/udev/udev-extraconf/mount.sh new file mode 100644 index 0000000000..2eb9affcc8 --- /dev/null +++ b/meta/recipes-core/udev/udev-extraconf/mount.sh | |||
@@ -0,0 +1,67 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # Called from udev | ||
4 | # | ||
5 | # Attempt to mount any added block devices and umount any removed devices | ||
6 | |||
7 | |||
8 | MOUNT="/bin/mount" | ||
9 | PMOUNT="/usr/bin/pmount" | ||
10 | UMOUNT="/bin/umount" | ||
11 | for line in `grep -v ^# /etc/udev/mount.blacklist` | ||
12 | do | ||
13 | if [ ` expr match "$DEVNAME" "$line" ` -gt 0 ]; | ||
14 | then | ||
15 | logger "udev/mount.sh" "[$DEVNAME] is blacklisted, ignoring" | ||
16 | exit 0 | ||
17 | fi | ||
18 | done | ||
19 | |||
20 | automount() { | ||
21 | name="`basename "$DEVNAME"`" | ||
22 | |||
23 | ! test -d "/media/$name" && mkdir -p "/media/$name" | ||
24 | |||
25 | if ! $MOUNT -t auto $DEVNAME "/media/$name" | ||
26 | then | ||
27 | #logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"/media/$name\" failed!" | ||
28 | rm_dir "/media/$name" | ||
29 | else | ||
30 | logger "mount.sh/automount" "Auto-mount of [/media/$name] successful" | ||
31 | touch "/tmp/.automount-$name" | ||
32 | fi | ||
33 | } | ||
34 | |||
35 | rm_dir() { | ||
36 | # We do not want to rm -r populated directories | ||
37 | if test "`find "$1" | wc -l | tr -d " "`" -lt 2 -a -d "$1" | ||
38 | then | ||
39 | ! test -z "$1" && rm -r "$1" | ||
40 | else | ||
41 | logger "mount.sh/automount" "Not removing non-empty directory [$1]" | ||
42 | fi | ||
43 | } | ||
44 | |||
45 | if [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ]; then | ||
46 | if [ -x "$PMOUNT" ]; then | ||
47 | $PMOUNT $DEVNAME 2> /dev/null | ||
48 | elif [ -x $MOUNT ]; then | ||
49 | $MOUNT $DEVNAME 2> /dev/null | ||
50 | fi | ||
51 | |||
52 | # If the device isn't mounted at this point, it isn't configured in fstab | ||
53 | grep -q "^$DEVNAME " /proc/mounts || automount | ||
54 | fi | ||
55 | |||
56 | |||
57 | |||
58 | if [ "$ACTION" = "remove" ] && [ -x "$UMOUNT" ] && [ -n "$DEVNAME" ]; then | ||
59 | for mnt in `cat /proc/mounts | grep "$DEVNAME" | cut -f 2 -d " " ` | ||
60 | do | ||
61 | $UMOUNT $mnt | ||
62 | done | ||
63 | |||
64 | # Remove empty directories from auto-mounter | ||
65 | name="`basename "$DEVNAME"`" | ||
66 | test -e "/tmp/.automount-$name" && rm_dir "/media/$name" | ||
67 | fi | ||