chiark / gitweb /
core/path: catch errors when adding watches
[elogind.git] / src / core / path.c
index dcb3b1ff60a7a3d7e4f4aa9af3f62bdfd16cefd0..fc101280a1e7c53df895726137f3a3a27dbb80cc 100644 (file)
@@ -79,6 +79,11 @@ int path_spec_watch(PathSpec *s, Unit *u) {
         s->primary_wd = inotify_add_watch(s->inotify_fd, k, flags_table[s->type]);
         if (s->primary_wd >= 0)
                 exists = true;
+        else if (errno != EACCES && errno != ENOENT) {
+                log_error("Failed to add watch on %s: %m", k);
+                r = -errno;
+                goto fail;
+        }
 
         do {
                 int flags;
@@ -97,8 +102,20 @@ int path_spec_watch(PathSpec *s, Unit *u) {
 
                 if (inotify_add_watch(s->inotify_fd, k, flags) >= 0)
                         exists = true;
+                else if (errno != EACCES && errno != ENOENT) {
+                        log_error("Failed to add watch on %s: %m", k);
+                        r = -errno;
+                        goto fail;
+                }
         } while (slash != k);
 
+        if (!exists) {
+                log_error("Failed to add watch on any of the components of %s: %m",
+                          s->path);
+                r = -errno;
+                goto fail;
+        }
+
         return 0;
 
 fail: