[4/13] Introduce hal_util_get_driver_name().
Cornelia Huck
cohuck at de.ibm.com
Mon Jun 27 01:45:37 PDT 2005
[4/13] Introduce hal_util_get_driver_name().
Split a function for getting the driver's name from hal_util_set_driver().
Use this function in hal_util_set_driver() and make it available to
other code.
osspec.c | 22 ++++++++++++++++------
osspec_linux.h | 2 ++
2 files changed, 18 insertions(+), 6 deletions(-)
Index: hald/linux2/osspec.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/osspec.c,v
retrieving revision 1.24
diff -u -r1.24 osspec.c
--- hald/linux2/osspec.c 27 Apr 2005 18:53:39 -0000 1.24
+++ hald/linux2/osspec.c 23 Jun 2005 13:59:57 -0000
@@ -569,23 +569,33 @@
}
gboolean
-hal_util_set_driver (HalDevice *d, const char *property_name, const char *sysfs_path)
+hal_util_get_driver_name (const char *sysfs_path, gchar *driver_name)
{
- 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;
+ g_snprintf (driver_name, strlen(buf), "%s", hal_util_get_last_element(buf));
+ return TRUE;
}
}
+ return FALSE;
+}
+
+gboolean
+hal_util_set_driver (HalDevice *d, const char *property_name, const char *sysfs_path)
+{
+ gboolean ret;
+ gchar driver_name[256];
+
+ memset (driver_name, '\0', sizeof (driver_name));
+ ret = hal_util_get_driver_name (sysfs_path, driver_name);
+ if (ret == TRUE)
+ hal_device_property_set_string (d, property_name, driver_name);
return ret;
}
Index: hald/linux2/osspec_linux.h
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/osspec_linux.h,v
retrieving revision 1.2
diff -u -r1.2 osspec_linux.h
--- hald/linux2/osspec_linux.h 27 Apr 2005 18:53:39 -0000 1.2
+++ hald/linux2/osspec_linux.h 23 Jun 2005 13:59:57 -0000
@@ -33,6 +33,8 @@
const gchar *get_hal_proc_path (void);
+gboolean hal_util_get_driver_name (const char *sysfs_path, gchar *driver_name);
+
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);
_______________________________________________
hal mailing list
hal at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/hal
More information about the Hal
mailing list