]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: add input/by-{id,path} symlinks for hidraw devices
authorNick Rosbrook <enr0n@ubuntu.com>
Fri, 24 Jan 2025 20:42:38 +0000 (15:42 -0500)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 27 Jan 2025 18:57:13 +0000 (18:57 +0000)
Take some of the same rule structure from 60-persistent-input.rules, and
apply it to hidraw devices in 60-persistent-hidraw.rules.

Since one of the motivations for this is being able to easily reference
FIDO tokens, add a special case when ID_FIDO_TOKEN==1, and add 'fido'
to the symlink.

rules.d/60-persistent-hidraw.rules [new file with mode: 0644]
rules.d/meson.build

diff --git a/rules.d/60-persistent-hidraw.rules b/rules.d/60-persistent-hidraw.rules
new file mode 100644 (file)
index 0000000..c22db7d
--- /dev/null
@@ -0,0 +1,26 @@
+# do not edit this file, it will be overwritten on update
+
+ACTION=="remove", GOTO="persistent_hidraw_end"
+SUBSYSTEM!="hidraw", GOTO="persistent_hidraw_end"
+KERNEL!="hidraw*", GOTO="persistent_hidraw_end"
+
+SUBSYSTEMS=="usb", ENV{ID_BUS}=="", IMPORT{builtin}="usb_id"
+SUBSYSTEMS=="usb", IMPORT{builtin}="path_id"
+
+ENV{ID_BUS}=="", GOTO="persistent_hidraw_bus_end"
+
+# by-id links
+ATTRS{bInterfaceNumber}=="|00", SYMLINK+="input/by-id/$env{ID_BUS}-$env{ID_SERIAL}-hidraw"
+ATTRS{bInterfaceNumber}=="?*", ATTRS{bInterfaceNumber}!="00", SYMLINK+="input/by-id/$env{ID_BUS}-$env{ID_SERIAL}-if$attr{bInterfaceNumber}-hidraw"
+
+# add a more readable 'fido' link for devices with ID_FIDO_TOKEN==1
+ENV{ID_FIDO_TOKEN}=="?*", ATTRS{bInterfaceNumber}=="|00", SYMLINK+="input/by-id/$env{ID_BUS}-$env{ID_SERIAL}-fido"
+ENV{ID_FIDO_TOKEN}=="?*", ATTRS{bInterfaceNumber}=="?*", ATTRS{bInterfaceNumber}!="00", SYMLINK+="input/by-id/$env{ID_BUS}-$env{ID_SERIAL}-if$attr{bInterfaceNumber}-fido"
+
+LABEL="persistent_hidraw_bus_end"
+
+# by-path
+ENV{ID_PATH}=="?*", SYMLINK+="input/by-path/$env{ID_PATH}-hidraw"
+ENV{ID_PATH_WITH_USB_REVISION}=="?*", SYMLINK+="input/by-path/$env{ID_PATH_WITH_USB_REVISION}-hidraw"
+
+LABEL="persistent_hidraw_end"
index 85d314c35cc60e073c7c9302df884e2a24dda8ae..4ee964c630ae06f7fe4a9d3e21bfc2f23d8a19ed 100644 (file)
@@ -15,6 +15,7 @@ rules = [
                '60-infiniband.rules',
                '60-input-id.rules',
                '60-persistent-alsa.rules',
+               '60-persistent-hidraw.rules',
                '60-persistent-input.rules',
                '60-persistent-storage-mtd.rules',
                '60-persistent-storage-tape.rules',