2 * Copyright (C) 1997-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
5 * This file is part of LVM2.
7 * This copyrighted material is made available to anyone wishing to use,
8 * modify, copy, or redistribute it subject to the terms and conditions
9 * of the GNU Lesser General Public License v.2.1.
11 * You should have received a copy of the GNU Lesser General Public License
12 * along with this program; if not, write to the Free Software Foundation,
13 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "pool_label.h"
26 static void _pool_not_supported(const char *op)
28 log_error("The '%s' operation is not supported for the pool labeller.",
32 static int _pool_can_handle(struct labeller *l __attribute__((unused)), void *buf, uint64_t sector)
38 * POOL label must always be in first sector
43 pool_label_in(&pd, buf);
45 /* can ignore 8 rightmost bits for ondisk format check */
46 if ((pd.pl_magic == POOL_MAGIC) &&
47 (pd.pl_version >> 8 == POOL_VERSION >> 8))
53 static int _pool_write(struct label *label __attribute__((unused)), void *buf __attribute__((unused)))
55 _pool_not_supported("write");
59 static int _pool_read(struct labeller *l, struct device *dev, void *buf,
64 return read_pool_label(&pl, l, dev, buf, label);
67 static int _pool_initialise_label(struct labeller *l __attribute__((unused)), struct label *label)
69 strcpy(label->type, "POOL");
74 static void _pool_destroy_label(struct labeller *l __attribute__((unused)), struct label *label __attribute__((unused)))
78 static void _label_pool_destroy(struct labeller *l)
83 struct label_ops _pool_ops = {
84 .can_handle = _pool_can_handle,
87 .verify = _pool_can_handle,
88 .initialise_label = _pool_initialise_label,
89 .destroy_label = _pool_destroy_label,
90 .destroy = _label_pool_destroy,
93 struct labeller *pool_labeller_create(struct format_type *fmt)
97 if (!(l = dm_malloc(sizeof(*l)))) {
98 log_error("Couldn't allocate labeller object.");
103 l->private = (const void *) fmt;