2 * Copyright (C) 2001-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
16 #ifndef _LVM_TEXT_IMPORT_EXPORT_H
17 #define _LVM_TEXT_IMPORT_EXPORT_H
20 #include "lvm-types.h"
26 * Constants to identify files this code can parse.
28 #define CONTENTS_FIELD "contents"
29 #define CONTENTS_VALUE "Text Format Volume Group"
31 #define FORMAT_VERSION_FIELD "version"
32 #define FORMAT_VERSION_VALUE 1
35 * VGs, PVs and LVs all have status bitsets, we gather together
36 * common code for reading and writing them.
39 COMPATIBLE_FLAG = 0x0,
46 struct text_vg_version_ops {
47 int (*check_version) (const struct config_tree * cf);
48 struct volume_group *(*read_vg) (struct format_instance * fid,
49 const struct config_tree *cf,
50 unsigned use_cached_pvs);
51 void (*read_desc) (struct dm_pool * mem, const struct config_tree *cf,
52 time_t *when, char **desc);
53 const char *(*read_vgname) (const struct format_type *fmt,
54 const struct config_tree *cft,
55 struct id *vgid, uint64_t *vgstatus,
56 char **creation_host);
59 struct text_vg_version_ops *text_vg_vsn1_init(void);
61 int print_flags(uint64_t status, int type, char *buffer, size_t size);
62 int read_flags(uint64_t *status, int type, const struct config_value *cv);
64 char *alloc_printed_tags(struct dm_list *tags);
65 int read_tags(struct dm_pool *mem, struct dm_list *tags, const struct config_value *cv);
67 int text_vg_export_file(struct volume_group *vg, const char *desc, FILE *fp);
68 int text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf);
69 struct volume_group *text_vg_import_file(struct format_instance *fid,
71 time_t *when, char **desc);
72 struct volume_group *text_vg_import_fd(struct format_instance *fid,
75 off_t offset, uint32_t size,
76 off_t offset2, uint32_t size2,
77 checksum_fn_t checksum_fn,
79 time_t *when, char **desc);
80 const char *text_vgname_import(const struct format_type *fmt,
82 off_t offset, uint32_t size,
83 off_t offset2, uint32_t size2,
84 checksum_fn_t checksum_fn, uint32_t checksum,
85 struct id *vgid, uint64_t *vgstatus,
86 char **creation_host);