summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Kukawka <danny.kukawka@web.de>2009-03-18 17:30:53 +0100
committerDanny Kukawka <danny.kukawka@web.de>2009-05-22 17:19:33 +0200
commitb40e19fd38a7ff5d01edbcd29b44f46582ce32ac (patch)
treec5749565b85b0b6a3affa91346015dc3718a4247
parent1040c6eee24829ba7a9eafad86fcd3007b21a50d (diff)
ignore ADD events if there is already a device with same sysfs_path
Ignore ADD events if there is already a device with the same syfs_path available in the GDL or TDL. This should prevent problems getting duplicated devices from calling 'udevadm trigger' (fd.o#18861) or from some other rare cases (see: http://lists.freedesktop.org/archives/hal/2009-February/012954.html). TODO: Check if it make sense to call a refresh for the already existing device instead of ignoring the event completely.
-rw-r--r--hald/linux/device.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/hald/linux/device.c b/hald/linux/device.c
index 66537823..1b3316a2 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -4829,11 +4829,22 @@ hotplug_event_begin_add_dev (const gchar *subsystem, const gchar *sysfs_path, co
handler = dev_handlers[i];
if (strcmp (handler->subsystem, subsystem) == 0) {
HalDevice *d;
+ HalDevice *check;
if (strcmp (subsystem, "scsi") == 0)
if (missing_scsi_host (sysfs_path, (HotplugEvent *)end_token, HOTPLUG_ACTION_ADD))
goto out;
+ /* check if there is already a device with this sysfs_path in the system */
+ if ((check = hal_device_store_match_key_value_string (hald_get_gdl (), "linux.sysfs_path", sysfs_path)) != NULL ||
+ (check = hal_device_store_match_key_value_string (hald_get_tdl (), "linux.sysfs_path", sysfs_path)) != NULL) {
+ HAL_WARNING(("Have already a device with sysfs_path='%s' and udi='%s'. Ignore new add event for now.",
+ sysfs_path, hal_device_get_udi(check)));
+ /* maybe we should do a refresh on the found device ??? */
+ hotplug_event_end (end_token);
+ goto out;
+ }
+
/* attempt to add the device */
d = handler->add (sysfs_path, device_file, parent_dev, parent_path);
if (d == NULL) {