]> sourceware.org Git - lvm2.git/blame - lib/label/label.h
thin: fix recent commits
[lvm2.git] / lib / label / label.h
CommitLineData
3dd5cbe5 1/*
6606c3ae 2 * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
be684599 3 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
3dd5cbe5 4 *
6606c3ae
AK
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
be684599 9 * of the GNU Lesser General Public License v.2.1.
6606c3ae 10 *
be684599 11 * You should have received a copy of the GNU Lesser General Public License
6606c3ae
AK
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
3dd5cbe5
PC
14 */
15
fc63d04f
JT
16#ifndef _LVM_LABEL_H
17#define _LVM_LABEL_H
3dd5cbe5 18
fc63d04f
JT
19#include "uuid.h"
20#include "device.h"
f4a7ce7c 21
5a52dca9
AK
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
4922197a
AK
27struct labeller;
28
dae08226
PR
29void allow_reads_with_lvmetad(void);
30
5a52dca9
AK
31/* On disk - 32 bytes */
32struct label_header {
72b2cb61 33 int8_t id[8]; /* LABELONE */
5a52dca9
AK
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 */
72b2cb61 37 int8_t type[8]; /* LVM2 001 */
5a52dca9
AK
38} __attribute__ ((packed));
39
40/* In core */
fc63d04f 41struct label {
5a52dca9
AK
42 char type[8];
43 uint64_t sector;
6036e5e0 44 struct labeller *labeller;
5a52dca9 45 void *info;
fc63d04f
JT
46};
47
48struct labeller;
49
50struct label_ops {
51 /*
52 * Is the device labelled with this format ?
53 */
4dc0ec22 54 int (*can_handle) (struct labeller * l, void *buf, uint64_t sector);
fc63d04f
JT
55
56 /*
57 * Write a label to a volume.
58 */
4dc0ec22 59 int (*write) (struct label * label, void *buf);
fc63d04f
JT
60
61 /*
5a52dca9 62 * Read a label from a volume.
fc63d04f 63 */
5a52dca9 64 int (*read) (struct labeller * l, struct device * dev,
4dc0ec22 65 void *buf, struct label ** label);
fc63d04f
JT
66
67 /*
5a52dca9 68 * Additional consistency checks for the paranoid.
fc63d04f 69 */
4dc0ec22 70 int (*verify) (struct labeller * l, void *buf, uint64_t sector);
fc63d04f
JT
71
72 /*
5a52dca9 73 * Populate label_type etc.
fc63d04f 74 */
5a52dca9 75 int (*initialise_label) (struct labeller * l, struct label * label);
fc63d04f 76
6036e5e0
JT
77 /*
78 * Destroy a previously read label.
79 */
5a52dca9 80 void (*destroy_label) (struct labeller * l, struct label * label);
6036e5e0 81
fc63d04f
JT
82 /*
83 * Destructor.
84 */
5a52dca9 85 void (*destroy) (struct labeller * l);
fc63d04f
JT
86};
87
88struct labeller {
89 struct label_ops *ops;
8ef2b021 90 const void *private;
f4a7ce7c 91};
3dd5cbe5 92
fc63d04f
JT
93int label_init(void);
94void label_exit(void);
95
96int label_register_handler(const char *name, struct labeller *handler);
97
98struct labeller *label_get_handler(const char *name);
99
493656dd 100int label_remove(struct device *dev);
17a6fc0b
DW
101int label_read(struct device *dev, struct label **result,
102 uint64_t scan_sector);
5a52dca9 103int label_write(struct device *dev, struct label *label);
493656dd 104int label_verify(struct device *dev);
5a52dca9
AK
105struct label *label_create(struct labeller *labeller);
106void label_destroy(struct label *label);
3dd5cbe5 107
fc63d04f 108#endif
This page took 0.095835 seconds and 5 git commands to generate.