a = last_path_component(marker);
if (image_name_is_valid(name_or_path)) {
- const char *e;
+ const char *e, *underscore;
/* We shall match against an image name. In that case let's compare the last component, and optionally
- * allow either a suffix of ".raw" or a series of "/". */
+ * allow either a suffix of ".raw" or a series of "/".
+ * But allow matching on a different version of the same image, when a "_" is used as a separator. */
+ underscore = strchr(name_or_path, '_');
+ if (underscore)
+ return strneq(a, name_or_path, underscore - name_or_path);
e = startswith(a, name_or_path);
if (!e)
e[strspn(e, "/")] == 0 ||
streq(e, ".raw");
} else {
- const char *b;
+ const char *b, *underscore;
size_t l;
/* We shall match against a path. Let's ignore any prefix here though, as often there are many ways to
if (strcspn(b, "/") != l)
return false;
- return memcmp(a, b, l) == 0;
+ underscore = strchr(b, '_');
+ if (underscore)
+ l = underscore - b;
+
+ return strneq(a, b, l);
}
}