Welcome to the Linux Foundation Forum!

USB Linux API: call ioctl requests from user space app

I want to create Linux app responsible to get/set some usb settings especially settings responsible of followings:

USB ports

USB Host controller and USB driver

USB devices

I followed the linux api document: https://www.kernel.org/doc/html/v4.14/driver-api/usb/usb.html I found that it can be done through ioctl I found a list of ioctl requests, for example USBDEVFS_GETDRIVER.

I found that if I want a first small test it can be like that:

struct usbdevfs_getdriver usbdriver;
int fd = open("device_file_name", O_RDWR);
ioctl(fd, USBDEVFS_GETDRIVER, (struct usbdevfs_getdriver*) &usbdriver);

So my question is: is that the right way? What should be the device_file_name in the second line of my code?

Categories

Upcoming Training