我的目的是检测在检测到/删除USB后生成的事件。(操作系统:Linux和语言C / C ++)。 为此,我使用Udevadm包来获取此事件,我得到以下输出:
UDEV [9494.049740] add /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host10/target10:0:0/10:0:0:0/block/sdb (block)
ACTION=add
DEVLINKS=/dev/disk/by-id/usb-WIKO_Mass_Storage_0123456789ABCDEF-0:0 /dev/disk/by-path/pci-0000:02:03.0-usb-0:1:1.0-scsi-0:0:0:0
DEVNAME=/dev/sdb
DEVPATH=/devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/host10/target10:0:0/10:0:0:0/block/sdb
DEVTYPE=disk
ID_BUS=usb
ID_INSTANCE=0:0
ID_MODEL=Mass_Storage
ID_MODEL_ENC=Mass\x20Storage\x20\x20\x20\x20
ID_MODEL_ID=0001
ID_PATH=pci-0000:02:03.0-usb-0:1:1.0-scsi-0:0:0:0
ID_PATH_TAG=pci-0000_02_03_0-usb-0_1_1_0-scsi-0_0_0_0
ID_REVISION=0000
ID_SERIAL=WIKO_Mass_Storage_0123456789ABCDEF-0:0
ID_SERIAL_SHORT=0123456789ABCDEF
ID_TYPE=disk
ID_USB_DRIVER=usb-storage
ID_USB_INTERFACES=:080650:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=WIKO
ID_VENDOR_ENC=WIKO\x20\x20\x20\x20
ID_VENDOR_ID=0bb4
MAJOR=8
MINOR=16
SEQNUM=2394
SUBSYSTEM=block
UDEV_LOG=3
UDISKS_PRESENTATION_NOPOLICY=0
USEC_INITIALIZED=9493993109
有没有办法在不解析变量中的所有输出的情况下获取"事件"," Action"和" DEVNAME"的类型字符串和之后收集重要信息?