how to find out if kernel or udev created a device node?
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/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
video1 nodes are already created prior to
udev being able to assign a more constant node like
I need some suggestions regarding which log-file or which command might help me to find out about what happens here.
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)
DEVNAME=/dev/video1 <<<<---- devname
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.dstuff could leave a lot of mysteries.
The following keys can get values assigned:
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'