tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: poll(2)ing for USB device changes
> Date: Wed, 24 Jun 2026 12:39:42 +0200
> From: Timo Buhrmester <timo%math.uni-bonn.de@localhost>
>
> usb(4) says:
> | The /dev/usbN can be opened and a few operations can be performed on it.
> | The poll(2) system call will say that I/O is possible on the controller
> | device when a USB device has been connected or disconnected to the bus.
This appears to be wrong. It may have been the case until mid-1999
when augustss@ split /dev/usb from /dev/usbN:
https://nxr.NetBSD.org/xref/src/sys/dev/usb/usb.c?r=1.26#458
The text you quoted predates that change, having been added in
mid-1998, and was presumably never updated to reflect the change:
https://nxr.NetBSD.org/xref/src/share/man/man4/usb.4?r=1.3
However, a later part of the man page is right:
USB EVENT INTERFACE
All USB events are reported via the /dev/usb device. This devices can be
opened for reading and each read(2) will yield an event record (if
something has happened). The poll(2) system call can be used to
determine if an event record is available for reading.
> int fd = open("/dev/usb0", O_RDONLY, 0);
> if (fd < 0)
> err(EXIT_FAILURE, "open /dev/usb0");
So changing this to /dev/usb will do something (and it will always
report ready until you consume the event by reading from it).
Can you file a PR to track this?
Home |
Main Index |
Thread Index |
Old Index