]> err.no Git - systemd/commitdiff
Cleanup a little.
authorScott James Remnant <scott@ubuntu.com>
Mon, 23 Feb 2009 17:21:24 +0000 (17:21 +0000)
committerScott James Remnant <scott@ubuntu.com>
Mon, 23 Feb 2009 17:21:24 +0000 (17:21 +0000)
Move some of the checks into udev_watch_begin() and udev_watch_clear()
so we don't have to repeat them all the time.

udev/udev-watch.c
udev/udevd.c

index 24688c3b19e690b42a9a8d790de6cb3eb048c29a..33b493d512f5afd60d351f9e65033c8619f7fc0c 100644 (file)
@@ -142,7 +142,7 @@ void udev_watch_begin(struct udev *udev, struct udev_device *dev)
        const char *filename;
        int wd;
 
-       if (inotify_fd < 0)
+       if (inotify_fd < 0 || major(udev_device_get_devnum(dev)) == 0)
                return;
 
        wd = inotify_add_watch(inotify_fd, udev_device_get_devnode(dev), IN_CLOSE_WRITE);
@@ -163,6 +163,9 @@ void udev_watch_clear(struct udev *udev, struct udev_device *dev)
        DIR *dir;
        struct dirent *ent;
 
+       if (inotify_fd < 0 || major(udev_device_get_devnum(dev)) == 0)
+               return;
+
        util_strlcpy(filename, udev_get_dev_path(udev), sizeof(filename));
        util_strlcat(filename, "/.udev/watch", sizeof(filename));
 
index 50205f1e43c3e4ddee4f3049bab5c9ede42510a1..27e64dae3acbb9a8a6d6f3388ac2842686b4e01e 100644 (file)
@@ -216,9 +216,7 @@ static void event_fork(struct udev_event *event)
                alarm(UDEV_EVENT_TIMEOUT);
 
                /* clear any existing udev watch on the node */
-               if (inotify_fd != -1 &&
-                   major(udev_device_get_devnum(event->dev)) != 0)
-                       udev_watch_clear(event->udev, event->dev);
+               udev_watch_clear(event->udev, event->dev);
 
                /* apply rules, create node, symlinks */
                err = udev_event_execute_rules(event, rules);
@@ -232,8 +230,7 @@ static void event_fork(struct udev_event *event)
                        udev_event_execute_run(event);
 
                /* apply/restore inotify watch */
-               if (err == 0 && event->inotify_watch && inotify_fd != -1 &&
-                   major(udev_device_get_devnum(event->dev)) != 0 &&
+               if (err == 0 && event->inotify_watch &&
                    strcmp(udev_device_get_action(event->dev), "remove") != 0)
                        info(event->udev, "device will be watched for changes\n");
                        udev_watch_begin(event->udev, event->dev);