cgroup: don't warn on cgroup.events EINVAL for top-level groups

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2021-04-24 07:42:31 +02:00
parent f6161b9be9
commit 985df20519
+17 -1
View File
@@ -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;
}