]>
sourceware.org Git - lvm2.git/blob - liblvm/lvm_misc.c
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
;
55 memset(&v
, 0, sizeof(v
));
59 if (!pv_get_property(pv
, &prop
))
62 if (!vg_get_property(vg
, &prop
))
65 if (!lv_get_property(lv
, &prop
))
68 if (!lvseg_get_property(lvseg
, &prop
))
71 if (!pvseg_get_property(pvseg
, &prop
))
74 log_errno(EINVAL
, "Invalid NULL handle passed to library function.");
78 v
.is_settable
= prop
.is_settable
;
79 v
.is_string
= prop
.is_string
;
80 v
.is_integer
= prop
.is_integer
;
82 v
.value
.string
= prop
.value
.string
;
84 v
.value
.integer
= prop
.value
.integer
;
90 int set_property(const pv_t pv
, const vg_t vg
, const lv_t lv
,
91 const char *name
, struct lvm_property_value
*v
)
93 struct lvm_property_type prop
;
97 prop
.value
.string
= v
->value
.string
;
99 prop
.value
.integer
= v
->value
.integer
;
101 if (!pv_set_property(pv
, &prop
)) {
106 if (!vg_set_property(vg
, &prop
)) {
111 if (!lv_set_property(lv
, &prop
)) {
This page took 0.039248 seconds and 5 git commands to generate.