到目前为止,我已经编写了一个Qt-Application,当我添加或删除usb设备时,它能够通过与uDevice守护进程(?)的套接字通信进行检测。
但我收到的相关信息对我来说并不是那么有用(至少不是从我目前的知识来看)。我正在尝试找到任何信息(接口的观点)我可以用一种方式构建我的代码,它可以提取必要的信息来查看:
a)插入式设备是否为大容量存储设备?
b)安装它的参数是什么。
由于与uDevice的通信工作和数据的解析,我甚至没有关于我正在接收的数据意味着什么,我希望当我刚刚提交收到的信息时,它不是偏离主题的uDevice。
这是我在添加单个USB-massstorage设备时收到的信息:
(每行一个包,但在插件后立即收到所有包)
add@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1
add@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0
add@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58
add@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58/scsi_host/host58
add@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58/target58:0:0
add@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58/target58:0:0/58:0:0:0
add@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58/target58:0:0/58:0:0:0/scsi_disk/58:0:0:0
add@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58/target58:0:0/58:0:0:0/scsi_device/58:0:0:0
add@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58/target58:0:0/58:0:0:0/scsi_generic/sg2
add@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58/target58:0:0/58:0:0:0/bsg/58:0:0:0
add@/devices/virtual/bdi/8:16
add@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58/target58:0:0/58:0:0:0/block/sdb
add@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58/target58:0:0/58:0:0:0/block/sdb/sdb1
这是我收到的删除同一设备的数据:
(特别注意其中一个通知包含“已更改”)
remove@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58/target58:0:0/58:0:0:0/bsg/58:0:0:0
remove@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58/target58:0:0/58:0:0:0/scsi_generic/sg2
remove@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58/target58:0:0/58:0:0:0/scsi_device/58:0:0:0
remove@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58/target58:0:0/58:0:0:0/scsi_disk/58:0:0:0
change@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58/target58:0:0/58:0:0:0/block/sdb
remove@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58/target58:0:0/58:0:0:0/block/sdb/sdb1
remove@/devices/virtual/bdi/8:16
remove@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58/target58:0:0/58:0:0:0/block/sdb
remove@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58/target58:0:0/58:0:0:0
remove@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58/target58:0:0
remove@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58/scsi_host/host58
remove@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host58
remove@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0
remove@/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1
所以现在我的问题是:如果这不是安装设备所需的数据,那么需要考虑从uDevice获取该信息。
如果有足够的信息来完成这项工作(我正在假设,因为我更有可能错过了完全理解这些数据甚至告诉我的知识!)究竟哪些行包含了信息以及如何提取这些信息?
注意: ubuntu系统在VMware虚拟机中运行。提及这一点是必要的,因为VM可能会改变usb设备可能处理的任何方式。