2
0
mirror of git://github.com/lxc/lxc synced 2025-08-31 21:55:48 +00:00

lxc-create to return 255 in case of error

to have same exit code for all lxc commands

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
Michel Normand
2009-05-18 22:27:35 +02:00
committed by Daniel Lezcano
parent 23075e69dc
commit 7f8306138a
2 changed files with 14 additions and 22 deletions

View File

@@ -61,14 +61,14 @@ static int create_lxc_directory(const char *dirname)
if (mkdir(LXCPATH, 0755) && errno != EEXIST) {
SYSERROR("failed to create %s directory", LXCPATH);
return -errno;
return -1;
}
sprintf(path, LXCPATH "/%s", dirname);
snprintf(path, MAXPATHLEN, LXCPATH "/%s", dirname);
if (mkdir(path, 0755)) {
SYSERROR("failed to create %s directory", path);
return -errno;
return -1;
}
return 0;
@@ -78,7 +78,7 @@ static int remove_lxc_directory(const char *dirname)
{
char path[MAXPATHLEN];
sprintf(path, LXCPATH "/%s", dirname);
snprintf(path, MAXPATHLEN, LXCPATH "/%s", dirname);
if (rmdir(path)) {
SYSERROR("failed to remove %s directory", path);
@@ -97,18 +97,15 @@ static int remove_lxc_directory(const char *dirname)
int lxc_create(const char *name, struct lxc_conf *conf)
{
int lock, err;
int lock, err = -1;
err = create_lxc_directory(name);
if (err < 0)
return err == -EEXIST ?
-LXC_ERROR_EEXIST : LXC_ERROR_INTERNAL;
if (create_lxc_directory(name))
return err;
lock = lxc_get_lock(name);
if (lock < 0)
return -LXC_ERROR_LOCK;
return err;
err = LXC_ERROR_INTERNAL;
if (lxc_mkstate(name)) {
ERROR("failed to create the state file for %s", name);
goto err;
@@ -119,8 +116,7 @@ int lxc_create(const char *name, struct lxc_conf *conf)
goto err_state;
}
err = lxc_configure(name, conf);
if (err) {
if (lxc_configure(name, conf)) {
ERROR("failed to set configuration for %s", name);
goto err_state;
}

View File

@@ -70,22 +70,18 @@ int main(int argc, char *argv[])
ret = lxc_arguments_parse(&my_args, argc, argv);
if (ret)
return 1;
return -1;
if (lxc_log_init(my_args.log_file, my_args.log_priority,
my_args.progname, my_args.quiet))
return 1;
return -1;
if (lxc_conf_init(&lxc_conf))
return 1;
return -1;
if (my_args.rcfile && lxc_config_read(my_args.rcfile, &lxc_conf))
return 1;
return -1;
ret = lxc_create(my_args.name, &lxc_conf);
if (ret)
return 1;
return 0;
return lxc_create(my_args.name, &lxc_conf);
}