2 * Copyright (C) 2008,2010 Red Hat, Inc. All rights reserved.
4 * This file is part of LVM2.
6 * This copyrighted material is made available to anyone wishing to use,
7 * modify, copy, or redistribute it subject to the terms and conditions
8 * of the GNU Lesser General Public License v.2.1.
10 * You should have received a copy of the GNU Lesser General Public License
11 * along with this program; if not, write to the Free Software Foundation,
12 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #include "properties.h"
20 struct dm_list *tag_list_copy(struct dm_pool *p, struct dm_list *tag_list)
26 if (!(list = dm_pool_zalloc(p, sizeof(*list)))) {
27 log_errno(ENOMEM, "Memory allocation fail for dm_list.");
32 dm_list_iterate_items(sl, tag_list) {
33 if (!(lsl = dm_pool_zalloc(p, sizeof(*lsl)))) {
35 "Memory allocation fail for lvm_lv_list.");
38 if (!(lsl->str = dm_pool_strdup(p, sl->str))) {
40 "Memory allocation fail for lvm_lv_list->str.");
43 dm_list_add(list, &lsl->list);
48 struct lvm_property_value get_property(const pv_t pv, const vg_t vg,
49 const lv_t lv, const lvseg_t lvseg,
50 const pvseg_t pvseg, const char *name)
52 struct lvm_property_type prop;
53 struct lvm_property_value v;
57 if (!pv_get_property(pv, &prop)) {
62 if (!vg_get_property(vg, &prop)) {
67 if (!lv_get_property(lv, &prop)) {
72 if (!lvseg_get_property(lvseg, &prop)) {
77 if (!pvseg_get_property(pvseg, &prop)) {
82 v.is_settable = prop.is_settable;
83 v.is_string = prop.is_string;
84 v.is_integer = prop.is_integer;
86 v.value.string = prop.value.string;
88 v.value.integer = prop.value.integer;
94 int set_property(const pv_t pv, const vg_t vg, const lv_t lv,
95 const char *name, struct lvm_property_value *v)
97 struct lvm_property_type prop;
101 prop.value.string = v->value.string;
103 prop.value.integer = v->value.integer;
105 if (!pv_set_property(pv, &prop)) {
110 if (!vg_set_property(vg, &prop)) {
115 if (!lv_set_property(lv, &prop)) {