chiark / gitweb /
[PATCH] don't call dev.d/ scripts twice, if directory = subsystem
[elogind.git] / udev.c
diff --git a/udev.c b/udev.c
index dad64288a9b08f0706807f305a47d7d115df930c..5ad7e425e6fc212433148a52b16489aca28afc4d 100644 (file)
--- a/udev.c
+++ b/udev.c
@@ -33,7 +33,7 @@
 
 #include "libsysfs/sysfs/libsysfs.h"
 #include "udev.h"
-#include "udev_lib.h"
+#include "udev_utils.h"
 #include "udev_sysfs.h"
 #include "udev_version.h"
 #include "namedev.h"
@@ -108,6 +108,7 @@ int main(int argc, char *argv[], char *envp[])
        udev_init_config();
 
        /* set signal handlers */
+       memset(&act, 0x00, sizeof(act));
        act.sa_handler = (void (*) (int))sig_handler;
        sigemptyset (&act.sa_mask);
        act.sa_flags = 0;
@@ -179,9 +180,9 @@ int main(int argc, char *argv[], char *envp[])
                        retval = udev_add_device(&udev, class_dev);
 
                        /* run dev.d/ scripts if we created a node or changed a netif name */
-                       if (udev.devname[0] != '\0') {
+                       if (udev_dev_d && udev.devname[0] != '\0') {
                                setenv("DEVNAME", udev.devname, 1);
-                               dev_d_execute(&udev, DEVD_DIR, DEVD_SUFFIX);
+                               udev_multiplex_directory(&udev, DEVD_DIR, DEVD_SUFFIX);
                        }
 
                        sysfs_close_class_device(class_dev);
@@ -192,10 +193,14 @@ int main(int argc, char *argv[], char *envp[])
                        /* get node from db, remove db-entry, delete created node */
                        retval = udev_remove_device(&udev);
 
-                       /* run dev.d/ scripts if we're not instructed to ignore the event */
+                       /* Set the DEVNAME if known */
                        if (udev.devname[0] != '\0') {
                                setenv("DEVNAME", udev.devname, 1);
-                               dev_d_execute(&udev, DEVD_DIR, DEVD_SUFFIX);
+                       }
+                       /* run dev.d/ scripts if we're not instructed to ignore the event */
+                       if (udev_dev_d && udev.devname[0] != '\0') {
+                               setenv("DEVNAME", udev.devname, 1);
+                               udev_multiplex_directory(&udev, DEVD_DIR, DEVD_SUFFIX);
                        }
 
                }
@@ -224,7 +229,7 @@ int main(int argc, char *argv[], char *envp[])
 
 hotplug:
        if (manage_hotplug_event())
-               dev_d_execute(&udev, HOTPLUGD_DIR, HOTPLUG_SUFFIX);
+               udev_multiplex_directory(&udev, HOTPLUGD_DIR, HOTPLUG_SUFFIX);
 
 exit:
        logging_close();