2004-05-05 01:25:57 +04:00
/*
* Copyright ( C ) 2001 - 2004 Sistina Software , Inc . All rights reserved .
2007-08-21 00:55:30 +04:00
* Copyright ( C ) 2004 - 2007 Red Hat , Inc . All rights reserved .
2004-05-05 01:25:57 +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-05-05 01:25:57 +04:00
*
2007-08-21 00:55:30 +04:00
* You should have received a copy of the GNU Lesser General Public License
2004-05-05 01:25:57 +04:00
* along with this program ; if not , write to the Free Software Foundation ,
* Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
*/
# ifndef _SEGTYPES_H
# define _SEGTYPES_H
2009-10-01 04:35:29 +04:00
# include "metadata-exported.h"
2004-05-05 01:25:57 +04:00
struct segtype_handler ;
struct cmd_context ;
struct config_tree ;
struct lv_segment ;
struct formatter ;
struct config_node ;
struct dev_manager ;
/* Feature flags */
2006-05-10 01:23:51 +04:00
# define SEG_CAN_SPLIT 0x00000001U
# define SEG_AREAS_STRIPED 0x00000002U
# define SEG_AREAS_MIRRORED 0x00000004U
# define SEG_SNAPSHOT 0x00000008U
# define SEG_FORMAT1_SUPPORT 0x00000010U
# define SEG_VIRTUAL 0x00000020U
# define SEG_CANNOT_BE_ZEROED 0x00000040U
2007-01-12 23:38:30 +03:00
# define SEG_MONITORED 0x00000080U
2009-10-16 21:41:49 +04:00
# define SEG_UNKNOWN 0x80000000U
2004-05-05 01:25:57 +04:00
2005-05-09 20:59:01 +04:00
# define seg_is_mirrored(seg) ((seg)->segtype->flags & SEG_AREAS_MIRRORED ? 1 : 0)
# define seg_is_striped(seg) ((seg)->segtype->flags & SEG_AREAS_STRIPED ? 1 : 0)
# define seg_is_snapshot(seg) ((seg)->segtype->flags & SEG_SNAPSHOT ? 1 : 0)
# define seg_is_virtual(seg) ((seg)->segtype->flags & SEG_VIRTUAL ? 1 : 0)
# define seg_can_split(seg) ((seg)->segtype->flags & SEG_CAN_SPLIT ? 1 : 0)
2005-11-09 01:52:26 +03:00
# define seg_cannot_be_zeroed(seg) ((seg)->segtype->flags & SEG_CANNOT_BE_ZEROED ? 1 : 0)
2007-01-12 23:38:30 +03:00
# define seg_monitored(seg) ((seg)->segtype->flags & SEG_MONITORED ? 1 : 0)
2009-10-16 21:41:49 +04:00
# define seg_unknown(seg) ((seg)->segtype->flags & SEG_UNKNOWN ? 1 : 0)
2005-05-09 20:59:01 +04:00
2005-06-01 20:51:55 +04:00
# define segtype_is_striped(segtype) ((segtype)->flags & SEG_AREAS_STRIPED ? 1 : 0)
# define segtype_is_mirrored(segtype) ((segtype)->flags & SEG_AREAS_MIRRORED ? 1 : 0)
# define segtype_is_virtual(segtype) ((segtype)->flags & SEG_VIRTUAL ? 1 : 0)
2004-05-05 01:25:57 +04:00
struct segment_type {
2009-07-08 16:36:01 +04:00
struct dm_list list ; /* Internal */
struct cmd_context * cmd ; /* lvm_register_segtype() sets this. */
2004-05-05 01:25:57 +04:00
uint32_t flags ;
struct segtype_handler * ops ;
const char * name ;
2009-07-08 16:36:01 +04:00
void * library ; /* lvm_register_segtype() sets this. */
void * private ; /* For the segtype handler to use. */
2004-05-05 01:25:57 +04:00
} ;
struct segtype_handler {
const char * ( * name ) ( const struct lv_segment * seg ) ;
void ( * display ) ( const struct lv_segment * seg ) ;
int ( * text_export ) ( const struct lv_segment * seg ,
struct formatter * f ) ;
int ( * text_import_area_count ) ( struct config_node * sn ,
uint32_t * area_count ) ;
int ( * text_import ) ( struct lv_segment * seg ,
const struct config_node * sn ,
2005-10-17 03:03:59 +04:00
struct dm_hash_table * pv_hash ) ;
2004-05-05 01:25:57 +04:00
int ( * merge_segments ) ( struct lv_segment * seg1 ,
struct lv_segment * seg2 ) ;
2005-11-09 01:52:26 +03:00
int ( * add_target_line ) ( struct dev_manager * dm , struct dm_pool * mem ,
2006-05-16 20:48:31 +04:00
struct cmd_context * cmd , void * * target_state ,
2005-11-09 01:52:26 +03:00
struct lv_segment * seg ,
2005-11-09 16:08:41 +03:00
struct dm_tree_node * node , uint64_t len ,
2005-11-09 01:52:26 +03:00
uint32_t * pvmove_mirror_count ) ;
2009-10-01 04:35:29 +04:00
int ( * target_percent ) ( void * * target_state ,
percent_range_t * percent_range ,
struct dm_pool * mem ,
2006-05-17 00:53:13 +04:00
struct cmd_context * cmd ,
2006-05-16 20:48:31 +04:00
struct lv_segment * seg , char * params ,
2004-05-05 01:25:57 +04:00
uint64_t * total_numerator ,
2008-07-15 04:25:52 +04:00
uint64_t * total_denominator ) ;
2009-02-28 23:04:24 +03:00
int ( * target_present ) ( struct cmd_context * cmd ,
const struct lv_segment * seg ,
2008-04-07 14:23:47 +04:00
unsigned * attributes ) ;
2006-10-03 21:55:20 +04:00
int ( * modules_needed ) ( struct dm_pool * mem ,
const struct lv_segment * seg ,
2008-11-04 01:14:30 +03:00
struct dm_list * modules ) ;
2004-05-05 01:25:57 +04:00
void ( * destroy ) ( const struct segment_type * segtype ) ;
2007-01-20 01:21:45 +03:00
int ( * target_monitored ) ( struct lv_segment * seg , int * pending ) ;
2007-01-24 19:51:24 +03:00
int ( * target_monitor_events ) ( struct lv_segment * seg , int events ) ;
int ( * target_unmonitor_events ) ( struct lv_segment * seg , int events ) ;
2004-05-05 01:25:57 +04:00
} ;
struct segment_type * get_segtype_from_string ( struct cmd_context * cmd ,
const char * str ) ;
2009-07-08 16:36:01 +04:00
struct segtype_library ;
int lvm_register_segtype ( struct segtype_library * seglib ,
struct segment_type * segtype ) ;
2004-05-05 01:25:57 +04:00
struct segment_type * init_striped_segtype ( struct cmd_context * cmd ) ;
2004-05-11 20:01:58 +04:00
struct segment_type * init_zero_segtype ( struct cmd_context * cmd ) ;
struct segment_type * init_error_segtype ( struct cmd_context * cmd ) ;
2008-06-25 20:52:27 +04:00
struct segment_type * init_free_segtype ( struct cmd_context * cmd ) ;
2009-10-16 21:41:49 +04:00
struct segment_type * init_unknown_segtype ( struct cmd_context * cmd , const char * name ) ;
2004-05-05 01:25:57 +04:00
# ifdef SNAPSHOT_INTERNAL
struct segment_type * init_snapshot_segtype ( struct cmd_context * cmd ) ;
# endif
# ifdef MIRRORED_INTERNAL
struct segment_type * init_mirrored_segtype ( struct cmd_context * cmd ) ;
# endif
2004-09-16 22:40:56 +04:00
# ifdef CRYPT_INTERNAL
struct segment_type * init_crypt_segtype ( struct cmd_context * cmd ) ;
# endif
2004-05-05 01:25:57 +04:00
# endif