forked from luck/tmp_suning_uos_patched
cgroup2: switch to option-by-option parsing
[again, carved out of patch by dhowells] [NB: we probably want to handle "source" in parse_param here] Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
8d2451f499
commit
e34a98d5b2
|
@ -54,6 +54,7 @@
|
|||
#include <linux/proc_ns.h>
|
||||
#include <linux/nsproxy.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/fs_parser.h>
|
||||
#include <linux/sched/cputime.h>
|
||||
#include <linux/psi.h>
|
||||
#include <net/sock.h>
|
||||
|
@ -1772,26 +1773,37 @@ int cgroup_show_path(struct seq_file *sf, struct kernfs_node *kf_node,
|
|||
return len;
|
||||
}
|
||||
|
||||
static int parse_cgroup_root_flags(char *data, unsigned int *root_flags)
|
||||
enum cgroup2_param {
|
||||
Opt_nsdelegate,
|
||||
nr__cgroup2_params
|
||||
};
|
||||
|
||||
static const struct fs_parameter_spec cgroup2_param_specs[] = {
|
||||
fsparam_flag ("nsdelegate", Opt_nsdelegate),
|
||||
{}
|
||||
};
|
||||
|
||||
static const struct fs_parameter_description cgroup2_fs_parameters = {
|
||||
.name = "cgroup2",
|
||||
.specs = cgroup2_param_specs,
|
||||
};
|
||||
|
||||
static int cgroup2_parse_param(struct fs_context *fc, struct fs_parameter *param)
|
||||
{
|
||||
char *token;
|
||||
struct cgroup_fs_context *ctx = cgroup_fc2context(fc);
|
||||
struct fs_parse_result result;
|
||||
int opt;
|
||||
|
||||
*root_flags = 0;
|
||||
opt = fs_parse(fc, &cgroup2_fs_parameters, param, &result);
|
||||
if (opt < 0)
|
||||
return opt;
|
||||
|
||||
if (!data || *data == '\0')
|
||||
switch (opt) {
|
||||
case Opt_nsdelegate:
|
||||
ctx->flags |= CGRP_ROOT_NS_DELEGATE;
|
||||
return 0;
|
||||
|
||||
while ((token = strsep(&data, ",")) != NULL) {
|
||||
if (!strcmp(token, "nsdelegate")) {
|
||||
*root_flags |= CGRP_ROOT_NS_DELEGATE;
|
||||
continue;
|
||||
}
|
||||
|
||||
pr_err("cgroup2: unknown option \"%s\"\n", token);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static void apply_cgroup_root_flags(unsigned int root_flags)
|
||||
|
@ -2074,15 +2086,6 @@ static void cgroup_fs_context_free(struct fs_context *fc)
|
|||
kfree(ctx);
|
||||
}
|
||||
|
||||
static int cgroup_parse_monolithic(struct fs_context *fc, void *data)
|
||||
{
|
||||
struct cgroup_fs_context *ctx = cgroup_fc2context(fc);
|
||||
|
||||
if (data)
|
||||
security_sb_eat_lsm_opts(data, &fc->security);
|
||||
return parse_cgroup_root_flags(data, &ctx->flags);
|
||||
}
|
||||
|
||||
static int cgroup_get_tree(struct fs_context *fc)
|
||||
{
|
||||
struct cgroup_namespace *ns = current->nsproxy->cgroup_ns;
|
||||
|
@ -2108,7 +2111,7 @@ static int cgroup_get_tree(struct fs_context *fc)
|
|||
|
||||
static const struct fs_context_operations cgroup_fs_context_ops = {
|
||||
.free = cgroup_fs_context_free,
|
||||
.parse_monolithic = cgroup_parse_monolithic,
|
||||
.parse_param = cgroup2_parse_param,
|
||||
.get_tree = cgroup_get_tree,
|
||||
.reconfigure = cgroup_reconfigure,
|
||||
};
|
||||
|
@ -2174,10 +2177,11 @@ struct file_system_type cgroup_fs_type = {
|
|||
};
|
||||
|
||||
static struct file_system_type cgroup2_fs_type = {
|
||||
.name = "cgroup2",
|
||||
.init_fs_context = cgroup_init_fs_context,
|
||||
.kill_sb = cgroup_kill_sb,
|
||||
.fs_flags = FS_USERNS_MOUNT,
|
||||
.name = "cgroup2",
|
||||
.init_fs_context = cgroup_init_fs_context,
|
||||
.parameters = &cgroup2_fs_parameters,
|
||||
.kill_sb = cgroup_kill_sb,
|
||||
.fs_flags = FS_USERNS_MOUNT,
|
||||
};
|
||||
|
||||
int cgroup_path_ns_locked(struct cgroup *cgrp, char *buf, size_t buflen,
|
||||
|
|
Loading…
Reference in New Issue
Block a user