Skip to content
Advertisement

linux: Create device file in the kernel driver code

The application needs a device file (usually in /dev) in order to use a kernel driver.

Is it wise to create this file in the driver code so the file will be created during insmod ?

Another way: create this file in a script (e.g /etc/rc.local)

Can you please tell what is the right way ?

Thank you, Zvika

Advertisement

Answer

Yes, it is wise to create this file in kernel.

On modern systems using devtmpfs the special device files are created in kernel. It was introduced into the kernel many years ago, so there is good chance that your kernel already has it.

However, if for some reason your kernel doesn’t have devtmpfs (which would mean it’s quite old), then you should rather use udev rules than init scripts.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement