linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Hotunplug
@ 2001-05-23  0:44 Stephen Williams
  2001-05-25  4:46 ` Hotunplug Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stephen Williams @ 2001-05-23  0:44 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 1480 bytes --]


I've made a go at implementing support for hot unplug in the hotplug
scripts. What I have done is calculated a path to a "remover" program
that is passed as the REMOVE environment variable to the existing add
scripts. If the add script wants to make something happen when the
device is removed, it writes something to the remover and marks it
executable.

The hotplug scripts' response to this is to run the remover when the
device is pulled. So this is the hotplug script for my device.  It is
called on add, and creates a remover to remove the symbolic link, like
so:

  case "$PRODUCT" in

  547/2235/*)
    exec /usr/sbin/gflashd -I /usr/share/gflash/aa55.ihx ;;

  12c5/*/*) 
    echo 'rm -f /var/run/gflash.lnk' > $REMOVER
    chmod u+x $REMOVER
    exec /usr/sbin/gflashd -m 0666 -L/var/run/gflash.lnk ;;

  esac

(The first case is loading the firmware, so a renumeration is about to
happen and the link is not ready to be created.)

I tested it on my system, and the good news is this that remove is very
fast. I pull the device and the /var/run/gflash.lnk goes away right away.
This is *exactly* what I want.

So I've attached a patch to the CVS version , for your critical review.
It's surprisingly small.

-- 
Steve Williams                "The woods are lovely, dark and deep.
steve@icarus.com              But I have promises to keep,
steve@picturel.com            and lines to code before I sleep,
http://www.picturel.com       And lines to code before I sleep."


[-- Attachment #2: usb-remove.patch --]
[-- Type: application/x-patch , Size: 2224 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Hotunplug
  2001-05-23  0:44 Hotunplug Stephen Williams
@ 2001-05-25  4:46 ` Greg KH
  2001-05-25 14:19 ` Hotunplug David Brownell
  2001-05-25 14:53 ` Hotunplug Stephen Williams
  2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2001-05-25  4:46 UTC (permalink / raw)
  To: linux-hotplug

On Tue, May 22, 2001 at 05:44:45PM -0700, Stephen Williams wrote:
> 
> I've made a go at implementing support for hot unplug in the hotplug
> scripts. What I have done is calculated a path to a "remover" program
> that is passed as the REMOVE environment variable to the existing add
> scripts. If the add script wants to make something happen when the
> device is removed, it writes something to the remover and marks it
> executable.

I like the idea of this, but the following lines make me nervous:

 
+    # Create a directory to hold remover programs. Close it up so
+    # that only hotplug scripts can write to this directory.
+    mkdir /var/run/usb
+    chmod 0700 /var/run/usb
+

Things like this should be done by the installer of the package, so as
to allow different distros handle this properly.

Also, the creation of directories should be done only once, not every
time.

If David doesn't object, I'll add this patch to cvs (without the above
change, but with the .spec file changed.)

thanks,

greg k-h

_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Hotunplug
  2001-05-23  0:44 Hotunplug Stephen Williams
  2001-05-25  4:46 ` Hotunplug Greg KH
@ 2001-05-25 14:19 ` David Brownell
  2001-05-25 14:53 ` Hotunplug Stephen Williams
  2 siblings, 0 replies; 4+ messages in thread
From: David Brownell @ 2001-05-25 14:19 UTC (permalink / raw)
  To: linux-hotplug

> +    # Create a directory to hold remover programs. Close it up so
> +    # that only hotplug scripts can write to this directory.
> +    mkdir /var/run/usb
> +    chmod 0700 /var/run/usb
> +
> 
> Things like this should be done by the installer of the package, so as
> to allow different distros handle this properly.
>
> Also, the creation of directories should be done only once, not every
> time.

Yes.  Though ... shouldn't the directory be configurable?
A default of /var/run/usb would be fine; the existing
machinery in /etc/sysconfig/usb should be able to change
such defaults.

And there are bootstrap issues too ... if this is run through
the /etc/rc.d/init.d/hotplug script, "/var/run/usb" won't be
readonly, but perhaps existing scripts should be run and then
removed (for crash recovery, with some appropriate ACTION
set in the environment during hotplug startup).


> If David doesn't object, I'll add this patch to cvs (without the above
> change, but with the .spec file changed.)

I'll not object, though as Miles noted there may be interesting
races on unplugging that don't get seen very often ... also, the
README directions for manual install should get updated.

- Dave




_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Hotunplug
  2001-05-23  0:44 Hotunplug Stephen Williams
  2001-05-25  4:46 ` Hotunplug Greg KH
  2001-05-25 14:19 ` Hotunplug David Brownell
@ 2001-05-25 14:53 ` Stephen Williams
  2 siblings, 0 replies; 4+ messages in thread
From: Stephen Williams @ 2001-05-25 14:53 UTC (permalink / raw)
  To: linux-hotplug

> Also, the creation of directories should be done only once, not every
> time.


david-b@pacbell.net said:
> And there are bootstrap issues too ... if this is run through the /etc/
> rc.d/init.d/hotplug script, "/var/run/usb" won't be readonly, but
> perhaps existing scripts should be run and then removed (for crash
> recovery, with some appropriate ACTION set in the environment during
> hotplug startup).

My intent in creating it in the usb.rc was to give the startup and
stop a chance to cleanup the /var/run/usb directory. It seems more
robust that way. However, I hadn't actually done anything along those
lines, so its OK either way with me.
-- 
Steve Williams                "The woods are lovely, dark and deep.
steve@icarus.com              But I have promises to keep,
steve@picturel.com            and lines to code before I sleep,
http://www.picturel.com       And lines to code before I sleep."



_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-05-25 14:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-05-23  0:44 Hotunplug Stephen Williams
2001-05-25  4:46 ` Hotunplug Greg KH
2001-05-25 14:19 ` Hotunplug David Brownell
2001-05-25 14:53 ` Hotunplug Stephen Williams

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).