1 /* $NetBSD: segtype.h,v 1.1.1.2 2009/12/02 00:26:34 haad Exp $ */
4 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
5 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
7 * This file is part of LVM2.
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.
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
21 #include "metadata-exported.h"
23 struct segtype_handler;
32 #define SEG_CAN_SPLIT 0x00000001U
33 #define SEG_AREAS_STRIPED 0x00000002U
34 #define SEG_AREAS_MIRRORED 0x00000004U
35 #define SEG_SNAPSHOT 0x00000008U
36 #define SEG_FORMAT1_SUPPORT 0x00000010U
37 #define SEG_VIRTUAL 0x00000020U
38 #define SEG_CANNOT_BE_ZEROED 0x00000040U
39 #define SEG_MONITORED 0x00000080U
40 #define SEG_UNKNOWN 0x80000000U
42 #define seg_is_mirrored(seg) ((seg)->segtype->flags & SEG_AREAS_MIRRORED ? 1 : 0)
43 #define seg_is_striped(seg) ((seg)->segtype->flags & SEG_AREAS_STRIPED ? 1 : 0)
44 #define seg_is_snapshot(seg) ((seg)->segtype->flags & SEG_SNAPSHOT ? 1 : 0)
45 #define seg_is_virtual(seg) ((seg)->segtype->flags & SEG_VIRTUAL ? 1 : 0)
46 #define seg_can_split(seg) ((seg)->segtype->flags & SEG_CAN_SPLIT ? 1 : 0)
47 #define seg_cannot_be_zeroed(seg) ((seg)->segtype->flags & SEG_CANNOT_BE_ZEROED ? 1 : 0)
48 #define seg_monitored(seg) ((seg)->segtype->flags & SEG_MONITORED ? 1 : 0)
49 #define seg_unknown(seg) ((seg)->segtype->flags & SEG_UNKNOWN ? 1 : 0)
51 #define segtype_is_striped(segtype) ((segtype)->flags & SEG_AREAS_STRIPED ? 1 : 0)
52 #define segtype_is_mirrored(segtype) ((segtype)->flags & SEG_AREAS_MIRRORED ? 1 : 0)
53 #define segtype_is_virtual(segtype) ((segtype)->flags & SEG_VIRTUAL ? 1 : 0)
56 struct dm_list list; /* Internal */
57 struct cmd_context *cmd; /* lvm_register_segtype() sets this. */
59 struct segtype_handler *ops;
61 void *library; /* lvm_register_segtype() sets this. */
62 void *private; /* For the segtype handler to use. */
65 struct segtype_handler {
66 const char *(*name) (const struct lv_segment * seg);
67 void (*display) (const struct lv_segment * seg);
68 int (*text_export) (const struct lv_segment * seg,
69 struct formatter * f);
70 int (*text_import_area_count) (struct config_node * sn,
71 uint32_t *area_count);
72 int (*text_import) (struct lv_segment * seg,
73 const struct config_node * sn,
74 struct dm_hash_table * pv_hash);
75 int (*merge_segments) (struct lv_segment * seg1,
76 struct lv_segment * seg2);
77 int (*add_target_line) (struct dev_manager *dm, struct dm_pool *mem,
78 struct cmd_context *cmd, void **target_state,
79 struct lv_segment *seg,
80 struct dm_tree_node *node, uint64_t len,
81 uint32_t *pvmove_mirror_count);
82 int (*target_percent) (void **target_state,
83 percent_range_t *percent_range,
85 struct cmd_context *cmd,
86 struct lv_segment *seg, char *params,
87 uint64_t *total_numerator,
88 uint64_t *total_denominator);
89 int (*target_present) (struct cmd_context *cmd,
90 const struct lv_segment *seg,
91 unsigned *attributes);
92 int (*modules_needed) (struct dm_pool *mem,
93 const struct lv_segment *seg,
94 struct dm_list *modules);
95 void (*destroy) (const struct segment_type * segtype);
96 int (*target_monitored) (struct lv_segment *seg, int *pending);
97 int (*target_monitor_events) (struct lv_segment *seg, int events);
98 int (*target_unmonitor_events) (struct lv_segment *seg, int events);
101 struct segment_type *get_segtype_from_string(struct cmd_context *cmd,
104 struct segtype_library;
105 int lvm_register_segtype(struct segtype_library *seglib,
106 struct segment_type *segtype);
108 struct segment_type *init_striped_segtype(struct cmd_context *cmd);
109 struct segment_type *init_zero_segtype(struct cmd_context *cmd);
110 struct segment_type *init_error_segtype(struct cmd_context *cmd);
111 struct segment_type *init_free_segtype(struct cmd_context *cmd);
112 struct segment_type *init_unknown_segtype(struct cmd_context *cmd, const char *name);
114 #ifdef SNAPSHOT_INTERNAL
115 struct segment_type *init_snapshot_segtype(struct cmd_context *cmd);
118 #ifdef MIRRORED_INTERNAL
119 struct segment_type *init_mirrored_segtype(struct cmd_context *cmd);
122 #ifdef CRYPT_INTERNAL
123 struct segment_type *init_crypt_segtype(struct cmd_context *cmd);