summaryrefslogtreecommitdiffstats
path: root/src/basic/cgroup-util.c
diff options
context:
space:
mode:
authorMike Gilbert <floppym@gentoo.org>2021-03-09 23:57:37 +0100
committerLennart Poettering <lennart@poettering.net>2021-03-17 15:42:22 +0100
commit2156061fb33811aedb160d1b476793a5b845b143 (patch)
tree91d2ba1ff09c373aec3ab8f47b4245d90e414052 /src/basic/cgroup-util.c
parentdhcp6: fix wrong length for IA_PD dhcp6 option (diff)
downloadsystemd-2156061fb33811aedb160d1b476793a5b845b143.tar.xz
systemd-2156061fb33811aedb160d1b476793a5b845b143.zip
cg_unified_cached: return ENOMEDIUM if we cannot find a known hierarchy
When the test suite is being run in a foreign environment, /sys/fs/cgroup might not be set up in a way that we recognize. Returning ENOMEDIUM causes the tests to be skipped in this case. Bug: https://bugs.gentoo.org/771819
Diffstat (limited to '')
-rw-r--r--src/basic/cgroup-util.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
index 527043a2b3..0b252eb28f 100644
--- a/src/basic/cgroup-util.c
+++ b/src/basic/cgroup-util.c
@@ -2052,8 +2052,14 @@ int cg_unified_cached(bool flush) {
unified_cache = CGROUP_UNIFIED_SYSTEMD;
unified_systemd_v232 = false;
} else {
- if (statfs("/sys/fs/cgroup/systemd/", &fs) < 0)
+ if (statfs("/sys/fs/cgroup/systemd/", &fs) < 0) {
+ if (errno == ENOENT) {
+ /* Some other software may have set up /sys/fs/cgroup in a configuration we do not recognize. */
+ log_debug_errno(errno, "Unsupported cgroupsv1 setup detected: name=systemd hierarchy not found.");
+ return -ENOMEDIUM;
+ }
return log_debug_errno(errno, "statfs(\"/sys/fs/cgroup/systemd\" failed: %m");
+ }
if (F_TYPE_EQUAL(fs.f_type, CGROUP2_SUPER_MAGIC)) {
log_debug("Found cgroup2 on /sys/fs/cgroup/systemd, unified hierarchy for systemd controller (v232 variant)");