Home > Software engineering >  linux: Create device file in the kernel driver code
linux: Create device file in the kernel driver code

Time:11-07

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

CodePudding user response:

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.

  • Related