summaryrefslogtreecommitdiffstats
path: root/source/a/device-mapper/64-device-mapper.rules
diff options
context:
space:
mode:
Diffstat (limited to 'source/a/device-mapper/64-device-mapper.rules')
-rw-r--r--source/a/device-mapper/64-device-mapper.rules37
1 files changed, 37 insertions, 0 deletions
diff --git a/source/a/device-mapper/64-device-mapper.rules b/source/a/device-mapper/64-device-mapper.rules
new file mode 100644
index 000000000..7e9a235db
--- /dev/null
+++ b/source/a/device-mapper/64-device-mapper.rules
@@ -0,0 +1,37 @@
+# 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-*", GOTO="device_mapper_end"
+ACTION!="add|change", GOTO="device_mapper_end"
+
+# 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{DM_NAME}="%c"
+
+# do not do anything if dmsetup does not provide a name
+ENV{DM_NAME}=="", NAME="", OPTIONS="ignore_device"
+
+# ignore luks crypt devices while not fully up
+ENV{DM_NAME}=="temporary-cryptsetup-*", NAME="", OPTIONS="ignore_device"
+
+# use queried name
+ENV{DM_NAME}=="?*", NAME="mapper/$env{DM_NAME}"
+
+SYMLINK+="disk/by-id/dm-name-$env{DM_NAME}"
+SYMLINK+="disk/by-name/$env{DM_NAME}"
+
+PROGRAM!="/sbin/dmsetup status -j %M -m %m", GOTO="device_mapper_end"
+ENV{DM_TYPE}="%c{3}"
+
+ENV{DM_TYPE}=="|*error*", GOTO="device_mapper_end"
+
+IMPORT{program}="vol_id --export $tempnode"
+OPTIONS="link_priority=50"
+ENV{DM_TYPE}=="*snapshot-origin*", OPTIONS="link_priority=60"
+ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
+ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
+
+LABEL="device_mapper_end"