Unverified Commit a493a694 by Christian Brauner Committed by Stéphane Graber

storage: switch to new rsync functions

parent 2ea2f3c8
...@@ -326,7 +326,6 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname, ...@@ -326,7 +326,6 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
const char *bdevdata, uint64_t newsize, int *needs_rdep) const char *bdevdata, uint64_t newsize, int *needs_rdep)
{ {
struct bdev *orig, *new; struct bdev *orig, *new;
pid_t pid;
int ret; int ret;
char *src_no_prefix; char *src_no_prefix;
bool snap = flags & LXC_CLONE_SNAPSHOT; bool snap = flags & LXC_CLONE_SNAPSHOT;
...@@ -336,6 +335,7 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname, ...@@ -336,6 +335,7 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
const char *oldname = c0->name; const char *oldname = c0->name;
const char *oldpath = c0->config_path; const char *oldpath = c0->config_path;
struct rsync_data data; struct rsync_data data;
char cmd_output[MAXPATHLEN];
/* If the container name doesn't show up in the rootfs path, then we /* If the container name doesn't show up in the rootfs path, then we
* don't know how to come up with a new name. * don't know how to come up with a new name.
...@@ -475,33 +475,28 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname, ...@@ -475,33 +475,28 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
return new; return new;
/* rsync the contents from source to target */ /* rsync the contents from source to target */
pid = fork(); data.orig = orig;
if (pid < 0) { data.new = new;
SYSERROR("fork"); if (am_unpriv()) {
goto err; ret = userns_exec_1(c0->lxc_conf, lxc_rsync_exec_wrapper, &data,
} "lxc_rsync_exec_wrapper");
if (pid > 0) {
int ret = wait_for_pid(pid);
bdev_put(orig);
if (ret < 0) { if (ret < 0) {
bdev_put(new); ERROR("Failed to rsync from \"%s\" into \"%s\"",
return NULL; orig->dest, new->dest);
goto err;
}
} else {
ret = run_command(cmd_output, sizeof(cmd_output),
lxc_rsync_exec_wrapper, (void *)&data);
if (ret < 0) {
ERROR("Failed to rsync from \"%s\" into \"%s\": %s",
orig->dest, new->dest, cmd_output);
goto err;
} }
return new;
} }
data.orig = orig; bdev_put(orig);
data.new = new; return new;
if (am_unpriv())
ret = userns_exec_1(c0->lxc_conf, rsync_rootfs_wrapper, &data,
"rsync_rootfs_wrapper");
else
ret = rsync_rootfs(&data);
if (ret < 0)
ERROR("Failed to rsync from");
exit(ret == 0 ? 0 : 1);
err: err:
bdev_put(orig); bdev_put(orig);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment