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;
{
char path[MAXPATHLEN];
- sprintf(path, LXCPATH "/%s", dirname);
+ snprintf(path, MAXPATHLEN, LXCPATH "/%s", dirname);
if (rmdir(path)) {
SYSERROR("failed to remove %s directory", path);
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;
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;
}
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);
}