diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index 7f1d43c92..afd472373 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -1026,6 +1026,11 @@ struct lv_list *find_lv_in_vg(const struct volume_group *vg, /* FIXME Merge these functions with ones above */ struct logical_volume *find_lv(const struct volume_group *vg, const char *lv_name); + +struct generic_logical_volume *find_historical_glv(const struct volume_group *vg, + const char *historical_lv_name, + struct glv_list **glvl_found); + struct physical_volume *find_pv_by_name(struct cmd_context *cmd, const char *pv_name, int allow_orphan, int allow_unformatted); diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 0d2211a1e..8b3c53c1b 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -2120,6 +2120,32 @@ struct logical_volume *find_lv(const struct volume_group *vg, return lvl ? lvl->lv : NULL; } +struct generic_logical_volume *find_historical_glv(const struct volume_group *vg, + const char *historical_lv_name, + struct glv_list **glvl_found) +{ + struct glv_list *glvl; + const char *ptr; + + /* Use last component */ + if ((ptr = strrchr(historical_lv_name, '/'))) + ptr++; + else + ptr = historical_lv_name; + + dm_list_iterate_items(glvl, &vg->historical_lvs) { + if (!strcmp(glvl->glv->historical->name, ptr)) { + if (glvl_found) + *glvl_found = glvl; + return glvl->glv; + } + } + + if (glvl_found) + *glvl_found = NULL; + return NULL; +} + struct physical_volume *find_pv(struct volume_group *vg, struct device *dev) { struct pv_list *pvl;