From 9caee129cddd66809d415462808d047c11af6a63 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Fri, 21 Sep 2018 10:41:38 +0200 Subject: [PATCH] confile: s/lxc.cgroup.keep/lxc.cgroup.relative/g Signed-off-by: Christian Brauner --- src/lxc/cgroups/cgfsng.c | 20 ++++++++++---------- src/lxc/conf.h | 2 +- src/lxc/confile.c | 28 +++++++++++++++------------- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index c37456b92..40517c22d 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -1749,7 +1749,7 @@ static bool cgfsng_escape(const struct cgroup_ops *ops, struct lxc_conf *conf) { int i; - if (conf->cgroup_meta.keep || geteuid()) + if (conf->cgroup_meta.relative || geteuid()) return true; for (i = 0; ops->hierarchies[i]; i++) { @@ -2281,7 +2281,7 @@ static bool cgroup_use_wants_controllers(const struct cgroup_ops *ops, /* At startup, parse_hierarchies finds all the info we need about cgroup * mountpoints and current cgroups, and stores it in @d. */ -static bool cg_hybrid_init(struct cgroup_ops *ops, bool keep) +static bool cg_hybrid_init(struct cgroup_ops *ops, bool relative) { int ret; char *basecginfo; @@ -2293,7 +2293,7 @@ static bool cg_hybrid_init(struct cgroup_ops *ops, bool keep) /* Root spawned containers escape the current cgroup, so use init's * cgroups as our base in that case. */ - if (!keep && (geteuid() == 0)) + if (!relative && (geteuid() == 0)) basecginfo = read_file("/proc/1/cgroup"); else basecginfo = read_file("/proc/self/cgroup"); @@ -2444,12 +2444,12 @@ static int cg_is_pure_unified(void) } /* Get current cgroup from /proc/self/cgroup for the cgroupfs v2 hierarchy. */ -static char *cg_unified_get_current_cgroup(bool keep) +static char *cg_unified_get_current_cgroup(bool relative) { char *basecginfo, *base_cgroup; char *copy = NULL; - if (!keep && (geteuid() == 0)) + if (!relative && (geteuid() == 0)) basecginfo = read_file("/proc/1/cgroup"); else basecginfo = read_file("/proc/self/cgroup"); @@ -2473,7 +2473,7 @@ cleanup_on_err: return copy; } -static int cg_unified_init(struct cgroup_ops *ops, bool keep) +static int cg_unified_init(struct cgroup_ops *ops, bool relative) { int ret; char *mountpoint, *subtree_path; @@ -2487,7 +2487,7 @@ static int cg_unified_init(struct cgroup_ops *ops, bool keep) if (ret != CGROUP2_SUPER_MAGIC) return 0; - base_cgroup = cg_unified_get_current_cgroup(keep); + base_cgroup = cg_unified_get_current_cgroup(relative); if (!base_cgroup) return -EINVAL; prune_init_scope(base_cgroup); @@ -2523,7 +2523,7 @@ static bool cg_init(struct cgroup_ops *ops, struct lxc_conf *conf) { int ret; const char *tmp; - bool keep = conf->cgroup_meta.keep; + bool relative = conf->cgroup_meta.relative; tmp = lxc_global_config_value("lxc.cgroup.use"); if (tmp) { @@ -2539,14 +2539,14 @@ static bool cg_init(struct cgroup_ops *ops, struct lxc_conf *conf) free(pin); } - ret = cg_unified_init(ops, keep); + ret = cg_unified_init(ops, relative); if (ret < 0) return false; if (ret == CGROUP2_SUPER_MAGIC) return true; - return cg_hybrid_init(ops, keep); + return cg_hybrid_init(ops, relative); } static bool cgfsng_data_init(struct cgroup_ops *ops) diff --git a/src/lxc/conf.h b/src/lxc/conf.h index 56e23428d..7d206a3af 100644 --- a/src/lxc/conf.h +++ b/src/lxc/conf.h @@ -77,7 +77,7 @@ struct lxc_cgroup { struct /* meta */ { char *controllers; char *dir; - bool keep; + bool relative; }; }; }; diff --git a/src/lxc/confile.c b/src/lxc/confile.c index 21e2d4a7e..b6b3032bb 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -92,7 +92,7 @@ lxc_config_define(cap_keep); lxc_config_define(cgroup_controller); lxc_config_define(cgroup2_controller); lxc_config_define(cgroup_dir); -lxc_config_define(cgroup_keep); +lxc_config_define(cgroup_relative); lxc_config_define(console_buffer_size); lxc_config_define(console_logfile); lxc_config_define(console_path); @@ -169,7 +169,7 @@ static struct lxc_config_t config[] = { { "lxc.cap.keep", set_config_cap_keep, get_config_cap_keep, clr_config_cap_keep, }, { "lxc.cgroup2", set_config_cgroup2_controller, get_config_cgroup2_controller, clr_config_cgroup2_controller, }, { "lxc.cgroup.dir", set_config_cgroup_dir, get_config_cgroup_dir, clr_config_cgroup_dir, }, - { "lxc.cgroup.keep", set_config_cgroup_keep, get_config_cgroup_keep, clr_config_cgroup_keep, }, + { "lxc.cgroup.relative", set_config_cgroup_relative, get_config_cgroup_relative, clr_config_cgroup_relative, }, { "lxc.cgroup", set_config_cgroup_controller, get_config_cgroup_controller, clr_config_cgroup_controller, }, { "lxc.console.buffer.size", set_config_console_buffer_size, get_config_console_buffer_size, clr_config_console_buffer_size, }, { "lxc.console.logfile", set_config_console_logfile, get_config_console_logfile, clr_config_console_logfile, }, @@ -1399,26 +1399,26 @@ static int set_config_cgroup_dir(const char *key, const char *value, return set_config_string_item(&lxc_conf->cgroup_meta.dir, value); } -static int set_config_cgroup_keep(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) +static int set_config_cgroup_relative(const char *key, const char *value, + struct lxc_conf *lxc_conf, void *data) { unsigned int converted; int ret; if (lxc_config_value_empty(value)) - return clr_config_cgroup_keep(key, lxc_conf, NULL); + return clr_config_cgroup_relative(key, lxc_conf, NULL); ret = lxc_safe_uint(value, &converted); if (ret < 0) return -ret; if (converted == 1) { - lxc_conf->cgroup_meta.keep = true; + lxc_conf->cgroup_meta.relative = true; return 0; } if (converted == 0) { - lxc_conf->cgroup_meta.keep = false; + lxc_conf->cgroup_meta.relative = false; return 0; } @@ -3240,11 +3240,12 @@ static int get_config_cgroup_dir(const char *key, char *retv, int inlen, return fulllen; } -static inline int get_config_cgroup_keep(const char *key, char *retv, int inlen, - struct lxc_conf *lxc_conf, void *data) +static inline int get_config_cgroup_relative(const char *key, char *retv, + int inlen, struct lxc_conf *lxc_conf, + void *data) { return lxc_get_conf_int(lxc_conf, retv, inlen, - lxc_conf->cgroup_meta.keep); + lxc_conf->cgroup_meta.relative); } static int get_config_idmaps(const char *key, char *retv, int inlen, @@ -3991,10 +3992,11 @@ static int clr_config_cgroup_dir(const char *key, struct lxc_conf *lxc_conf, return 0; } -static inline int clr_config_cgroup_keep(const char *key, - struct lxc_conf *lxc_conf, void *data) +static inline int clr_config_cgroup_relative(const char *key, + struct lxc_conf *lxc_conf, + void *data) { - lxc_conf->cgroup_meta.keep = false; + lxc_conf->cgroup_meta.relative = false; return 0; } -- 2.47.2