2001-11-21 12:20:05 +03:00
/*
2004-03-30 23:35:44 +04:00
* Copyright ( C ) 2001 - 2004 Sistina Software , Inc . All rights reserved .
2007-08-21 00:55:30 +04:00
* Copyright ( C ) 2004 - 2006 Red Hat , Inc . All rights reserved .
2001-11-21 12:20:05 +03:00
*
2004-03-30 23:35:44 +04:00
* This file is part of LVM2 .
*
* This copyrighted material is made available to anyone wishing to use ,
* modify , copy , or redistribute it subject to the terms and conditions
2007-08-21 00:55:30 +04:00
* of the GNU Lesser General Public License v .2 .1 .
2004-03-30 23:35:44 +04:00
*
2007-08-21 00:55:30 +04:00
* You should have received a copy of the GNU Lesser General Public License
2004-03-30 23:35:44 +04:00
* along with this program ; if not , write to the Free Software Foundation ,
2016-01-21 13:49:46 +03:00
* Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA
2001-11-21 12:20:05 +03:00
*/
# ifndef _LVM_TEXT_IMPORT_EXPORT_H
# define _LVM_TEXT_IMPORT_EXPORT_H
2018-05-14 12:30:20 +03:00
# include "lib/config/config.h"
# include "lib/metadata/metadata.h"
# include "lib/cache/lvmcache.h"
2001-12-20 14:52:54 +03:00
# include <stdio.h>
2001-12-11 15:16:58 +03:00
2002-07-02 22:47:43 +04:00
/*
2002-07-11 18:09:26 +04:00
* Constants to identify files this code can parse .
2002-07-02 22:47:43 +04:00
*/
# define CONTENTS_FIELD "contents"
# define CONTENTS_VALUE "Text Format Volume Group"
# define FORMAT_VERSION_FIELD "version"
# define FORMAT_VERSION_VALUE 1
/*
* VGs , PVs and LVs all have status bitsets , we gather together
* common code for reading and writing them .
*/
2017-05-26 16:47:17 +03:00
enum pv_vg_lv_e {
PV_FLAGS = 1 ,
2001-12-11 15:16:58 +03:00
VG_FLAGS ,
2008-07-10 15:30:57 +04:00
LV_FLAGS ,
2001-12-11 15:16:58 +03:00
} ;
2017-05-26 16:47:17 +03:00
# define COMPATIBLE_FLAG 0x01
# define STATUS_FLAG 0x02
2017-05-29 15:20:38 +03:00
# define SEGTYPE_FLAG 0x04
2017-05-26 16:47:17 +03:00
2002-11-18 17:04:08 +03:00
struct text_vg_version_ops {
2011-08-30 18:55:15 +04:00
int ( * check_version ) ( const struct dm_config_tree * cf ) ;
2019-10-29 22:31:37 +03:00
struct volume_group * ( * read_vg ) ( struct cmd_context * cmd ,
const struct format_type * fmt ,
struct format_instance * fid ,
const struct dm_config_tree * cft ) ;
2011-08-30 18:55:15 +04:00
void ( * read_desc ) ( struct dm_pool * mem , const struct dm_config_tree * cf ,
2002-11-18 17:04:08 +03:00
time_t * when , char * * desc ) ;
2019-10-29 22:31:37 +03:00
2016-02-09 22:32:26 +03:00
int ( * read_vgsummary ) ( const struct format_type * fmt ,
const struct dm_config_tree * cft ,
struct lvmcache_vgsummary * vgsummary ) ;
2002-11-18 17:04:08 +03:00
} ;
2024-05-03 15:43:22 +03:00
const struct text_vg_version_ops * text_vg_vsn1_init ( void ) ;
2002-11-18 17:04:08 +03:00
2017-05-26 16:47:17 +03:00
int print_flags ( char * buffer , size_t size , enum pv_vg_lv_e type , int mask , uint64_t status ) ;
int read_flags ( uint64_t * status , enum pv_vg_lv_e type , int mask , const struct dm_config_value * cv ) ;
2001-12-11 15:16:58 +03:00
2017-05-29 15:20:05 +03:00
int print_segtype_lvflags ( char * buffer , size_t size , uint64_t status ) ;
2017-07-20 20:13:32 +03:00
int read_segtype_lvflags ( uint64_t * status , char * segtype_str ) ;
2017-05-29 15:20:05 +03:00
2002-11-18 17:04:08 +03:00
int text_vg_export_file ( struct volume_group * vg , const char * desc , FILE * fp ) ;
2019-07-01 23:00:34 +03:00
size_t text_vg_export_raw ( struct volume_group * vg , const char * desc , char * * buf , uint32_t * alloc_size ) ;
2018-02-07 00:18:11 +03:00
struct volume_group * text_read_metadata_file ( struct format_instance * fid ,
2002-11-18 17:04:08 +03:00
const char * file ,
time_t * when , char * * desc ) ;
2018-02-07 00:18:11 +03:00
struct volume_group * text_read_metadata ( struct format_instance * fid ,
2002-11-18 17:04:08 +03:00
const char * file ,
2015-03-19 02:43:02 +03:00
struct cached_vg_fmtdata * * vg_fmtdata ,
unsigned * use_previous_vg ,
2017-12-07 06:34:59 +03:00
struct device * dev , int primary_mda ,
2002-11-18 17:04:08 +03:00
off_t offset , uint32_t size ,
off_t offset2 , uint32_t size2 ,
checksum_fn_t checksum_fn ,
2018-04-20 18:43:50 +03:00
uint32_t checksum ,
2002-11-18 17:04:08 +03:00
time_t * when , char * * desc ) ;
2015-03-19 02:43:02 +03:00
2018-02-07 00:18:11 +03:00
int text_read_metadata_summary ( const struct format_type * fmt ,
2017-12-07 06:34:59 +03:00
struct device * dev , dev_io_reason_t reason ,
2015-03-19 02:43:02 +03:00
off_t offset , uint32_t size ,
off_t offset2 , uint32_t size2 ,
checksum_fn_t checksum_fn ,
2018-04-20 18:43:50 +03:00
int checksum_only ,
struct lvmcache_vgsummary * vgsummary ) ;
2001-11-21 12:20:05 +03:00
# endif