From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kay Sievers Date: Fri, 19 Aug 2005 17:18:46 +0000 Subject: Re: general hotplug/udev questions Message-Id: <20050819171846.GA22030@vrfy.org> List-Id: References: <1124394814.4483.46.camel@rich> In-Reply-To: <1124394814.4483.46.camel@rich> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org On Fri, Aug 19, 2005 at 10:11:16AM -0700, Greg KH wrote: > On Fri, Aug 19, 2005 at 06:56:47PM +0200, Kay Sievers wrote: > > On Fri, Aug 19, 2005 at 09:47:59AM -0700, Greg KH wrote: > > > On Fri, Aug 19, 2005 at 10:33:02PM +0600, Alexander E. Patrakov wrote: > > > > Greg KH wrote: > > > > > > > > >On Fri, Aug 19, 2005 at 03:09:59PM +0600, Alexander E. Patrakov wrote: > > > > > > > > > > > > > > >>Do I understand correctly that the "crawl through sysfs" approach means > > > > >>bus-specific conversion between sysfs contents (e.g the fact that > > > > >>/sys/bus/usb/devices/1-1/idProduct contains "4002" here) and environment > > > > >>variables (in this case, PRODUCT=...)? > > > > >> > > > > >> > > > > > > > > > >Yes, but it's a world easier now that we have added the 'modalias' sysfs > > > > >files so we don't have to reconstruct anything. All we care about at > > > > >coldplug time is loading the modules and creating existing device nodes. > > > > > > > > > > > > > > Sorry, no. We should also care about providing some hook for packages > > > > like SANE and gPhoto2 to chown/chmod pseudofiles in /proc/bus/usb. This > > > > requires perfect reconstruction of at least $PRODUCT and $DEVICE. > > > > > > Like Kay said, /proc/bus/usb/???/ is now dead. We have sane device nodes for > > > those usbfs files now that udev can manipulate the permissions for > > > properly. Run the latest -mm trees to see this. > > > > > > Kay, you have a libusb patch to support this, right? Care to share it? > > > > It requires this crazy udev rule: > > SUBSYSTEM="usb_device", PROGRAM="/bin/sh -c 'X=%k X=$${X#usbdev} B=$${X%%%%.*} D=$${X#*.}; echo bus/usb/$$B/$$D'", SYMLINK+="%c" > > Ugh. Is there any way we can change the kernel name of the class device > to make this easier to handle? Hm, probably not, unless I get subclass > devices working real soon... Not that I know. We could add regex support to udev to solve that in-process. :) > And do we need/want to care about the leading 0's like usbfs had? Works fine without, but adding it with the shell should be easy, just makes the rule a bit longer. :) > > ### > > Patch against libusb, to prepare for the upcoming changes in > > the Linux usb core, which will create real device nodes in /dev > > with udev. The following rule: > > SUBSYSTEM="usb_device", PROGRAM="/bin/sh -c 'X=%k X=$${X#usbdev} B=$${X%%%%.*} D=$${X#*.}; echo bus/usb/$$B/$$D'", SYMLINK="%c" > > > > creates a similar structure in /dev as usbfs creates in /proc to > > be picked up by libusb. > > > > I've removed the fallback to /sys/bus/usb cause this is completely > > wrong and can and will never work and /dev/usb is used differently > > and will also not provide access to the raw usb devices. > > > > Signed-off-by: Kay Sievers > > --- > > > > diff -u -r1.73 linux.c > > --- linux.c 1 Mar 2005 19:36:42 -0000 1.73 > > +++ linux.c 9 Aug 2005 00:06:43 -0000 > > @@ -636,11 +636,8 @@ > > if (check_usb_vfs("/proc/bus/usb")) { > > strncpy(usb_path, "/proc/bus/usb", sizeof(usb_path) - 1); > > usb_path[sizeof(usb_path) - 1] = 0; > > - } else if (check_usb_vfs("/sys/bus/usb")) { /* 2.6 Kernel with sysfs */ > > - strncpy(usb_path, "/sys/bus/usb", sizeof(usb_path) -1); > > - usb_path[sizeof(usb_path) - 1] = 0; > > - } else if (check_usb_vfs("/dev/usb")) { > > - strncpy(usb_path, "/dev/usb", sizeof(usb_path) - 1); > > + } else if (check_usb_vfs("/dev/bus/usb")) { > > + strncpy(usb_path, "/dev/bus/usb", sizeof(usb_path) -1); > > usb_path[sizeof(usb_path) - 1] = 0; > > } else > > usb_path[0] = 0; /* No path, no USB support */ > > > Hm, why was libusb checking for sysfs stuff in the first place? It > couldn't do anything with those files, right? No, it doesn't make sense. Seems someone was a bit confused about sysfs and thought /proc/bus will move to /sys/bus :) Kay ------------------------------------------------------- SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf _______________________________________________ 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