Linux - KernelThis forum is for all discussion relating to the Linux kernel.
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.
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?
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.
Distribution: Mandriva, Red Hat, Fedora Core, MontaVista
Posts: 23
Rep:
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.