Provided a way to translate metadata IDs return by udev event to human readable label
pilebones opened this issue · 1 comments
pilebones commented
Example of Uevent from this tool:
2017/10/20 23:47:29 Handle netlink.UEvent{
Action: "remove",
KObj: "/devices/pci0000:00/0000:00:14.0/usb1/1-1",
Env: {"PRODUCT":"58f/6387/10b", "TYPE":"0/0/0", "DEVNUM":"005", "SEQNUM":"2549", "ACTION":"remove", "DEVPATH":"/devices/pci0000:00/0000:00:14.0/usb1/1-1", "SUBSYSTEM":"usb", "MAJOR":"189", "MINOR":"4", "DEVNAME":"bus/usb/001/005", "DEVTYPE":"usb_device", "BUSNUM":"001"},
}
PRODUCT
should be translate to extract the vendor, manufacturer and product name.
Example with a basic USB storage using udevadm
:
ID_MODEL=USB_DISK_30X
ID_MODEL_ENC=USB\x20DISK\x2030X\x20\x20\x20\x20
ID_REVISION=0110
DEVTYPE=usb_device
ID_BUS=usb
SUBSYSTEM=usb
ID_MODEL_FROM_DATABASE=DataTraveler 2.0 1GB/4GB Flash Drive / Patriot Xporter 4GB Flash Drive
ID_SERIAL=_USB_DISK_30X_07720F2E040C
ID_MODEL_ID=1d00
ID_VENDOR_ENC=\x20\x20\x20\x20\x20\x20\x20\x20
ID_VENDOR_ID=13fe
PRODUCT=13fe/1d00/110
ID_VENDOR_FROM_DATABASE=Kingston Technology Company Inc.
ID_SERIAL_SHORT=07720F2E040C
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pilebones commented
Feature already fonctionnal and native, ie:
2018/07/10 13:08:02 Handle netlink.UEvent{
Action: "bind",
KObj: "/devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1.1/2-1.1:1.1",
Env: {"USEC_INITIALIZED":"5095183791", "ID_MODEL_FROM_DATABASE":"Keyboard", "DEVPATH":"/devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1.1/2-1.1:1.1", "SUBSYSTEM":"usb", "DEVTYPE":"usb_interface", "DRIVER":"usbhid", "TYPE":"0/0/0", "ID_VENDOR_FROM_DATABASE":"Cherry GmbH", "ACTION":"bind", "PRODUCT":"46a/23/220", "INTERFACE":"3/0/0", "MODALIAS":"usb:v046Ap0023d0220dc00dsc00dp00ic03isc00ip00in01", "SEQNUM":"3109"},
}
2018/07/10 13:08:02 Handle netlink.UEvent{
Action: "bind",
KObj: "/devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1.1",
Env: {"BUSNUM":"002", "DEVNUM":"009", "ID_MODEL_ENC":"0023", "ID_REVISION":"0220", "ACTION":"bind", "DEVPATH":"/devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1.1", "PRODUCT":"46a/23/220", "SEQNUM":"3110", "MINOR":"136", "ID_VENDOR":"046a", "ID_MODEL_FROM_DATABASE":"Keyboard", "SUBSYSTEM":"usb", "DEVTYPE":"usb_device", "DRIVER":"usb", "ID_USB_INTERFACES":":030101:030000:", "DEVNAME":"/dev/bus/usb/002/009", "TYPE":"0/0/0", "MAJOR":"189", "ID_MODEL":"0023", "ID_MODEL_ID":"0023", "ID_SERIAL":"046a_0023", "ID_BUS":"usb", "ID_VENDOR_FROM_DATABASE":"Cherry GmbH", "USEC_INITIALIZED":"5095111292", "ID_VENDOR_ENC":"046a", "ID_VENDOR_ID":"046a"},
}