#include "formats-util.h"
#include "process-util.h"
#include "path-util.h"
-#include "unit-name.h"
+// #include "unit-name.h"
#include "fileio.h"
-#include "special.h"
+// #include "special.h"
#include "mkdir.h"
#include "login-util.h"
#include "cgroup-util.h"
return 1;
}
-/// UNNEEDED by elogind
-#if 0
int cg_create_and_attach(const char *controller, const char *path, pid_t pid) {
int r, q;
/* This does not remove the cgroup on failure */
return r;
}
-#endif // 0
int cg_attach(const char *controller, const char *path, pid_t pid) {
_cleanup_free_ char *fs = NULL;
return -ENODATA;
}
-/// UNNEEDED by elogind
-#if 0
int cg_install_release_agent(const char *controller, const char *agent) {
_cleanup_free_ char *fs = NULL, *contents = NULL;
const char *sc;
return 0;
}
-#endif // 0
int cg_is_empty(const char *controller, const char *path) {
_cleanup_fclose_ FILE *f = NULL;
}
int cg_get_root_path(char **path) {
+/// elogind does not support systemd scopes and slices
+#if 0
char *p, *e;
int r;
*path = p;
return 0;
+#else
+ assert(path);
+ return cg_pid_get_path(ELOGIND_CGROUP_CONTROLLER, 1, path);
+#endif // 0
}
int cg_shift_path(const char *cgroup, const char *root, const char **shifted) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
int cg_path_decode_unit(const char *cgroup, char **unit){
char *c, *s;
size_t n;
return cg_path_get_machine_name(cgroup, machine);
}
+#endif // 0
int cg_path_get_session(const char *path, char **session) {
+ /* Elogind uses a flat hierarchy, just "/SESSION". The only
+ wrinkle is that SESSION might be escaped. */
+#if 0
_cleanup_free_ char *unit = NULL;
char *start, *end;
int r;
*end = 0;
if (!session_id_valid(start))
return -ENXIO;
+#else
+ const char *e, *n, *start;
+
+ assert(path);
+ assert(path[0] == '/');
+
+ e = path + 1;
+ n = strchrnul(e, '/');
+ if (e == n)
+ return -ENOENT;
+
+ start = strndupa(e, n - e);
+ start = cg_unescape(start);
+
+ if (!start[0])
+ return -ENOENT;
+#endif // 0
if (session) {
char *rr;
return cg_path_get_session(cgroup, session);
}
+/// UNNEEDED by elogind
+#if 0
int cg_path_get_owner_uid(const char *path, uid_t *uid) {
_cleanup_free_ char *slice = NULL;
char *start, *end;
return cg_path_get_user_slice(cgroup, slice);
}
+#endif // 0
char *cg_escape(const char *p) {
bool need_prefix = false;
return 0;
}
+#endif // 0
int cg_set_attribute(const char *controller, const char *path, const char *attribute, const char *value) {
_cleanup_free_ char *p = NULL;
return write_string_file_no_create(p, value);
}
+/// UNNEEDED by elogind
+#if 0
int cg_get_attribute(const char *controller, const char *path, const char *attribute, char **ret) {
_cleanup_free_ char *p = NULL;
int r;
return read_one_line_file(p, ret);
}
-#endif // 0
-/// UNNEEDED by elogind
-#if 0
int cg_create_everywhere(CGroupMask supported, CGroupMask mask, const char *path) {
CGroupController c;
int r, unified;
return 0;
}
+#endif // 0
int cg_mask_supported(CGroupMask *ret) {
CGroupMask mask = 0;
return 0;
}
+/// UNNEEDED by elogind
+#if 0
int cg_kernel_controllers(Set *controllers) {
_cleanup_fclose_ FILE *f = NULL;
char buf[LINE_MAX];
if (statfs("/sys/fs/cgroup/", &fs) < 0)
return -errno;
+/// elogind can not support the unified hierarchy as a controller,
+/// so always assume a classical hierarchy.
+/// If, ond only *if*, someone really wants to substitute systemd-login
+/// in an environment managed by systemd with elogin, we might have to
+/// add such a support.
+#if 0
if (F_TYPE_EQUAL(fs.f_type, CGROUP_SUPER_MAGIC))
unified_cache = true;
else if (F_TYPE_EQUAL(fs.f_type, TMPFS_MAGIC))
+#else
+ if (F_TYPE_EQUAL(fs.f_type, TMPFS_MAGIC))
+#endif // elogind
unified_cache = false;
else
return -ENOEXEC;
return unified_cache;
}
+/// UNNEEDED by elogind
+#if 0
void cg_unified_flush(void) {
unified_cache = -1;
}
return 0;
}
+#endif // 0
bool cg_is_unified_wanted(void) {
static thread_local int wanted = -1;
}
}
+/// UNNEEDED by elogind
+#if 0
bool cg_is_legacy_wanted(void) {
return !cg_is_unified_wanted();
}
+#endif // 0
static const char *cgroup_controller_table[_CGROUP_CONTROLLER_MAX] = {
[CGROUP_CONTROLLER_CPU] = "cpu",