The uevent message contains information about the device (example). This information contains registered vendor and model identification for devices connected to buses such as PCI and USB. Udev parses these events and constructs a fixed-form module name which it passes to modprobe
. modprobe
looks under /lib/modules/VERSION
for a file called depmod.alias
which is generated when the kernel is installed and that maps the fixed-form module names to actual driver module file names. See Are driver modules loaded and unloaded automatically? for more details about the process — that answer describes the earlier days when the kernel called modprobe
directly, but the way modprobe
and module aliases work hasn't changed.
See also Michael Opdenacker's presentation “Hotplugging with udev” which has more examples and describes other aspects of device management with udev, and the Linux from scratch guide which has a section on how the fixed-form module names are defined.
modprobe
loads a module by calling the init_module
system call. It doesn't interact with sysfs in any way. When the module is loaded, the kernel creates an entry for it in /sys/module
. Any entry that appears elsewhere in sysfs is up to the code in the module (e.g. a module with a driver for a type of USB devices will call some generic USB support code that adds an entry under /sys/bus/usb/drivers
).
/sys/bus/drivers
directory ? Also does modprobe communicate back with the kernel through netlink socket ? Does it communicate back to sysfs ? – Shady Programmer Dec 14 '16 at 11:42init_module
system call. – Gilles 'SO- stop being evil' Dec 14 '16 at 13:11