LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How are the numbers generated? (https://www.linuxquestions.org/questions/linux-general-1/how-are-the-numbers-generated-96284/)

pe2338 09-24-2003 09:18 AM

How are the numbers generated?
 
Hello everybody!

I have been searching for this on google and on the forum, but I couldn't find something related...

I am wondering : How are the char/block major/minor numbers assigned?
I came first accross this problem when I installed for the first time the Nvidia driver that was char-major-195. Hit it back on the rtc clock with char-major-135 and again with the bttv module that was char-major-80 (although I found a tutorial that indicated to use 81).

Coming back to the question, how are these assigned? Some pointers, links...

thanks!

itsjustme 09-24-2003 10:00 AM

From:
http://www.tux.org/lkml/#s2-8

8. What's this major/minor device number thing?

* (REG) Device numbers are the traditional Unix way to provide a mapping between the filesystem and device drivers. A device number is a combination of a major number and a minor number. Currently Linux has 8 bit majors and minors. When you open a device file (character or block device) the kernel takes the major number from the inode and indexes into a table of driver structure pointers. The specific driver structure is then used to call the driver open() method, which in turn may interpret the minor number. There are two tables: one for character devices and one for block devices, each are 256 entries maximum. Obviously, there must be agreement between device numbers used in a driver and files in /dev. The kernel source has the file Documentation/devices.tex which lists all the official major and minor numbers. H. Peter Anvin (HPA) maintains this list. If you write a new driver (for public consumption), you will need to get a major number allocated by HPA. See the Q/A on devfs for an improved (IMHO) mechanism for handling device drivers.

EDIT: devices.tex is a typo in that doc, or has changed. Search on your system for devices.txt.


All times are GMT -5. The time now is 06:57 PM.