2 * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004-2007 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
22 #define LABEL_ID "LABELONE"
23 #define LABEL_SIZE SECTOR_SIZE /* Think very carefully before changing this */
24 #define LABEL_SCAN_SECTORS 4L
25 #define LABEL_SCAN_SIZE (LABEL_SCAN_SECTORS << SECTOR_SHIFT)
29 /* On disk - 32 bytes */
31 int8_t id[8]; /* LABELONE */
32 uint64_t sector_xl; /* Sector number of this label */
33 uint32_t crc_xl; /* From next field to end of sector */
34 uint32_t offset_xl; /* Offset from start of struct to contents */
35 int8_t type[8]; /* LVM2 001 */
36 } __attribute__ ((packed));
42 struct labeller *labeller;
50 * Is the device labelled with this format ?
52 int (*can_handle) (struct labeller * l, void *buf, uint64_t sector);
55 * Write a label to a volume.
57 int (*write) (struct label * label, void *buf);
60 * Read a label from a volume.
62 int (*read) (struct labeller * l, struct device * dev,
63 void *buf, struct label ** label);
66 * Additional consistency checks for the paranoid.
68 int (*verify) (struct labeller * l, void *buf, uint64_t sector);
71 * Populate label_type etc.
73 int (*initialise_label) (struct labeller * l, struct label * label);
76 * Destroy a previously read label.
78 void (*destroy_label) (struct labeller * l, struct label * label);
83 void (*destroy) (struct labeller * l);
87 struct label_ops *ops;
92 void label_exit(void);
94 int label_register_handler(const char *name, struct labeller *handler);
96 struct labeller *label_get_handler(const char *name);
98 int label_remove(struct device *dev);
99 int label_read(struct device *dev, struct label **result,
100 uint64_t scan_sector);
101 int label_write(struct device *dev, struct label *label);
102 int label_verify(struct device *dev);
103 struct label *label_create(struct labeller *labeller);
104 void label_destroy(struct label *label);