summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2018-07-22 04:42:34 +0000
committerLuke Shumaker <lukeshu@parabola.nu>2018-08-16 21:55:17 -0400
commit9515697826ecf6899bc3c50e91b7c12b96fbf6b9 (patch)
tree68c4fdc5ad85636e4fd25f6ca825ae8a962a69ac
parent4312657456f1d253045e3b661cc96568c52f9e50 (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.c32
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.",