186d7f5d3SJohn Marino /* $NetBSD: import-export.h,v 1.1.1.1 2008/12/22 00:18:16 haad Exp $ */ 286d7f5d3SJohn Marino 386d7f5d3SJohn Marino /* 486d7f5d3SJohn Marino * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. 586d7f5d3SJohn Marino * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. 686d7f5d3SJohn Marino * 786d7f5d3SJohn Marino * This file is part of LVM2. 886d7f5d3SJohn Marino * 986d7f5d3SJohn Marino * This copyrighted material is made available to anyone wishing to use, 1086d7f5d3SJohn Marino * modify, copy, or redistribute it subject to the terms and conditions 1186d7f5d3SJohn Marino * of the GNU Lesser General Public License v.2.1. 1286d7f5d3SJohn Marino * 1386d7f5d3SJohn Marino * You should have received a copy of the GNU Lesser General Public License 1486d7f5d3SJohn Marino * along with this program; if not, write to the Free Software Foundation, 1586d7f5d3SJohn Marino * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 1686d7f5d3SJohn Marino */ 1786d7f5d3SJohn Marino 1886d7f5d3SJohn Marino #ifndef _LVM_TEXT_IMPORT_EXPORT_H 1986d7f5d3SJohn Marino #define _LVM_TEXT_IMPORT_EXPORT_H 2086d7f5d3SJohn Marino 2186d7f5d3SJohn Marino #include "config.h" 2286d7f5d3SJohn Marino #include "lvm-types.h" 2386d7f5d3SJohn Marino #include "metadata.h" 2486d7f5d3SJohn Marino 2586d7f5d3SJohn Marino #include <stdio.h> 2686d7f5d3SJohn Marino 2786d7f5d3SJohn Marino /* 2886d7f5d3SJohn Marino * Constants to identify files this code can parse. 2986d7f5d3SJohn Marino */ 3086d7f5d3SJohn Marino #define CONTENTS_FIELD "contents" 3186d7f5d3SJohn Marino #define CONTENTS_VALUE "Text Format Volume Group" 3286d7f5d3SJohn Marino 3386d7f5d3SJohn Marino #define FORMAT_VERSION_FIELD "version" 3486d7f5d3SJohn Marino #define FORMAT_VERSION_VALUE 1 3586d7f5d3SJohn Marino 3686d7f5d3SJohn Marino /* 3786d7f5d3SJohn Marino * VGs, PVs and LVs all have status bitsets, we gather together 3886d7f5d3SJohn Marino * common code for reading and writing them. 3986d7f5d3SJohn Marino */ 4086d7f5d3SJohn Marino enum { 4186d7f5d3SJohn Marino COMPATIBLE_FLAG = 0x0, 4286d7f5d3SJohn Marino VG_FLAGS, 4386d7f5d3SJohn Marino PV_FLAGS, 4486d7f5d3SJohn Marino LV_FLAGS, 4586d7f5d3SJohn Marino STATUS_FLAG = 0x8, 4686d7f5d3SJohn Marino }; 4786d7f5d3SJohn Marino 4886d7f5d3SJohn Marino struct text_vg_version_ops { 4986d7f5d3SJohn Marino int (*check_version) (struct config_tree * cf); 5086d7f5d3SJohn Marino struct volume_group *(*read_vg) (struct format_instance * fid, 5186d7f5d3SJohn Marino struct config_tree * cf); 5286d7f5d3SJohn Marino void (*read_desc) (struct dm_pool * mem, struct config_tree * cf, 5386d7f5d3SJohn Marino time_t *when, char **desc); 5486d7f5d3SJohn Marino const char *(*read_vgname) (const struct format_type *fmt, 5586d7f5d3SJohn Marino struct config_tree *cft, 5686d7f5d3SJohn Marino struct id *vgid, uint32_t *vgstatus, 5786d7f5d3SJohn Marino char **creation_host); 5886d7f5d3SJohn Marino }; 5986d7f5d3SJohn Marino 6086d7f5d3SJohn Marino struct text_vg_version_ops *text_vg_vsn1_init(void); 6186d7f5d3SJohn Marino 6286d7f5d3SJohn Marino int print_flags(uint32_t status, int type, char *buffer, size_t size); 6386d7f5d3SJohn Marino int read_flags(uint32_t *status, int type, struct config_value *cv); 6486d7f5d3SJohn Marino 6586d7f5d3SJohn Marino int print_tags(struct dm_list *tags, char *buffer, size_t size); 6686d7f5d3SJohn Marino int read_tags(struct dm_pool *mem, struct dm_list *tags, struct config_value *cv); 6786d7f5d3SJohn Marino 6886d7f5d3SJohn Marino int text_vg_export_file(struct volume_group *vg, const char *desc, FILE *fp); 6986d7f5d3SJohn Marino int text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf); 7086d7f5d3SJohn Marino struct volume_group *text_vg_import_file(struct format_instance *fid, 7186d7f5d3SJohn Marino const char *file, 7286d7f5d3SJohn Marino time_t *when, char **desc); 7386d7f5d3SJohn Marino struct volume_group *text_vg_import_fd(struct format_instance *fid, 7486d7f5d3SJohn Marino const char *file, 7586d7f5d3SJohn Marino struct device *dev, 7686d7f5d3SJohn Marino off_t offset, uint32_t size, 7786d7f5d3SJohn Marino off_t offset2, uint32_t size2, 7886d7f5d3SJohn Marino checksum_fn_t checksum_fn, 7986d7f5d3SJohn Marino uint32_t checksum, 8086d7f5d3SJohn Marino time_t *when, char **desc); 8186d7f5d3SJohn Marino const char *text_vgname_import(const struct format_type *fmt, 8286d7f5d3SJohn Marino struct device *dev, 8386d7f5d3SJohn Marino off_t offset, uint32_t size, 8486d7f5d3SJohn Marino off_t offset2, uint32_t size2, 8586d7f5d3SJohn Marino checksum_fn_t checksum_fn, uint32_t checksum, 8686d7f5d3SJohn Marino struct id *vgid, uint32_t *vgstatus, 8786d7f5d3SJohn Marino char **creation_host); 8886d7f5d3SJohn Marino 8986d7f5d3SJohn Marino #endif 90