I am new to Linux kernel programming. I wish to develop a program to read USB drive information like its manufacturer name, capacity, etc. I know about descriptors and their attributes. But I don't understand how to enumerate USB drives connected to the system. I am looking for the function which initiates connection between kernel and USB port. How is it possible?
相关问题
- Multiple sockets for clients to connect to
- Is shmid returned by shmget() unique across proces
- What is the best way to do a search in a large fil
- glDrawElements only draws half a quad
- how to get running process information in java?
You don't need to program the kernel as such - in fact to read the device info you don't even need a device driver.
The USB system is different in the newer 2.6 kernels so a lot of the online tutorials may be out of date - but start here http://www.linux-usb.org/
If you do want to write a USB device driver see this Linux journal tutorial
Do you really want to do a kernel programming? There is an lsusb utility, capable of reading "USB drive information like its manufacturer name", descriptors... It also can enumerate all usb devices.
Sources of
lsusb
are e.g. here http://www.google.com/codesearch#VKTEFMx6wp0/lsusb.cIf you are doing a writing an USB driver, which works in kernel mode, I suggest you read some existing usb driver and USB driver programming FAQ.