chiark / gitweb /
move debugging strings inside #ifdef DEBUG
[elogind.git] / udev / udev-event.c
index fcb999370974db5624dcc510c8833b83e46adb47..a6459eb8d931e4f071b70c96342963f3f28c07f4 100644 (file)
@@ -291,16 +291,21 @@ found:
                                err(event->udev, "missing file parameter for attr\n");
                        else {
                                const char *val;
-                               char value[UTIL_NAME_SIZE] = "";
+                               char value[UTIL_NAME_SIZE];
                                size_t size;
 
+                               value[0] = '\0';
+                               /* read the value specified by [usb/]*/
                                util_resolve_subsys_kernel(event->udev, attr, value, sizeof(value), 1);
 
-                               val = udev_device_get_sysattr_value(event->dev, attr);
-                               if (val != NULL)
-                                       util_strlcpy(value, val, sizeof(value));
+                               /* try to read attribute of the current device */
+                               if (value[0] == '\0') {
+                                       val = udev_device_get_sysattr_value(event->dev, attr);
+                                       if (val != NULL)
+                                               util_strlcpy(value, val, sizeof(value));
+                               }
 
-                               /* try the current device, other matches may have selected */
+                               /* try to read the attribute of the parent device, other matches have selected */
                                if (value[0] == '\0' && event->dev_parent != NULL && event->dev_parent != event->dev) {
                                        val = udev_device_get_sysattr_value(event->dev_parent, attr);
                                        if (val != NULL)
@@ -701,6 +706,11 @@ int udev_event_execute_run(struct udev_event *event)
 
                        util_strlcpy(program, cmd, sizeof(program));
                        udev_event_apply_format(event, program, sizeof(program));
+                       if (event->trace)
+                               fprintf(stderr, "run  %s (%llu) '%s'\n",
+                                      udev_device_get_syspath(event->dev),
+                                      udev_device_get_seqnum(event->dev),
+                                      program);
                        envp = udev_device_get_properties_envp(event->dev);
                        if (util_run_program(event->udev, program, envp, NULL, 0, NULL) != 0) {
                                if (!udev_list_entry_get_flag(list_entry))