]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: introduce ID_BLOCK_SUBSYSTEM property
authorLennart Poettering <lennart@poettering.net>
Fri, 24 Oct 2025 15:13:12 +0000 (17:13 +0200)
committerLennart Poettering <lennart@poettering.net>
Sat, 1 Nov 2025 21:01:35 +0000 (22:01 +0100)
Virtual block devices are a bit weird: they have no parent device, and
thus cannot be related to the subsystem they belong to, except by
pattern matching their name. This is OK to do if one knows what to look
for. However for tools that do not want to carry a list of known
subsystems with their appropriate matching patters this sucks. Let's
introduce a new ID_BLOCK_SUBSYSTEM property we can set on block devices
that carries an explicit string for this. Do so for a small number of
key subsystems: DM, loopback and zram.

rules.d/60-block.rules

index cf307389b843f5552b04affca74a8ef43cd01ec5..9d54a65e022eb61e1a70326cba118c647c0c3363 100644 (file)
@@ -14,3 +14,11 @@ ACTION!="remove", SUBSYSTEM=="block", \
 
 # Reset access rights to each loopback device once it gets detached.
 ACTION=="change", SUBSYSTEM=="block", KERNEL=="loop*", ENV{DISK_MEDIA_CHANGE}=="1", TEST!="loop/backing_file", GROUP="disk", MODE="660"
+
+# Provide a somewhat cleaned up field indicating the subsystem various
+# 'virtual' block devices belong too, in order to avoid replicating name based
+# pattern matching in every consumer
+ACTION!="remove", SUBSYSTEM=="block", KERNEL=="dm-*", ENV{ID_BLOCK_SUBSYSTEM}="dm"
+ACTION!="remove", SUBSYSTEM=="block", KERNEL=="loop*", ENV{ID_BLOCK_SUBSYSTEM}="loop"
+ACTION!="remove", SUBSYSTEM=="block", KERNEL=="md*", ENV{ID_BLOCK_SUBSYSTEM}="md"
+ACTION!="remove", SUBSYSTEM=="block", KERNEL=="zram*", ENV{ID_BLOCK_SUBSYSTEM}="zram"