Programming This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
09-30-2004, 07:52 AM
|
#1
|
|
Member
Registered: Jul 2004
Posts: 72
Rep:
|
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.
|
|
|
|
09-30-2004, 09:12 AM
|
#2
|
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530
Rep: 
|
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.
Or am I wrong about this?
|
|
|
|
10-01-2004, 03:53 AM
|
#3
|
|
Member
Registered: Jul 2004
Posts: 72
Original Poster
Rep:
|
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.
|
|
|
|
10-01-2004, 04:15 AM
|
#4
|
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530
Rep: 
|
Quote:
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...
|
|
|
|
10-01-2004, 09:09 AM
|
#5
|
|
Member
Registered: Jul 2004
Posts: 72
Original Poster
Rep:
|
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.
|
|
|
|
11-01-2004, 09:37 AM
|
#6
|
|
LQ Newbie
Registered: Jul 2003
Location: UK
Distribution: Fedora 5, Knoppix, Ubuntu
Posts: 27
Rep:
|
According to the Linux LKM programming guide you should use the mknod system call. Try "man 2 mknod" for more info.
Don't forget to delete the file when you cleanup!
R.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:37 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|