I'm learning to write a simple kernel module that implements open, read, write, close, ioctl
syscalls for reading/writing in kernel memory (something like a shared memory / IPC demo).
I used to call mknod
for binding the major/minor number allocated by the driver with a character file. But I questioned myself about why we aren't always required to manually do so when we attach an USB pendrive to the system, and I discovered udev
.
I know how to use kobject_init_and_add()
and kobject_uevent()
to create a node in sysfs
tree and notify udev
, but while exploring /sys
folder I noticed the /sys/dev/char
folder, that contains symlinks to devices, named like major:minor
. I don't understand why I can't find here the major/minor couple of my driver... Am I supposed to manually do something else from inside the module?
How can I find a full-but-simple example on how to properly describe and handle my "virtual" device in the sysfs tree?