[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Hotplug and unloading modules

On Thu, 26 Dec 2002, Marc Wilson wrote:

> On Thu, Dec 26, 2002 at 06:11:06PM -0800, Bill Moseley wrote:
> > Is there a way to either unload the modules automatically on hotplug
> > disconnect so that it will run my script again on next hotsync?
> Sure.  Just have your action script unload it explicitly:
> $ cat /etc/hotplug/usb/visor
> #!/bin/sh
> /bin/su mwilson -c /usr/local/bin/coldsync
> /sbin/rmmod visor usbserial

In my case I'm using jpilot-sync.

This first example unloads the modules:


/usr/bin/logger "running visor!"
/sbin/rmmod visor usbserial

But this one doesn't unload the modules:


/usr/bin/logger "running visor!"

sleep 2
/bin/su moseley -c /usr/bin/jpilot-sync
sleep 2
/sbin/rmmod visor usbserial

The hotsync works, but after this completes I still have:

# lsmod
Module                  Size  Used by    Tainted: P  
visor                  10156   1 
usbserial              18044   0  [visor]
usbcore                49760   1  [visor usbserial usbkbd usb-uhci]

So that means on next hotsync visor is not loaded, and thus
/etc/hotplug/usb/visor is not run.

Stuff I don't understand, but running jpilot-sync must bump the reference
count on the visor module. 

# rmmod visor usbserial
visor: Device or resource busy
usbserial: Device or resource busy

Bill Moseley moseley@hank.org

Reply to: