summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-03-03 01:49:11 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-03-03 08:55:53 -0500
commit28a79bd28b706e33825ec01fc651dbd76a252ea3 (patch)
tree487c71cc457f20b78733bd872a87a092434a7b4d /src/core
parente0207c8d91514350c6a1bf0dda9337823004c371 (diff)
core/path: catch errors when adding watches
Errors because of oom conditions or descriptor exhaustion should not be ignored. We probably cannot recover from those conditions. Current behaviour wrt. insufficient permissions is described in the man page. It might make sense in case of user sessions, so I left it as is.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/path.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/core/path.c b/src/core/path.c
index dcb3b1ff60..fc101280a1 100644
--- a/src/core/path.c
+++ b/src/core/path.c
@@ -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: