提交 3ef77a54 编写于 作者: L Lubomir Rintel 提交者: Ján Tomko

node_device_udev: Try harder to get human readable vendor:product

The manufacurer and product from USB device itself are usually not particularly
useful -- they tend to be missing, or ugly (all-uppercase, padded with spaces,
etc.). Prefer what's in the usb id database and fall back to descriptors only
if the device is too new to be in database.

https://bugzilla.redhat.com/show_bug.cgi?id=1138887
上级 7e649c54
......@@ -580,6 +580,7 @@ static int udevProcessUSBDevice(struct udev_device *device,
{
union _virNodeDevCapData *data = &def->caps->data;
int ret = -1;
int err;
if (udevGetUintProperty(device,
"BUSNUM",
......@@ -602,10 +603,17 @@ static int udevProcessUSBDevice(struct udev_device *device,
goto out;
}
if (udevGetStringSysfsAttr(device,
"manufacturer",
&data->usb_dev.vendor_name) == PROPERTY_ERROR) {
err = udevGetStringProperty(device,
"ID_VENDOR_FROM_DATABASE",
&data->usb_dev.vendor_name);
if (err == PROPERTY_ERROR)
goto out;
if (err == PROPERTY_MISSING) {
if (udevGetStringSysfsAttr(device,
"manufacturer",
&data->usb_dev.vendor_name) == PROPERTY_ERROR) {
goto out;
}
}
if (udevGetUintProperty(device,
......@@ -615,10 +623,17 @@ static int udevProcessUSBDevice(struct udev_device *device,
goto out;
}
if (udevGetStringSysfsAttr(device,
"product",
&data->usb_dev.product_name) == PROPERTY_ERROR) {
err = udevGetStringProperty(device,
"ID_MODEL_FROM_DATABASE",
&data->usb_dev.product_name);
if (err == PROPERTY_ERROR)
goto out;
if (err == PROPERTY_MISSING) {
if (udevGetStringSysfsAttr(device,
"product",
&data->usb_dev.product_name) == PROPERTY_ERROR) {
goto out;
}
}
if (udevGenerateDeviceName(device, def, NULL) != 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册