[PATCH] hal-disable-polling symlink support

Doug Goldstein cardoe at gentoo.org
Fri Aug 31 11:54:46 PDT 2007


allows hal-disable-polling to take a device node that's actually a symlink to
real device node and successfully resolve it and use it rather then error out
with device not found.

diff --git a/tools/hal-disable-polling.c b/tools/hal-disable-polling.c
index 44d886c..b47737d 100644
--- a/tools/hal-disable-polling.c
+++ b/tools/hal-disable-polling.c
@@ -76,7 +76,7 @@ int
 main (int argc, char *argv[])
 {
 	char *udi = NULL;
-	char *device = NULL;
+	char *device = NULL, *real_device;
         dbus_bool_t is_version = FALSE;
         dbus_bool_t enable_polling = FALSE;
 	DBusError error;
@@ -178,9 +178,23 @@ main (int argc, char *argv[])
                 int n;
 
                 devices = libhal_manager_find_device_string_match (hal_ctx, "block.device", device, &num_devices, NULL);
-                if (devices == NULL) {
-                        fprintf (stderr, "Cannot find device %s.\n", device);
-                        return 1;
+		if (devices == NULL || devices[0] == NULL) {
+                        real_device = realpath(device, NULL);
+                        if (real_device == NULL) {
+                                fprintf (stderr, "Cannot find device %s.\n", device);
+                                return 1;
+                        }
+
+                        devices = libhal_manager_find_device_string_match (hal_ctx, "block.device", real_device,
+                                &num_devices, NULL);
+
+                        if (devices == NULL) {
+                                fprintf (stderr, "Cannot find symlinked device %s -> %s.\n", device, real_device);
+                                return 1;
+                        }
+
+                        fprintf (stderr, "Following symlink from %s to %s.\n", device, real_device);
+			free(real_device);
                 }
 
                 for (n = 0; devices[n] != NULL; n++) {
-- 
1.5.3.rc7


--------------010505000202090802090201--


More information about the hal mailing list