diff options
author | Dave Wysochanski <dwysocha@redhat.com> | 2010-09-30 13:52:55 +0000 |
---|---|---|
committer | Dave Wysochanski <dwysocha@redhat.com> | 2010-09-30 13:52:55 +0000 |
commit | 14663348d03bdb8b6f30e9a30f0b65b2f0a659d9 (patch) | |
tree | 85053068f1f2d9cbb0a329dda5ae6699ad048b41 /lib/metadata/pv.c | |
parent | e32e2eb01130623281d79d64c08bcadb6736f043 (diff) | |
download | lvm2-14663348d03bdb8b6f30e9a30f0b65b2f0a659d9.tar.gz lvm2-14663348d03bdb8b6f30e9a30f0b65b2f0a659d9.tar.xz lvm2-14663348d03bdb8b6f30e9a30f0b65b2f0a659d9.zip |
Add {pv|vg|lv}_attr_dup() functions and refactor 'disp' functions.
Move the creating of the 'attr' strings into a common function so
they can be called from the 'disp' functions as well as the new
'get' property functions.
Add "_dup" suffix to indicate memory is allocated.
Refactor pvstatus_disp to take pv argument and call pv_attr_dup().
Diffstat (limited to 'lib/metadata/pv.c')
-rw-r--r-- | lib/metadata/pv.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/metadata/pv.c b/lib/metadata/pv.c index dc4a300b..7c603e11 100644 --- a/lib/metadata/pv.c +++ b/lib/metadata/pv.c @@ -163,6 +163,27 @@ int is_missing_pv(const struct physical_volume *pv) return pv_field(pv, status) & MISSING_PV ? 1 : 0; } +char *pv_attr_dup(struct dm_pool *mem, const struct physical_volume *pv) +{ + char *repstr; + + if (!(repstr = dm_pool_zalloc(mem, 3))) { + log_error("dm_pool_alloc failed"); + return NULL; + } + + if (pv->status & ALLOCATABLE_PV) + repstr[0] = 'a'; + else + repstr[0] = '-'; + + if (pv->status & EXPORTED_VG) + repstr[1] = 'x'; + else + repstr[1] = '-'; + return repstr; +} + unsigned pv_mda_set_ignored(const struct physical_volume *pv, unsigned mda_ignored) { struct lvmcache_info *info; |