2 * Copyright (C) 2008,2009 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
17 #include "lvm-string.h"
21 const char *lvm_pv_get_uuid(const pv_t pv)
23 return pv_uuid_dup(pv);
26 const char *lvm_pv_get_name(const pv_t pv)
28 return dm_pool_strndup(pv->vg->vgmem,
29 (const char *)pv_dev_name(pv), NAME_LEN + 1);
32 uint64_t lvm_pv_get_mda_count(const pv_t pv)
34 return (uint64_t) pv_mda_count(pv);
37 uint64_t lvm_pv_get_dev_size(const pv_t pv)
39 return (uint64_t) SECTOR_SIZE * pv_dev_size(pv);
42 uint64_t lvm_pv_get_size(const pv_t pv)
44 return (uint64_t) SECTOR_SIZE * pv_size_field(pv);
47 uint64_t lvm_pv_get_free(const pv_t pv)
49 return (uint64_t) SECTOR_SIZE * pv_free(pv);
52 struct lvm_property_value lvm_pv_get_property(const pv_t pv, const char *name)
54 return get_property(pv, NULL, NULL, NULL, NULL, name);
57 struct lvm_property_value lvm_pvseg_get_property(const pvseg_t pvseg,
60 return get_property(NULL, NULL, NULL, NULL, pvseg, name);
63 struct dm_list *lvm_pv_list_pvsegs(pv_t pv)
67 struct pv_segment *pvl;
69 if (dm_list_empty(&pv->segments))
72 if (!(list = dm_pool_zalloc(pv->vg->vgmem, sizeof(*list)))) {
73 log_errno(ENOMEM, "Memory allocation fail for dm_list.");
78 dm_list_iterate_items(pvl, &pv->segments) {
79 if (!(pvseg = dm_pool_zalloc(pv->vg->vgmem, sizeof(*pvseg)))) {
81 "Memory allocation fail for lvm_pvseg_list.");
85 dm_list_add(list, &pvseg->list);
90 pv_t lvm_pv_from_name(vg_t vg, const char *name)
94 dm_list_iterate_items(pvl, &vg->pvs) {
95 if (!strcmp(name, pv_dev_name(pvl->pv)))
101 pv_t lvm_pv_from_uuid(vg_t vg, const char *uuid)
106 if (strlen(uuid) < ID_LEN) {
107 log_errno (EINVAL, "Invalid UUID string length");
110 if (strlen(uuid) >= ID_LEN) {
111 if (!id_read_format(&id, uuid)) {
112 log_errno(EINVAL, "Invalid UUID format");
116 dm_list_iterate_items(pvl, &vg->pvs) {
117 if (id_equal(&id, &pvl->pv->id))
124 int lvm_pv_resize(const pv_t pv, uint64_t new_size)
126 /* FIXME: add pv resize code here */
127 log_error("NOT IMPLEMENTED YET");