[PATCH] HAL 0.4 - don't add a device if we already have it

Kay Sievers kay.sievers at vrfy.org
Mon Mar 14 10:05:10 PST 2005


While playing around with hotplug event replay from initramfs, it happens,
that events are generated for devices HAL already knows from its coldplug
run. This leads to a lot of funny double entries in the device store. :)

We should prevent the device addition by hotplug events if we already
have one with the same sysfs-devpath.

Thanks,
Kay
-------------- next part --------------
--- hald/linux/osspec.c	2005-01-23 22:57:01.000000000 +0100
+++ hald/linux/osspec.c	2005-03-14 17:35:19.000000000 +0100
@@ -1010,6 +1010,11 @@ add_device (const char *given_sysfs_path
 
 	strncpy (sysfs_path, given_sysfs_path, SYSFS_PATH_MAX);
 
+	if (hal_device_store_match_key_value_string (hald_get_gdl (), "linux.sysfs_path", sysfs_path)) {
+		HAL_WARNING (("devpath %s already present in the store, don't add device", sysfs_path));
+		return NULL;
+	}
+
 	len1 = snprintf (buf1, SYSFS_PATH_MAX, "%s/block", sysfs_mount_path);
 	len2 = snprintf (buf2, SYSFS_PATH_MAX, "%s/class", sysfs_mount_path);
 	if (strncmp (sysfs_path, buf1, len1) == 0 || strncmp (sysfs_path, buf2, len2) == 0) {
-------------- next part --------------
_______________________________________________
hal mailing list
hal at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/hal


More information about the Hal mailing list