1/* $NetBSD$ */ 2 3/* 4 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. 5 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. 6 * 7 * This file is part of LVM2. 8 * 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. 12 * 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 16 */ 17 18#ifndef _LVM_TEXT_IMPORT_EXPORT_H 19#define _LVM_TEXT_IMPORT_EXPORT_H 20 21#include "config.h" 22#include "lvm-types.h" 23#include "metadata.h" 24 25#include <stdio.h> 26 27/* 28 * Constants to identify files this code can parse. 29 */ 30#define CONTENTS_FIELD "contents" 31#define CONTENTS_VALUE "Text Format Volume Group" 32 33#define FORMAT_VERSION_FIELD "version" 34#define FORMAT_VERSION_VALUE 1 35 36/* 37 * VGs, PVs and LVs all have status bitsets, we gather together 38 * common code for reading and writing them. 39 */ 40enum { 41 COMPATIBLE_FLAG = 0x0, 42 VG_FLAGS, 43 PV_FLAGS, 44 LV_FLAGS, 45 STATUS_FLAG = 0x8, 46}; 47 48struct text_vg_version_ops { 49 int (*check_version) (struct config_tree * cf); 50 struct volume_group *(*read_vg) (struct format_instance * fid, 51 struct config_tree * cf); 52 void (*read_desc) (struct dm_pool * mem, struct config_tree * cf, 53 time_t *when, char **desc); 54 const char *(*read_vgname) (const struct format_type *fmt, 55 struct config_tree *cft, 56 struct id *vgid, uint32_t *vgstatus, 57 char **creation_host); 58}; 59 60struct text_vg_version_ops *text_vg_vsn1_init(void); 61 62int print_flags(uint32_t status, int type, char *buffer, size_t size); 63int read_flags(uint32_t *status, int type, struct config_value *cv); 64 65int print_tags(struct dm_list *tags, char *buffer, size_t size); 66int read_tags(struct dm_pool *mem, struct dm_list *tags, struct config_value *cv); 67 68int text_vg_export_file(struct volume_group *vg, const char *desc, FILE *fp); 69int text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf); 70struct volume_group *text_vg_import_file(struct format_instance *fid, 71 const char *file, 72 time_t *when, char **desc); 73struct volume_group *text_vg_import_fd(struct format_instance *fid, 74 const char *file, 75 struct device *dev, 76 off_t offset, uint32_t size, 77 off_t offset2, uint32_t size2, 78 checksum_fn_t checksum_fn, 79 uint32_t checksum, 80 time_t *when, char **desc); 81const char *text_vgname_import(const struct format_type *fmt, 82 struct device *dev, 83 off_t offset, uint32_t size, 84 off_t offset2, uint32_t size2, 85 checksum_fn_t checksum_fn, uint32_t checksum, 86 struct id *vgid, uint32_t *vgstatus, 87 char **creation_host); 88 89#endif 90