Linux Kernel Check VID / PID Number?

2019-09-05 03:57发布

What I am looking for is the command to check the live USB disks serial number from within a kernel module.

from within the kernel, lsusb won't work.

TMI Clause: I am developing a live USB device for a client, and this will be a current part of our copy protection.

2条回答
甜甜的少女心
2楼-- · 2019-09-05 04:15

After a day of looking I've found the answer which can be found on StackOverflow here.

Essentially:

usb_bus_list is declared in #include <linux/usb/hcd.h>, which allows for its child functions to be called.

查看更多
闹够了就滚
3楼-- · 2019-09-05 04:26

Your program would be querying the serial number via the operating system. And you know what, your client has the ability to alter the operating system, so your program would not be able to completely trust the information provided by the OS.

If you're willing to trust the client (not to alter the OS), see how the hdparm program in Linux obtains its HDD detail information (including the serial number), or alternatively crawl through the /sys/devices/ hierarchy to find out the hard disks and their detail data (couldn't find it for the moment, but I think the serial info would be there as well).

If, on the other hand, you would like to expect your clients to cheat, then you would better not let them use your application at all.

查看更多
登录 后发表回答