The register_chrdev()
function in kernel registers a character device:
int register_chrdev(unsigned int major, const char*name,
struct file_operations*ops));
If major
is 0
the kernel dynamically allocates a major number and the register function returns it.
Now, let's assume a module foo.ko
wants to use /dev/foo
with a dynamic major number. How does the userspace learn what major number to pass to mknod
to create /dev/foo
?