[systemd-devel] Scan all USB devices from Linux service

Greg KH gregkh at linuxfoundation.org
Wed Feb 14 15:14:20 UTC 2024


On Wed, Feb 14, 2024 at 08:24:25PM +0530, Muni Sekhar wrote:
> HI all,
> 
> USB devices can have multiple interfaces (functional units) that serve
> different purposes (e.g., data transfer, control, audio, etc.).
> 
> Each interface can have an associated string descriptor (referred to
> as iInterface). The string descriptor provides a human-readable name
> or description for the interface.
> 
> >From user space service utility, How to scan all the USB devices
> connected to the system and read each interface string
> descriptor(iInterface)  and check whether it matches "Particular
> String" or not.

Just write some code to do so using either libusb, or your own sysfs
scanning logic or talk directly to all of the usb devices using usbfs.

> The service program should trigger scanning all the USB devices on any
> USB device detection or removal. Can libusb be used for it?

For detection/removal, no, libusb isn't for that.  udev can provide you
the needed callbacks to your code for that situation.

But what problem are you trying to solve that isn't already handled by
the kernel and userspace usb handling logic already?

good luck!

greg k-h


More information about the systemd-devel mailing list