]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
confile: add getter for lxc.arch
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 31 May 2017 03:00:17 +0000 (05:00 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 31 May 2017 08:03:25 +0000 (10:03 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/confile.c

index 297018a1cd24fecbd21d3465f742f70b14cec3e8..283b1032fdd15000d932bf310595c6b8578448c4 100644 (file)
@@ -65,6 +65,7 @@
 lxc_log_define(lxc_confile, lxc);
 
 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 set_config_pts(const char *, const char *, struct lxc_conf *);
 static int set_config_tty(const char *, const char *, struct lxc_conf *);
 static int set_config_ttydir(const char *, const char *, struct lxc_conf *);
@@ -126,8 +127,7 @@ static int set_config_no_new_privs(const char *, const char *, struct lxc_conf *
 static int set_config_limit(const char *, const char *, struct lxc_conf *);
 
 static struct lxc_config_t config[] = {
-
-       { "lxc.arch",                 set_config_personality,           NULL, NULL},
+       { "lxc.arch",                 set_config_personality,          get_config_personality, NULL},
        { "lxc.pts",                  set_config_pts,                   NULL, NULL},
        { "lxc.tty",                  set_config_tty,                   NULL, NULL},
        { "lxc.devttydir",            set_config_ttydir,                NULL, NULL},
@@ -2578,28 +2578,6 @@ static int lxc_get_conf_int(struct lxc_conf *c, char *retv, int inlen, int v)
        return snprintf(retv, inlen, "%d", v);
 }
 
-static int lxc_get_arch_entry(struct lxc_conf *c, char *retv, int inlen)
-{
-       int fulllen = 0;
-
-       if (!retv)
-               inlen = 0;
-       else
-               memset(retv, 0, inlen);
-
-       #if HAVE_SYS_PERSONALITY_H
-       int len = 0;
-
-       switch(c->personality) {
-       case PER_LINUX32: strprint(retv, inlen, "i686"); break;
-       case PER_LINUX: strprint(retv, inlen, "x86_64"); break;
-       default: break;
-       }
-       #endif
-
-       return fulllen;
-}
-
 /*
  * If you ask for a specific cgroup value, i.e. lxc.cgroup.devices.list,
  * then just the value(s) will be printed.  Since there still could be
@@ -3031,8 +3009,6 @@ int lxc_get_config_item(struct lxc_conf *c, const char *key, char *retv,
                return lxc_get_conf_int(c, retv, inlen, c->pts);
        else if (strcmp(key, "lxc.devttydir") == 0)
                v = c->ttydir;
-       else if (strcmp(key, "lxc.arch") == 0)
-               return lxc_get_arch_entry(c, retv, inlen);
        else if (strcmp(key, "lxc.aa_profile") == 0)
                v = c->lsm_aa_profile;
        else if (strcmp(key, "lxc.aa_allow_incomplete") == 0)
@@ -3688,3 +3664,32 @@ static int set_config_no_new_privs(const char *key, const char *value,
 
        return 0;
 }
+
+/* Callbacks to get configuration items. */
+static int get_config_personality(struct lxc_container *c, const char *key,
+                                 char *retv, int inlen)
+{
+       int fulllen = 0;
+
+       if (!retv)
+               inlen = 0;
+       else
+               memset(retv, 0, inlen);
+
+#if HAVE_SYS_PERSONALITY_H
+       int len = 0;
+
+       switch (c->lxc_conf->personality) {
+       case PER_LINUX32:
+               strprint(retv, inlen, "i686");
+               break;
+       case PER_LINUX:
+               strprint(retv, inlen, "x86_64");
+               break;
+       default:
+               break;
+       }
+#endif
+
+       return fulllen;
+}