diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2018-07-22 04:42:34 +0000 |
---|---|---|
committer | Luke Shumaker <lukeshu@parabola.nu> | 2018-07-23 23:59:44 -0400 |
commit | dac6f23171a0380157a81cef3cf56c5830056101 (patch) | |
tree | 3dab0705cc171f4edbfdd2768ebf5f4ff92a0b42 | |
parent | de050077434da6011854ea219073bd19bd7db102 (diff) |
cgroup-util: Get stricter about mode detection
Currently, cg_unified_update() recognizes OpenRC cgroup-v1/v2 hybrid has
systemd-v233 cgroup-v1/v2 hybrid; later systemd code will be in for a shock
when /sys/fs/cgroup/systemd doesn't exist!
-rw-r--r-- | src/basic/cgroup-util.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index 19db958c31..352d2ef964 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -2490,25 +2490,25 @@ static int cg_unified_update(void) { log_debug("Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy"); unified_cache = CGROUP_UNIFIED_ALL; } else if (F_TYPE_EQUAL(fs.f_type, TMPFS_MAGIC)) { - if (statfs("/sys/fs/cgroup/unified/", &fs) == 0 && - F_TYPE_EQUAL(fs.f_type, CGROUP2_SUPER_MAGIC)) { - log_debug("Found cgroup2 on /sys/fs/cgroup/unified, unified hierarchy for systemd controller"); - unified_cache = CGROUP_UNIFIED_SYSTEMD233; - } else { - if (statfs("/sys/fs/cgroup/systemd/", &fs) < 0) - 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)"); - unified_cache = CGROUP_UNIFIED_SYSTEMD232; - } else if (F_TYPE_EQUAL(fs.f_type, CGROUP_SUPER_MAGIC)) { - log_debug("Found cgroup on /sys/fs/cgroup/systemd, legacy hierarchy"); - unified_cache = CGROUP_UNIFIED_NONE; + if (statfs("/sys/fs/cgroup/systemd/", &fs) < 0) + 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, hybrid hierarchy (systemd v232 variant)"); + unified_cache = CGROUP_UNIFIED_SYSTEMD232; + } else if (F_TYPE_EQUAL(fs.f_type, CGROUP_SUPER_MAGIC)) { + if (statfs("/sys/fs/cgroup/unified/", &fs) == 0 && + F_TYPE_EQUAL(fs.f_type, CGROUP2_SUPER_MAGIC)) { + log_debug("Found cgroup on /sys/fs/cgroup/systemd, cgroup2 on /sys/fs/cgroup/unified, hybrid hierarchy (systemd v233+ variant)"); + unified_cache = CGROUP_UNIFIED_SYSTEMD233; } else { - log_debug("Unexpected filesystem type %llx mounted on /sys/fs/cgroup/systemd, assuming legacy hierarchy", - (unsigned long long) fs.f_type); + log_debug("Found cgroup on /sys/fs/cgroup/systemd, no /sys/fs/cgroup/unified, legacy hierarchy (systemd variant)"); unified_cache = CGROUP_UNIFIED_NONE; } + } else { + log_debug("Unexpected filesystem type %llx mounted on /sys/fs/cgroup/systemd", + (unsigned long long) fs.f_type); + return -ENOMEDIUM; } } else { log_debug("Unknown filesystem type %llx mounted on /sys/fs/cgroup.", |