2010-06-27 14:04:54 +00:00
|
|
|
KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"
|
2010-11-15 03:25:01 +00:00
|
|
|
PROGRAM="/bin/grep -q ' %M:%m /[^ ]* /' /proc/self/mountinfo", PROGRAM!="/bin/grep -q ' %M:%m / /media/' /proc/self/mountinfo", GOTO="media_by_label_auto_mount_end"
|
2010-05-03 14:57:08 +00:00
|
|
|
|
2010-06-27 14:04:54 +00:00
|
|
|
# Import FS infos
|
|
|
|
IMPORT{program}="/sbin/blkid -o udev -p %N"
|
|
|
|
|
|
|
|
# Get a label if present, otherwise specify one
|
|
|
|
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
|
|
|
|
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"
|
2010-05-03 14:57:08 +00:00
|
|
|
|
|
|
|
# Global mount options
|
2010-06-27 14:04:54 +00:00
|
|
|
ACTION=="add", ENV{mount_options}="noatime"
|
|
|
|
# Filesystem-specific mount options
|
|
|
|
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"
|
|
|
|
|
|
|
|
# Mount the device
|
|
|
|
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"
|
2010-05-03 14:57:08 +00:00
|
|
|
|
2010-06-27 14:04:54 +00:00
|
|
|
# Clean up after removal
|
|
|
|
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"
|
2010-05-03 14:57:08 +00:00
|
|
|
|
2010-06-27 14:04:54 +00:00
|
|
|
# Exit
|
2010-05-03 14:57:08 +00:00
|
|
|
LABEL="media_by_label_auto_mount_end"
|