LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 02-07-2007, 03:18 PM   #1
deardron
Member
 
Registered: Dec 2003
Location: Russia/Iceland
Distribution: Ubuntu 6, NetBSD 3.1, Cygwin
Posts: 39

Rep: Reputation: 15
major number vs. driver code


Hello all,

I wonder how a given major number is assigned to a certain driver in kernel code? I.e. where can I read which routine of drivers code corresponds to which major number?
 
Old 02-08-2007, 09:57 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Are you talking about device major numbers or what?
 
Old 02-08-2007, 03:23 PM   #3
deardron
Member
 
Registered: Dec 2003
Location: Russia/Iceland
Distribution: Ubuntu 6, NetBSD 3.1, Cygwin
Posts: 39

Original Poster
Rep: Reputation: 15
Yes, about device major numbers.
 
Old 02-08-2007, 03:27 PM   #4
rshaw
Senior Member
 
Registered: Apr 2001
Location: Perry, Iowa
Distribution: Mepis , Debian
Posts: 2,692

Rep: Reputation: 45
http://www.kernel.org/pub/linux/docs...vices-2.6+.txt

is that what you are after?
 
Old 02-09-2007, 06:07 AM   #5
deardron
Member
 
Registered: Dec 2003
Location: Russia/Iceland
Distribution: Ubuntu 6, NetBSD 3.1, Cygwin
Posts: 39

Original Poster
Rep: Reputation: 15
Well, rather no than yes. You are right pointing to a document where these major numbers are listed and explained. But I need to know, in which file/part of kernel code these numbers are resolved? I mean what procedure tells kernel that if it gets a call with a device major number 9, it should activate the driver for either SCSI tape or RAID metadisk devices according to that listing? There must exist a table for correspondances between major numbers and their handlers like it is with syscalls and their handlers in entry.S (sys_call_table). Hope it's clear now.
 
Old 02-18-2007, 12:00 PM   #6
hal_2001
LQ Newbie
 
Registered: Oct 2003
Location: UK
Distribution: Mandriva, Red Hat, Fedora Core, MontaVista
Posts: 23

Rep: Reputation: 16
In a running system, the major numbers in use can be seen using:

cat /proc/devices

The major numbers are used in the /dev/ entries. Therefore, opening a /dev entry causes the major number to select the associated driver.

The major numbers are registered by the driver when the driver is loaded. Some major numbers are hard-coded by the driver and some can be dynamically allocated by the kernel but then needs dynamically allocated /dev entries.

Try greping the Linux driver source code for the #define MAJOR
 
  


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
changing Major Number binumohanr AIX 1 07-28-2006 07:59 AM
Major number for device driver... Elric of Grans Programming 2 07-12-2005 04:06 PM
what is a major number and a minor number ? Menestrel Linux - Newbie 2 10-11-2004 07:53 AM
why there is a need for minor number and major number for monitor/keyboard in pc? tripathi Solaris / OpenSolaris 1 11-07-2003 09:36 AM
major/minor number zyan Linux - Newbie 2 06-25-2001 06:57 PM

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

All times are GMT -5. The time now is 12:51 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