LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 07-30-2009, 12:24 PM   #1
ENVee
LQ Newbie
 
Registered: Jul 2007
Posts: 18

Rep: Reputation: 0
Device Major Numbers


Hello,

I am a newbie to the Linux kernel development and have a question regarding major number assignment.

I came across some information that in 2.6.x kernels , during boot up , the kernel creates the sysfs file hierarchy for every device that it finds attached. It then sends hotplug events for each of these new devices to udev which then reads the sysfs filesystem to create corresponding device nodes in /dev.

However , I also noticed that there are drivers which still use a static major number (defined in linux/major.h) e.g: in a call to
Code:
register_chrdev
, the input driver uses INPUT_MAJOR (
Code:
/* #define INPUT_MAJOR 13 */
).

So , if the driver registers its own major number whereas udev creates a dev node with another major number , how is a driver associated with a particular device node ?
 
Old 07-31-2009, 07:03 AM   #2
robvoo
LQ Newbie
 
Registered: Jul 2009
Distribution: debian, ubuntu
Posts: 22

Rep: Reputation: 2
Read this section from the Linux Device Driver book version 3, LDD3 for short.

http://www.makelinux.net/ldd3/chp-3-sect-2.shtml

This describes, dynamic and static allocation of major numbers.

Should you have questions afterwards don't hasitate to ask.

Best regards,
 
Old 07-31-2009, 11:46 AM   #3
ENVee
LQ Newbie
 
Registered: Jul 2007
Posts: 18

Original Poster
Rep: Reputation: 0
Device and Device node

Thanks for pointing me to that link !

Ok....So I understood from the script how dynamic allocation of major numbers takes place and how a device node is created based on this newly allocated major number.

I also read somewhere(probably in udev docs) that the sysfs information is created by the drivers in 2 ways :

1) If the driver is statically built into the kernel image , then the information is available immediately at boot time. This enables udevd to see the sysfs event immediately and thus create the device node.

2) If the driver is a module , then the information in sysfs is visible only when the driver module is loaded. Thus , udevd will react accordingly only when the driver is loaded.

So , my next questions are :
1) If a driver is responsible for getting a major number as well as creating the device node , then how does a device get associated with a particular device node ?

2) If I connect a device to my PC , after it has booted into linux , then does the kernel automatically load/register the driver (if it is a module) and create it's device node ?


Thanks !
 
Old 07-31-2009, 10:23 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
There is a daemon called hotplug that is responsible for responding to "USB device inserted" events. When properly configured, it will handle the task of recognizing that the device has been installed, figuring out what device it is, and loading the appropriate drivers for it.

Distros are normally set up these days to do all of this correctly.
 
Old 08-02-2009, 01:55 AM   #5
ENVee
LQ Newbie
 
Registered: Jul 2007
Posts: 18

Original Poster
Rep: Reputation: 0
thanks sundialsvcs........
I assume this would not be true for the non-usb devices then I guess ?
I mean if a non-usb device is connected to the PC after it has booted up , would I need to load it's driver manullay in order to have it's device node created ?
I mean how does one particular device get associated with a device node ?

I can understand that the association of a driver with a device node takes place by way of the major number.
 
  


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
Major and Minor numbers with partitions raj_hcl1986@rediffma Linux - Newbie 3 05-12-2013 06:07 PM
how to find major and minor device numbers Steve Riley Red Hat 2 03-25-2008 06:46 PM
special device node minor and major numbers crash88 Linux - General 1 06-22-2006 12:17 PM
Where can i find major and minor numbers yugandhar Linux - Software 1 06-02-2006 03:30 AM
devfs max major/minor numbers devershetty Linux - Newbie 1 06-17-2003 09:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 09:33 AM.

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