hal/hald callout.c, 1.16, NONE callout.h, 1.3, NONE util.c, 1.1,
1.2 util.h, 1.1, 1.2
David Zeuthen
david at freedesktop.org
Tue Feb 8 14:37:00 PST 2005
- Previous message: hal ChangeLog,1.407,1.408 configure.in,1.65,1.66
- Next message: 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
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvs/hal/hal/hald
In directory gabe:/tmp/cvs-serv18131
Modified Files:
util.c util.h
Removed Files:
callout.c callout.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
--- callout.c DELETED ---
--- callout.h DELETED ---
Index: util.c
===================================================================
RCS file: /cvs/hal/hal/hald/util.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- util.c 8 Feb 2005 16:44:20 -0000 1.1
+++ util.c 8 Feb 2005 22:36:58 -0000 1.2
@@ -162,146 +162,6 @@
return parent_path;
}
-
-
-/* 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;
-}
-
-
-/** 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;
-}
-
gchar *
hal_util_get_normalized_path (const gchar *path1, const gchar *path2)
{
@@ -722,28 +582,6 @@
}
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;
-}
-
-gboolean
hal_util_path_ascend (gchar *path)
{
gchar *p;
Index: util.h
===================================================================
RCS file: /cvs/hal/hal/hald/util.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- util.h 8 Feb 2005 16:44:20 -0000 1.1
+++ util.h 8 Feb 2005 22:36:58 -0000 1.2
@@ -37,10 +37,6 @@
gchar *hal_util_get_parent_path (const gchar *path);
-gboolean hal_util_get_device_file (const gchar *sysfs_path, gchar *dev_file, gsize dev_file_length);
-
-HalDevice *hal_util_find_closest_ancestor (const gchar *sysfs_path);
-
gchar *hal_util_get_normalized_path (const gchar *path1, const gchar *path2);
gboolean hal_util_get_int_from_file (const gchar *directory, const gchar *file, gint *result, gint base);
@@ -57,8 +53,6 @@
void hal_util_compute_udi (HalDeviceStore *store, gchar *dst, gsize dstsize, const gchar *format, ...);
-gboolean hal_util_set_driver (HalDevice *d, const char *property_name, const char *sysfs_path);
-
gboolean hal_util_path_ascend (gchar *path);
@@ -115,7 +109,4 @@
#define HAL_PATH_MAX 256
-extern char hal_sysfs_path [HAL_PATH_MAX];
-extern char hal_proc_path [HAL_PATH_MAX];
-
#endif /* UTIL_H */
- Previous message: hal ChangeLog,1.407,1.408 configure.in,1.65,1.66
- Next message: 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
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the hal-commit
mailing list