11.5 Hotplug Support


11.5 Hotplug Support

Now that we've covered Linux USB and IEEE 1394 support, you should learn a little about Linux hotplug support, a system that can handle the automatic configuration and cleanup of devices when you plug them into the system.

The idea is simple; the kernel runs /sbin/hotplug when you plug in a device. Here's the procedure:

  1. You plug in a device. The kernel notices.

  2. The kernel runs /sbin/hotplug type , where type is the device type ( usb , ieee1394 , scsi , and so on). The kernel sets a number of device- related environment variables in the new hotplug process.

  3. The /etc/hotplug script runs /etc/hotplug/ type .agent .

  4. The /etc/hotplug/ type .agent script tries to configure the device.

There really isn't much more to it than this. Each device type's .agent file has its own method of configuring devices. For example, usb.agent goes through these steps:

  1. usb.agent looks in /etc/hotplug/usb.distmap and /etc/hotplug/usb.usermap to locate a kernel module for the devices.

  2. Having identified a module, usb.agent attempts to load the module.

  3. If /etc/hotplug/usb/ type exists, usb.agent runs that program.

Linux hotplug is almost entirely script-driven, which means that the details are even more subject to change than the rest of Linux. However, keep in mind that if you ever have problems or questions you can always read the hotplug scripts to determine what they are trying to do, even if the documentation is inadequate or out of date.




How Linux Works
How Linux Works: What Every Superuser Should Know
ISBN: 1593270356
EAN: 2147483647
Year: 2004
Pages: 189
Authors: Brian Ward

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net