This file is handy for status viewing tools in user
mode, which can scan the text format and ignore most of it.
More detailed device status (including class and vendor
status) is available from device-specific files.
For information about the current format of this file,
see the
Documentation/usb/proc_usb_info.txt
file in your Linux kernel sources.
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.