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/vg.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/vg.c')
-rw-r--r-- | lib/metadata/vg.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c index 40270ec9..3315c7e1 100644 --- a/lib/metadata/vg.c +++ b/lib/metadata/vg.c @@ -434,3 +434,40 @@ int vg_set_clustered(struct volume_group *vg, int clustered) return 1; } +char *vg_attr_dup(struct dm_pool *mem, const struct volume_group *vg) +{ + char *repstr; + + if (!(repstr = dm_pool_zalloc(mem, 7))) { + log_error("dm_pool_alloc failed"); + return NULL; + } + + if (vg->status & LVM_WRITE) + repstr[0] = 'w'; + else + repstr[0] = 'r'; + + if (vg_is_resizeable(vg)) + repstr[1] = 'z'; + else + repstr[1] = '-'; + + if (vg_is_exported(vg)) + repstr[2] = 'x'; + else + repstr[2] = '-'; + + if (vg_missing_pv_count(vg)) + repstr[3] = 'p'; + else + repstr[3] = '-'; + + repstr[4] = alloc_policy_char(vg->alloc); + + if (vg_is_clustered(vg)) + repstr[5] = 'c'; + else + repstr[5] = '-'; + return repstr; +} |