On Tue, Aug 29, 2006 at 08:30:45AM -0700, David Brownell wrote: > On Monday 28 August 2006 1:27 pm, Sam Bishop wrote: > > + /* To see what's changed, compare the file's previous and current > > + contents or scan the filesystem. (Scanning is more precise.) */ > > Rather than "more precise", "less error prone" ... there are nasty error > paths in the "compare" case. Better yet, don't mention that.
Sure. I also removed the bit where I call HAL a program... Thanks for your help, David. A little more detail on how and when to poll() /proc/bus/usb/devices. Signed-off-by: Sam Bishop <[EMAIL PROTECTED]> --- linux-2.6.17.9/Documentation/DocBook/usb.tmpl.orig 2006-08-24 13:32:07.602622546 -0600 +++ linux-2.6.17.9/Documentation/DocBook/usb.tmpl 2006-08-29 10:25:25.913847688 -0600 @@ -463,14 +463,25 @@ file in your Linux kernel sources. </para> - <para>Otherwise the main use for this file from programs - is to poll() it to get notifications of usb devices - as they're plugged or unplugged. - To see what changed, you'd need to read the file and - compare "before" and "after" contents, scan the filesystem, - or see its hotplug event. + <para>This file, in combination with the poll() system call, can + also be used to detect when devices are added or removed: +<programlisting>int fd; +struct pollfd pfd; + +fd = open("/proc/bus/usb/devices", O_RDONLY); +pfd = { fd, POLLIN, 0 }; +for (;;) { + /* The first time through, this call will return immediately. */ + poll(&pfd, 1, -1); + + /* To see what's changed, compare the file's previous and current + contents or scan the filesystem. */ +}</programlisting> + Note that this behavior is intended to be used for informational + and debug purposes. It would be more appropriate to use udev or + HAL to initialize a device or start a user-mode helper program, for + instance. </para> - </sect1> <sect1> ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel