overlay: simplify logic

parent 70e95c8d
...@@ -338,20 +338,17 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char ...@@ -338,20 +338,17 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
s1 = clean_new_path; s1 = clean_new_path;
s2 = clean_old_path; s2 = clean_old_path;
s3 = (char *)cname; s3 = (char *)cname;
name_len = strlen(cname);
len = strlen(clean_new_path);
} else if (!strncmp(s2, "/snaps", sizeof("/snaps") - 1)) { } else if (!strncmp(s2, "/snaps", sizeof("/snaps") - 1)) {
s1 = clean_old_path; s1 = clean_old_path;
s2 = clean_new_path; s2 = clean_new_path;
s3 = (char *)oldname; s3 = (char *)oldname;
name_len = strlen(oldname);
len = strlen(clean_old_path);
} else { } else {
free(clean_old_path); free(clean_old_path);
free(clean_new_path); free(clean_new_path);
return 0; return 0;
} }
len = strlen(s1);
if (!strncmp(s1, s2, len)) { if (!strncmp(s1, s2, len)) {
char *tmp; char *tmp;
...@@ -369,19 +366,10 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char ...@@ -369,19 +366,10 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
return 0; return 0;
} }
tmp += name_len + 1;
if (*tmp == '\0') {
free(clean_old_path);
free(clean_new_path);
return 0;
}
if (!strncmp(tmp, "snaps", sizeof("snaps") - 1)) {
free(clean_old_path); free(clean_old_path);
free(clean_new_path); free(clean_new_path);
return LXC_CLONE_SNAPSHOT; return LXC_CLONE_SNAPSHOT;
} }
}
free(clean_old_path); free(clean_old_path);
free(clean_new_path); free(clean_new_path);
......
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