linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Dan Gray" <dan@dangray.org>
To: linux-hotplug@vger.kernel.org
Subject: It just works - USB removal script suggestion/patch
Date: Thu, 02 Jun 2005 11:37:06 +0000	[thread overview]
Message-ID: <3456677@dangray.org> (raw)

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

             reply	other threads:[~2005-06-02 11:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-02 11:37 Dan Gray [this message]
2005-06-02 12:59 ` It just works - USB removal script suggestion/patch Stefan Schweizer
2005-06-02 15:09 ` Dan Gray

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3456677@dangray.org \
    --to=dan@dangray.org \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).