From 985df20519b07f244d00a7429c8740d043dd5353 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sat, 24 Apr 2021 07:42:31 +0200 Subject: [PATCH] cgroup: don't warn on cgroup.events EINVAL for top-level groups Signed-off-by: Joachim Wiberg --- src/iwatch.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/iwatch.c b/src/iwatch.c index 205bc8c1..f910e124 100644 --- a/src/iwatch.c +++ b/src/iwatch.c @@ -94,8 +94,24 @@ int iwatch_add(struct iwatch *iw, char *file, uint32_t mask) wd = inotify_add_watch(iw->fd, path, IWATCH_MASK | mask); if (wd < 0) { - if (errno != EEXIST) + switch (errno) { + case EEXIST: + break; + + case EINVAL: + /* + * some older kernels, notably 4.19, don't like + * inotify on top-level cgroups in cgroup v2 + */ + if (!strncmp(path, "/sys/fs/cgroup", 14)) + break; /* ignore error */ + /* fallthrough */ + + default: _pe("Failed adding watcher for %s", path); + break; + } + free(path); return -1; }