umläute
umläute

Reputation: 31284

making linux virtual device driver work with udev

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:

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).

Upvotes: 0

Views: 1396

Answers (1)

Hercules dd
Hercules dd

Reputation: 225

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.

Upvotes: 1

Related Questions