# sysfs is populated after the event is sent
ACTION=="add", DEVPATH=="/devices/*", ENV{PHYSDEVBUS}=="?*", WAIT_FOR_SYSFS="bus"
-ACTION=="add", SUBSYSTEM=="scsi", WAIT_FOR_SYSFS="ioerr_cnt"
+ACTION=="add", KERNEL=="[0-9]*:[0-9]*", SUBSYSTEM=="scsi", WAIT_FOR_SYSFS="ioerr_cnt"
ACTION=="add", SUBSYSTEM=="net", WAIT_FOR_SYSFS="address"
ACTION=="add", SUBSYSTEM=="net", ENV{PHYSDEVDRIVER}=="?*", WAIT_FOR_SYSFS="device/driver"
--- /dev/null
+# device mapper links hook into "change" events, when the dm table
+# becomes available; some table-types must be ignored
+
+KERNEL=="device-mapper", NAME="mapper/control"
+
+KERNEL=="dm-*", ACTION=="add|change", GOTO="device_mapper_do"
+GOTO="device_mapper_end"
+LABEL="device_mapper_do"
+
+# lookup device name
+# use dmsetup, until devmap_name is provided by sys-fs/device-mapper
+PROGRAM=="/sbin/dmsetup -j %M -m %m --noopencount --noheadings -c -o name info",
+ ENV{ID_DM_NAME}="%c"
+
+# do not do anything if dmsetup does not provide a name
+ENV{ID_DM_NAME}=="", NAME="", OPTIONS="ignore_device"
+
+# ignore luks crypt devices while not fully up
+ENV{ID_DM_NAME}=="temporary-cryptsetup-*", NAME="", OPTIONS="ignore_device"
+
+# use queried name
+ENV{ID_DM_NAME}=="?*", NAME="mapper/$env{ID_DM_NAME}"
+
+PROGRAM!="/sbin/dmsetup status -j %M -m %m", GOTO="device_mapper_end"
+RESULT=="|*snapshot*|*error*", GOTO="device_mapper_end"
+
+IMPORT{program}="vol_id --export $tempnode"
+ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID}", OPTIONS="link_priority=50"
+ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_SAFE}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_SAFE}", OPTIONS="link_priority=50"
+
+LABEL="device_mapper_end"
+++ /dev/null
-# /etc/udev/rules/95-net.rules: device naming rules for udev
-#
-# Gentoo specific rules
-#
-# There are a number of modifiers that are allowed to be used in some of the
-# fields. See the udev man page for a full description of them.
-#
-# Try not to modify this file, if you wish to change things, create a new rule
-# file that can be run before this one.
-#
-
-# Activate our network if we can
-SUBSYSTEM=="net", ACTION=="add", RUN+="net.sh %k start", OPTIONS="last_rule"
-SUBSYSTEM=="net", ACTION=="remove", RUN+="net.sh %k stop", OPTIONS="last_rule"
-
--- /dev/null
+# /etc/udev/rules/95-udev-late.rules: device naming rules for udev
+#
+# Gentoo specific rules
+#
+# There are a number of modifiers that are allowed to be used in some of the
+# fields. See the udev man page for a full description of them.
+#
+# Try not to modify this file, if you wish to change things, create a new rule
+# file that can be run before this one.
+#
+
+# Activate our network if we can
+SUBSYSTEM=="net", ACTION=="add", RUN+="net.sh %k start"
+SUBSYSTEM=="net", ACTION=="remove", RUN+="net.sh %k stop"
+
+# debug events to /events, but not on default udev_log="err"
+ENV{UDEV_LOG}=="[4-9]", RUN+="eventrecorder.sh"
+
+# event to be catched by udevmonitor
+RUN+="socket:/org/kernel/udev/monitor"
+
KERNEL=="msr[0-9]*", NAME="cpu/%n/msr"
KERNEL=="microcode", NAME="cpu/microcode"
-# dm devices
-# lookup device name and create device in /dev/mapper
-# use dmsetup, until devmap_name is provided by sys-fs/device-mapper
-ACTION=="add|change", SUBSYSTEM=="block", KERNEL=="dm-*", \
- PROGRAM="/sbin/dmsetup -j %M -m %m --noopencount --noheadings -c -o name info", \
- NAME="mapper/%c"
-KERNEL=="device-mapper", NAME="mapper/control"
-
# fb devices
KERNEL=="fb[0-9]*", NAME="fb/%n", SYMLINK+="%k", GROUP="video"
KERNEL=="mice", NAME="input/%k", MODE="0644"
KERNEL=="mouse*", NAME="input/%k", MODE="0644"
KERNEL=="event*", NAME="input/%k", MODE="0600"
-KERNEL=="js*", NAME="input/%k", MODE="664"
+KERNEL=="js*", NAME="input/%k", MODE="0664"
KERNEL=="ts*", NAME="input/%k", MODE="0600"
# loop devices
LABEL="hotplug_no_add_event"
LABEL="gentoo_device_rules_end"
-
-# be backward compatible for a while with the /etc/dev.d and /etc/hotplug.d/ systems
-# run /etc/hotplug.d/ stuff only if we came from a hotplug event, not for udevstart
-#ENV{UDEVD_EVENT}=="1", RUN+="udev_run_hotplugd $env{SUBSYSTEM}"
-
-# always run /etc/dev.d/ stuff for now.
-RUN+="udev_run_devd $env{SUBSYSTEM}"
-
-# debugging monitor
-RUN+="socket:/org/kernel/udev/monitor"