Re: how does kernel know?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



every device file in linux has a MAJOR nbr associated with it. The
kernel uses this major number to determine what type of device is
being opened (see the MACRO's S_IS[CHR/BLK/SOCK..etc] in
include/linux/stat.h). then uses this info and the major nbr to
index into an array which holds the registered drivers fops structure

ex. if u do open(/dev/ttyS0,XX) the kernel figures out it's a char
device and then finally uses the major nbr to index an array
"chrdevs[]" to get the fops struct (this is the struct that the
driver registered via a call to register_chrdev()).

HTH,
-mandeep

On Thu, 2004-09-30 at 17:26, Zeeshan Ali wrote:
> Hello,
>    Whenever i open the device /dev/lpN, the kernel automatically loads
> the appropriate driver for that device, as if it has a list of major
> number to module mapping. How/where does the kernel do it?
> 
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
> 

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux