hal/hald/linux2 Makefile.am, 1.7, 1.8 acpi.c, 1.6, 1.7 apm.c, 1.2, 1.3 coldplug.c, 1.7, 1.8 hotplug.c, 1.8, 1.9 osspec.c, 1.9, 1.10 osspec_linux.h, NONE, 1.1 pmu.c, 1.2, 1.3

David Zeuthen david at freedesktop.org
Tue Feb 8 14:37:00 PST 2005


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

Modified Files:
	Makefile.am acpi.c apm.c coldplug.c hotplug.c osspec.c pmu.c 
Added Files:
	osspec_linux.h 
Log Message:
2005-02-08  David Zeuthen  <davidz at redhat.com>

	* hald/linux2/osspec.c: 
	(hal_util_get_udevinfo_path):
	(hal_util_get_device_file):
	(hal_util_set_driver):
	(hal_util_find_closest_ancestor): Moved to here from ../util.c
	(get_hal_sysfs_path): New function
	(get_hal_proc_path): New function
	
	* hald/linux2/osspec_linux.h: New file; export the functions
	mentioned above



Index: Makefile.am
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- Makefile.am	8 Feb 2005 16:44:20 -0000	1.7
+++ Makefile.am	8 Feb 2005 22:36:58 -0000	1.8
@@ -14,6 +14,7 @@
 
 libhald_linux2_la_SOURCES =					\
 				osspec.c			\
+	osspec_linux.h						\
 	hotplug.h		hotplug.c			\
 	coldplug.h		coldplug.c			\
 	physdev.h		physdev.c			\

Index: acpi.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/acpi.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- acpi.c	8 Feb 2005 20:11:05 -0000	1.6
+++ acpi.c	8 Feb 2005 22:36:58 -0000	1.7
@@ -31,6 +31,8 @@
 #include "../hald_dbus.h"
 #include "util.h"
 
+#include "osspec_linux.h"
+
 #include "acpi.h"
 #include "hotplug.h"
 
@@ -229,19 +231,19 @@
 					    "/proc/acpi", "info", "version", 0);
 
 	/* collect batteries */
-	snprintf (path, sizeof (path), "%s/acpi/battery", hal_proc_path);
+	snprintf (path, sizeof (path), "%s/acpi/battery", get_hal_proc_path ());
 	acpi_synthesize (path, ACPI_TYPE_BATTERY);
 
 	/* collect AC adapters */
-	snprintf (path, sizeof (path), "%s/acpi/ac_adapter", hal_proc_path);
+	snprintf (path, sizeof (path), "%s/acpi/ac_adapter", get_hal_proc_path ());
 	acpi_synthesize (path, ACPI_TYPE_AC_ADAPTER);
 
 	/* collect buttons */
-	snprintf (path, sizeof (path), "%s/acpi/button/lid", hal_proc_path);
+	snprintf (path, sizeof (path), "%s/acpi/button/lid", get_hal_proc_path ());
 	acpi_synthesize (path, ACPI_TYPE_BUTTON);
-	snprintf (path, sizeof (path), "%s/acpi/button/power", hal_proc_path);
+	snprintf (path, sizeof (path), "%s/acpi/button/power", get_hal_proc_path ());
 	acpi_synthesize (path, ACPI_TYPE_BUTTON);
-	snprintf (path, sizeof (path), "%s/acpi/button/sleep", hal_proc_path);
+	snprintf (path, sizeof (path), "%s/acpi/button/sleep", get_hal_proc_path ());
 	acpi_synthesize (path, ACPI_TYPE_BUTTON);
 
 out:

Index: apm.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/apm.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- apm.c	8 Feb 2005 16:44:20 -0000	1.2
+++ apm.c	8 Feb 2005 22:36:58 -0000	1.3
@@ -211,7 +211,7 @@
 	hal_device_property_set_bool (computer, "power_management.is_enabled", TRUE);
 	hal_device_property_set_string (computer, "power_management.type", "apm");
 
-	snprintf (path, sizeof (path), "%s/apm", hal_proc_path);
+	snprintf (path, sizeof (path), "%s/apm", get_hal_proc_path ());
 
 	hotplug_event = g_new0 (HotplugEvent, 1);
 	hotplug_event->is_add = TRUE;

Index: coldplug.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/coldplug.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- coldplug.c	8 Feb 2005 16:44:20 -0000	1.7
+++ coldplug.c	8 Feb 2005 22:36:58 -0000	1.8
@@ -45,6 +45,8 @@
 #include "../device_info.h"
 #include "../hald_conf.h"
 
+#include "osspec_linux.h"
+
 #include "util.h"
 #include "coldplug.h"
 #include "hotplug.h"
@@ -124,18 +126,18 @@
 
 	/* build bus map */
 	sysfs_to_bus_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-	g_snprintf (path, HAL_PATH_MAX, "%s/bus", hal_sysfs_path);
+	g_snprintf (path, HAL_PATH_MAX, "%s/bus", get_hal_sysfs_path ());
 	if ((dir = g_dir_open (path, 0, &err)) == NULL) {
-		HAL_ERROR (("Unable to open %/bus: %s", hal_sysfs_path, err->message));
+		HAL_ERROR (("Unable to open %/bus: %s", get_hal_sysfs_path (), err->message));
 		g_error_free (err);
 		goto error;
 	}
 	while ((f = g_dir_read_name (dir)) != NULL) {
 		GDir *dir1;
 
-		g_snprintf (path, HAL_PATH_MAX, "%s/bus/%s", hal_sysfs_path, f);
+		g_snprintf (path, HAL_PATH_MAX, "%s/bus/%s", get_hal_sysfs_path (), f);
 		if ((dir1 = g_dir_open (path, 0, &err)) == NULL) {
-			HAL_ERROR (("Unable to open %/bus/%s: %s", hal_sysfs_path, f, err->message));
+			HAL_ERROR (("Unable to open %/bus/%s: %s", get_hal_sysfs_path (), f, err->message));
 			g_error_free (err);
 			goto error;
 		}
@@ -145,10 +147,10 @@
 				GDir *dir2;
 
 				g_snprintf (path, HAL_PATH_MAX, "%s/bus/%s/%s", 
-					    hal_sysfs_path, f, f1);
+					    get_hal_sysfs_path (), f, f1);
 				if ((dir2 = g_dir_open (path, 0, &err)) == NULL) {
 					HAL_ERROR (("Unable to open %s/bus/%s/%s: %s", 
-						    hal_sysfs_path, f, f1, err->message));
+						    get_hal_sysfs_path (), f, f1, err->message));
 					g_error_free (err);
 					goto error;
 				}
@@ -156,16 +158,16 @@
 					gchar *target;
 					gchar *normalized_target;
 					g_snprintf (path, HAL_PATH_MAX, "%s/bus/%s/%s/%s", 
-						    hal_sysfs_path, f, f1, f2);
+						    get_hal_sysfs_path (), f, f1, f2);
 					if ((target = g_file_read_link (path, &err)) == NULL) {
 						HAL_ERROR (("%s/bus/%s/%s/%s is not a symlink: %s!", 
-							    hal_sysfs_path, 
+							    get_hal_sysfs_path (), 
 							    f, f1, f2, err->message));
 						g_error_free (err);
 						goto error;
 					}
 
-					g_snprintf (path, HAL_PATH_MAX, "%s/bus/%s/%s", hal_sysfs_path, f, f1);
+					g_snprintf (path, HAL_PATH_MAX, "%s/bus/%s/%s", get_hal_sysfs_path (), f, f1);
 					normalized_target = hal_util_get_normalized_path (path, target);
 					g_free (target);
 
@@ -181,17 +183,17 @@
 
 	/* build class map and class device map */
 	sysfs_to_class_in_devices_map = g_hash_table_new (g_str_hash, g_str_equal);
-	g_snprintf (path, HAL_PATH_MAX, "%s/class" , hal_sysfs_path);
+	g_snprintf (path, HAL_PATH_MAX, "%s/class" , get_hal_sysfs_path ());
 	if ((dir = g_dir_open (path, 0, &err)) == NULL) {
-		HAL_ERROR (("Unable to open %/class: %s", hal_sysfs_path, err->message));
+		HAL_ERROR (("Unable to open %/class: %s", get_hal_sysfs_path (), err->message));
 		goto error;
 	}
 	while ((f = g_dir_read_name (dir)) != NULL) {
 		GDir *dir1;
 
-		g_snprintf (path, HAL_PATH_MAX, "%s/class/%s" , hal_sysfs_path, f);
+		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", hal_sysfs_path, f, err->message));
+			HAL_ERROR (("Unable to open %/class/%s: %s", get_hal_sysfs_path (), f, err->message));
 			g_error_free (err);
 			goto error;
 		}
@@ -199,17 +201,17 @@
 			gchar *target;
 			gchar *normalized_target;
 
-			g_snprintf (path1, HAL_PATH_MAX, "%s/class/%s/%s/device", hal_sysfs_path, f, f1);
+			g_snprintf (path1, HAL_PATH_MAX, "%s/class/%s/%s/device", get_hal_sysfs_path (), f, f1);
 			/* Accept net devices without device links too, they may be coldplugged PCMCIA devices */
 			if (((target = g_file_read_link (path1, NULL)) == NULL)) {
 				/* no device link */
-				g_snprintf (path1, HAL_PATH_MAX, "%s/class/%s/%s", hal_sysfs_path, f, f1);
+				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 (f));
 			} else {
 				GSList *classdev_strings;
 
-				g_snprintf (path2, HAL_PATH_MAX, "%s/class/%s/%s", hal_sysfs_path, f, f1);
+				g_snprintf (path2, HAL_PATH_MAX, "%s/class/%s/%s", get_hal_sysfs_path (), f, f1);
 				if (target) {
 					normalized_target = hal_util_get_normalized_path (path2, target);
 					g_free (target);
@@ -231,24 +233,24 @@
 	/* Now traverse /sys/devices and consult the map we've just
 	 * built; this includes adding a) bus devices; and b) class
 	 * devices that sit in /sys/devices */
-	g_snprintf (path, HAL_PATH_MAX, "%s/devices", hal_sysfs_path);
+	g_snprintf (path, HAL_PATH_MAX, "%s/devices", get_hal_sysfs_path ());
 	if ((dir = g_dir_open (path, 0, &err)) == NULL) {
-		HAL_ERROR (("Unable to open %/devices: %s", hal_sysfs_path, err->message));
+		HAL_ERROR (("Unable to open %/devices: %s", get_hal_sysfs_path (), err->message));
 		g_error_free (err);
 		goto error;
 	}
 	while ((f = g_dir_read_name (dir)) != NULL) {
 		GDir *dir1;
 
-		g_snprintf (path, HAL_PATH_MAX, "%s/devices/%s", hal_sysfs_path, f);
+		g_snprintf (path, HAL_PATH_MAX, "%s/devices/%s", get_hal_sysfs_path (), f);
 		if ((dir1 = g_dir_open (path, 0, &err)) == NULL) {
-			HAL_ERROR (("Unable to open %/devices/%s: %s", hal_sysfs_path, f, err->message));
+			HAL_ERROR (("Unable to open %/devices/%s: %s", get_hal_sysfs_path (), f, err->message));
 			g_error_free (err);
 			goto error;
 		}
 		while ((f1 = g_dir_read_name (dir1)) != NULL) {
 
-			g_snprintf (path, HAL_PATH_MAX, "%s/devices/%s/%s", hal_sysfs_path, f, f1);
+			g_snprintf (path, HAL_PATH_MAX, "%s/devices/%s/%s", get_hal_sysfs_path (), f, f1);
 			coldplug_compute_visit_device (path, sysfs_to_bus_map, sysfs_to_class_in_devices_map);
 		}
 		g_dir_close (dir1);
@@ -283,7 +285,7 @@
 	g_slist_free (sysfs_other_class_dev);
 
 	/* add block devices */
-	g_snprintf (path, HAL_PATH_MAX, "%s/block", hal_sysfs_path);
+	g_snprintf (path, HAL_PATH_MAX, "%s/block", get_hal_sysfs_path ());
 	if ((dir = g_dir_open (path, 0, &err)) == NULL) {
 		HAL_ERROR (("Unable to open %s: %s", path, err->message));
 		g_error_free (err);
@@ -296,12 +298,12 @@
 		gchar *target;
 		gchar *normalized_target;
 
-		g_snprintf (path, HAL_PATH_MAX, "%s/block/%s", hal_sysfs_path, f);
+		g_snprintf (path, HAL_PATH_MAX, "%s/block/%s", get_hal_sysfs_path (), f);
 #ifdef HAL_COLDPLUG_VERBOSE
 		printf ("block: %s (block)\n",  path);
 #endif
 
-		g_snprintf (path1, HAL_PATH_MAX, "%s/block/%s/device", hal_sysfs_path, f);
+		g_snprintf (path1, HAL_PATH_MAX, "%s/block/%s/device", get_hal_sysfs_path (), f);
 		if (((target = g_file_read_link (path1, NULL)) != NULL)) {
 			normalized_target = hal_util_get_normalized_path (path1, target);
 			g_free (target);

Index: hotplug.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/hotplug.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- hotplug.c	8 Feb 2005 16:44:20 -0000	1.8
+++ hotplug.c	8 Feb 2005 22:36:58 -0000	1.9
@@ -48,8 +48,9 @@
 #include "../device_info.h"
 #include "../hald_conf.h"
 
-#include "hotplug.h"
+#include "osspec_linux.h"
 
+#include "hotplug.h"
 #include "physdev.h"
 #include "classdev.h"
 #include "blockdev.h"
@@ -95,14 +96,14 @@
 				      hotplug_event->sysfs.sysfs_path, hotplug_event->sysfs.net_ifindex));
 			
 			
-			g_snprintf (path, HAL_PATH_MAX, "%s/class/net" , hal_sysfs_path);
+			g_snprintf (path, HAL_PATH_MAX, "%s/class/net" , get_hal_sysfs_path());
 			if ((dir = g_dir_open (path, 0, &err)) == NULL) {
-				HAL_ERROR (("Unable to open %/class/net: %s", hal_sysfs_path, err->message));
+				HAL_ERROR (("Unable to open %/class/net: %s", get_hal_sysfs_path(), err->message));
 				g_error_free (err);
 				goto out;
 			}
 			while ((f = g_dir_read_name (dir)) != NULL) {
-				g_snprintf (path1, HAL_PATH_MAX, "%s/class/net/%s" , hal_sysfs_path, f);
+				g_snprintf (path1, HAL_PATH_MAX, "%s/class/net/%s" , get_hal_sysfs_path (), f);
 				if (hal_util_get_int_from_file (path1, "ifindex", &ifindex, 10)) {
 					if (ifindex == hotplug_event->sysfs.net_ifindex) {
 						HAL_INFO (("Using sysfs path %s for ifindex %d", path1, ifindex));
@@ -132,9 +133,9 @@
 	static gsize sys_block_path_len = 0;
 
 	if (sys_block_path_len == 0) {
-		sys_devices_path_len = g_snprintf (sys_devices_path, HAL_PATH_MAX, "%s/devices", hal_sysfs_path);
-		sys_class_path_len   = g_snprintf (sys_class_path, HAL_PATH_MAX, "%s/class", hal_sysfs_path);
-		sys_block_path_len   = g_snprintf (sys_block_path, HAL_PATH_MAX, "%s/block", hal_sysfs_path);
+		sys_devices_path_len = g_snprintf (sys_devices_path, HAL_PATH_MAX, "%s/devices", get_hal_sysfs_path ());
+		sys_class_path_len   = g_snprintf (sys_class_path, HAL_PATH_MAX, "%s/class", get_hal_sysfs_path ());
+		sys_block_path_len   = g_snprintf (sys_block_path, HAL_PATH_MAX, "%s/block", get_hal_sysfs_path ());
 	}
 
 

Index: osspec.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/osspec.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- osspec.c	8 Feb 2005 21:17:38 -0000	1.9
+++ osspec.c	8 Feb 2005 22:36:58 -0000	1.10
@@ -82,9 +82,23 @@
 #include "apm.h"
 #include "pmu.h"
 
+#include "osspec_linux.h"
+
 char hal_sysfs_path [HAL_PATH_MAX];
 char hal_proc_path [HAL_PATH_MAX];
 
+const gchar *
+get_hal_sysfs_path (void)
+{
+	return hal_sysfs_path;
+}
+
+const gchar *
+get_hal_proc_path (void)
+{
+	return hal_sysfs_path;
+}
+
 static gboolean
 hald_helper_data (GIOChannel *source, GIOCondition condition, gpointer user_data)
 {
@@ -300,3 +314,163 @@
 {
 	return hotplug_reprobe_tree (d);
 }
+
+/* Returns the path of the udevinfo program 
+ *
+ * @return                      Path or NULL if udevinfo program is not found
+ */
+static const gchar *
+hal_util_get_udevinfo_path (void)
+{
+	guint i;
+	struct stat s;
+	static gchar *path = NULL;
+	gchar *possible_paths[] = { 
+		"/sbin/udevinfo",
+		"/usr/bin/udevinfo",
+		"/usr/sbin/udevinfo",
+		"/usr/local/sbin/udevinfo"
+	};
+
+	if (path != NULL)
+		return path;
+
+	for (i = 0; i < sizeof (possible_paths) / sizeof (char *); i++) {
+		if (stat (possible_paths[i], &s) == 0 && S_ISREG (s.st_mode)) {
+			path = possible_paths[i];
+			break;
+		}
+	}
+	return path;
+}
+
+/** Get the name of the special device file given the sysfs path.
+ *
+ *  @param  sysfs_path          Path to class device in sysfs
+ *  @param  dev_file            Where the special device file name should be stored
+ *  @param  dev_file_length     Size of dev_file character array
+ *  @return                     TRUE only if the device file could be found
+ */
+gboolean
+hal_util_get_device_file (const gchar *sysfs_path, gchar *dev_file, gsize dev_file_length)
+{
+	int i;
+	gsize sysfs_path_len;
+	gsize sysfs_mount_path_len;
+	gchar sysfs_path_trunc[HAL_PATH_MAX];
+	gchar sysfs_path_dev_trunc[HAL_PATH_MAX + 4];
+	char *udev_argv[7] = { NULL, 
+			       "-r", "-q", "name", "-p",
+			       sysfs_path_trunc, NULL };
+	char *udev_stdout;
+	char *udev_stderr;
+	int udev_exitcode;
+	struct stat statbuf;
+
+	/* check for dev file in sysfs path */
+	sysfs_path_len = strlen (sysfs_path);
+	strncpy (sysfs_path_dev_trunc, sysfs_path, HAL_PATH_MAX);
+	strncat (sysfs_path_dev_trunc + sysfs_path_len, "/dev", 4);
+	if (stat (sysfs_path_dev_trunc, &statbuf) != 0)
+		return FALSE;
+
+	/* get path to udevinfo */
+	udev_argv[0] = (char *) hal_util_get_udevinfo_path ();
+	if (udev_argv[0] == NULL)
+		return FALSE;
+
+	/* compute truncated sysfs path as udevinfo doesn't want the sysfs_mount_path (e.g. /sys) prefix */
+	sysfs_mount_path_len = strlen (hal_sysfs_path);
+	if (strlen (sysfs_path) > sysfs_mount_path_len) {
+		strncpy (sysfs_path_trunc, sysfs_path + sysfs_mount_path_len, HAL_PATH_MAX - sysfs_mount_path_len);
+	}
+
+	/* Now invoke udevinfo */
+	if (udev_argv[0] == NULL || g_spawn_sync ("/",
+						  udev_argv,
+						  NULL,
+						  0,
+						  NULL,
+						  NULL,
+						  &udev_stdout,
+						  &udev_stderr,
+						  &udev_exitcode,
+						  NULL) != TRUE) {
+		HAL_ERROR (("Couldn't invoke %s", udev_argv[0]));
+		return FALSE;
+	}
+
+	if (udev_exitcode != 0) {
+		HAL_ERROR (("%s returned %d for %s", udev_argv[0], udev_exitcode, sysfs_path_trunc));
+		return FALSE;
+	}
+
+	/* sanitize string returned by udev */
+	for (i = 0; udev_stdout[i] != 0; i++) {
+		if (udev_stdout[i] == '\r' || udev_stdout[i] == '\n') {
+			udev_stdout[i] = 0;
+			break;
+		}
+	}
+
+	/*HAL_INFO (("got device file %s for %s", udev_stdout, sysfs_path));*/
+
+	strncpy (dev_file, udev_stdout, dev_file_length);
+	return TRUE;
+}
+
+gboolean
+hal_util_set_driver (HalDevice *d, const char *property_name, const char *sysfs_path)
+{
+	gboolean ret;
+	gchar driver_path[HAL_PATH_MAX];
+	struct stat statbuf;
+
+	ret = FALSE;
+
+	g_snprintf (driver_path, sizeof (driver_path), "%s/driver", sysfs_path);
+	if (stat (driver_path, &statbuf) == 0) {
+		gchar buf[256];
+		memset (buf, '\0', sizeof (buf));
+		if (readlink (driver_path, buf, sizeof (buf) - 1) > 0) {
+			hal_device_property_set_string (d, property_name, hal_util_get_last_element (buf));
+			ret = TRUE;
+		}
+	}
+
+	return ret;
+}
+
+/** Find the closest ancestor by looking at sysfs paths
+ *
+ *  @param  sysfs_path           Path into sysfs, e.g. /sys/devices/pci0000:00/0000:00:1d.7/usb1/1-0:1.0
+ *  @return                      Parent Hal Device Object or #NULL if there is none
+ */
+HalDevice *
+hal_util_find_closest_ancestor (const gchar *sysfs_path)
+{	
+	gchar buf[512];
+	HalDevice *parent;
+
+	parent = NULL;
+
+	strncpy (buf, sysfs_path, sizeof (buf));
+	do {
+		char *p;
+
+		p = strrchr (buf, '/');
+		if (p == NULL)
+			break;
+		*p = '\0';
+
+		parent = hal_device_store_match_key_value_string (hald_get_gdl (), 
+								  "linux.sysfs_path_device", 
+								  buf);
+		if (parent != NULL)
+			break;
+
+	} while (TRUE);
+
+	return parent;
+}
+

--- NEW FILE: osspec_linux.h ---
/***************************************************************************
 * CVSID: $Id: osspec_linux.h,v 1.1 2005/02/08 22:36:58 david Exp $
 *
 * osspec_linux.h : OS Specific interface
 *
 * Copyright (C) 2003 David Zeuthen, <david at fubar.dk>
 *
 * Licensed under the Academic Free License version 2.0
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 **************************************************************************/

#ifndef OSSPEC_LINUX_H
#define OSSPEC_LINUX_H

#include <glib.h>
#include "../device.h"

const gchar *get_hal_sysfs_path (void);

const gchar *get_hal_proc_path (void);

gboolean hal_util_get_device_file (const gchar *sysfs_path, gchar *dev_file, gsize dev_file_length);

gboolean hal_util_set_driver (HalDevice *d, const char *property_name, const char *sysfs_path);

HalDevice *hal_util_find_closest_ancestor (const gchar *sysfs_path);


#endif /* OSSPEC_LINUX_H */

Index: pmu.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/pmu.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- pmu.c	8 Feb 2005 16:44:20 -0000	1.2
+++ pmu.c	8 Feb 2005 22:36:58 -0000	1.3
@@ -88,7 +88,7 @@
 		/* we're discharging if, and only if, we are not plugged into the wall */
 		{
 			char buf[HAL_PATH_MAX];
-			snprintf (buf, sizeof (buf), "%s/pmu/info", hal_proc_path);
+			snprintf (buf, sizeof (buf), "%s/pmu/info", get_hal_proc_path ());
 			hal_util_set_bool_elem_from_file (d, "battery.rechargeable.is_discharging", buf, "", 
 							  "AC Power", 0, "0");
 		}
@@ -163,7 +163,7 @@
 	hal_device_property_set_string (computer, "power_management.type", "pmu");
 
 	/* AC Adapter */
-	snprintf (path, sizeof (path), "%s/pmu/info", hal_proc_path);
+	snprintf (path, sizeof (path), "%s/pmu/info", get_hal_proc_path ());
 	hotplug_event = g_new0 (HotplugEvent, 1);
 	hotplug_event->is_add = TRUE;
 	hotplug_event->type = HOTPLUG_EVENT_PMU;
@@ -172,7 +172,7 @@
 	hotplug_event_enqueue (hotplug_event);
 
 	error = NULL;
-	snprintf (path, sizeof (path), "%s/pmu", hal_proc_path);
+	snprintf (path, sizeof (path), "%s/pmu", get_hal_proc_path ());
 	dir = g_dir_open (path, 0, &error);
 	if (dir != NULL) {
 		const gchar *f;
@@ -182,7 +182,7 @@
 			gchar buf[HAL_PATH_MAX];
 			int battery_num;
 
-			snprintf (buf, sizeof (buf), "%s/pmu/%s", hal_proc_path, f);
+			snprintf (buf, sizeof (buf), "%s/pmu/%s", get_hal_proc_path (), f);
 			if (sscanf (f, "battery_%d", &battery_num) == 1) {
 				HAL_INFO (("Processing %s", buf));
 				




More information about the hal-commit mailing list