Implement a function to return the last segment in a LV. Signed-off-by: Mikulas Patocka --- lib/metadata/metadata-exported.h | 1 + lib/metadata/metadata.c | 10 ++++++++++ 2 files changed, 11 insertions(+) Index: LVM2.2.02.73/lib/metadata/metadata-exported.h =================================================================== --- LVM2.2.02.73.orig/lib/metadata/metadata-exported.h 2010-09-10 18:32:55.000000000 +0200 +++ LVM2.2.02.73/lib/metadata/metadata-exported.h 2010-09-10 18:54:44.000000000 +0200 @@ -716,6 +716,7 @@ const char *find_vgname_from_pvid(struct const char *pvid); /* Find LV segment containing given LE */ struct lv_segment *first_seg(const struct logical_volume *lv); +struct lv_segment *last_seg(const struct logical_volume *lv); /* Index: LVM2.2.02.73/lib/metadata/metadata.c =================================================================== --- LVM2.2.02.73.orig/lib/metadata/metadata.c 2010-08-12 06:11:49.000000000 +0200 +++ LVM2.2.02.73/lib/metadata/metadata.c 2010-09-10 18:54:44.000000000 +0200 @@ -2087,6 +2087,16 @@ struct lv_segment *first_seg(const struc return NULL; } +struct lv_segment *last_seg(const struct logical_volume *lv) +{ + struct lv_segment *seg; + + dm_list_iterate_back_items(seg, &lv->segments) + return seg; + + return NULL; +} + int vg_remove_mdas(struct volume_group *vg) { struct metadata_area *mda;