udev: Add /dev/media/by-path symlinks for media controllers
authorMax Staudt <mstaudt@chromium.org>
Thu, 22 Feb 2024 08:47:36 +0000 (17:47 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 22 Feb 2024 19:27:29 +0000 (19:27 +0000)
commit04f19d673587252040e04bf55d9425d00e1f24d0
tree45d19af4e552aa84dc008a4341b1a12431398c10
parent3976c430927e1bfefa0413f80ebac84ab9a64350
udev: Add /dev/media/by-path symlinks for media controllers

Add persistent symlinks for media controller ("mediaX") devices, based
on their ID_PATH udev properties.

For example, if the uvcvideo driver creates /dev/media0, a persistent
name may be:
/dev/media/by-path/pci-0000:04:00.3-usb-0:1:1.0-media-controller

Persistent links are a handy tool to make scripts self-documenting
during development or in tests, as well as less error prone in case of
devices changing enumeration order. For media controllers, one can
alternatively scan through all of them and look for a matching bus_info
in their struct media_device_info, but the links are much handier when
drafting something by hand.

A similar pattern already exists for Video4Linux /dev/videoX devices,
see 60-persistent-v4l.rules for those.
rules.d/60-persistent-media-controller.rules [new file with mode: 0644]