LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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


Reply
  Search this Thread
Old 05-04-2012, 06:57 AM   #1
utkarshrawat
Member
 
Registered: Jul 2007
Posts: 120

Rep: Reputation: 15
Dynamic Allocation of Major Numbers


I have a question in driver when ever we do
Code:
register_chrdev (major, “name”,*fops)
when major = 0, it returns a dynamically
allocated major number
But the disadvantage is that we can’t create the device nodes because the major number assigned to
your module can’t be guaranteed to always be the same.
How can we retrieve major number from /proc/devices/ before doing mknod .i.e . I dont want to see mknod everytime ,how it can be done dynamically. I think some script file is required to write .
 
Old 05-05-2012, 03:18 AM   #2
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Quote:
Originally Posted by utkarshrawat View Post
But the disadvantage is that we can’t create the device nodes because the major number assigned to your module can’t be guaranteed to always be the same.
You mean, you can't create a device node that persists between reboots. This is exactly why we use udev.

If you don't want to use udev, write an init script that retrieves the major and minor number of your device node by reading the /sys/devices/.../yourdevice/dev file (which I believe is provided by the device subsystem core; available immediately after the register_chrdev() call has completed), then creates or recreates the device node in /dev.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] dynamic memory allocation in assembly hda7 Linux - Software 9 10-28-2009 08:25 AM
Dynamic Memory Allocation jvff Programming 1 09-05-2005 05:01 AM
dynamic memory allocation failure guam Programming 4 04-13-2005 09:16 AM
pointers and dynamic memory allocation deveraux83 Programming 2 01-24-2004 10:35 AM
Dynamic Memory Allocation query dhanakom Programming 2 07-21-2003 02:19 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration