Search code examples
linuxlinux-device-driverlibusbudev

Is there some way of getting sysname in libusb like edev?


I need to get the device name of a device, which, by default, is on edev function: https://www.kernel.org/pub/linux/utils/kernel/hotplug/libudev/libudev-udev-device.html#udev-device-get-sysname

udev_device_get_sysname ()

const char *        udev_device_get_sysname             (struct             udev_device *udev_device);
udev_device :

udev device
Returns :

the sys name of the device device

But all the work with the device are done in libusb, it would be terrible to use udev only for the sysname, and it's really strange that I cannot find similar functions in libusb.

Anybody know about it?

Thanks in advance!


Solution

  • Finally I solve it on my own, in a very stupid way.

    I got the busnum and devnum of a device in libusb, and iter all devices in udev, if a device has the same busnum and devnum, return it's sysname.

    I get busnum by udev api, devnum by cat /syspath/devnum.

    Vid Pid won't work since same devices have same ids.

    Hope this will be of help.