2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
5 * This file is part of LVM2.
7 * This copyrighted material is made available to anyone wishing to use,
8 * modify, copy, or redistribute it subject to the terms and conditions
9 * of the GNU Lesser General Public License v.2.1.
11 * You should have received a copy of the GNU Lesser General Public License
12 * along with this program; if not, write to the Free Software Foundation,
13 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #ifndef _LVM_TOOLLIB_H
17 #define _LVM_TOOLLIB_H
19 #include "metadata-exported.h"
21 int autobackup_set(void);
22 int autobackup_init(const char *backup_dir, int keep_days, int keep_number,
24 int autobackup(struct volume_group *vg);
26 struct volume_group *recover_vg(struct cmd_context *cmd, const char *vgname,
29 typedef int (*process_single_vg_fn_t) (struct cmd_context * cmd,
31 struct volume_group * vg,
33 typedef int (*process_single_pv_fn_t) (struct cmd_context *cmd,
34 struct volume_group *vg,
35 struct physical_volume *pv,
37 typedef int (*process_single_lv_fn_t) (struct cmd_context *cmd,
38 struct logical_volume *lv,
40 typedef int (*process_single_seg_fn_t) (struct cmd_context * cmd,
41 struct lv_segment * seg,
43 typedef int (*process_single_pvseg_fn_t) (struct cmd_context * cmd,
44 struct volume_group * vg,
45 struct pv_segment * pvseg,
48 int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
49 uint32_t flags, void *handle,
50 process_single_vg_fn_t process_single_vg);
52 int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
53 struct volume_group *vg, uint32_t lock_type,
54 int scan_label_only, void *handle,
55 process_single_pv_fn_t process_single_pv);
57 int process_each_segment_in_pv(struct cmd_context *cmd,
58 struct volume_group *vg,
59 struct physical_volume *pv,
61 process_single_pvseg_fn_t process_single_pvseg);
63 int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
64 uint32_t flags, void *handle,
65 process_single_lv_fn_t process_single_lv);
68 int process_each_segment_in_lv(struct cmd_context *cmd,
69 struct logical_volume *lv, void *handle,
70 process_single_seg_fn_t process_single_seg);
72 int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
73 const struct dm_list *tags, void *handle,
74 process_single_pv_fn_t process_single_pv);
77 int process_each_lv_in_vg(struct cmd_context *cmd,
78 struct volume_group *vg,
79 const struct dm_list *arg_lvnames,
80 const struct dm_list *tags,
81 struct dm_list *failed_lvnames,
83 process_single_lv_fn_t process_single_lv);
85 char *default_vgname(struct cmd_context *cmd);
86 const char *extract_vgname(struct cmd_context *cmd, const char *lv_name);
87 char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
88 unsigned *dev_dir_found);
91 * Builds a list of pv's from the names in argv. Used in
94 struct dm_list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int argc,
95 char **argv, int allocatable_only);
97 struct dm_list *clone_pv_list(struct dm_pool *mem, struct dm_list *pvs);
99 void vgcreate_params_set_defaults(struct vgcreate_params *vp_def,
100 struct volume_group *vg);
101 int vgcreate_params_set_from_args(struct cmd_context *cmd,
102 struct vgcreate_params *vp_new,
103 struct vgcreate_params *vp_def);
104 int lv_refresh(struct cmd_context *cmd, struct logical_volume *lv);
105 int vg_refresh_visible(struct cmd_context *cmd, struct volume_group *vg);
106 void lv_spawn_background_polling(struct cmd_context *cmd,
107 struct logical_volume *lv);
108 int pvcreate_params_validate(struct cmd_context *cmd,
109 int argc, char **argv,
110 struct pvcreate_params *pp);
112 int get_activation_monitoring_mode(struct cmd_context *cmd,
113 struct volume_group *vg,
114 int *monitoring_mode);
115 int get_stripe_params(struct cmd_context *cmd, uint32_t *stripes,
116 uint32_t *stripe_size);