提交 2c054ca1 编写于 作者: G Giuseppe Scrivano 提交者: Eric Blake

udev: consider the device a CDROM when ID_CDROM=1

Some CDROM devices are reported by udev to have an ID_TYPE="generic"
thus it is necessary to check if ID_CDROM is present.

As a side effect, treating ID_TYPE="generic" as a missing ID_TYPE will
enable checks for ID_DRIVE_FLASH_SD and ID_DRIVE_FLOPPY and the
udevKludgeStorageType heuristic.
Signed-off-by: NGiuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: NEric Blake <eblake@redhat.com>
上级 16c19ec1
/* /*
* node_device_udev.c: node device enumeration - libudev implementation * node_device_udev.c: node device enumeration - libudev implementation
* *
* Copyright (C) 2009-2013 Red Hat, Inc. * Copyright (C) 2009-2014 Red Hat, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
...@@ -1093,20 +1093,27 @@ static int udevProcessStorage(struct udev_device *device, ...@@ -1093,20 +1093,27 @@ static int udevProcessStorage(struct udev_device *device,
if (udevGetStringProperty(device, if (udevGetStringProperty(device,
"ID_TYPE", "ID_TYPE",
&data->storage.drive_type) != PROPERTY_FOUND) { &data->storage.drive_type) != PROPERTY_FOUND ||
STREQ(def->caps->data.storage.drive_type, "generic")) {
int tmp_int = 0; int tmp_int = 0;
/* All floppy drives have the ID_DRIVE_FLOPPY prop. This is /* All floppy drives have the ID_DRIVE_FLOPPY prop. This is
* needed since legacy floppies don't have a drive_type */ * needed since legacy floppies don't have a drive_type */
if ((udevGetIntProperty(device, "ID_DRIVE_FLOPPY", if (udevGetIntProperty(device, "ID_DRIVE_FLOPPY",
&tmp_int, 0) == PROPERTY_FOUND) && &tmp_int, 0) == PROPERTY_FOUND &&
(tmp_int == 1)) { tmp_int == 1) {
if (VIR_STRDUP(data->storage.drive_type, "floppy") < 0) if (VIR_STRDUP(data->storage.drive_type, "floppy") < 0)
goto out; goto out;
} else if ((udevGetIntProperty(device, "ID_DRIVE_FLASH_SD", } else if (udevGetIntProperty(device, "ID_CDROM",
&tmp_int, 0) == PROPERTY_FOUND) && &tmp_int, 0) == PROPERTY_FOUND &&
(tmp_int == 1)) { tmp_int == 1) {
if (VIR_STRDUP(data->storage.drive_type, "cd") < 0)
goto out;
} else if (udevGetIntProperty(device, "ID_DRIVE_FLASH_SD",
&tmp_int, 0) == PROPERTY_FOUND &&
tmp_int == 1) {
if (VIR_STRDUP(data->storage.drive_type, "sd") < 0) if (VIR_STRDUP(data->storage.drive_type, "sd") < 0)
goto out; goto out;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册