[lxc-devel] [patch 3/7] Extend lxc_conf with multiply fstab files

Andrian Nord nightnord at gmail.com
Mon Dec 7 10:38:56 UTC 2009


This replaces single-string fstab entry into lxc_conf with list and
changes confile parsing to use this.

Adding to tail required, as fstab order in file could be important

Signed-off-by: Andrian Nord <NightNord at gmail.com>

diff --git a/src/lxc/conf.h b/src/lxc/conf.h
index 59a5560..a8cfac9 100644
--- a/src/lxc/conf.h
+++ b/src/lxc/conf.h
@@ -135,13 +135,13 @@ struct lxc_tty_info {
  */
 struct lxc_conf {
 	char *rootfs;
-	char *fstab;
 	char *name;
 	int tty;
 	int pts;
 	struct utsname *utsname;
 	struct lxc_list cgroup;
 	struct lxc_list network;
+	struct lxc_list fstab_files;
 	struct lxc_list mount_list;
 	struct lxc_tty_info tty_info;
 	char console[MAXPATHLEN];
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 36166a3..50315c9 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -816,7 +684,6 @@ out:
 int lxc_conf_init(const char *name, struct lxc_conf *conf)
 {
 	conf->rootfs = NULL;
-	conf->fstab = NULL;
 	conf->utsname = NULL;
 
 	conf->name = strdup(name);
@@ -830,6 +697,7 @@ int lxc_conf_init(const char *name, struct lxc_conf *conf)
 	conf->console[0] = '\0';
 	lxc_list_init(&conf->cgroup);
 	lxc_list_init(&conf->network);
+	lxc_list_init(&conf->fstab_files);
 	lxc_list_init(&conf->mount_list);
 	return 0;
 }
diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 7b954b1..ed3fc63 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -478,17 +479,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;
 }
 




More information about the lxc-devel mailing list