]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/cgroup-setup: introduce cg_is_legacy_force_enabled
authorMike Yuan <me@yhndnzj.com>
Sun, 25 Feb 2024 01:03:16 +0000 (09:03 +0800)
committerMike Yuan <me@yhndnzj.com>
Tue, 27 Feb 2024 15:08:59 +0000 (23:08 +0800)
src/shared/cgroup-setup.c
src/shared/cgroup-setup.h

index 934a16eaf389e249d21918ba4a32192949d90fce..ab76ee51027d76a7a953a98ea4612491027ca98a 100644 (file)
@@ -154,6 +154,22 @@ bool cg_is_hybrid_wanted(void) {
         return (wanted = r > 0 ? !b : is_default);
 }
 
+bool cg_is_legacy_force_enabled(void) {
+        bool force;
+
+        if (!cg_is_legacy_wanted())
+                return false;
+
+        /* If in container, we have to follow host's cgroup hierarchy. */
+        if (detect_container() > 0)
+                return true;
+
+        if (proc_cmdline_get_bool("SYSTEMD_CGROUP_ENABLE_LEGACY_FORCE", /* flags = */ 0, &force) < 0)
+                return false;
+
+        return force;
+}
+
 int cg_weight_parse(const char *s, uint64_t *ret) {
         uint64_t u;
         int r;
index 1b6f0716c634232110f7b4f3670ccc88bbf62ef2..c35884ee4d67a321cc8b1f12f723c756b8f6c473 100644 (file)
@@ -10,6 +10,7 @@
 bool cg_is_unified_wanted(void);
 bool cg_is_legacy_wanted(void);
 bool cg_is_hybrid_wanted(void);
+bool cg_is_legacy_force_enabled(void);
 
 int cg_weight_parse(const char *s, uint64_t *ret);
 int cg_cpu_weight_parse(const char *s, uint64_t *ret);