#endif // 0
option('default-hierarchy', type : 'combo',
choices : ['legacy', 'hybrid', 'unified'], value : 'hybrid',
- description : 'default cgroup hierarchy')
+ description : 'default cgroup hierarchy
+ "legacy" assumes cgroups version 1 mounted on /sys/fs/cgroup
+ "hybrid" assumes cgroups version 2 mounted on /sys/fs/cgroup/unified and
+ cgroups version 1 mounted on /sys/fs/cgroup.
+ "unified" assumes cgroups version 2 on /sys/fs/cgroup')
#if 0 /// UNNEEDED by elogind
# option('time-epoch', type : 'string',
# description : 'time epoch for time clients')
int cg_pid_get_path(const char *controller, pid_t pid, char **path) {
_cleanup_fclose_ FILE *f = NULL;
char line[LINE_MAX];
-#if 0 // At elogind we do not want that (false alarm) "maybe uninitialized" warning
+#if 0 /// At elogind we do not want that (false alarm) "maybe uninitialized" warning
const char *fs, *controller_str;
#else
const char *fs, *controller_str = NULL;
assert(p);
assert(slice);
-#if 0 // nothing to skip in elogind
+#if 0 /// nothing to skip in elogind
t = skip_user_prefix(p);
if (!t)
return -ENXIO;
if (statfs("/sys/fs/cgroup/", &fs) < 0)
return -errno;
-#if 0 /// UNNEEDED by elogind
if (F_TYPE_EQUAL(fs.f_type, CGROUP2_SUPER_MAGIC))
unified_cache = CGROUP_UNIFIED_ALL;
else if (F_TYPE_EQUAL(fs.f_type, TMPFS_MAGIC)) {
F_TYPE_EQUAL(fs.f_type, CGROUP2_SUPER_MAGIC)) {
unified_cache = CGROUP_UNIFIED_SYSTEMD;
unified_systemd_v232 = false;
+#if 0 /// elogind uses its own name
} else if (statfs("/sys/fs/cgroup/systemd/", &fs) == 0 &&
F_TYPE_EQUAL(fs.f_type, CGROUP2_SUPER_MAGIC)) {
unified_cache = CGROUP_UNIFIED_SYSTEMD;
} else {
if (statfs("/sys/fs/cgroup/systemd/", &fs) < 0)
return -errno;
+#else
+ } else if (statfs("/sys/fs/cgroup/elogind/", &fs) == 0 &&
+ F_TYPE_EQUAL(fs.f_type, CGROUP2_SUPER_MAGIC)) {
+ unified_cache = CGROUP_UNIFIED_SYSTEMD;
+ unified_systemd_v232 = true;
+ } else {
+ if (statfs("/sys/fs/cgroup/elogind/", &fs) < 0)
+ return -errno;
+#endif // 0
if (!F_TYPE_EQUAL(fs.f_type, CGROUP_SUPER_MAGIC))
return -ENOMEDIUM;
unified_cache = CGROUP_UNIFIED_NONE;
}
} else
return -ENOMEDIUM;
-#else
- /* elogind can not support the unified hierarchy as a controller,
- * so always assume a classical hierarchy.
- * If, and only *if*, someone really wants to substitute systemd-login
- * in an environment managed by systemd with elogind, we might have to
- * add such a support. */
- unified_cache = CGROUP_UNIFIED_NONE;
-#endif // 0
return 0;
}
if (unified_cache >= CGROUP_UNIFIED_ALL)
return true;
+#if 0 /// only if elogind is the controller we can use cgroups2 in hybrid mode
return streq_ptr(controller, SYSTEMD_CGROUP_CONTROLLER);
+#else
+ return streq_ptr(controller, SYSTEMD_CGROUP_CONTROLLER_HYBRID);
+#endif // 0
}
int cg_all_unified(void) {
return 0;
}
+#endif // 0
bool cg_is_unified_wanted(void) {
static thread_local int wanted = -1;
if (cg_unified_flush() >= 0)
return (wanted = unified_cache >= CGROUP_UNIFIED_ALL);
+#if 0 /// elogind is not init and has no business with kernel command line
/* Otherwise, let's see what the kernel command line has to say.
* Since checking is expensive, cache a non-error result. */
r = proc_cmdline_get_bool("systemd.unified_cgroup_hierarchy", &b);
+#endif // 0
return (wanted = r > 0 ? b : is_default);
}
unified_cache == CGROUP_UNIFIED_ALL)
return (wanted = false);
+#if 0 /// elogind is not init and has no business with kernel command line
/* Otherwise, let's see what the kernel command line has to say.
* Since checking is expensive, cache a non-error result. */
r = proc_cmdline_get_bool("systemd.legacy_systemd_cgroup_controller", &b);
+#endif // 0
/* The meaning of the kernel option is reversed wrt. to the return value
* of this function, hence the negation. */
return (wanted = r > 0 ? !b : is_default);
}
-#else
-bool cg_is_unified_wanted(void) {
- return false;
-}
-bool cg_is_legacy_wanted(void) {
- return true;
-}
-bool cg_is_hybrid_wanted(void) {
- return false;
-}
-#endif // 0
#if 0 /// UNNEEDED by elogind
int cg_weight_parse(const char *s, uint64_t *ret) {
cap_list_txt = custom_target(
'cap-list.txt',
output : 'cap-list.txt',
-#if 0 // elogind needs musl_missing.h, so generate_cap_list must know the source root
+#if 0 /// elogind needs musl_missing.h, so generate_cap_list must know the source root
# command : [generate_cap_list, cpp, config_h, missing_h],
#else
command : [generate_cap_list, cpp, meson.source_root(), config_h, missing_h],
if (delete && m->cgroup_root)
(void) cg_trim(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_root, false);
-#if 0 /// elogind does not support the unified hierarchy, yet.
+#if 0 /// elogind is not init
m->cgroup_empty_event_source = sd_event_source_unref(m->cgroup_empty_event_source);
m->cgroup_inotify_wd_unit = hashmap_free(m->cgroup_inotify_wd_unit);
#endif // 0
{ "tmpfs", "/sys/fs/cgroup", "tmpfs", "mode=755", MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME,
cg_is_legacy_wanted, MNT_FATAL|MNT_IN_CONTAINER },
-#if 0 /// UNNEEDED by elogind
{ "cgroup", "/sys/fs/cgroup/unified", "cgroup2", "nsdelegate", MS_NOSUID|MS_NOEXEC|MS_NODEV,
cg_is_hybrid_wanted, MNT_IN_CONTAINER },
{ "cgroup", "/sys/fs/cgroup/unified", "cgroup2", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV,
cg_is_hybrid_wanted, MNT_IN_CONTAINER },
+#if 0 /// UNNEEDED by elogind
{ "cgroup", "/sys/fs/cgroup/systemd", "cgroup", "none,name=systemd,xattr", MS_NOSUID|MS_NOEXEC|MS_NODEV,
cg_is_legacy_wanted, MNT_IN_CONTAINER },
{ "cgroup", "/sys/fs/cgroup/systemd", "cgroup", "none,name=systemd", MS_NOSUID|MS_NOEXEC|MS_NODEV,
uid_t u, u2;
char *t, **seats, **sessions;
-#if 0 /// elogind does not support systemd slices
+#if 0 /// elogind does not support systemd units
r = sd_pid_get_unit(0, &unit);
assert_se(r >= 0 || r == -ENODATA);
log_info("sd_pid_get_unit(0, …) → \"%s\"", strna(unit));
r = sd_pid_get_user_unit(0, &user_unit);
assert_se(r >= 0 || r == -ENODATA);
log_info("sd_pid_get_user_unit(0, …) → \"%s\"", strna(user_unit));
+#endif // 0
r = sd_pid_get_slice(0, &slice);
assert_se(r >= 0 || r == -ENODATA);
log_info("sd_pid_get_slice(0, …) → \"%s\"", strna(slice));
-#endif // 0
r = sd_pid_get_session(0, &session);
if (r < 0) {
free(path);
assert_se(cg_get_path(SYSTEMD_CGROUP_CONTROLLER, "/test-b/test-d", NULL, &path) == 0);
+#if 0 /// elogind uses its own name
assert_se(path_equal(path, "/sys/fs/cgroup/systemd/test-b/test-d"));
+#else
+ assert_se(path_equal(path, "/sys/fs/cgroup/elogind/test-b/test-d"));
+#endif // 0
free(path);
assert_se(cg_is_empty(SYSTEMD_CGROUP_CONTROLLER, "/test-a") > 0);