From: Daniel Lezcano Date: Thu, 28 May 2009 10:10:50 +0000 (+0200) Subject: create the container with an empty configuration X-Git-Tag: lxc_0_6_3~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4fcc0112bd5f3b7aaa26b1d734d7e7229eee738d;p=thirdparty%2Flxc.git create the container with an empty configuration Fix the code to not fail when the specified configuration file is empty. Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/lxc_create.c b/src/lxc/lxc_create.c index 9d23aa9c3..d6a3a9ba5 100644 --- a/src/lxc/lxc_create.c +++ b/src/lxc/lxc_create.c @@ -35,6 +35,8 @@ #include "confile.h" #include "arguments.h" +lxc_log_define(lxc_create, lxc); + static int my_parser(struct lxc_arguments* args, int c, char* arg) { switch (c) { @@ -63,6 +65,11 @@ Options :\n\ .checker = NULL, }; +static int copy_config_file(const char *name, const char *file) +{ + return 0; +} + int main(int argc, char *argv[]) { struct lxc_conf lxc_conf; @@ -79,9 +86,22 @@ int main(int argc, char *argv[]) if (lxc_conf_init(&lxc_conf)) return -1; - if (my_args.rcfile && lxc_config_read(my_args.rcfile, &lxc_conf)) + if (my_args.rcfile && lxc_config_read(my_args.rcfile, &lxc_conf)) { + ERROR("failed to read the configuration file"); return -1; + } - return lxc_create(my_args.name, &lxc_conf); + if (lxc_create(my_args.name, &lxc_conf)) { + ERROR("failed to create the container"); + return -1; + } + + if (copy_config_file(my_args.name, my_args.rcfile)) { + ERROR("failed to copy the configuration file"); + lxc_destroy(my_args.name); + return -1; + } + + return 0; } diff --git a/src/lxc/parse.c b/src/lxc/parse.c index 5cd8470ef..b3d1194eb 100644 --- a/src/lxc/parse.c +++ b/src/lxc/parse.c @@ -67,7 +67,7 @@ int lxc_file_for_each_line(const char *file, lxc_file_cb callback, char *buffer, size_t len, void* data) { FILE *f; - int err = -1; + int err = 0; f = fopen(file, "r"); if (!f) {