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:
You plug in a device. The kernel notices.
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.
The /etc/hotplug script runs /etc/hotplug/type.agent.
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:
usb.agent looks in /etc/hotplug/usb.distmap and /etc/hotplug/usb.usermap to locate a kernel module for the devices.
Having identified a module, usb.agent attempts to load the module.
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.