From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kay Sievers Date: Fri, 11 Mar 2005 08:54:57 +0000 Subject: Re: New hotplug interface is not working right for me Message-Id: <1110531297.4918.40.camel@localhost.localdomain> List-Id: References: <20050311060405.GA16141@thyrsus.com> In-Reply-To: <20050311060405.GA16141@thyrsus.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org On Thu, 2005-03-10 at 22:45 -0800, Greg KH wrote: > On Fri, Mar 11, 2005 at 01:04:05AM -0500, Eric S. Raymond wrote: > > Greg KH : > > > On Fri, Mar 11, 2005 at 12:20:54AM -0500, Eric S. Raymond wrote: > > > > Greg KH : > > > > > > The problem appears to be that whatever thread of control is creating > > > > > > the /dev/ttyUSB* node is running asynchronously with the hotplug > > > > > > script and does not reliably (or even usually) create it before the > > > > > > gpsd instance gets spawned and goes looking for the node. > > > > > > > > > > Then use the /etc/dev.d/ interface instead. That requires udev and a > > > > > 2.6 kernel, but is the only way you can know exactly when the /dev entry > > > > > is created. > > > > > > > > Where is this documented? > > > > > > In the udev documentation and a simple google search brings it up. > > > > > > > Even if the /etc/dev.d/ interface works, that doesn't really make it > > > > acceptable that the /etc/hotplug.d/ interface is broken. There is some > > > > locking that ought to be happening and isn't. > > > > > > The interface is not broken, you are trying to trigger off of two > > > different hotplug events (one when the device appears, and a different > > > one when the device node is to be created.) > > > > If it's not broken, then it's not documented either. > > You are watching for the wrong hotplug event, how can we document that? > :) If the hotplug helper in /proc/sys/kernel/hotplug is set to /sbin/udevsend, what all major distributions seems to do today, than there is nearly no difference between /etc/hotplug.d/ and /etc/dev.d/. Both directories are handled after the node creation with the same kernel hotplug event and have the name of the created/removed node in the environment. > > Or, at least, I don't see any documentation that tells me about a > > second hotplug event when /dev/ttyUSB0 is created. It is the _same_ hotplug event but an additional path of execution that only happens if udev created/removed a device node or a renamed a network interface. That was needed before we took over the hotplug event management with udev, cause applications wanted to know the name of the added device node. It is documented in the udev man page. > Now, if I could > > write a script that would fire on only only /dev/ttyUSB* creation events and > > allow me to filter on the vendor/product ID, that would be fine -- those > > are what I'm really interested in. Yeah, I'm all for doing this with udev rules. It is already working on my box. We just need to agree if and how we should do that. The plan is to add hotplug scripts with udev rules and execute scripts based on the same rule logic we use to name the device node. Your hook into hotplug with a udev rule would look like this: ACTION="add", SYSFS{vendor}="GPS", SYSFS{product}="0815", NAME="gps", HOTPLUG="/usr/bin/gps-something" > You can, just put your script into /etc/hotplug.d/tty and watch for the > device name to be ttyUSB*. Then walk the sysfs chain back up the > directory to see the vendor and product id of the device attached to > that ttyUSB device. That should work, but that script will add a noticeable overhead, cause it is executed for all hundreds of ttys on every bootup and for every vc open and close. Something similar adds a ~8 seconds delay on bootup for one of my slower boxes. Thanks, Kay ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_ide95&alloc_id396&op=click _______________________________________________ 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