4 # Attemp to mount any added block devices
5 # and remove any removed devices
9 PMOUNT="/usr/bin/pmount"
11 name="`basename "$DEVNAME"`"
13 for line in `cat /etc/udev/mount.blacklist | grep -v ^#`
15 if ( echo "$DEVNAME" | grep -q "$line" )
17 logger "udev/mount.sh" "[$DEVNAME] is blacklisted, ignoring"
23 ! test -d "/media/$name" && mkdir -p "/media/$name"
25 if ! $MOUNT -t auto -o sync $DEVNAME "/media/$name"
27 #logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"/media/$name\" failed!"
30 logger "mount.sh/automount" "Auto-mount of [/media/$name] successful"
31 touch "/tmp/.automount-$name"
36 # We do not want to rm -r populated directories
37 if test "`find "$1" | wc -l | tr -d " "`" -lt 2 -a -d "$1"
39 ! test -z "$1" && rm -r "$1"
41 logger "mount.sh/automount" "Not removing non-empty directory [$1]"
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
52 # If the device isn't mounted at this point, it isn't configured in fstab
53 # 20061107: Small correction: The rootfs partition may be called just "rootfs" and not by
54 # its true device name so this would break. If the rootfs is mounted on two places
55 # during boot, it confuses the heck out of fsck. So Im auto-adding the root-partition
56 # to /etc/udev/mount.blacklist via postinst
58 cat /proc/mounts | awk '{print $1}' | grep -q "^$DEVNAME$" || automount
64 if [ "$ACTION" = "remove" ] && [ -x "$UMOUNT" ] && [ -n "$DEVNAME" ]; then
65 for mnt in `cat /proc/mounts | grep "$DEVNAME" | cut -f 2 -d " " `
70 # Remove empty directories from auto-mounter
71 test -e "/tmp/.automount-$name" && rm_dir "/media/$name"