On Monday 28 August 2006 1:27 pm, Sam Bishop wrote:
> On Thu, Aug 24, 2006 at 03:04:33PM -0700, David Brownell wrote:
> > Just revert to the previous language ... if you want, emphasize that
> > the scanning is to figure out precisely what changed.
>
> How's this? (I've made a few other small changes too.)
>
>
>
> 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-28
> 14:19:40.719391520 -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. (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.
> +}</programlisting>
> + Note that this behavior is intended to be used for informational
> + and debug purposes. It would be more appropriate to use programs
> + such as 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
> _______________________________________________
> [email protected]
> To unsubscribe, use the last form field at:
> https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
>
-------------------------------------------------------------------------
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
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel