Tizen 2.1 base
[external/device-mapper.git] / lib / format_text / import-export.h
1 /*
2  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.  
3  * Copyright (C) 2004-2006 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_TEXT_IMPORT_EXPORT_H
17 #define _LVM_TEXT_IMPORT_EXPORT_H
18
19 #include "config.h"
20 #include "lvm-types.h"
21 #include "metadata.h"
22
23 #include <stdio.h>
24
25 /*
26  * Constants to identify files this code can parse.
27  */
28 #define CONTENTS_FIELD "contents"
29 #define CONTENTS_VALUE "Text Format Volume Group"
30
31 #define FORMAT_VERSION_FIELD "version"
32 #define FORMAT_VERSION_VALUE 1
33
34 /*
35  * VGs, PVs and LVs all have status bitsets, we gather together
36  * common code for reading and writing them.
37  */
38 enum {
39         COMPATIBLE_FLAG = 0x0,
40         VG_FLAGS,
41         PV_FLAGS,
42         LV_FLAGS,
43         STATUS_FLAG = 0x8,
44 };
45
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);
57 };
58
59 struct text_vg_version_ops *text_vg_vsn1_init(void);
60
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);
63
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);
66
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,
70                                          const char *file,
71                                          time_t *when, char **desc);
72 struct volume_group *text_vg_import_fd(struct format_instance *fid,
73                                        const char *file,
74                                        struct device *dev,
75                                        off_t offset, uint32_t size,
76                                        off_t offset2, uint32_t size2,
77                                        checksum_fn_t checksum_fn,
78                                        uint32_t checksum,
79                                        time_t *when, char **desc);
80 const char *text_vgname_import(const struct format_type *fmt,
81                                struct device *dev,
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);
87
88 #endif