return _do_lv_pool_lv_dup(mem, lv, 1);
}
+struct logical_volume *lv_data_lv(const struct logical_volume *lv)
+{
+ struct lv_segment *seg = (lv_is_thin_pool(lv) || lv_is_cache_pool(lv)) ?
+ first_seg(lv) : NULL;
+ struct logical_volume *data_lv = seg ? seg_lv(seg, 0) : NULL;
+
+ return data_lv;
+}
+
static char *_do_lv_data_lv_dup(struct dm_pool *mem, const struct logical_volume *lv,
int uuid)
{
- struct lv_segment *seg = (lv_is_thin_pool(lv) || lv_is_cache_pool(lv)) ?
- first_seg(lv) : NULL;
+ struct logical_volume *data_lv = lv_data_lv(lv);
- if (seg) {
- if (uuid)
- return lv_uuid_dup(mem, seg_lv(seg, 0));
- else
- return lv_name_dup(mem, seg_lv(seg, 0));
- }
+ if (!data_lv)
+ return NULL;
- return NULL;
+ if (uuid)
+ return lv_uuid_dup(mem, data_lv);
+ else
+ return lv_name_dup(mem, data_lv);
}
char *lv_data_lv_dup(struct dm_pool *mem, const struct logical_volume *lv)
struct logical_volume *lv_convert_lv(const struct logical_volume *lv);
struct logical_volume *lv_origin_lv(const struct logical_volume *lv);
struct logical_volume *lv_mirror_log_lv(const struct logical_volume *lv);
+struct logical_volume *lv_data_lv(const struct logical_volume *lv);
char *lv_parent_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_origin_uuid_dup(struct dm_pool *mem, const struct logical_volume *lv);
int uuid)
{
const struct logical_volume *lv = (const struct logical_volume *) data;
- const struct lv_segment *seg = (lv_is_pool(lv)) ? first_seg(lv) : NULL;
+ struct logical_volume *data_lv = lv_data_lv(lv);
- if (seg) {
- if (uuid)
- return _uuid_disp(rh, mem, field, &seg_lv(seg, 0)->lvid.id[1], private);
- else
- return _lvname_disp(rh, mem, field, seg_lv(seg, 0), private);
- }
+ if (!data_lv)
+ return _field_set_value(field, "", NULL);
- return _field_set_value(field, "", NULL);
+ if (uuid)
+ return _uuid_disp(rh, mem, field, &data_lv->lvid.id[1], private);
+ else
+ return _lvname_disp(rh, mem, field, data_lv, private);
}
static int _datalv_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),