Hotplug fix

There was a report that plugging in two USB drives simultaneously they did not appear on the desktop. So, I examined /sbin/pup_event_frontend_d, the daemon script that detects when block devices (that is, drives) are added or removed and updates the desktop drive icons. I ended up giving it a complete overhaul.

I had also discovered a problem with the 2.6.21.7 kernel. I had udev rules so that 'udevd' would signal pup_event_frontend_d whenever a block device is added or removed. However, as the 2.6.21.7 kernel uevents do not set the DEVTYPE variable, I cannot specify that in the rules, which resulted in multiple signals being sent to pup_event_frontend_d, which confuses the script.

On top of that, pup_event_frontend_d has a complex structure. It has to wait on block events from udevd, but it also has to have its own four-second loop as some devices (ex., CD/DVD media) need to be polled periodically. For sometime now I have realised that it would be better to abandon some of the sophistication and just have a simple polling loop. That is, uedevd no longer has rules to signal pup_event_frontend_d. The script is just in a simple two-second loop monitoring /sys/block for changes, and also performing four-second probes.

This has greatly simplified the script, and it now handles multiple simultaneous hotplug events. I think that I may have fixed other potential anomalies also.

So, score a point for the old-fashioned way of doing things. Primitive and simple. I don't think that it uses much more system resources either.

Posted on 4 Sep 2008, 11:04


No comments posted yet.