smeeb
smeeb

Reputation: 29577

How are some Linux device drivers automatically loaded/unloaded?

With regards to Linux device drivers, my understanding (obtained from reading this excellent DIY article) is that there are essentially six events/parts of a device driver "lifecycle":

Thanks to that article and countless others, I can now write a whole bunch of C code to implement hooks/callbacks for what should happen when the kernel issues Open, Read, Write and Close commands. But, it seems that the driver must be loaded/released manually by issuing an insmod (load) and rmmod (release) at the shell.

However, I know this can't be the case because certain devices, like USB, allow you to connect/disconnect them dynamically/on-the-fly, and their respective drivers must be automatically loaded/released on-the-fly as well.

So this stirs up the following question: How do certain technologies, like USB, automate the execution of insmod and rmmod (hence the dynamic loading/releasing of USB device drivers)?

Upvotes: 2

Views: 2423

Answers (2)

moueza
moueza

Reputation: 69

Hotplug! cf man udev : in /lib or /usr/lib or /etc/udev/udev.d with priorities, you have rules ([0-9]*descriptionName.rules) which make matching between device properties from pci and fitting module to load.

sudo udevadm monitor --env

to see the messages

Upvotes: 1

jjm
jjm

Reputation: 461

Its based on linux hotplug. The below link may useful for you.

https://web.archive.org/web/20150316211806/http://www.makelinux.net/ldd3/chp-14-sect-7

Upvotes: 1

Related Questions