5 # Attempt to mount any added block devices and remove any removed devices.
9 PMOUNT="/usr/bin/pmount"
11 blkid="/usr/sbin/blkid"
12 name="`basename "$DEVNAME"`"
13 name2="`$blkid "$DEVNAME" -o value -s LABEL`"
16 for line in `cat /etc/udev/mount.blacklist | grep -v ^#`
18 if ( echo "$DEVNAME" | grep -q "$line" )
20 logger "udev/mount.sh" "[$DEVNAME] is blacklisted, ignoring"
29 while ( cat /proc/mounts | grep "/media/$name2" ); do
35 ! test -d "/media/$name" && mkdir -p "/media/$name"
37 if ! $MOUNT -t auto -o dirsync,noatime,umask=0 $DEVNAME "/media/$name" && ! $MOUNT -t auto -o dirsync,noatime $DEVNAME "/media/$name"
39 #logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"/media/$name\" failed!"
42 logger "mount.sh/automount" "Auto-mount of [/media/$name] successful"
43 touch "/tmp/.automount-$name"
48 # We do not want to rm -r populated directories
49 if test "`find "$1" | wc -l | tr -d " "`" -lt 2 -a -d "$1"
51 ! test -z "$1" && rm -r "$1"
53 logger "mount.sh/automount" "Not removing non-empty directory [$1]"
57 if [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ]; then
58 if [ -x "$PMOUNT" ]; then
59 $PMOUNT $DEVNAME 2> /dev/null
60 elif [ -x $MOUNT ]; then
61 $MOUNT $DEVNAME 2> /dev/null
64 # If the device isn't mounted at this point, it isn't configured in fstab
65 # 20061107: Small correction: The rootfs partition may be called just "rootfs" and not by
66 # its true device name so this would break. If the rootfs is mounted on two places
67 # during boot, it confuses the heck out of fsck. So Im auto-adding the root-partition
68 # to /etc/udev/mount.blacklist via postinst
70 cat /proc/mounts | awk '{print $1}' | grep -q "^$DEVNAME$" || automount
74 if [ "$ACTION" = "remove" ] && [ -x "$UMOUNT" ] && [ -n "$DEVNAME" ]; then
75 for mnt in `cat /proc/mounts | grep "$DEVNAME" | cut -f 2 -d " " `
77 # 20100306: Remove the mount point forcibly (Lazy) as the user has already removed the device by the
78 # DJWillis: time this fires so any handles are bad anyway. This should stop 'stale' folders being
79 # left around all the time.
83 # Remove empty directories from auto-mounter
84 test -e "/tmp/.automount-$name" && rm_dir "$mnt"