summaryrefslogtreecommitdiffstats
path: root/meta/packages/udev/files/mount.sh
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2006-07-21 10:10:31 +0000
committerRichard Purdie <richard@openedhand.com>2006-07-21 10:10:31 +0000
commitb2f192faabe412adce79534e22efe9fb69ee40e2 (patch)
tree7076c49d4286f8a1733650bd8fbc7161af200d57 /meta/packages/udev/files/mount.sh
parent2cf0eadf9f730027833af802d7e6c90b44248f80 (diff)
downloadpoky-b2f192faabe412adce79534e22efe9fb69ee40e2.tar.gz
Rename /openembedded/ -> /meta/
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@530 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/packages/udev/files/mount.sh')
-rw-r--r--meta/packages/udev/files/mount.sh67
1 files changed, 67 insertions, 0 deletions
diff --git a/meta/packages/udev/files/mount.sh b/meta/packages/udev/files/mount.sh
new file mode 100644
index 0000000000..48c7844690
--- /dev/null
+++ b/meta/packages/udev/files/mount.sh
@@ -0,0 +1,67 @@
1#!/bin/sh
2#
3# Called from udev
4# Attemp to mount any added block devices
5# and remove any removed devices
6#
7
8MOUNT="/bin/mount"
9PMOUNT="/usr/bin/pmount"
10UMOUNT="/bin/umount"
11name="`basename "$DEVNAME"`"
12
13for line in `cat /etc/udev/mount.blacklist | grep -v ^#`
14do
15 if ( echo "$DEVNAME" | grep -q "$line" )
16 then
17 logger "udev/mount.sh" "[$DEVNAME] is blacklisted, ignoring"
18 exit 0
19 fi
20done
21
22automount() {
23 ! test -d "/media/$name" && mkdir -p "/media/$name"
24
25 if ! $MOUNT -t auto -o sync $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
35rm_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
45if [ "$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 cat /proc/mounts | awk '{print $1}' | grep -q "^$DEVNAME$" || automount
54
55fi
56
57
58
59if [ "$ACTION" = "remove" ] && [ -x "$UMOUNT" ] && [ -n "$DEVNAME" ]; then
60 for mnt in `cat /proc/mounts | grep "$DEVNAME" | cut -f 2 -d " " `
61 do
62 $UMOUNT $mnt
63 done
64
65 # Remove empty directories from auto-mounter
66 test -e "/tmp/.automount-$name" && rm_dir "/media/$name"
67fi