4 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
5 * Copyright (C) 2004-2009 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
18 #ifndef _LVM_TOOLLIB_H
19 #define _LVM_TOOLLIB_H
21 #include "metadata-exported.h"
23 int autobackup_set(void);
24 int autobackup_init(const char *backup_dir
, int keep_days
, int keep_number
,
26 int autobackup(struct volume_group
*vg
);
28 struct volume_group
*recover_vg(struct cmd_context
*cmd
, const char *vgname
,
31 int process_each_vg(struct cmd_context
*cmd
, int argc
, char **argv
,
32 uint32_t flags
, void *handle
,
33 int (*process_single
) (struct cmd_context
* cmd
,
35 struct volume_group
* vg
,
38 int process_each_pv(struct cmd_context
*cmd
, int argc
, char **argv
,
39 struct volume_group
*vg
, uint32_t lock_type
,
40 int scan_label_only
, void *handle
,
41 int (*process_single
) (struct cmd_context
* cmd
,
42 struct volume_group
* vg
,
43 struct physical_volume
* pv
,
46 int process_each_segment_in_pv(struct cmd_context
*cmd
,
47 struct volume_group
*vg
,
48 struct physical_volume
*pv
,
50 int (*process_single
) (struct cmd_context
* cmd
,
51 struct volume_group
* vg
,
52 struct pv_segment
* pvseg
,
55 int process_each_lv(struct cmd_context
*cmd
, int argc
, char **argv
,
56 uint32_t flags
, void *handle
,
57 int (*process_single
) (struct cmd_context
* cmd
,
58 struct logical_volume
* lv
,
61 int process_each_segment_in_lv(struct cmd_context
*cmd
,
62 struct logical_volume
*lv
, void *handle
,
63 int (*process_single
) (struct cmd_context
* cmd
,
64 struct lv_segment
* seg
,
67 typedef int (*process_single_pv_fn_t
) (struct cmd_context
*cmd
,
68 struct volume_group
*vg
,
69 struct physical_volume
*pv
,
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
);
76 typedef int (*process_single_lv_fn_t
) (struct cmd_context
*cmd
,
77 struct logical_volume
*lv
,
80 int process_each_lv_in_vg(struct cmd_context
*cmd
,
81 const struct volume_group
*vg
,
82 const struct dm_list
*arg_lvnames
,
83 const struct dm_list
*tags
,
85 process_single_lv_fn_t process_single
);
87 char *default_vgname(struct cmd_context
*cmd
);
88 const char *extract_vgname(struct cmd_context
*cmd
, const char *lv_name
);
89 char *skip_dev_dir(struct cmd_context
*cmd
, const char *vg_name
,
90 unsigned *dev_dir_found
);
93 * Builds a list of pv's from the names in argv. Used in
96 struct dm_list
*create_pv_list(struct dm_pool
*mem
, struct volume_group
*vg
, int argc
,
97 char **argv
, int allocatable_only
);
99 struct dm_list
*clone_pv_list(struct dm_pool
*mem
, struct dm_list
*pvs
);
101 int apply_lvname_restrictions(const char *name
);
102 int is_reserved_lvname(const char *name
);
104 void vgcreate_params_set_defaults(struct vgcreate_params
*vp_def
,
105 struct volume_group
*vg
);
106 int vgcreate_params_set_from_args(struct cmd_context
*cmd
,
107 struct vgcreate_params
*vp_new
,
108 struct vgcreate_params
*vp_def
);
109 int lv_refresh(struct cmd_context
*cmd
, struct logical_volume
*lv
);
110 int vg_refresh_visible(struct cmd_context
*cmd
, struct volume_group
*vg
);
111 void lv_spawn_background_polling(struct cmd_context
*cmd
,
112 struct logical_volume
*lv
);
113 int pvcreate_params_validate(struct cmd_context
*cmd
,
114 int argc
, char **argv
,
115 struct pvcreate_params
*pp
);