storage: make storage_dir() smart

parent 70d6bd97
......@@ -3802,7 +3802,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");
......
......@@ -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;
......
......@@ -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 <storage type>:<container path>
* the confile parser will have split this into <storage type>
* and <container path> and set the <bdev_type> member in the
* lxc_rootfs struct to <storage type> and the <path> member
* will be set to a clean <container path> without the <storage
* type> prefix. This is the new, clean way of handling storage
* type specifications. If the <storage type> 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
......
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