Unverified Commit ba68feca by Christian Brauner Committed by Stéphane Graber

confile: adapt layout of getter callback

parent a91be265
...@@ -55,73 +55,73 @@ ...@@ -55,73 +55,73 @@
lxc_log_define(lxc_confile, lxc); lxc_log_define(lxc_confile, lxc);
static int set_config_personality(const char *, const char *, struct lxc_conf *); static int set_config_personality(const char *, const char *, struct lxc_conf *);
static int get_config_personality(struct lxc_container *, const char *, char *, int); static int get_config_personality(const char *, char *, int, struct lxc_conf *);
static int set_config_pts(const char *, const char *, struct lxc_conf *); static int set_config_pts(const char *, const char *, struct lxc_conf *);
static int get_config_pts(struct lxc_container *, const char *, char *, int); static int get_config_pts(const char *, char *, int, struct lxc_conf *);
static int set_config_tty(const char *, const char *, struct lxc_conf *); static int set_config_tty(const char *, const char *, struct lxc_conf *);
static int get_config_tty(struct lxc_container *, const char *, char *, int); static int get_config_tty(const char *, char *, int, struct lxc_conf *);
static int set_config_ttydir(const char *, const char *, struct lxc_conf *); static int set_config_ttydir(const char *, const char *, struct lxc_conf *);
static int get_config_ttydir(struct lxc_container *, const char *, char *, int); static int get_config_ttydir(const char *, char *, int, struct lxc_conf *);
static int set_config_kmsg(const char *, const char *, struct lxc_conf *); static int set_config_kmsg(const char *, const char *, struct lxc_conf *);
static int get_config_kmsg(struct lxc_container *, const char *, char *, int); static int get_config_kmsg(const char *, char *, int, struct lxc_conf *);
static int set_config_lsm_aa_profile(const char *, const char *, struct lxc_conf *); static int set_config_lsm_aa_profile(const char *, const char *, struct lxc_conf *);
static int get_config_lsm_aa_profile(struct lxc_container *, const char *, char *, int); static int get_config_lsm_aa_profile(const char *, char *, int, struct lxc_conf *);
static int set_config_lsm_aa_incomplete(const char *, const char *, struct lxc_conf *); static int set_config_lsm_aa_incomplete(const char *, const char *, struct lxc_conf *);
static int get_config_lsm_aa_incomplete(struct lxc_container *, const char *, char *, int); static int get_config_lsm_aa_incomplete(const char *, char *, int, struct lxc_conf *);
static int set_config_lsm_se_context(const char *, const char *, struct lxc_conf *); static int set_config_lsm_se_context(const char *, const char *, struct lxc_conf *);
static int get_config_lsm_se_context(struct lxc_container *, const char *, char *, int); static int get_config_lsm_se_context(const char *, char *, int, struct lxc_conf *);
static int set_config_cgroup(const char *, const char *, struct lxc_conf *); static int set_config_cgroup(const char *, const char *, struct lxc_conf *);
static int get_config_cgroup(struct lxc_container *, const char *, char *, int); static int get_config_cgroup(const char *, char *, int, struct lxc_conf *);
static int set_config_idmaps(const char *, const char *, struct lxc_conf *); static int set_config_idmaps(const char *, const char *, struct lxc_conf *);
static int get_config_idmaps(struct lxc_container *, const char *, char *, int); static int get_config_idmaps(const char *, char *, int, struct lxc_conf *);
static int set_config_loglevel(const char *, const char *, struct lxc_conf *); static int set_config_loglevel(const char *, const char *, struct lxc_conf *);
static int get_config_loglevel(struct lxc_container *, const char *, char *, int); static int get_config_loglevel(const char *, char *, int, struct lxc_conf *);
static int set_config_logfile(const char *, const char *, struct lxc_conf *); static int set_config_logfile(const char *, const char *, struct lxc_conf *);
static int get_config_logfile(struct lxc_container *, const char *, char *, int); static int get_config_logfile(const char *, char *, int, struct lxc_conf *);
static int set_config_mount(const char *, const char *, struct lxc_conf *); static int set_config_mount(const char *, const char *, struct lxc_conf *);
static int get_config_mount(struct lxc_container *, const char *, char *, int); static int get_config_mount(const char *, char *, int, struct lxc_conf *);
static int set_config_mount_auto(const char *, const char *, struct lxc_conf *); static int set_config_mount_auto(const char *, const char *, struct lxc_conf *);
static int get_config_mount_auto(struct lxc_container *, const char *, char *, int); static int get_config_mount_auto(const char *, char *, int, struct lxc_conf *);
static int set_config_fstab(const char *, const char *, struct lxc_conf *); static int set_config_fstab(const char *, const char *, struct lxc_conf *);
static int get_config_fstab(struct lxc_container *, const char *, char *, int); static int get_config_fstab(const char *, char *, int, struct lxc_conf *);
static int set_config_rootfs(const char *, const char *, struct lxc_conf *); static int set_config_rootfs(const char *, const char *, struct lxc_conf *);
static int get_config_rootfs(struct lxc_container *, const char *, char *, int); static int get_config_rootfs(const char *, char *, int, struct lxc_conf *);
static int set_config_rootfs_mount(const char *, const char *, struct lxc_conf *); static int set_config_rootfs_mount(const char *, const char *, struct lxc_conf *);
static int get_config_rootfs_mount(struct lxc_container *, const char *, char *, int); static int get_config_rootfs_mount(const char *, char *, int, struct lxc_conf *);
static int set_config_rootfs_options(const char *, const char *, struct lxc_conf *); static int set_config_rootfs_options(const char *, const char *, struct lxc_conf *);
static int get_config_rootfs_options(struct lxc_container *, const char *, char *, int); static int get_config_rootfs_options(const char *, char *, int, struct lxc_conf *);
static int set_config_rootfs_backend(const char *, const char *, struct lxc_conf *); static int set_config_rootfs_backend(const char *, const char *, struct lxc_conf *);
static int get_config_rootfs_backend(struct lxc_container *, const char *, char *, int); static int get_config_rootfs_backend(const char *, char *, int, struct lxc_conf *);
static int set_config_pivotdir(const char *, const char *, struct lxc_conf *); static int set_config_pivotdir(const char *, const char *, struct lxc_conf *);
static int get_config_pivotdir(struct lxc_container *, const char *, char *, int); static int get_config_pivotdir(const char *, char *, int, struct lxc_conf *);
static int set_config_utsname(const char *, const char *, struct lxc_conf *); static int set_config_utsname(const char *, const char *, struct lxc_conf *);
static int get_config_utsname(struct lxc_container *, const char *, char *, int); static int get_config_utsname(const char *, char *, int, struct lxc_conf *);
static int set_config_hooks(const char *, const char *, struct lxc_conf *lxc_conf); static int set_config_hooks(const char *, const char *, struct lxc_conf *lxc_conf);
static int get_config_hooks(struct lxc_container *, const char *, char *, int); static int get_config_hooks(const char *, char *, int, struct lxc_conf *);
static int set_config_network(const char *, const char *, struct lxc_conf *); static int set_config_network(const char *, const char *, struct lxc_conf *);
static int get_config_network(struct lxc_container *, const char *, char *, int); static int get_config_network(const char *, char *, int, struct lxc_conf *);
static int set_config_network_type(const char *, const char *, struct lxc_conf *); static int set_config_network_type(const char *, const char *, struct lxc_conf *);
static int set_config_network_flags(const char *, const char *, struct lxc_conf *); static int set_config_network_flags(const char *, const char *, struct lxc_conf *);
...@@ -138,61 +138,61 @@ static int set_config_network_script_up(const char *, const char *, struct lxc_c ...@@ -138,61 +138,61 @@ static int set_config_network_script_up(const char *, const char *, struct lxc_c
static int set_config_network_script_down(const char *, const char *, struct lxc_conf *); static int set_config_network_script_down(const char *, const char *, struct lxc_conf *);
static int set_config_network_ipv6(const char *, const char *, struct lxc_conf *); static int set_config_network_ipv6(const char *, const char *, struct lxc_conf *);
static int set_config_network_ipv6_gateway(const char *, const char *, struct lxc_conf *); static int set_config_network_ipv6_gateway(const char *, const char *, struct lxc_conf *);
static int get_config_network_item(struct lxc_container *, const char *, char *, int); static int get_config_network_item(const char *, char *, int, struct lxc_conf *);
static int set_config_cap_drop(const char *, const char *, struct lxc_conf *); static int set_config_cap_drop(const char *, const char *, struct lxc_conf *);
static int get_config_cap_drop(struct lxc_container *, const char *, char *, int); static int get_config_cap_drop(const char *, char *, int, struct lxc_conf *);
static int set_config_cap_keep(const char *, const char *, struct lxc_conf *); static int set_config_cap_keep(const char *, const char *, struct lxc_conf *);
static int get_config_cap_keep(struct lxc_container *, const char *, char *, int); static int get_config_cap_keep(const char *, char *, int, struct lxc_conf *);
static int set_config_console(const char *, const char *, struct lxc_conf *); static int set_config_console(const char *, const char *, struct lxc_conf *);
static int get_config_console(struct lxc_container *, const char *, char *, int); static int get_config_console(const char *, char *, int, struct lxc_conf *);
static int set_config_console_logfile(const char *, const char *, struct lxc_conf *); static int set_config_console_logfile(const char *, const char *, struct lxc_conf *);
static int get_config_console_logfile(struct lxc_container *, const char *, char *, int); static int get_config_console_logfile(const char *, char *, int, struct lxc_conf *);
static int set_config_seccomp(const char *, const char *, struct lxc_conf *); static int set_config_seccomp(const char *, const char *, struct lxc_conf *);
static int get_config_seccomp(struct lxc_container *, const char *, char *, int); static int get_config_seccomp(const char *, char *, int, struct lxc_conf *);
static int set_config_includefile(const char *, const char *, struct lxc_conf *); static int set_config_includefile(const char *, const char *, struct lxc_conf *);
static int set_config_network_nic(const char *, const char *, struct lxc_conf *); static int set_config_network_nic(const char *, const char *, struct lxc_conf *);
static int set_config_autodev(const char *, const char *, struct lxc_conf *); static int set_config_autodev(const char *, const char *, struct lxc_conf *);
static int get_config_autodev(struct lxc_container *, const char *, char *, int); static int get_config_autodev(const char *, char *, int, struct lxc_conf *);
static int set_config_haltsignal(const char *, const char *, struct lxc_conf *); static int set_config_haltsignal(const char *, const char *, struct lxc_conf *);
static int get_config_haltsignal(struct lxc_container *, const char *, char *, int); static int get_config_haltsignal(const char *, char *, int, struct lxc_conf *);
static int set_config_rebootsignal(const char *, const char *, struct lxc_conf *); static int set_config_rebootsignal(const char *, const char *, struct lxc_conf *);
static int get_config_rebootsignal(struct lxc_container *, const char *, char *, int); static int get_config_rebootsignal(const char *, char *, int, struct lxc_conf *);
static int set_config_stopsignal(const char *, const char *, struct lxc_conf *); static int set_config_stopsignal(const char *, const char *, struct lxc_conf *);
static int get_config_stopsignal(struct lxc_container *, const char *, char *, int); static int get_config_stopsignal(const char *, char *, int, struct lxc_conf *);
static int set_config_start(const char *, const char *, struct lxc_conf *); static int set_config_start(const char *, const char *, struct lxc_conf *);
static int get_config_start(struct lxc_container *, const char *, char *, int); static int get_config_start(const char *, char *, int, struct lxc_conf *);
static int set_config_monitor(const char *, const char *, struct lxc_conf *); static int set_config_monitor(const char *, const char *, struct lxc_conf *);
static int get_config_monitor(struct lxc_container *, const char *, char *, int); static int get_config_monitor(const char *, char *, int, struct lxc_conf *);
static int set_config_group(const char *, const char *, struct lxc_conf *); static int set_config_group(const char *, const char *, struct lxc_conf *);
static int get_config_group(struct lxc_container *, const char *, char *, int); static int get_config_group(const char *, char *, int, struct lxc_conf *);
static int set_config_environment(const char *, const char *, struct lxc_conf *); static int set_config_environment(const char *, const char *, struct lxc_conf *);
static int get_config_environment(struct lxc_container *, const char *, char *, int); static int get_config_environment(const char *, char *, int, struct lxc_conf *);
static int set_config_init_cmd(const char *, const char *, struct lxc_conf *); static int set_config_init_cmd(const char *, const char *, struct lxc_conf *);
static int get_config_init_cmd(struct lxc_container *, const char *, char *, int); static int get_config_init_cmd(const char *, char *, int, struct lxc_conf *);
static int set_config_init_uid(const char *, const char *, struct lxc_conf *); static int set_config_init_uid(const char *, const char *, struct lxc_conf *);
static int get_config_init_uid(struct lxc_container *, const char *, char *, int); static int get_config_init_uid(const char *, char *, int, struct lxc_conf *);
static int set_config_init_gid(const char *, const char *, struct lxc_conf *); static int set_config_init_gid(const char *, const char *, struct lxc_conf *);
static int get_config_init_gid(struct lxc_container *, const char *, char *, int); static int get_config_init_gid(const char *, char *, int, struct lxc_conf *);
static int set_config_ephemeral(const char *, const char *, struct lxc_conf *); static int set_config_ephemeral(const char *, const char *, struct lxc_conf *);
static int get_config_ephemeral(struct lxc_container *, const char *, char *, int); static int get_config_ephemeral(const char *, char *, int, struct lxc_conf *);
static struct lxc_config_t config[] = { static struct lxc_config_t config[] = {
{ "lxc.arch", set_config_personality, get_config_personality, NULL}, { "lxc.arch", set_config_personality, get_config_personality, NULL},
...@@ -2996,8 +2996,8 @@ static int set_config_ephemeral(const char *key, const char *value, ...@@ -2996,8 +2996,8 @@ static int set_config_ephemeral(const char *key, const char *value,
} }
/* Callbacks to get configuration items. */ /* Callbacks to get configuration items. */
static int get_config_personality(struct lxc_container *c, const char *key, static int get_config_personality(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
int fulllen = 0; int fulllen = 0;
...@@ -3009,7 +3009,7 @@ static int get_config_personality(struct lxc_container *c, const char *key, ...@@ -3009,7 +3009,7 @@ static int get_config_personality(struct lxc_container *c, const char *key,
#if HAVE_SYS_PERSONALITY_H #if HAVE_SYS_PERSONALITY_H
int len = 0; int len = 0;
switch (c->lxc_conf->personality) { switch (c->personality) {
case PER_LINUX32: case PER_LINUX32:
strprint(retv, inlen, "i686"); strprint(retv, inlen, "i686");
break; break;
...@@ -3024,16 +3024,16 @@ static int get_config_personality(struct lxc_container *c, const char *key, ...@@ -3024,16 +3024,16 @@ static int get_config_personality(struct lxc_container *c, const char *key,
return fulllen; return fulllen;
} }
static int get_config_pts(struct lxc_container *c, const char *key, char *retv, static int get_config_pts(const char *key, char *retv, int inlen,
int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_int(c->lxc_conf, retv, inlen, c->lxc_conf->pts); return lxc_get_conf_int(c, retv, inlen, c->pts);
} }
static int get_config_tty(struct lxc_container *c, const char *key, char *retv, static int get_config_tty(const char *key, char *retv, int inlen,
int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_int(c->lxc_conf, retv, inlen, c->lxc_conf->tty); return lxc_get_conf_int(c, retv, inlen, c->tty);
} }
static inline int lxc_get_conf_str(char *retv, int inlen, const char *value) static inline int lxc_get_conf_str(char *retv, int inlen, const char *value)
...@@ -3046,35 +3046,35 @@ static inline int lxc_get_conf_str(char *retv, int inlen, const char *value) ...@@ -3046,35 +3046,35 @@ static inline int lxc_get_conf_str(char *retv, int inlen, const char *value)
return strlen(value); return strlen(value);
} }
static int get_config_ttydir(struct lxc_container *c, const char *key, static int get_config_ttydir(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_str(retv, inlen, c->lxc_conf->ttydir); return lxc_get_conf_str(retv, inlen, c->ttydir);
} }
static int get_config_kmsg(struct lxc_container *c, const char *key, char *retv, static int get_config_kmsg(const char *key, char *retv, int inlen,
int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_int(c->lxc_conf, retv, inlen, c->lxc_conf->kmsg); return lxc_get_conf_int(c, retv, inlen, c->kmsg);
} }
static int get_config_lsm_aa_profile(struct lxc_container *c, const char *key, static int get_config_lsm_aa_profile(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_str(retv, inlen, c->lxc_conf->lsm_aa_profile); return lxc_get_conf_str(retv, inlen, c->lsm_aa_profile);
} }
static int get_config_lsm_aa_incomplete(struct lxc_container *c, static int get_config_lsm_aa_incomplete(const char *key, char *retv, int inlen,
const char *key, char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_int(c->lxc_conf, retv, inlen, return lxc_get_conf_int(c, retv, inlen,
c->lxc_conf->lsm_aa_allow_incomplete); c->lsm_aa_allow_incomplete);
} }
static int get_config_lsm_se_context(struct lxc_container *c, const char *key, static int get_config_lsm_se_context(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_str(retv, inlen, c->lxc_conf->lsm_se_context); return lxc_get_conf_str(retv, inlen, c->lsm_se_context);
} }
/* /*
...@@ -3086,8 +3086,8 @@ static int get_config_lsm_se_context(struct lxc_container *c, const char *key, ...@@ -3086,8 +3086,8 @@ static int get_config_lsm_se_context(struct lxc_container *c, const char *key,
* If you ask for 'lxc.cgroup", then all cgroup entries will be printed, * If you ask for 'lxc.cgroup", then all cgroup entries will be printed,
* in 'lxc.cgroup.subsystem.key = value' format. * in 'lxc.cgroup.subsystem.key = value' format.
*/ */
static int get_config_cgroup(struct lxc_container *c, const char *key, static int get_config_cgroup(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
struct lxc_list *it; struct lxc_list *it;
int len; int len;
...@@ -3106,7 +3106,7 @@ static int get_config_cgroup(struct lxc_container *c, const char *key, ...@@ -3106,7 +3106,7 @@ static int get_config_cgroup(struct lxc_container *c, const char *key,
else else
return -1; return -1;
lxc_list_for_each(it, &c->lxc_conf->cgroup) { lxc_list_for_each(it, &c->cgroup) {
struct lxc_cgroup *cg = it->elem; struct lxc_cgroup *cg = it->elem;
if (get_all) { if (get_all) {
strprint(retv, inlen, "lxc.cgroup.%s = %s\n", cg->subsystem, cg->value); strprint(retv, inlen, "lxc.cgroup.%s = %s\n", cg->subsystem, cg->value);
...@@ -3118,8 +3118,8 @@ static int get_config_cgroup(struct lxc_container *c, const char *key, ...@@ -3118,8 +3118,8 @@ static int get_config_cgroup(struct lxc_container *c, const char *key,
return fulllen; return fulllen;
} }
static int get_config_idmaps(struct lxc_container *c, const char *key, static int get_config_idmaps(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
struct lxc_list *it; struct lxc_list *it;
int len, listlen, ret; int len, listlen, ret;
...@@ -3152,8 +3152,8 @@ static int get_config_idmaps(struct lxc_container *c, const char *key, ...@@ -3152,8 +3152,8 @@ static int get_config_idmaps(struct lxc_container *c, const char *key,
else else
memset(retv, 0, inlen); memset(retv, 0, inlen);
listlen = lxc_list_len(&c->lxc_conf->id_map); listlen = lxc_list_len(&c->id_map);
lxc_list_for_each(it, &c->lxc_conf->id_map) lxc_list_for_each(it, &c->id_map)
{ {
struct id_map *map = it->elem; struct id_map *map = it->elem;
ret = snprintf(buf, __LXC_IDMAP_STR_BUF, "%c %lu %lu %lu", ret = snprintf(buf, __LXC_IDMAP_STR_BUF, "%c %lu %lu %lu",
...@@ -3167,28 +3167,28 @@ static int get_config_idmaps(struct lxc_container *c, const char *key, ...@@ -3167,28 +3167,28 @@ static int get_config_idmaps(struct lxc_container *c, const char *key,
return fulllen; return fulllen;
} }
static int get_config_loglevel(struct lxc_container *c, const char *key, static int get_config_loglevel(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
const char *v; const char *v;
v = lxc_log_priority_to_string(c->lxc_conf->loglevel); v = lxc_log_priority_to_string(c->loglevel);
return lxc_get_conf_str(retv, inlen, v); return lxc_get_conf_str(retv, inlen, v);
} }
static int get_config_logfile(struct lxc_container *c, const char *key, static int get_config_logfile(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_str(retv, inlen, c->lxc_conf->logfile); return lxc_get_conf_str(retv, inlen, c->logfile);
} }
static int get_config_fstab(struct lxc_container *c, const char *key, static int get_config_fstab(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_str(retv, inlen, c->lxc_conf->fstab); return lxc_get_conf_str(retv, inlen, c->fstab);
} }
static int get_config_mount_auto(struct lxc_container *c, const char *key, static int get_config_mount_auto(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
int len, fulllen = 0; int len, fulllen = 0;
const char *sep = ""; const char *sep = "";
...@@ -3198,10 +3198,10 @@ static int get_config_mount_auto(struct lxc_container *c, const char *key, ...@@ -3198,10 +3198,10 @@ static int get_config_mount_auto(struct lxc_container *c, const char *key,
else else
memset(retv, 0, inlen); memset(retv, 0, inlen);
if (!(c->lxc_conf->auto_mounts & LXC_AUTO_ALL_MASK)) if (!(c->auto_mounts & LXC_AUTO_ALL_MASK))
return 0; return 0;
switch (c->lxc_conf->auto_mounts & LXC_AUTO_PROC_MASK) { switch (c->auto_mounts & LXC_AUTO_PROC_MASK) {
case LXC_AUTO_PROC_MIXED: case LXC_AUTO_PROC_MIXED:
strprint(retv, inlen, "%sproc:mixed", sep); strprint(retv, inlen, "%sproc:mixed", sep);
sep = " "; sep = " ";
...@@ -3214,7 +3214,7 @@ static int get_config_mount_auto(struct lxc_container *c, const char *key, ...@@ -3214,7 +3214,7 @@ static int get_config_mount_auto(struct lxc_container *c, const char *key,
break; break;
} }
switch (c->lxc_conf->auto_mounts & LXC_AUTO_SYS_MASK) { switch (c->auto_mounts & LXC_AUTO_SYS_MASK) {
case LXC_AUTO_SYS_RO: case LXC_AUTO_SYS_RO:
strprint(retv, inlen, "%ssys:ro", sep); strprint(retv, inlen, "%ssys:ro", sep);
sep = " "; sep = " ";
...@@ -3231,7 +3231,7 @@ static int get_config_mount_auto(struct lxc_container *c, const char *key, ...@@ -3231,7 +3231,7 @@ static int get_config_mount_auto(struct lxc_container *c, const char *key,
break; break;
} }
switch (c->lxc_conf->auto_mounts & LXC_AUTO_CGROUP_MASK) { switch (c->auto_mounts & LXC_AUTO_CGROUP_MASK) {
case LXC_AUTO_CGROUP_NOSPEC: case LXC_AUTO_CGROUP_NOSPEC:
strprint(retv, inlen, "%scgroup", sep); strprint(retv, inlen, "%scgroup", sep);
sep = " "; sep = " ";
...@@ -3271,8 +3271,8 @@ static int get_config_mount_auto(struct lxc_container *c, const char *key, ...@@ -3271,8 +3271,8 @@ static int get_config_mount_auto(struct lxc_container *c, const char *key,
return fulllen; return fulllen;
} }
static int get_config_mount(struct lxc_container *c, const char *key, static int get_config_mount(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
int len, fulllen = 0; int len, fulllen = 0;
struct lxc_list *it; struct lxc_list *it;
...@@ -3282,7 +3282,7 @@ static int get_config_mount(struct lxc_container *c, const char *key, ...@@ -3282,7 +3282,7 @@ static int get_config_mount(struct lxc_container *c, const char *key,
else else
memset(retv, 0, inlen); memset(retv, 0, inlen);
lxc_list_for_each(it, &c->lxc_conf->mount_list) lxc_list_for_each(it, &c->mount_list)
{ {
strprint(retv, inlen, "%s\n", (char *)it->elem); strprint(retv, inlen, "%s\n", (char *)it->elem);
} }
...@@ -3290,46 +3290,46 @@ static int get_config_mount(struct lxc_container *c, const char *key, ...@@ -3290,46 +3290,46 @@ static int get_config_mount(struct lxc_container *c, const char *key,
return fulllen; return fulllen;
} }
static int get_config_rootfs(struct lxc_container *c, const char *key, static int get_config_rootfs(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_str(retv, inlen, c->lxc_conf->rootfs.path); return lxc_get_conf_str(retv, inlen, c->rootfs.path);
} }
static int get_config_rootfs_mount(struct lxc_container *c, const char *key, static int get_config_rootfs_mount(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_str(retv, inlen, c->lxc_conf->rootfs.mount); return lxc_get_conf_str(retv, inlen, c->rootfs.mount);
} }
static int get_config_rootfs_options(struct lxc_container *c, const char *key, static int get_config_rootfs_options(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_str(retv, inlen, c->lxc_conf->rootfs.options); return lxc_get_conf_str(retv, inlen, c->rootfs.options);
} }
static int get_config_rootfs_backend(struct lxc_container *c, const char *key, static int get_config_rootfs_backend(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_str(retv, inlen, c->lxc_conf->rootfs.bdev_type); return lxc_get_conf_str(retv, inlen, c->rootfs.bdev_type);
} }
static int get_config_pivotdir(struct lxc_container *c, const char *key, static int get_config_pivotdir(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return 0; return 0;
} }
static int get_config_utsname(struct lxc_container *c, const char *key, static int get_config_utsname(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_str( return lxc_get_conf_str(
retv, inlen, retv, inlen,
c->lxc_conf->utsname ? c->lxc_conf->utsname->nodename : NULL); c->utsname ? c->utsname->nodename : NULL);
} }
static int get_config_hooks(struct lxc_container *c, const char *key, static int get_config_hooks(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
char *subkey; char *subkey;
int len, fulllen = 0, found = -1; int len, fulllen = 0, found = -1;
...@@ -3359,14 +3359,14 @@ static int get_config_hooks(struct lxc_container *c, const char *key, ...@@ -3359,14 +3359,14 @@ static int get_config_hooks(struct lxc_container *c, const char *key,
else else
memset(retv, 0, inlen); memset(retv, 0, inlen);
lxc_list_for_each(it, &c->lxc_conf->hooks[found]) { lxc_list_for_each(it, &c->hooks[found]) {
strprint(retv, inlen, "%s\n", (char *)it->elem); strprint(retv, inlen, "%s\n", (char *)it->elem);
} }
return fulllen; return fulllen;
} }
static int get_config_network(struct lxc_container *c, const char *key, static int get_config_network(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
int len, fulllen = 0; int len, fulllen = 0;
struct lxc_list *it; struct lxc_list *it;
...@@ -3376,7 +3376,7 @@ static int get_config_network(struct lxc_container *c, const char *key, ...@@ -3376,7 +3376,7 @@ static int get_config_network(struct lxc_container *c, const char *key,
else else
memset(retv, 0, inlen); memset(retv, 0, inlen);
lxc_list_for_each(it, &c->lxc_conf->network) { lxc_list_for_each(it, &c->network) {
struct lxc_netdev *n = it->elem; struct lxc_netdev *n = it->elem;
const char *t = lxc_net_type_to_str(n->type); const char *t = lxc_net_type_to_str(n->type);
strprint(retv, inlen, "%s\n", t ? t : "(invalid)"); strprint(retv, inlen, "%s\n", t ? t : "(invalid)");
...@@ -3393,8 +3393,8 @@ static int get_config_network(struct lxc_container *c, const char *key, ...@@ -3393,8 +3393,8 @@ static int get_config_network(struct lxc_container *c, const char *key,
* things like veth.pair return '' if invalid (i.e. if called for vlan * things like veth.pair return '' if invalid (i.e. if called for vlan
* type). * type).
*/ */
static int get_config_network_item(struct lxc_container *c, const char *key, static int get_config_network_item(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
char *p1; char *p1;
int len, fulllen = 0; int len, fulllen = 0;
...@@ -3415,7 +3415,7 @@ static int get_config_network_item(struct lxc_container *c, const char *key, ...@@ -3415,7 +3415,7 @@ static int get_config_network_item(struct lxc_container *c, const char *key,
return -1; return -1;
p1++; p1++;
netdev = get_netdev_from_key(key, &c->lxc_conf->network); netdev = get_netdev_from_key(key, &c->network);
if (!netdev) if (!netdev)
return -1; return -1;
if (strcmp(p1, "name") == 0) { if (strcmp(p1, "name") == 0) {
...@@ -3512,8 +3512,8 @@ static int get_config_network_item(struct lxc_container *c, const char *key, ...@@ -3512,8 +3512,8 @@ static int get_config_network_item(struct lxc_container *c, const char *key,
return fulllen; return fulllen;
} }
static int get_config_cap_drop(struct lxc_container *c, const char *key, static int get_config_cap_drop(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
int len, fulllen = 0; int len, fulllen = 0;
struct lxc_list *it; struct lxc_list *it;
...@@ -3523,14 +3523,14 @@ static int get_config_cap_drop(struct lxc_container *c, const char *key, ...@@ -3523,14 +3523,14 @@ static int get_config_cap_drop(struct lxc_container *c, const char *key,
else else
memset(retv, 0, inlen); memset(retv, 0, inlen);
lxc_list_for_each(it, &c->lxc_conf->caps) { lxc_list_for_each(it, &c->caps) {
strprint(retv, inlen, "%s\n", (char *)it->elem); strprint(retv, inlen, "%s\n", (char *)it->elem);
} }
return fulllen; return fulllen;
} }
static int get_config_cap_keep(struct lxc_container *c, const char *key, static int get_config_cap_keep(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
int len, fulllen = 0; int len, fulllen = 0;
struct lxc_list *it; struct lxc_list *it;
...@@ -3540,82 +3540,75 @@ static int get_config_cap_keep(struct lxc_container *c, const char *key, ...@@ -3540,82 +3540,75 @@ static int get_config_cap_keep(struct lxc_container *c, const char *key,
else else
memset(retv, 0, inlen); memset(retv, 0, inlen);
lxc_list_for_each(it, &c->lxc_conf->keepcaps) { lxc_list_for_each(it, &c->keepcaps) {
strprint(retv, inlen, "%s\n", (char *)it->elem); strprint(retv, inlen, "%s\n", (char *)it->elem);
} }
return fulllen; return fulllen;
} }
static int get_config_console(struct lxc_container *c, const char *key, static int get_config_console(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_str(retv, inlen, c->lxc_conf->console.path); return lxc_get_conf_str(retv, inlen, c->console.path);
} }
static int get_config_console_logfile(struct lxc_container *c, const char *key, static int get_config_console_logfile(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_str(retv, inlen, c->lxc_conf->console.log_path); return lxc_get_conf_str(retv, inlen, c->console.log_path);
} }
static int get_config_seccomp(struct lxc_container *c, const char *key, static int get_config_seccomp(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_str(retv, inlen, c->lxc_conf->seccomp); return lxc_get_conf_str(retv, inlen, c->seccomp);
} }
static int get_config_autodev(struct lxc_container *c, const char *key, static int get_config_autodev(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_int(c->lxc_conf, retv, inlen, c->lxc_conf->autodev); return lxc_get_conf_int(c, retv, inlen, c->autodev);
} }
static int get_config_haltsignal(struct lxc_container *c, const char *key, static int get_config_haltsignal(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_int(c->lxc_conf, retv, inlen, return lxc_get_conf_int(c, retv, inlen, c->haltsignal);
c->lxc_conf->haltsignal);
} }
static int get_config_rebootsignal(struct lxc_container *c, const char *key, static int get_config_rebootsignal(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_int(c->lxc_conf, retv, inlen, return lxc_get_conf_int(c, retv, inlen, c->rebootsignal);
c->lxc_conf->rebootsignal);
} }
static int get_config_stopsignal(struct lxc_container *c, const char *key, static int get_config_stopsignal(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_int(c->lxc_conf, retv, inlen, return lxc_get_conf_int(c, retv, inlen, c->stopsignal);
c->lxc_conf->stopsignal);
} }
static int get_config_start(struct lxc_container *c, const char *key, static int get_config_start(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
if (strcmp(key, "lxc.start.auto") == 0) if (strcmp(key, "lxc.start.auto") == 0)
return lxc_get_conf_int(c->lxc_conf, retv, inlen, return lxc_get_conf_int(c, retv, inlen, c->start_auto);
c->lxc_conf->start_auto);
else if (strcmp(key, "lxc.start.delay") == 0) else if (strcmp(key, "lxc.start.delay") == 0)
return lxc_get_conf_int(c->lxc_conf, retv, inlen, return lxc_get_conf_int(c, retv, inlen, c->start_delay);
c->lxc_conf->start_delay);
else if (strcmp(key, "lxc.start.order") == 0) else if (strcmp(key, "lxc.start.order") == 0)
return lxc_get_conf_int(c->lxc_conf, retv, inlen, return lxc_get_conf_int(c, retv, inlen, c->start_order);
c->lxc_conf->start_order);
return -1; return -1;
} }
static int get_config_monitor(struct lxc_container *c, const char *key, static int get_config_monitor(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_int(c->lxc_conf, retv, inlen, return lxc_get_conf_int(c, retv, inlen, c->monitor_unshare);
c->lxc_conf->monitor_unshare);
} }
static int get_config_group(struct lxc_container *c, const char *key, static int get_config_group(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
int len, fulllen = 0; int len, fulllen = 0;
struct lxc_list *it; struct lxc_list *it;
...@@ -3625,14 +3618,14 @@ static int get_config_group(struct lxc_container *c, const char *key, ...@@ -3625,14 +3618,14 @@ static int get_config_group(struct lxc_container *c, const char *key,
else else
memset(retv, 0, inlen); memset(retv, 0, inlen);
lxc_list_for_each(it, &c->lxc_conf->groups) { lxc_list_for_each(it, &c->groups) {
strprint(retv, inlen, "%s\n", (char *)it->elem); strprint(retv, inlen, "%s\n", (char *)it->elem);
} }
return fulllen; return fulllen;
} }
static int get_config_environment(struct lxc_container *c, const char *key, static int get_config_environment(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
int len, fulllen = 0; int len, fulllen = 0;
struct lxc_list *it; struct lxc_list *it;
...@@ -3642,35 +3635,32 @@ static int get_config_environment(struct lxc_container *c, const char *key, ...@@ -3642,35 +3635,32 @@ static int get_config_environment(struct lxc_container *c, const char *key,
else else
memset(retv, 0, inlen); memset(retv, 0, inlen);
lxc_list_for_each(it, &c->lxc_conf->environment) { lxc_list_for_each(it, &c->environment) {
strprint(retv, inlen, "%s\n", (char *)it->elem); strprint(retv, inlen, "%s\n", (char *)it->elem);
} }
return fulllen; return fulllen;
} }
static int get_config_init_cmd(struct lxc_container *c, const char *key, static int get_config_init_cmd(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_str(retv, inlen, c->lxc_conf->init_cmd); return lxc_get_conf_str(retv, inlen, c->init_cmd);
} }
static int get_config_init_uid(struct lxc_container *c, const char *key, static int get_config_init_uid(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_int(c->lxc_conf, retv, inlen, return lxc_get_conf_int(c, retv, inlen, c->init_uid);
c->lxc_conf->init_uid);
} }
static int get_config_init_gid(struct lxc_container *c, const char *key, static int get_config_init_gid(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_int(c->lxc_conf, retv, inlen, return lxc_get_conf_int(c, retv, inlen, c->init_gid);
c->lxc_conf->init_gid);
} }
static int get_config_ephemeral(struct lxc_container *c, const char *key, static int get_config_ephemeral(const char *key, char *retv, int inlen,
char *retv, int inlen) struct lxc_conf *c)
{ {
return lxc_get_conf_int(c->lxc_conf, retv, inlen, return lxc_get_conf_int(c, retv, inlen, c->ephemeral);
c->lxc_conf->ephemeral);
} }
...@@ -33,7 +33,7 @@ struct lxc_list; ...@@ -33,7 +33,7 @@ struct lxc_list;
struct lxc_container; struct lxc_container;
typedef int (*config_set_cb)(const char *, const char *, struct lxc_conf *); typedef int (*config_set_cb)(const char *, const char *, struct lxc_conf *);
typedef int (*config_get_cb)(struct lxc_container *, const char *, char *, int); typedef int (*config_get_cb)(const char *, char *, int, struct lxc_conf *);
typedef int (*config_clear_cb)(void); typedef int (*config_clear_cb)(void);
struct lxc_config_t { struct lxc_config_t {
char *name; char *name;
......
...@@ -1999,7 +1999,7 @@ static int do_lxcapi_get_config_item(struct lxc_container *c, const char *key, c ...@@ -1999,7 +1999,7 @@ static int do_lxcapi_get_config_item(struct lxc_container *c, const char *key, c
* implemented. * implemented.
*/ */
if (config && config->get) if (config && config->get)
ret = config->get(c, key, retv, inlen); ret = config->get(key, retv, inlen, c->lxc_conf);
container_mem_unlock(c); container_mem_unlock(c);
return ret; return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment