From eeddb2256e870126f85a564fecfb45649010dfa1 Mon Sep 17 00:00:00 2001 From: Sam Bishop Date: Mon, 28 Aug 2006 16:52:15 -0600 Subject: [PATCH] --- yaml --- r: 36353 b: refs/heads/master c: 06afff00bcab0e384afbef70194fd3469532abdf h: refs/heads/master i: 36351: eff43d17bea19f7e90870a076bfa379f4a858db7 v: v3 --- [refs] | 2 +- trunk/Documentation/DocBook/usb.tmpl | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/[refs] b/[refs] index 5e2f8c7dd764..1d7a1d0a228d 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 341323269258ab8484077a9c70db804fbae6ae93 +refs/heads/master: 06afff00bcab0e384afbef70194fd3469532abdf diff --git a/trunk/Documentation/DocBook/usb.tmpl b/trunk/Documentation/DocBook/usb.tmpl index 8a28f76b9359..3608472d7b74 100644 --- a/trunk/Documentation/DocBook/usb.tmpl +++ b/trunk/Documentation/DocBook/usb.tmpl @@ -453,14 +453,25 @@ file in your Linux kernel sources. - 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. + This file, in combination with the poll() system call, can + also be used to detect when devices are added or removed: +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.) */ +} + 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. -