xref: /dragonfly/contrib/lvm2/dist/tools/toollib.h (revision 3170ffd7)
1 /*	$NetBSD: toollib.h,v 1.1.1.3 2009/12/02 00:25:56 haad Exp $	*/
2 
3 /*
4  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
5  * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
6  *
7  * This file is part of LVM2.
8  *
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.
12  *
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
16  */
17 
18 #ifndef _LVM_TOOLLIB_H
19 #define _LVM_TOOLLIB_H
20 
21 #include "metadata-exported.h"
22 
23 int autobackup_set(void);
24 int autobackup_init(const char *backup_dir, int keep_days, int keep_number,
25 		    int autobackup);
26 int autobackup(struct volume_group *vg);
27 
28 struct volume_group *recover_vg(struct cmd_context *cmd, const char *vgname,
29 				uint32_t lock_type);
30 
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,
34 					   const char *vg_name,
35 					   struct volume_group * vg,
36 					   void *handle));
37 
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,
44 					   void *handle));
45 
46 int process_each_segment_in_pv(struct cmd_context *cmd,
47 			       struct volume_group *vg,
48 			       struct physical_volume *pv,
49 			       void *handle,
50 			       int (*process_single) (struct cmd_context * cmd,
51 						      struct volume_group * vg,
52 						      struct pv_segment * pvseg,
53 						      void *handle));
54 
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,
59 					   void *handle));
60 
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,
65 						      void *handle));
66 
67 typedef int (*process_single_pv_fn_t) (struct cmd_context *cmd,
68 				  struct volume_group *vg,
69 				  struct physical_volume *pv,
70 				  void *handle);
71 
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);
75 
76 typedef int (*process_single_lv_fn_t) (struct cmd_context *cmd,
77 				  struct logical_volume *lv,
78 				  void *handle);
79 
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,
84 			  void *handle,
85 			  process_single_lv_fn_t process_single);
86 
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);
91 
92 /*
93  * Builds a list of pv's from the names in argv.  Used in
94  * lvcreate/extend.
95  */
96 struct dm_list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int argc,
97 			    char **argv, int allocatable_only);
98 
99 struct dm_list *clone_pv_list(struct dm_pool *mem, struct dm_list *pvs);
100 
101 int apply_lvname_restrictions(const char *name);
102 int is_reserved_lvname(const char *name);
103 
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);
116 
117 #endif
118