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.60/lib/metadata/metadata-exported.h =================================================================== --- LVM2.2.02.60.orig/lib/metadata/metadata-exported.h 2010-02-08 20:15:25.000000000 +0100 +++ LVM2.2.02.60/lib/metadata/metadata-exported.h 2010-02-08 20:31:58.000000000 +0100 @@ -614,6 +614,7 @@ struct physical_volume *find_pv_by_name( /* 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.60/lib/metadata/metadata.c =================================================================== --- LVM2.2.02.60.orig/lib/metadata/metadata.c 2010-01-21 22:09:23.000000000 +0100 +++ LVM2.2.02.60/lib/metadata/metadata.c 2010-02-08 20:31:58.000000000 +0100 @@ -1746,6 +1746,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; +} + /* Find segment at a given physical extent in a PV */ struct pv_segment *find_peg_by_pe(const struct physical_volume *pv, uint32_t pe) {