已知 usb 的 pid vid,如何对加载的u盘进行管理
思路,找到 U盘的厂商信息中的pid和 vid 对应关系,然后控制 U盘的加载
但是 U盘信息中没有pid 和 vid
root@li-PC:/sys/kernel/debug/usb# df
文件系统 1K-块 已用 可用 已用% 挂载点
udev 945652 0 945652 0% /dev
tmpfs 195140 1528 193612 1% /run
/dev/sda2 37924256 13317744 22650368 38% /
tmpfs 975692 45420 930272 5% /dev/shm
tmpfs 5120 4 5116 1% /run/lock
tmpfs 975692 0 975692 0% /sys/fs/cgroup
tmpfs 195136 20 195116 1% /run/user/1001
/dev/sdc1 61438976 106624 61332352 1% /media/bkdrong/新加卷
root@li-PC:/sys/kernel/debug/usb# lsusb -v
显示的部分内容
Bus 001 Device 003: ID 090c:1000 Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) Flash Drive
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x090c Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.)
idProduct 0x1000 Flash Drive
bcdDevice 11.00
iManufacturer 1 aigo
iProduct 2 MiniKing
iSerial 3 AA00000000007330
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 300mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk-Only
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
root@li-PC:/dev/disk/by-id# ls -l
总用量 0
lrwxrwxrwx 1 root root 9 4月 12 15:08 ata-VMware_Virtual_SATA_CDRW_Drive_01000000000000000001 -> ../../sr0
lrwxrwxrwx 1 root root 9 4月 12 15:40 usb-aigo_MiniKing_AA00000000007330-0:0 -> ../../sdc
lrwxrwxrwx 1 root root 10 4月 12 15:40 usb-aigo_MiniKing_AA00000000007330-0:0-part1 -> ../../sdc1
中每一个设备永久的描述符中含有 序列号,并且和设备 /dev/sdc … 有个对应关系。
pid+vid <-> usb序列号 <-> u盘的设备名
这样就将 pid +vid 和 u盘的设备名相对应,就可以进行管理了。
书以博客以记之.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)