5 # Attempt to mount any added block devices and umount any removed devices
8 MOUNT="/bin/mount -o ro"
9 PMOUNT="/usr/bin/pmount"
10 UMOUNT="/bin/umount -f"
11 for line in `grep -h -v ^# /etc/udev/mount.blacklist /etc/udev/mount.blacklist.d/*`
13 if [ ` expr match "$DEVNAME" "$line" ` -gt 0 ];
15 logger "udev/mount.sh" "[$DEVNAME] is blacklisted, ignoring"
21 name="`basename "$DEVNAME"`"
23 ! test -d "/run/media/$name" && mkdir -p "/run/media/$name"
24 # Silent util-linux's version of mounting auto
25 if [ "x`readlink $MOUNT`" = "x/bin/mount.util-linux" ] ;
27 MOUNT="$MOUNT -o silent"
30 # If filesystem type is vfat, change the ownership group to 'disk', and
31 # grant it with w/r/x permissions.
34 MOUNT="$MOUNT -o umask=007,gid=`awk -F':' '/^disk/{print $3}' /etc/group`"
41 if ! $MOUNT -t auto $DEVNAME "/run/media/$name"
43 #logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"/run/media/$name\" failed!"
44 rm_dir "/run/media/$name"
46 logger "mount.sh/automount" "Auto-mount of [/run/media/$name] successful"
47 touch "/tmp/.automount-$name"
52 # We do not want to rm -r populated directories
53 if test "`find "$1" | wc -l | tr -d " "`" -lt 2 -a -d "$1"
55 ! test -z "$1" && rm -r "$1"
57 logger "mount.sh/automount" "Not removing non-empty directory [$1]"
61 # No ID_FS_TYPE for cdrom device, yet it should be mounted
62 name="`basename "$DEVNAME"`"
63 [ -e /sys/block/$name/device/media ] && media_type=`cat /sys/block/$name/device/media`
65 if [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ] && [ -n "$ID_FS_TYPE" -o "$media_type" = "cdrom" ]; then
66 if [ -x "$PMOUNT" ]; then
67 $PMOUNT $DEVNAME 2> /dev/null
68 elif [ -x $MOUNT ]; then
69 $MOUNT $DEVNAME 2> /dev/null
72 # If the device isn't mounted at this point, it isn't
73 # configured in fstab (note the root filesystem can show up as
74 # /dev/root in /proc/mounts, so check the device number too)
75 if expr $MAJOR "*" 256 + $MINOR != `stat -c %d /`; then
76 grep -q "^$DEVNAME " /proc/mounts || automount
81 if [ "$ACTION" = "remove" ] || [ "$ACTION" = "change" ] && [ -x "$UMOUNT" ] && [ -n "$DEVNAME" ]; then
82 for mnt in `cat /proc/mounts | grep "$DEVNAME" | cut -f 2 -d " " `
87 # Remove empty directories from auto-mounter
88 name="`basename "$DEVNAME"`"
89 test -e "/tmp/.automount-$name" && rm_dir "/run/media/$name"