struct lxc_container *c2 = NULL;
char newpath[MAXPATHLEN];
int ret, storage_copied = 0;
- const char *n, *l;
char *origroot = NULL;
struct clone_update_data data;
FILE *fout;
}
// Make sure the container doesn't yet exist.
- n = newname ? newname : c->name;
- l = lxcpath ? lxcpath : c->get_config_path(c);
- ret = snprintf(newpath, MAXPATHLEN, "%s/%s/config", l, n);
+ if (!newname)
+ newname = c->name;
+ if (!lxcpath)
+ lxcpath = c->get_config_path(c);
+ ret = snprintf(newpath, MAXPATHLEN, "%s/%s/config", lxcpath, newname);
if (ret < 0 || ret >= MAXPATHLEN) {
SYSERROR("clone: failed making config pathname");
goto out;
fclose(fout);
c->lxc_conf->rootfs.path = origroot;
- sprintf(newpath, "%s/%s/rootfs", l, n);
+ sprintf(newpath, "%s/%s/rootfs", lxcpath, newname);
if (mkdir(newpath, 0755) < 0) {
SYSERROR("error creating %s", newpath);
goto out;
}
}
- c2 = lxc_container_new(n, l);
+ c2 = lxc_container_new(newname, lxcpath);
if (!c2) {
- ERROR("clone: failed to create new container (%s %s)", n, l);
+ ERROR("clone: failed to create new container (%s %s)", newname,
+ lxcpath);
goto out;
}