summaryrefslogtreecommitdiffstats
path: root/liblvm/lvm_pv.c
blob: 7926bff8e779c523f59260793ead1697b3b5a894 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 * Copyright (C) 2008,2009 Red Hat, Inc. All rights reserved.
 *
 * This file is part of LVM2.
 *
 * This copyrighted material is made available to anyone wishing to use,
 * modify, copy, or redistribute it subject to the terms and conditions
 * of the GNU Lesser General Public License v.2.1.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include "lib.h"
#include "lvm2app.h"
#include "metadata-exported.h"
#include "lvm-string.h"

const char *lvm_pv_get_uuid(const pv_t pv)
{
	char uuid[64] __attribute((aligned(8)));

	if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
		log_error(INTERNAL_ERROR "Unable to convert uuid");
		return NULL;
	}
	return dm_pool_strndup(pv->vg->vgmem, (const char *)uuid, 64);
}

const char *lvm_pv_get_name(const pv_t pv)
{
	return dm_pool_strndup(pv->vg->vgmem,
			       (const char *)pv_dev_name(pv), NAME_LEN + 1);
}

uint64_t lvm_pv_get_mda_count(const pv_t pv)
{
	return (uint64_t) pv_mda_count(pv);
}

uint64_t lvm_pv_get_dev_size(const pv_t pv)
{
	return (uint64_t) SECTOR_SIZE * pv_dev_size(pv);
}

uint64_t lvm_pv_get_size(const pv_t pv)
{
	return (uint64_t) SECTOR_SIZE * pv_size_field(pv);
}

uint64_t lvm_pv_get_free(const pv_t pv)
{
	return (uint64_t) SECTOR_SIZE * pv_free(pv);
}

int lvm_pv_resize(const pv_t pv, uint64_t new_size)
{
	/* FIXME: add pv resize code here */
	log_error("NOT IMPLEMENTED YET");
	return -1;
}