waffleman
waffleman

Reputation: 4339

How to get a Linux character device to show up in /dev automatically without running mknod?

What is the best way to get a character to show up in /dev? I have a driver that calls register_chrdev, and I see the entry in /proc/devices when I load the module. However, I still have to call mknod on the command-line in order to get it show up in /dev.

Is there a good way to do this programmatic-ally at module load time?

Upvotes: 2

Views: 3501

Answers (1)

user502515
user502515

Reputation: 4454

To have a device node automatically created, for example by means of udev or devtmpfs, an accompanying kevent needs to be generated. register_chrdev alone does not do this. Instead, it is required to follow the device/driver model (see also Documentation/driver-model/), and make use of kobjects.

Compare with drivers/char/misc.c for one of the simpler examples: it uses device_create(). The prerequisite for that is having a struct class, also showcased by misc.c.

Upvotes: 2

Related Questions