Re: automatic driver loading functionality in Linux

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

 



On Tue, Jan 26, 2010 at 11:17:27PM +0530, Joel Fernandes wrote:
> > modprobe is "smart" and knows what modules support what devices based on
> > the cache it creates when you run 'depmod' when a new kernel is
> > installed.
> >
> > That information is found in the drivers themselves.
> >
> > See the modprobe code for details if you wish to know the exact
> > mechanisms involved, it's pretty easy code to understand.
> 
> Hi Greg, Thanks a lot :)
> 
> I just went through the depmod code and it seems that the tables are
> stored in the 'modinfo' section of the ELF object, and depmod extracts
> this and dumps it to a map file. And then udev would do a match with
> this map file whenever a new device is detected and load the required
> module using modprobe. Do you think my analysis is correct?

Close, I don't think the map files are used anymore, and are only around
for backward compatibility.

What you want to look at is the modules.alias file.  That is what makes
things so simple, it creates a mapping from a device/product id to the
actual module.

So then you can do something as simple as:
	modprobe <contents of uevent MODALIAS env variable>
and modprobe will look at the alias file, and match things up.

For example, when I plug a usb flash device in, I get:
	MODALIAS=usb:v154Bp6545d0200dc00dsc00dp00ic08isc06ip50
so you can do:
	modprobe usb:v154Bp6545d0200dc00dsc00dp00ic08isc06ip50
looking at the module.alias file, it will match with the usb-storage
module, and load that.

Or it should, I just tried that out and it didn't quite work out, I'm
probably forgetting a step here, but I think you get the general idea.

Hope this helps,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at 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