chiark / gitweb /
Cleanup a little.
[elogind.git] / udev / udev-watch.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;
 
        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);
                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;
 
        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));
 
        util_strlcpy(filename, udev_get_dev_path(udev), sizeof(filename));
        util_strlcat(filename, "/.udev/watch", sizeof(filename));