[lxc-devel] lxc-clone outputs some logs
KATOH Yasufumi
karma at jazz.email.ne.jp
Wed Nov 5 00:21:30 UTC 2014
>>> On Tue, 4 Nov 2014 13:12:40 +0000
in message "Re: [lxc-devel] lxc-clone outputs some logs"
Serge Hallyn-san wrote:
> That looks good, thanks! Better than what I was thinking :)
Thanks! :-)
> Could you please resend on its own with a signed-off-by?
> Also let's add a check to make sure that the strrchr doesn't
> return NULL, because I don't see where we're ensuring that now.
> It would crash somewhere anyway if that was the case, but
> all the more reason to catch it.
OK. I think so too. I will resend the patch later.
> >
> > ---
> > src/lxc/bdev.c | 21 ++++++++++++++++++++-
> > 1 file changed, 20 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/lxc/bdev.c b/src/lxc/bdev.c
> > index ae5c77c..b303e00 100644
> > --- a/src/lxc/bdev.c
> > +++ b/src/lxc/bdev.c
> > @@ -3328,6 +3328,7 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
> > const char *oldname = c0->name;
> > const char *oldpath = c0->config_path;
> > struct rsync_data data;
> > + char *rootfs;
> >
> > /* 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
> > @@ -3338,12 +3339,30 @@ struct bdev *bdev_copy(struct lxc_container *c0, const char *cname,
> > return NULL;
> > }
> >
> > - orig = bdev_init(c0->lxc_conf, src, src, NULL);
> > + orig = bdev_init(c0->lxc_conf, src, NULL, NULL);
> > if (!orig) {
> > ERROR("failed to detect blockdev type for %s", src);
> > return NULL;
> > }
> >
> > + if (!orig->dest) {
> > + int ret;
> > + orig->dest = malloc(MAXPATHLEN);
> > + if (!orig->dest) {
> > + ERROR("out of memory");
> > + bdev_put(orig);
> > + return NULL;
> > + }
> > + rootfs = strrchr(orig->src, '/');
> > + rootfs++;
> > + ret = snprintf(orig->dest, MAXPATHLEN, "%s/%s/%s", oldpath, oldname, rootfs);
> > + if (ret < 0 || ret >= MAXPATHLEN) {
> > + ERROR("rootfs path too long");
> > + bdev_put(orig);
> > + return NULL;
> > + }
> > + }
> > +
> > /*
> > * special case for snapshot - if caller requested maybe_snapshot and
> > * keepbdevtype and backing store is directory, then proceed with a copy
> > --
> > 2.1.1
> > _______________________________________________
> > lxc-devel mailing list
> > lxc-devel at lists.linuxcontainers.org
> > http://lists.linuxcontainers.org/listinfo/lxc-devel
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel
More information about the lxc-devel
mailing list