Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 106526 - usbmouse hotplug script "add"s device but does not "remove" it.
Summary: usbmouse hotplug script "add"s device but does not "remove" it.
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: x86 Linux
: High minor (vote)
Assignee: Greg Kroah-Hartman (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-19 08:28 UTC by John (EBo) David
Modified: 2006-04-17 08:50 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John (EBo) David 2005-09-19 08:28:29 UTC
After a recent update the script to load/unload the usbmouse driver died.  The
problem appears that the script is not being called during the removal process.

The script file /etc/hotplug/usb/usbmouse invokes correctly when the device
usbmouse is plugged in (which was verified by adding some diagnostic writes
dumping $ACTION, $0, $REMOVER, and a date/time -stamp.  The handler is never
being called when the device is removed.

Possible reason is that the $REMOVER variable is now set to
"%sys%devices%pci0000:00%0000:00:1d.0%usb2%2-2%2-2:1.0" and is used to create a
symbolic link in /var/run/usb/ to the device handeler /etc/hotplug/usb/usbmouse.




Reproducible: Always
Steps to Reproduce:
On my system

1. modify the /etc/hotplug/usbmouse script for diagnostics (please note that I
compiled the psmouse into the kernel and use synclient to turn the touchpad
on/off instead of removing the psmodule):

#!/bin/sh

# this removes the psmouse.ko kernel module for the touchpad when a
# usb mouse is plugged in, and re-inserts the module when the usb mouse
#is removed.

echo >>  /bla
echo "$ACTION " `date` >> /bla
if test "$ACTION" = "add"  ; then
#    rmmod psmouse

    synclient TouchpadOff=1
echo "TouchpadOff=1" >> /bla
echo "  remover = $0 -> $REMOVER" >> /bla

    if test -n "$REMOVER" ; then
        # usb.agent sets this variable to point to an executable that
        # will be run on remove, if it exists
        ln -s "$0" "$REMOVER"
    fi
elif test "$ACTION" = "remove" ; then
#    modprobe psmouse

    synclient TouchpadOff=0
echo "$ACTION " `date` > /bla
echo "TouchpadOff=0" >> /bla

# else unknown action?
echo " UNKNOWN --- $ACTION " `date` > /bla
fi

2. plug/unplug the device several times.

3. view the diagnostic "log" file

Actual Results:  

The actual results show that the handler is only invoked on adds and the
"$REMOVER" is never called:

...

add  Mon Sep 19 11:12:49 EDT 2005
TouchpadOff=1
  remover = /etc/hotplug/usb/usbmouse ->
/var/run/usb/%sys%devices%pci0000:00%0000:00:1d.0%usb2%2-2%2-2:1.0

add  Mon Sep 19 11:22:22 EDT 2005
TouchpadOff=1
  remover = /etc/hotplug/usb/usbmouse ->
/var/run/usb/%sys%devices%pci0000:00%0000:00:1d.0%usb2%2-2%2-2:1.0


Expected Results:  
The remover should have been called and written the following diagnostic:

remove `date`
TouchpadOff=0

...



Portage 2.0.51.22-r2 (default-linux/x86/2005.0, gcc-3.3.6, glibc-2.3.5-r1,
2.6.12-gentoo-r10 i686)
=================================================================
System uname: 2.6.12-gentoo-r10 i686 Intel(R) Celeron(R) M processor         1.40GHz
Gentoo Base System version 1.6.13
dev-lang/python:     2.3.5-r2
sys-apps/sandbox:    1.2.12
sys-devel/autoconf:  2.13, 2.59-r6
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6
sys-devel/binutils:  2.15.92.0.2-r10
sys-devel/libtool:   1.5.18-r1
virtual/os-headers:  2.6.11-r2
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O3 -march=i686 -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3.3/env
/usr/kde/3.3/share/config /usr/kde/3.3/shutdown /usr/kde/3/share/config
/usr/lib/X11/xkb /usr/lib/mozilla/defaults/pref /usr/share/config
/usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/
/usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/
/usr/share/texmf/xdvi/ /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-O3 -march=i686 -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks sandbox sfperms strict"
GENTOO_MIRRORS="http://distfiles.gentoo.org
http://distro.ibiblio.org/pub/Linux/distributions/gentoo"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="x86 X Xaw3d a52 aac acpi alsa apache2 apm arts atlas audiofile avi
bash-completion bcmath berkdb bitmap-fonts bzlib calendar cdr crypt cscope ctype
cups curl db2 dbm dbx dvd dvdr dvdread eds emacs emboss encode esd exif f77 f90
f95 fam ffmpeg fftw flash flatfile foomaticdb fortran freetype ftp gd gdbm gif
gmp gnome gnutils gphoto2 gpm gps gstreamer gtk gtk2 hal imagemagick imap imlib
inifileipv6 java javascript jpeg junit kde kdeenablefinal kerb4 kerberos lcms
ldap lesstif libg++ libwww lm_sensors mad mhash mikmod mime ming mmap mng motif
mozilla mp3 mpeg mpi mule mysql mysqli ncurses netcdf nhc98 nls nptl odbc
offensive ofx ogg oggvorbis openal opengl oss pam pcmcia pcre pdflib perl php
pic pie plotutils png pnp posix postgres ppds profile python qdbm qt quicktime
readline scanner sdl sharedmem slang slp sockets socks5 spell spl sse ssl svg
symlink tcltk tcpd test tetex threads tiff tokenizer truetype truetype-fonts
trusted type1-fonts unicode usb v4l vorbis wmf wxwindows xine xml xml2 xmlrpc
xmms xpm xv zlib userland_GNU kernel_linux elibc_glibc"
Unset:  ASFLAGS, CTARGET, LANG, LC_ALL, LDFLAGS, LINGUAS, PORTDIR_OVERLAY

===============================================================

I consider this a minor problem because I can turn the touchpad back on by
executing the command:

  synclient TouchpadOff=0
Comment 1 John (EBo) David 2005-09-19 12:23:07 UTC
I broke away a little time and may have tracked down the problem...

The usb.agent declares a "remover" by one of 3 expressions.  Since I am running
a 2.6.* kernel, I use the following:

  REMOVER=/var/run/usb/$(readlink -f $SYSFS/$DEVPATH | sed -e 's;/;%;g')

The readlink appears to check the actual file system path (which does not exist
at the time that the usb.agent is setting itself up to either add or remover
later in the script).  The first attempt (simply echoing the path to sed) works
but produces a a double % in the path due to the fact that $DEVPATH starts with
a leading /.

I have changed this expression with:

  REMOVER=/var/run/usb/$(echo $SYSFS/$DEVPATH | sed -e 's;/;%;g' | sed -e
's;%%;%;g')

to remove the double %% and everything seems to be working.



Synopsys:

  The problem appeasrs to be caused by a timing issue where the appropriate
$SYSFS/$DEVPATH directory is removed prior to the hotplug device agent being
invoked.  During invocation of usb.agent both $SYSFS and $DEVPATH have
appropriate valuse so the workaround entails processing those strings directly
and not checking for the existance of those paths.

Comment 2 Karl Hakimian 2005-10-07 08:06:30 UTC
I have worked around this problem by replacing the line

REMOVER=/var/run/usb/$(readlink -f $SYSFS/$DEVPATH | sed -e 's;/;%;g')

with

REMOVER=/var/run/usb/$(echo ${SYSFS}${DEVPATH} | sed -e 's;/;%;g')

Not sure if the problem is gentoo or upstream, but the usb.agent script should
be fixed.
Comment 3 Greg Kroah-Hartman (RETIRED) gentoo-dev 2006-04-17 08:50:07 UTC
The hotplug package is being obsoleted by udev, so no new changes will be
made to it at this time, sorry.