]> err.no Git - systemd/commitdiff
[PATCH] use blacklist on device "remove" and remove dev.d/ call code duplication
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Sun, 28 Nov 2004 12:47:36 +0000 (13:47 +0100)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 06:00:29 +0000 (23:00 -0700)
udev.c

diff --git a/udev.c b/udev.c
index 3a97eb1046d006009abf65053cfdfabcb7c8916b..958fa4eb0a3292e981ba4f3b1b9cd735750947ee 100644 (file)
--- a/udev.c
+++ b/udev.c
@@ -156,11 +156,11 @@ int main(int argc, char *argv[], char *envp[])
                        /* wait for sysfs and possibly add node */
                        dbg("udev add");
 
-                       /* skip blacklisted subsystems */
+                       /* skip subsystems without "dev", but handle net devices */
                        if (udev.type != 'n' && subsystem_expect_no_dev(udev.subsystem)) {
                                dbg("don't care about '%s' devices", udev.subsystem);
                                goto hotplug;
-                       };
+                       }
 
                        snprintf(path, SYSFS_PATH_MAX, "%s%s", sysfs_path, udev.devpath);
                        class_dev = wait_class_device_open(path);
@@ -178,26 +178,25 @@ int main(int argc, char *argv[], char *envp[])
                        /* name, create node, store in db */
                        retval = udev_add_device(&udev, class_dev);
 
-                       /* run dev.d/ scripts if we created a node or changed a netif name */
-                       if (udev_dev_d && udev.devname[0] != '\0') {
-                               setenv("DEVNAME", udev.devname, 1);
-                               udev_multiplex_directory(&udev, DEVD_DIR, DEVD_SUFFIX);
-                       }
-
                        sysfs_close_class_device(class_dev);
                } else if (strcmp(action, "remove") == 0) {
                        /* possibly remove a node */
                        dbg("udev remove");
 
+                       /* skip subsystems without "dev" */
+                       if (subsystem_expect_no_dev(udev.subsystem)) {
+                               dbg("don't care about '%s' devices", udev.subsystem);
+                               goto hotplug;
+                       }
+
                        /* 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 */
-                       if (udev_dev_d && udev.devname[0] != '\0') {
-                               setenv("DEVNAME", udev.devname, 1);
-                               udev_multiplex_directory(&udev, DEVD_DIR, DEVD_SUFFIX);
-                       }
-
+               /* run dev.d/ scripts if we created/deleted a node or changed a netif name */
+               if (udev_dev_d && udev.devname[0] != '\0') {
+                       setenv("DEVNAME", udev.devname, 1);
+                       udev_multiplex_directory(&udev, DEVD_DIR, DEVD_SUFFIX);
                }
        } else if ((strncmp(devpath, "/devices/", 9) == 0)) {
                if (strcmp(action, "add") == 0) {