]> sourceware.org Git - lvm2.git/blob - lib/label/label.h
thin: fix recent commits
[lvm2.git] / lib / label / label.h
1 /*
2 * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
4 *
5 * This file is part of LVM2.
6 *
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.
10 *
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
14 */
15
16 #ifndef _LVM_LABEL_H
17 #define _LVM_LABEL_H
18
19 #include "uuid.h"
20 #include "device.h"
21
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)
26
27 struct labeller;
28
29 void allow_reads_with_lvmetad(void);
30
31 /* On disk - 32 bytes */
32 struct label_header {
33 int8_t id[8]; /* LABELONE */
34 uint64_t sector_xl; /* Sector number of this label */
35 uint32_t crc_xl; /* From next field to end of sector */
36 uint32_t offset_xl; /* Offset from start of struct to contents */
37 int8_t type[8]; /* LVM2 001 */
38 } __attribute__ ((packed));
39
40 /* In core */
41 struct label {
42 char type[8];
43 uint64_t sector;
44 struct labeller *labeller;
45 void *info;
46 };
47
48 struct labeller;
49
50 struct label_ops {
51 /*
52 * Is the device labelled with this format ?
53 */
54 int (*can_handle) (struct labeller * l, void *buf, uint64_t sector);
55
56 /*
57 * Write a label to a volume.
58 */
59 int (*write) (struct label * label, void *buf);
60
61 /*
62 * Read a label from a volume.
63 */
64 int (*read) (struct labeller * l, struct device * dev,
65 void *buf, struct label ** label);
66
67 /*
68 * Additional consistency checks for the paranoid.
69 */
70 int (*verify) (struct labeller * l, void *buf, uint64_t sector);
71
72 /*
73 * Populate label_type etc.
74 */
75 int (*initialise_label) (struct labeller * l, struct label * label);
76
77 /*
78 * Destroy a previously read label.
79 */
80 void (*destroy_label) (struct labeller * l, struct label * label);
81
82 /*
83 * Destructor.
84 */
85 void (*destroy) (struct labeller * l);
86 };
87
88 struct labeller {
89 struct label_ops *ops;
90 const void *private;
91 };
92
93 int label_init(void);
94 void label_exit(void);
95
96 int label_register_handler(const char *name, struct labeller *handler);
97
98 struct labeller *label_get_handler(const char *name);
99
100 int label_remove(struct device *dev);
101 int label_read(struct device *dev, struct label **result,
102 uint64_t scan_sector);
103 int label_write(struct device *dev, struct label *label);
104 int label_verify(struct device *dev);
105 struct label *label_create(struct labeller *labeller);
106 void label_destroy(struct label *label);
107
108 #endif
This page took 0.038858 seconds and 5 git commands to generate.