overlay: adapt to new config rootfs parser

parent 63c9ffa0
......@@ -4054,8 +4054,8 @@ static bool do_lxcapi_snapshot_restore(struct lxc_container *c, const char *snap
if (!strcmp(bdev->type, "overlay") || !strcmp(bdev->type, "overlayfs"))
flags |= LXC_STORAGE_INTERNAL_OVERLAY_RESTORE;
rest = lxcapi_clone(snap, newname, c->config_path, flags,
bdev->type, NULL, 0, NULL);
rest = lxcapi_clone(snap, newname, c->config_path, flags, bdev->type,
NULL, 0, NULL);
storage_put(bdev);
if (rest && lxcapi_is_defined(rest))
b = true;
......
......@@ -199,12 +199,11 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
return -22;
}
nsrc = strchr(osrc, ':') + 1;
if ((nsrc != osrc + 8) && (nsrc != osrc + 10)) {
ERROR("Detected \":\" in \"%s\" at wrong position", osrc);
free(osrc);
return -22;
}
nsrc = osrc;
if (strncmp(osrc, "overlay:", 8) == 0)
nsrc += 8;
else if (strncmp(osrc, "overlayfs:", 10) == 0)
nsrc += 10;
odelta = strchr(nsrc, ':');
if (!odelta) {
......@@ -457,22 +456,17 @@ int ovl_create(struct lxc_storage *bdev, const char *dest, const char *n,
int ovl_destroy(struct lxc_storage *orig)
{
bool ovl;
char *upper = orig->src;
ovl = !strncmp(upper, "overlay:", 8);
if (!ovl && strncmp(upper, "overlayfs:", 10))
return -22;
/* For an overlay container the rootfs is considered immutable
* and cannot be removed when restoring from a snapshot.
*/
if (orig->flags & LXC_STORAGE_INTERNAL_OVERLAY_RESTORE)
return 0;
if (ovl)
if (strncmp(upper, "overlay:", 8) == 0)
upper += 8;
else
else if (strncmp(upper, "overlayfs:", 10) == 0)
upper += 10;
upper = strchr(upper, ':');
......@@ -485,10 +479,10 @@ int ovl_destroy(struct lxc_storage *orig)
bool ovl_detect(const char *path)
{
if (!strncmp(path, "overlayfs:", 10))
if (!strncmp(path, "overlay:", 8))
return true;
if (!strncmp(path, "overlay:", 8))
if (!strncmp(path, "overlayfs:", 10))
return true;
return false;
......@@ -521,18 +515,19 @@ int ovl_mount(struct lxc_storage *bdev)
ERROR("Failed to allocate memory");
return -1;
}
upper = dup;
lower = dup;
/* support multiple lower layers */
lower = strstr(dup, ":/");
if (!lower) {
ERROR("Failed to detect \":/\" in string \"%s\"", dup);
free(dup);
return -22;
}
if (strncmp(dup, "overlay:", 8) == 0)
lower += 8;
else if (strncmp(dup, "overlayfs:", 10) == 0)
lower += 10;
if (upper != lower)
upper = lower;
lower++;
upper = lower;
while ((tmp = strstr(++upper, ":/"))) {
/* support multiple lower layers */
while ((tmp = strstr(upper, ":/"))) {
tmp++;
upper = tmp;
}
......
......@@ -268,10 +268,9 @@ struct lxc_storage *storage_get(const char *type)
size_t i;
struct lxc_storage *bdev;
for (i = 0; i < numbdevs; i++) {
for (i = 0; i < numbdevs; i++)
if (strcmp(bdevs[i].name, type) == 0)
break;
}
if (i == numbdevs)
return NULL;
......@@ -284,7 +283,7 @@ struct lxc_storage *storage_get(const char *type)
bdev->ops = bdevs[i].ops;
bdev->type = bdevs[i].name;
if (!strcmp(bdev->type, "aufs"))
if (strcmp(bdev->type, "aufs") == 0)
WARN("The \"aufs\" driver will is deprecated and will soon be "
"removed. For similar functionality see the \"overlay\" "
"storage driver");
......@@ -296,7 +295,7 @@ static struct lxc_storage *do_storage_create(const char *dest, const char *type,
const char *cname,
struct bdev_specs *specs)
{
int ret;
struct lxc_storage *bdev;
if (!type)
......@@ -306,7 +305,8 @@ static struct lxc_storage *do_storage_create(const char *dest, const char *type,
if (!bdev)
return NULL;
if (bdev->ops->create(bdev, dest, cname, specs) < 0) {
ret = bdev->ops->create(bdev, dest, cname, specs);
if (ret < 0) {
storage_put(bdev);
return NULL;
}
......
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