From 7bb878863c0e76bddb0bb062234c2ae1e4b3fb06 Mon Sep 17 00:00:00 2001 From: Serge Hallyn Date: Fri, 21 Feb 2014 14:36:06 -0600 Subject: [PATCH] add dir support MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit It used to be supported with the lxc-create.in script, and the manpage says it's supported... So let's just support it. Now sudo lxc-create -t download --dir /opt/ab -n ab works, creating the container rootfs under /opt/ab. This generally isn't something I'd recommend, however telling users to use a different lxc-path isn't as friendly as I'd like, because each lxcpath requires separate lxc-ls and lxc-autostart runs. Signed-off-by: Serge Hallyn Acked-by: Stéphane Graber --- src/lxc/bdev.c | 5 ++++- src/lxc/bdev.h | 1 + src/lxc/lxc_create.c | 3 +-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lxc/bdev.c b/src/lxc/bdev.c index 6d8860967..952cfebec 100644 --- a/src/lxc/bdev.c +++ b/src/lxc/bdev.c @@ -477,7 +477,10 @@ static int dir_destroy(struct bdev *orig) static int dir_create(struct bdev *bdev, const char *dest, const char *n, struct bdev_specs *specs) { - bdev->src = strdup(dest); + if (specs->dir) + bdev->src = strdup(specs->dir); + else + bdev->src = strdup(dest); bdev->dest = strdup(dest); if (!bdev->src || !bdev->dest) { ERROR("Out of memory"); diff --git a/src/lxc/bdev.h b/src/lxc/bdev.h index 7efc1647f..cc0bf02bf 100644 --- a/src/lxc/bdev.h +++ b/src/lxc/bdev.h @@ -48,6 +48,7 @@ struct bdev_specs { char *lv; char *thinpool; // lvm thin pool to use, if any } lvm; + char *dir; }; struct bdev_ops { diff --git a/src/lxc/lxc_create.c b/src/lxc/lxc_create.c index a3684c16f..eee6ffd79 100644 --- a/src/lxc/lxc_create.c +++ b/src/lxc/lxc_create.c @@ -256,8 +256,7 @@ int main(int argc, char *argv[]) spec.lvm.thinpool = my_args.thinpool; } if (my_args.dir) { - ERROR("--dir is not yet supported"); - exit(1); + spec.dir = my_args.dir; } if (strcmp(my_args.bdevtype, "_unset") == 0) -- 2.47.2