nspawn: drop cgv1 handling; core: drop cgroup agent (#36764)
This commit is contained in:
@@ -1028,10 +1028,6 @@ int cg_get_root_path(char **ret_path) {
|
||||
return r;
|
||||
|
||||
e = endswith(p, "/" SPECIAL_INIT_SCOPE);
|
||||
if (!e)
|
||||
e = endswith(p, "/" SPECIAL_SYSTEM_SLICE); /* legacy */
|
||||
if (!e)
|
||||
e = endswith(p, "/system"); /* even more legacy */
|
||||
if (e)
|
||||
*e = 0;
|
||||
|
||||
@@ -2078,59 +2074,6 @@ int cg_mask_supported(CGroupMask *ret) {
|
||||
return cg_mask_supported_subtree(root, ret);
|
||||
}
|
||||
|
||||
int cg_kernel_controllers(Set **ret) {
|
||||
_cleanup_set_free_ Set *controllers = NULL;
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
/* Determines the full list of kernel-known controllers. Might include controllers we don't actually support
|
||||
* and controllers that aren't currently accessible (because not mounted). This does not include "name="
|
||||
* pseudo-controllers. */
|
||||
|
||||
r = fopen_unlocked("/proc/cgroups", "re", &f);
|
||||
if (r == -ENOENT) {
|
||||
*ret = NULL;
|
||||
return 0;
|
||||
}
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* Ignore the header line */
|
||||
(void) read_line(f, SIZE_MAX, NULL);
|
||||
|
||||
for (;;) {
|
||||
_cleanup_free_ char *controller = NULL;
|
||||
int enabled = 0;
|
||||
|
||||
if (fscanf(f, "%ms %*i %*i %i", &controller, &enabled) != 2) {
|
||||
|
||||
if (ferror(f))
|
||||
return -errno;
|
||||
|
||||
if (feof(f))
|
||||
break;
|
||||
|
||||
return -EBADMSG;
|
||||
}
|
||||
|
||||
if (!enabled)
|
||||
continue;
|
||||
|
||||
if (!cg_controller_is_valid(controller))
|
||||
return -EBADMSG;
|
||||
|
||||
r = set_ensure_consume(&controllers, &string_hash_ops_free, TAKE_PTR(controller));
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
*ret = TAKE_PTR(controllers);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The hybrid mode was initially implemented in v232 and simply mounted cgroup2 on
|
||||
* /sys/fs/cgroup/systemd. This unfortunately broke other tools (such as docker) which expected the v1
|
||||
* "name=systemd" hierarchy on /sys/fs/cgroup/systemd. From v233 and on, the hybrid mode mounts v2 on
|
||||
|
||||
@@ -311,8 +311,6 @@ int cg_mask_supported_subtree(const char *root, CGroupMask *ret);
|
||||
int cg_mask_from_string(const char *s, CGroupMask *ret);
|
||||
int cg_mask_to_string(CGroupMask mask, char **ret);
|
||||
|
||||
int cg_kernel_controllers(Set **controllers);
|
||||
|
||||
bool cg_ns_supported(void);
|
||||
bool cg_freezer_supported(void);
|
||||
bool cg_kill_supported(void);
|
||||
|
||||
+15
-27
@@ -62,13 +62,13 @@ int procfs_tasks_set_limit(uint64_t limit) {
|
||||
/* As pid_max is about the numeric pid_t range we'll bump it if necessary, but only ever increase it, never
|
||||
* decrease it, as threads-max is the much more relevant sysctl. */
|
||||
if (limit > pid_max-1) {
|
||||
sprintf(buffer, "%" PRIu64, limit+1); /* Add one, since PID 0 is not a valid PID */
|
||||
xsprintf(buffer, "%" PRIu64, limit+1); /* Add one, since PID 0 is not a valid PID */
|
||||
r = write_string_file("/proc/sys/kernel/pid_max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
sprintf(buffer, "%" PRIu64, limit);
|
||||
xsprintf(buffer, "%" PRIu64, limit);
|
||||
r = write_string_file("/proc/sys/kernel/threads-max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER);
|
||||
if (r < 0) {
|
||||
uint64_t threads_max;
|
||||
@@ -175,46 +175,34 @@ int procfs_cpu_get_usage(nsec_t *ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int convert_meminfo_value_to_uint64_bytes(const char *word, uint64_t *ret) {
|
||||
int convert_meminfo_value_to_uint64_bytes(const char *s, uint64_t *ret) {
|
||||
_cleanup_free_ char *w = NULL;
|
||||
char *digits, *e;
|
||||
uint64_t v;
|
||||
size_t n;
|
||||
int r;
|
||||
|
||||
assert(word);
|
||||
assert(s);
|
||||
assert(ret);
|
||||
|
||||
w = strdup(word);
|
||||
if (!w)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Determine length of numeric value */
|
||||
n = strspn(w, WHITESPACE);
|
||||
digits = w + n;
|
||||
n = strspn(digits, DIGITS);
|
||||
if (n == 0)
|
||||
return -EINVAL;
|
||||
e = digits + n;
|
||||
|
||||
/* Ensure the line ends in " kB" */
|
||||
n = strspn(e, WHITESPACE);
|
||||
if (n == 0)
|
||||
return -EINVAL;
|
||||
if (!streq(e + n, "kB"))
|
||||
r = extract_first_word(&s, &w, /* separators = */ NULL, /* flags = */ 0);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
return -EINVAL;
|
||||
|
||||
*e = 0;
|
||||
r = safe_atou64(digits, &v);
|
||||
/* Ensure the line ends in "kB" */
|
||||
if (!streq(s, "kB"))
|
||||
return -EINVAL;
|
||||
|
||||
r = safe_atou64(w, &v);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (v == UINT64_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
if (v > UINT64_MAX/1024)
|
||||
if (!MUL_ASSIGN_SAFE(&v, U64_KB))
|
||||
return -EOVERFLOW;
|
||||
|
||||
*ret = v * 1024U;
|
||||
*ret = v;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user