问题
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.
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/17629242/linux-kernel-check-vid-pid-number