4 * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
5 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
7 * This file is part of LVM2.
9 * This copyrighted material is made available to anyone wishing to use,
10 * modify, copy, or redistribute it subject to the terms and conditions
11 * of the GNU Lesser General Public License v.2.1.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #define LABEL_ID "LABELONE"
25 #define LABEL_SIZE SECTOR_SIZE /* Think very carefully before changing this */
26 #define LABEL_SCAN_SECTORS 4L
27 #define LABEL_SCAN_SIZE (LABEL_SCAN_SECTORS << SECTOR_SHIFT)
31 /* On disk - 32 bytes */
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
));
44 struct labeller
*labeller
;
52 * Is the device labelled with this format ?
54 int (*can_handle
) (struct labeller
* l
, void *buf
, uint64_t sector
);
57 * Write a label to a volume.
59 int (*write
) (struct label
* label
, void *buf
);
62 * Read a label from a volume.
64 int (*read
) (struct labeller
* l
, struct device
* dev
,
65 void *buf
, struct label
** label
);
68 * Additional consistency checks for the paranoid.
70 int (*verify
) (struct labeller
* l
, void *buf
, uint64_t sector
);
73 * Populate label_type etc.
75 int (*initialise_label
) (struct labeller
* l
, struct label
* label
);
78 * Destroy a previously read label.
80 void (*destroy_label
) (struct labeller
* l
, struct label
* label
);
85 void (*destroy
) (struct labeller
* l
);
89 struct label_ops
*ops
;
94 void label_exit(void);
96 int label_register_handler(const char *name
, struct labeller
*handler
);
98 struct labeller
*label_get_handler(const char *name
);
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
);