How to create a device node from the init_module code of a Linux kernel module?

I am writing a module for the linux kernel and I want to create some device nodes in the init function

int init_module(void)
{
    Major = register_chrdev(0, DEVICE_NAME, &fops);
 // Now I want to create device nodes with the returned major number
}

I also want the kernel to assign a minor number for my first node, and then I will assign the other nodes' minor numbers by myself.

How can I do this in the code. I dont want to create devices from the shell using mknod

45
задан Ciro Santilli 新疆改造中心法轮功六四事件 6 August 2017 в 09:25
поделиться