From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Dan Gray" Date: Thu, 02 Jun 2005 11:37:06 +0000 Subject: It just works - USB removal script suggestion/patch Message-Id: <3456677@dangray.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org Hi, I've been playing around with hotplug for a while now and am not entirely happy with the way that usb.agent handles removal requests. The documentation is fairly wooly on the subject, and initially it appears as though the $ACTION received by the specified agent script can be one of 'add' or 'remove' - this is of course not the case (as far as I can see). While we should all RTFM this required a trawl through the source and the skills of an experianced user. This patch is aimed at 'Desktop Linux' where a user would presumably have admin rights but not necessarily alot of experiance and may need a clear model within which to place the necessary removal script without playing with the hotplugging 'base' scripts and damaging the system. So I tracked down the /var/run/usb/ based 'remover' script and the system works very well. I think that there is a problem however with the functionality of this system for the non-skilled user, in that the name for the script is not intuitive and it must be created every time that the usb device is inserted (if the script is trivial that a simple 'echo' from the insertion script can do it, if non-trivial a script must be copied from elsewhere), this seems over complicated and, should a user wish to create a removal script, it requires that they edit the agent script in /etc/hotplug/usb/ directly, hardly desirable. The last few months we've been hearing alot about 'it just works', and trying to simplify some of linux' functions and so heres my proposition as a patch to usb.agent: --------------------------- < basicVendor=$1 < basicProduct=$2 < 379d373 < 443,459d436 < < usb_convert_vars < < # Since the 'remover' function is a little obscure and requires a user < # to delve into a few levels of code we add the possibility to add a < # simple script named after a devices vendorID and productID to < # the directory /etc/hotplug/removers/. If present and executable < # this script runs on product removal. Less elegant perhaps, but < # much, much simpler and possible for a user to fathom, extracting the < # corrent Vendor and Product ID from a simple 'dmesg'. < < if [ -f /etc/hotplug/removers/$basicVendor:$basicProduct ]; then < if [ -x /etc/hotplug/removers/$basicVendor:$basicProduct ]; then < /etc/hotplug/removers/$basicVendor:$basicProduct < fi < fi < ------------------ As you can see, we can create an additional removel script in /etc/rc.d/usb/removers/ named for the device in question (i.e. /etc/rc.d/usb/removers/66f:4100 ) which, if present and executable will be called whenever the device is removed. This method, while not as elegant as the existing solution is an addition to it and removes the need for a user to edit any configuration scripts other that that contained in '/etc/rc.d/usb/removers/', which presumably they wish to create in the first place. If a distro or user wishes to make use of the '/var/run/usb' remover functionality they are free to so but a user may simply use the file above to add any additional functionality without the risk of fubar'ing the system (although the script is still run with root permissions, and created with admin permissions, but I trust my meaning is clear). Obviously the same can be done for the insertion case, but I didn't require that functionality and it will be trivial to add. I've not extended this to FireWire as I don't have a system to test it on. What do you think? Any chance of getting this made 'official'??? Regards Dan Gray ------------------------------------------------------- This SF.Net email is sponsored by Yahoo. Introducing Yahoo! Search Developer Network - Create apps using Yahoo! Search APIs Find out how you can build Yahoo! directly into your own Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel