6

Is there any way to find out who created a device node? If it has been udev or the kernel itself?

In the specific case of mine, I have two webcams. Nodes created for them are /dev/video0 and /dev/video1. Unfortunately this is not a constant assignment. Now I thought that would be the case when using udev, but when I create a udev rule it seems to me that video0 and video1 nodes are already created prior to udev being able to assign a more constant node like /dev/videoLogitech.

I need some suggestions regarding which log-file or which command might help me to find out about what happens here.

5

If you want to check order of actions use:

udevadm monitor --property

by doing this you get a listing of actions. When you add your camera one of the first entries is likely to be something like:

KERNEL[110935.814197] add      /devices/.../video4linux/video1 (video4linux)
ACTION=add
DEVNAME=/dev/video1  <<<<---- devname

As pointed out by @goldilocks:

Unfortunately, if you are using systemd, it's version of udev has a complex "persistent naming scheme" that's hard coded into udevd, so you are right, just parsing the rules.d stuff could leave a lot of mysteries.

Also from man udev for systemd:

The following keys can get values assigned:

NAME The name to use for a network interface. See systemd.link(5) for a higher-level mechanism for setting the interface name. The name of a device node cannot be changed by udev, only additional symlinks can be created.


Naming and debugging

Your best option is likely to use something like:

udevadm test $(udevadm info -q path -n video1)

It gives you a "test run" on your rule(s) and report any errors.

After adding/changing a rule, remember to reload with:

udevadm control --reload-rules

When it comes to naming a devices you likely get something like:

NAME="smile2thecamera" ignored, kernel device nodes can not be renamed; 
      please fix it in /etc/udev/rules.d/83-webcam.rules:6

You could instead use a SYMLINK (if that suffice) as in:

KERNEL=="video[0-9]", .... SYMLINK+="video-logitech"

Should give you something like this on test:

creating link '/dev/video-logitech' to '/dev/video1'
creating symlink '/dev/video-logitech' to 'video1'

DEVLINKS=.... /dev/video-logitech
  • "As for who named the device it is the kernel" -- not necessarily, see here. Symlinking sounds like the simplest solution anyway. – goldilocks Feb 1 '15 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.