chiark / gitweb /
Put a log message in a more sensible place.
[elogind.git] / udev / udevd.c
index 50205f1e43c3e4ddee4f3049bab5c9ede42510a1..c764b33b0ad2ca1856dba74d97523cb26b11a2f1 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_end(event->udev, event->dev);
 
                /* apply rules, create node, symlinks */
                err = udev_event_execute_rules(event, rules);
@@ -232,10 +230,8 @@ 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);
 
                info(event->udev, "seq %llu exit with %i\n", udev_device_get_seqnum(event->dev), err);
@@ -543,19 +539,18 @@ static int handle_inotify(struct udev *udev)
        read(inotify_fd, buf, nbytes);
 
        for (pos = 0, ev = (struct inotify_event *)(buf + pos); pos < nbytes; pos += sizeof(struct inotify_event) + ev->len) {
-               const char *syspath;
+               struct udev_device *dev;
 
                dbg(udev, "inotify event: %x for %d (%s)\n", ev->mask, ev->wd, ev->len ? ev->name : "*");
-
-               syspath = udev_watch_lookup(udev, ev->wd);
-               if (syspath != NULL) {
-                       dbg(udev, "inotify event: %x for %s\n", ev->mask, syspath);
+               dev = udev_watch_lookup(udev, ev->wd);
+               if (dev != NULL) {
+                       dbg(udev, "inotify event: %x for %s\n", ev->mask, udev_device_get_devnode(dev));
                        if (ev->mask & IN_CLOSE_WRITE) {
                                char filename[UTIL_PATH_SIZE];
                                int fd;
 
-                               info(udev, "device %s closed, synthesising 'change'\n", syspath);
-                               util_strlcpy(filename, syspath, sizeof(filename));
+                               info(udev, "device %s closed, synthesising 'change'\n", udev_device_get_devnode(dev));
+                               util_strlcpy(filename, udev_device_get_syspath(dev), sizeof(filename));
                                util_strlcat(filename, "/uevent", sizeof(filename));
                                fd = open(filename, O_WRONLY);
                                if (fd < 0 || write(fd, "change", 6) < 0)
@@ -563,7 +558,9 @@ static int handle_inotify(struct udev *udev)
                                close(fd);
                        }
                        if (ev->mask & IN_IGNORED)
-                               udev_watch_end(udev, ev->wd);
+                               udev_watch_end(udev, dev);
+
+                       udev_device_unref(dev);
                } else {
                        reload_config = 1;
                }