how to create device node for dynamically allocated major number
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
how to create device node for dynamically allocated major number
Hi all,
I am writing a char driver for which the major number is not statically assigned.
i pass zero as argument for 'register_chrdev' so that major number is dynamically generated.
But now I do not know how to create the device node since i the major number is not known.
Could someone help me how to get the major number to create device node.
I did not find any information in /proc/devices after loading the driver.
I know next-to-nothing about kernel-programming, but I doubt it's actually possible to have dynamic major devie numbers.
AFAIK the new devfs is made to overcome this limitation, but I assume it does not have anything to do with major number etc. like with the "old" device-driver system.
Hi Hko,
It is certainly possible to dynamically allocate a major number while registering the driver. This can be done by passing zero as the argument for 'register_chr_dev' function which was confirmed in my driver by printing the return value of 'register_chr_dev'.
I do not know anything about devfs and i will look into that.
Originally posted by appas It is certainly possible to dynamically allocate a major number while registering the driver. This can be done by passing zero as the argument for 'register_chr_dev' function which was confirmed in my driver by printing the return value of 'register_chr_dev'.
OK. Learned something new here. Thanks.
I didn't know, and I didn't expect it, because how would you know which major number to use for the /dev node? Which is exactly your question...
Hi all,
First of all, sorry for the misleading statement i used in the thread starting
Quote:
" I did not find any information in /proc/devices after loading the driver."
After loading the module, /proc/devices contains information about the major number and device.
Now i can get the major number for the device and then execute "mknod" to create the device.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.