0

I'm trying to fix the v4l2loopback driver to work with udev (to have udev automatically assign stable device names).

The problem seems to be, that the device driver doesn't expose a few fields that are seemingly required by udev to properly work with the standard 60-persistent-v4l.rules, namely:

  • ID_BUS
  • ID_SERIAL
  • ID_PATH

Also, running udevadm test-builtin path_id on the device doesn't return anything (and the exit-code is 1).

Now any example I've found in the net assumes that I want to write a USB device driver. Unfortunately this is not true for the v4l2loopback device, which is a virtual device.

So the question is:

How do I add PATH, SERIAL and BUS properties to a virtual device driver, in order to make udev see them?

Note: The question is really targeted at fixing the device driver so that it plays nicely with existing udev rules (rather than tweaking udev so that it recognizes the device properly).

umläute
  • 28,885
  • 9
  • 68
  • 122

1 Answers1

1

Run this command to see everything sent from linux kernel to user space udev:

$ udevadm monitor --environment --udev

If this shows what you need then use it in rule file otherwise create a shell script, invoke that script from within udev rule file and then from shell script parse sysfs to get parameters you are looking for. This is typical standard way fo doing it.

The environment variables are sent from kernel using add_uevent_var() function. In kernel mainly core, class and bus drivers calls functions to create and send uevent. Take a look at this link to note bus anc class driver. This link is also helpful to explore more about it.

One important difference to note between virtual and real device is when we get access to kobject on which we can call functions.

Hercules dd
  • 215
  • 1
  • 5
  • thanks; the question was really geared more towards tweaking the device driver to play nicely with existing udev rules. i guess the Q needs some clarification... – umläute Dec 07 '17 at 08:39