struct rsync_data *arg = data;
return rsync_rootfs(arg);
}
+
+bool bdev_is_dir(const char *path)
+{
+ struct bdev *orig = bdev_init(path, NULL, NULL);
+ bool ret = false;
+ if (!orig)
+ return ret;
+ if (strcmp(orig->type, "dir") == 0)
+ ret = true;
+ bdev_put(orig);
+ return ret;
+}
+
/*
* If we're not snaphotting, then bdev_copy becomes a simple case of mount
* the original, mount the new, and rsync the contents.
char *overlayfs_getlower(char *p);
+bool bdev_is_dir(const char *path);
+
/*
* Instantiate a bdev object. The src is used to determine which blockdev
* type this should be. The dst and data are optional, and will be used
*/
flags = LXC_CLONE_SNAPSHOT | LXC_CLONE_KEEPMACADDR | LXC_CLONE_KEEPNAME |
LXC_CLONE_KEEPBDEVTYPE | LXC_CLONE_MAYBE_SNAPSHOT;
+ if (bdev_is_dir(c->lxc_conf->rootfs.path)) {
+ ERROR("Snapshot of directory-backed container requested.");
+ ERROR("Making a copy-clone. If you do want snapshots, then");
+ ERROR("please create an overlayfs clone first, snapshot that");
+ ERROR("and keep the original container pristine.");
+ flags &= ~LXC_CLONE_SNAPSHOT | LXC_CLONE_MAYBE_SNAPSHOT;
+ }
c2 = c->clone(c, newname, snappath, flags, NULL, NULL, 0, NULL);
if (!c2) {
ERROR("clone of %s:%s failed", c->config_path, c->name);