From: Christian Brauner Date: Tue, 28 Nov 2017 10:44:49 +0000 (+0100) Subject: storage: make storage_dir() smart X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=146094d6b63b47a50a2cb3c2f85a0f9957a23cc9;p=thirdparty%2Flxc.git storage: make storage_dir() smart Signed-off-by: Christian Brauner Signed-off-by: Adrian Reber --- diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index afa8b8b7b..d86c33071 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -3740,7 +3740,7 @@ static int do_lxcapi_snapshot(struct lxc_container *c, const char *commentfile) */ flags = LXC_CLONE_SNAPSHOT | LXC_CLONE_KEEPMACADDR | LXC_CLONE_KEEPNAME | LXC_CLONE_KEEPBDEVTYPE | LXC_CLONE_MAYBE_SNAPSHOT; - if (storage_is_dir(c->lxc_conf, c->lxc_conf->rootfs.path)) { + if (storage_is_dir(c->lxc_conf)) { ERROR("Snapshot of directory-backed container requested."); ERROR("Making a copy-clone. If you do want snapshots, then"); ERROR("please create an aufs or overlay clone first, snapshot that"); diff --git a/src/lxc/storage/storage.c b/src/lxc/storage/storage.c index 58940f44b..8d5b39907 100644 --- a/src/lxc/storage/storage.c +++ b/src/lxc/storage/storage.c @@ -650,12 +650,16 @@ struct lxc_storage *storage_init(struct lxc_conf *conf, const char *src, return bdev; } -bool storage_is_dir(struct lxc_conf *conf, const char *path) +bool storage_is_dir(struct lxc_conf *conf) { struct lxc_storage *orig; + char *type = conf->rootfs.bdev_type; bool bret = false; - orig = storage_init(conf, path, NULL, NULL); + if (type) + return (strcmp(type, "dir") == 0); + + orig = storage_init(conf, conf->lxc_rootfs.path, NULL, NULL); if (!orig) return bret; diff --git a/src/lxc/storage/storage.h b/src/lxc/storage/storage.h index 7156543e9..da59adf95 100644 --- a/src/lxc/storage/storage.h +++ b/src/lxc/storage/storage.h @@ -109,7 +109,19 @@ struct lxc_storage { int flags; }; -extern bool storage_is_dir(struct lxc_conf *conf, const char *path); +/** + * storage_is_dir : Check whether the roots is a directory. This function will + * trust the config file. If the config file key + * lxc.rootfs.path is set to : + * the confile parser will have split this into + * and and set the member in the + * lxc_rootfs struct to and the member + * will be set to a clean without the prefix. This is the new, clean way of handling storage + * type specifications. If the prefix is not + * detected liblxc will try to detect the storage type. + */ +extern bool storage_is_dir(struct lxc_conf *conf); extern bool storage_can_backup(struct lxc_conf *conf); /* Instantiate a lxc_storage object. The src is used to determine which blockdev