When I run /etc/init.d/coldplug script I get errors about non-existent files. They come from sane-backends' /etc/hotplug/usb/libusbscanner script trying to change file permissions and ownership for my USB scanner. The $DEVICE variable passed to the script points to an invalid directory '/proc/bus/usb/001/002'. Note that my scanner is plugged into second USB controller and exists in /proc filesystem as '/proc/bus/usb/002/002'. It seems, that this misdetection of bus number is caused by a bug in usb.rc script. It relies on a value from devnum file of USB controller entry in sysfs: ----lines from usb.rc---- devbus=$( ( echo -n 000 ; cat $devlink/../../devnum) | grep -o ...\$ ) devdev=$( ( echo -n 000 ; cat $devlink/../devnum ) | grep -o ...\$ ) DEVICE="/proc/bus/usb/$devbus/$devdev" -----------end----------- However on my system, every /sys/bus/usb/devices/usb?/devnum file contains '1'. This means that every hardware connected to USB bus greater than 001 will be incorrectly handled in hotplug scripts. Reproducible: Always Steps to Reproduce: 1. 2. 3. Portage 2.0.51-r3 (default-linux/x86/2004.2, gcc-3.3.4, glibc-2.3.4.20040808-r1, 2.6.9-gentoo-r4 i686) ================================================================= System uname: 2.6.9-gentoo-r4 i686 Intel(R) Pentium(R) 4 CPU 3.00GHz Gentoo Base System version 1.4.16 ccache version 2.3 [enabled] Autoconf: sys-devel/autoconf-2.59-r5 Automake: sys-devel/automake-1.8.5-r1 Binutils: sys-devel/binutils-2.14.90.0.8-r1 Headers: sys-kernel/linux26-headers-2.6.8.1 Libtools: sys-devel/libtool-1.5.2-r5 ACCEPT_KEYWORDS="x86" AUTOCLEAN="yes" CFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer" CHOST="i686-pc-linux-gnu" COMPILER="" CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3. 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/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="-march=pentium4 -O3 -pipe -fomit-frame-pointer" DISTDIR="/usr/portage/distfiles" FEATURES="autoaddcvs ccache distlocks sandbox sfperms userpriv usersandbox" GENTOO_MIRRORS="http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror/ ftp:/ /ftp.tu-clausthal.de/pub/linux/gentoo/ ftp://sunsite.informatik.rwth-aachen.de/ pub/Linux/gentoo http://gentoo.oregonstate.edu/ http://www.ibiblio.org/pub/ Linux/distributions/gentoo" MAKEOPTS="-j2" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="" SYNC="rsync://rsync.gentoo.org/gentoo-portage" USE="3ds X Xaw3d aalib acpi adns alsa apache2 apm arts audiofile avi bash- completion berkdb bitmap-fonts bonobo cdparanoia cdr crypt cscope cups dga directfb divx4linux doc dv dvb dvd dvdread edl encode esd f77 faad fam fbcon flac foomaticdb fortran gdbm gif gimp gimpprint gnome gpm gstreamer gtk gtk2 gtkhtml guile icc imagemagick imap imlib innodb ipv6 jabber jack java jikes jpeg jpeg2k junit justify kde lcms libcaca libg++ libwww lzo mad maildir mbox mikmod mmx mmx2 mng monkey motif mozcalendar mozdevelop mozilla mozsvg mozxmlterm mpeg mysql nas ncurses network nls nptl offensive oggvorbis openal opengl oss pam pcre pdflib perl pg-hier pg-intdatetime pg-vacuumdelay pic png postgres ppds python qt qtmt quicktime readline real rtc sasl scanner sdl slang smooth snmp socks5 speex spell sse ssl stroke svga tcltk tcpd tetex tga theora tiff truetype unicode usb vim-with-xx86 xchatdccserver xine xml xml2 xmms xprint xv xvid yv12 zlib" lsusb output: Bus 005 Device 001: ID 0000:0000 Bus 004 Device 001: ID 0000:0000 Bus 003 Device 001: ID 0000:0000 Bus 002 Device 002: ID 07b3:0015 Plustek, Inc. OpticPro U24 Scanner Bus 002 Device 001: ID 0000:0000 Bus 001 Device 001: ID 0000:0000 USB controllers' devnum files: cat /sys/bus/usb/devices/usb?/devnum 1 1 1 1 1
*** This bug has been marked as a duplicate of 50934 ***
This is not a duplicate of 50934, libusbscanner has nothing to do with this bug, as it gets invalid data from hotplug. The bug is located in usb.rc in a loop which enumerates USB devices based on sysfs hierarchy. <=hotplug-20040401 performs this correctly, only latest version in portage is broken. This code fragment comes from usb.rc: PRODUCT="$(cat $devlink/../idVendor)/$(cat $devlink/../idProduct)/$(cat $devlink/../bcdDevice)" if [ -f $devlink/../../devnum ] then devbus=$( ( echo -n 000 ; cat $devlink/../../devnum ) | grep -o ...\$ ) devdev=$( ( echo -n 000 ; cat $devlink/../devnum ) | grep -o ...\$ ) DEVICE="/proc/bus/usb/$devbus/$devdev" else DEVICE= fi When the if condition above evaluates to true, $devbus contains invalid value (always 1, since UHC is assigned devnum 1 in the kernel). Then appropriate usb module is called, but with incorrect, non-null DEVICE value. This causes error messages in my init scripts. Bug 50934 relates to invalid device id, not bus id, which is the case here (besides, sane-backends' device id fix isn't executed at all, because DEVICE variable is non-null here). When if condition evaluates to false, PRODUCT variable on my machine contains data from host controller entry. Thus idVendor, idProduct are both set to 0000 and don't match any entry in USB usermaps. No usb module is called in this situation, so there is no way bug 50934 can be a duplicate of this one. I don't know, whether the fix should be implemented on sane-backends' or hotplug' side, but I'm pretty sure that 50934 is not related to this issue, as it deals with older hotplug version.
Ok, so what should the fix be for the hotplug scripts to properly handle this situation? Care to attach a patch?
Created attachment 44078 [details, diff] patch for hotplug-20040923 usb.rc file This patch fixes coldplug scripts on my machine (kernel 2.6.9). I don't know if it's correct to extract bus id from sysfs directory name, but it's the only way I could find. It should also be consistent with kernel side hotplug support.
Created attachment 44903 [details, diff] same kind of idea as Adam's, bit different I ran into exact same problem. This is how I fixed it up before I ran into Adam's patch. Similiar idea...
Lee, can you make a patch, and attach it, not the whole file itself?
Comment on attachment 44903 [details, diff] same kind of idea as Adam's, bit different whoops, wrong file! sorry
Created attachment 45105 [details, diff] variant patch what I meant to post
*** This bug has been marked as a duplicate of bug 82729 ***