[lxc-devel] [patch 3/6] [draft] Add variables and multimount in confile
Andrian Nord
nightnord at gmail.com
Tue Nov 17 23:14:59 UTC 2009
Updated for new git. Behaviour rather trivial.
Signed-off-by: Andrian Nord <NightNord at gmail.com>
diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 7a2b300..d35ee96 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -35,6 +35,7 @@
#include "config.h"
#include "parse.h"
+#include "variables.h"
#include <lxc/log.h>
#include <lxc/conf.h>
@@ -477,17 +478,30 @@ static int config_cgroup(const char *key, char *value, struct lxc_conf *lxc_conf
static int config_fstab(const char *key, char *value, struct lxc_conf *lxc_conf)
{
+ struct lxc_list *fstabs = &lxc_conf->fstab_files;
+ struct lxc_list *list;
+
if (strlen(value) >= MAXPATHLEN) {
ERROR("%s path is too long", value);
return -1;
}
- lxc_conf->fstab = strdup(value);
- if (!lxc_conf->fstab) {
- SYSERROR("failed to duplicate string %s", value);
+ list = malloc(sizeof(*list));
+ if (!list) {
+ SYSERROR("failed to allocate memory");
return -1;
}
+ lxc_list_init(list);
+ list->elem = strdup(value);
+
+ if (!list->elem) {
+ SYSERROR("failed to duplicate string %s: no memory", value);
+ return -1;
+ }
+
+ lxc_list_add_tail(fstabs, list);
+
return 0;
}
@@ -570,7 +584,9 @@ static int parse_line(void *buffer, void *data)
char *line = buffer;
char *dot;
char *key;
- char *value;
+ char *value, *expanded;
+
+ int ret;
if (lxc_is_line_empty(line))
return 0;
@@ -600,7 +616,16 @@ static int parse_line(void *buffer, void *data)
return -1;
}
- return config->cb(key, value, state->lxc_conf);
+ if (lxc_resolve_variables(value, &expanded, state->lxc_conf)) {
+ ERROR("%s: variable resolution failed", state->file);
+ return -1;
+ }
+
+ ret = config->cb(key, expanded, state->lxc_conf);
+
+ free(expanded);
+
+ return ret;
}
int lxc_config_read(const char *file, struct lxc_conf *conf)
More information about the lxc-devel
mailing list