udevadm: allow to specify device by device ID

We have already exposed device ID in the output of device ID in J
fields. Also sd_device_get_device_id() and sd_device_new_from_device_id()
are already public. Hence, making udevadm accept device IDs may be
useful.

With this change, as we save several data in /run/udev with device ID,
we can call udevadm something like the following:
```
udevadm info $(ls /run/udev/tags/uaccess)
```
Then, we can show all devices that has uaccess tag.
This commit is contained in:
Yu Watanabe
2025-05-29 04:04:22 +09:00
parent 337f45d811
commit d0ba749e8c
5 changed files with 42 additions and 34 deletions
+3
View File
@@ -82,6 +82,9 @@ udevadm control --revert
udevadm info /dev/null
udevadm info /sys/class/net/$netdev
udevadm info "$(systemd-escape -p --suffix device /sys/devices/virtual/net/$netdev)"
[[ "$(udevadm info --json=short n1 | jq -r .DEVICE_ID)" == n1 ]]
udevadm info "$(udevadm info --json=short /dev/null | jq -r .DEVICE_ID)"
udevadm info "$(udevadm info --json=short /sys/class/net/$netdev | jq -r .DEVICE_ID)"
udevadm info --property DEVNAME /sys/class/net/$netdev
udevadm info --property DEVNAME --value /sys/class/net/$netdev
udevadm info --property HELLO /sys/class/net/$netdev