hal/hald/linux2 coldplug.c,1.18,1.19

Kay Sievers kay at freedesktop.org
Tue Nov 1 20:27:26 PST 2005


Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv24238/hald/linux2

Modified Files:
	coldplug.c 
Log Message:
2005-11-02  Kay Sievers  <kay.sievers at vrfy.org>

        * hald/linux2/coldplug.c: (coldplug_synthesize_events): Prepare for 2.6.15.
        Check if we find a symlink instead of a class device pointing to a device
        below a class device. This kernel sysfs layout will change again in the future,
        for now resolve the link to the "real" device path, like real hotplug events
        devpath would have.



Index: coldplug.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/coldplug.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- coldplug.c	27 Sep 2005 09:42:12 -0000	1.18
+++ coldplug.c	2 Nov 2005 04:27:24 -0000	1.19
@@ -415,7 +415,7 @@
 
 		g_snprintf (path, HAL_PATH_MAX, "%s/class/%s" , get_hal_sysfs_path (), f);
 		if ((dir1 = g_dir_open (path, 0, &err)) == NULL) {
-			HAL_ERROR (("Unable to open %/class/%s: %s", get_hal_sysfs_path (), f, err->message));
+			HAL_ERROR (("Unable to open %s/class/%s: %s", get_hal_sysfs_path (), f, err->message));
 			g_error_free (err);
 			goto error;
 		}
@@ -423,17 +423,33 @@
 			gchar *target;
 			gchar *normalized_target;
 
-			g_snprintf (path1, HAL_PATH_MAX, "%s/class/%s/%s/device", get_hal_sysfs_path (), f, f1);
+			g_snprintf (path2, HAL_PATH_MAX, "%s/class/%s/%s", get_hal_sysfs_path (), f, f1);
+
+			/* check if we find a symlink here pointing to a device _inside_ a class device,
+			 * like "input" in 2.6.15. This kernel sysfs layout will change again in the future,
+			 * for now resolve the link to the "real" device path, like real hotplug events
+			 * devpath would have
+			 */
+			if ((target = g_file_read_link (path2, NULL)) != NULL) {
+				char *pos = strrchr(path2, '/');
+
+				if (pos)
+					pos[0] = '\0';
+				normalized_target = hal_util_get_normalized_path (path2, target);
+				g_free (target);
+				g_strlcpy(path2, normalized_target, sizeof(path2));
+				g_free (normalized_target);
+			}
+
 			/* Accept net devices without device links too, they may be coldplugged PCMCIA devices */
+			g_snprintf (path1, HAL_PATH_MAX, "%s/device", path2);
 			if (((target = g_file_read_link (path1, NULL)) == NULL)) {
 				/* no device link */
-				g_snprintf (path1, HAL_PATH_MAX, "%s/class/%s/%s", get_hal_sysfs_path (), f, f1);
-				sysfs_other_class_dev = g_slist_append (sysfs_other_class_dev, g_strdup (path1));
+				sysfs_other_class_dev = g_slist_append (sysfs_other_class_dev, g_strdup (path2));
 				sysfs_other_class_dev = g_slist_append (sysfs_other_class_dev, g_strdup (f));
 			} else {
 				GSList *classdev_strings;
 
-				g_snprintf (path2, HAL_PATH_MAX, "%s/class/%s/%s", get_hal_sysfs_path (), f, f1);
 				normalized_target = hal_util_get_normalized_path (path2, target);
 				g_free (target);
 




More information about the hal-commit mailing list