xref: /dflybsd-src/contrib/lvm2/dist/tools/toollib.h (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino /*	$NetBSD: toollib.h,v 1.1.1.3 2009/12/02 00:25:56 haad Exp $	*/
286d7f5d3SJohn Marino 
386d7f5d3SJohn Marino /*
486d7f5d3SJohn Marino  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
586d7f5d3SJohn Marino  * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
686d7f5d3SJohn Marino  *
786d7f5d3SJohn Marino  * This file is part of LVM2.
886d7f5d3SJohn Marino  *
986d7f5d3SJohn Marino  * This copyrighted material is made available to anyone wishing to use,
1086d7f5d3SJohn Marino  * modify, copy, or redistribute it subject to the terms and conditions
1186d7f5d3SJohn Marino  * of the GNU Lesser General Public License v.2.1.
1286d7f5d3SJohn Marino  *
1386d7f5d3SJohn Marino  * You should have received a copy of the GNU Lesser General Public License
1486d7f5d3SJohn Marino  * along with this program; if not, write to the Free Software Foundation,
1586d7f5d3SJohn Marino  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1686d7f5d3SJohn Marino  */
1786d7f5d3SJohn Marino 
1886d7f5d3SJohn Marino #ifndef _LVM_TOOLLIB_H
1986d7f5d3SJohn Marino #define _LVM_TOOLLIB_H
2086d7f5d3SJohn Marino 
2186d7f5d3SJohn Marino #include "metadata-exported.h"
2286d7f5d3SJohn Marino 
2386d7f5d3SJohn Marino int autobackup_set(void);
2486d7f5d3SJohn Marino int autobackup_init(const char *backup_dir, int keep_days, int keep_number,
2586d7f5d3SJohn Marino 		    int autobackup);
2686d7f5d3SJohn Marino int autobackup(struct volume_group *vg);
2786d7f5d3SJohn Marino 
2886d7f5d3SJohn Marino struct volume_group *recover_vg(struct cmd_context *cmd, const char *vgname,
2986d7f5d3SJohn Marino 				uint32_t lock_type);
3086d7f5d3SJohn Marino 
3186d7f5d3SJohn Marino int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
3286d7f5d3SJohn Marino 		    uint32_t flags, void *handle,
3386d7f5d3SJohn Marino 		    int (*process_single) (struct cmd_context * cmd,
3486d7f5d3SJohn Marino 					   const char *vg_name,
3586d7f5d3SJohn Marino 					   struct volume_group * vg,
3686d7f5d3SJohn Marino 					   void *handle));
3786d7f5d3SJohn Marino 
3886d7f5d3SJohn Marino int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
3986d7f5d3SJohn Marino 		    struct volume_group *vg, uint32_t lock_type,
4086d7f5d3SJohn Marino 		    int scan_label_only, void *handle,
4186d7f5d3SJohn Marino 		    int (*process_single) (struct cmd_context * cmd,
4286d7f5d3SJohn Marino 					   struct volume_group * vg,
4386d7f5d3SJohn Marino 					   struct physical_volume * pv,
4486d7f5d3SJohn Marino 					   void *handle));
4586d7f5d3SJohn Marino 
4686d7f5d3SJohn Marino int process_each_segment_in_pv(struct cmd_context *cmd,
4786d7f5d3SJohn Marino 			       struct volume_group *vg,
4886d7f5d3SJohn Marino 			       struct physical_volume *pv,
4986d7f5d3SJohn Marino 			       void *handle,
5086d7f5d3SJohn Marino 			       int (*process_single) (struct cmd_context * cmd,
5186d7f5d3SJohn Marino 						      struct volume_group * vg,
5286d7f5d3SJohn Marino 						      struct pv_segment * pvseg,
5386d7f5d3SJohn Marino 						      void *handle));
5486d7f5d3SJohn Marino 
5586d7f5d3SJohn Marino int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
5686d7f5d3SJohn Marino 		    uint32_t flags, void *handle,
5786d7f5d3SJohn Marino 		    int (*process_single) (struct cmd_context * cmd,
5886d7f5d3SJohn Marino 					   struct logical_volume * lv,
5986d7f5d3SJohn Marino 					   void *handle));
6086d7f5d3SJohn Marino 
6186d7f5d3SJohn Marino int process_each_segment_in_lv(struct cmd_context *cmd,
6286d7f5d3SJohn Marino 			       struct logical_volume *lv, void *handle,
6386d7f5d3SJohn Marino 			       int (*process_single) (struct cmd_context * cmd,
6486d7f5d3SJohn Marino 						      struct lv_segment * seg,
6586d7f5d3SJohn Marino 						      void *handle));
6686d7f5d3SJohn Marino 
6786d7f5d3SJohn Marino typedef int (*process_single_pv_fn_t) (struct cmd_context *cmd,
6886d7f5d3SJohn Marino 				  struct volume_group *vg,
6986d7f5d3SJohn Marino 				  struct physical_volume *pv,
7086d7f5d3SJohn Marino 				  void *handle);
7186d7f5d3SJohn Marino 
7286d7f5d3SJohn Marino int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
7386d7f5d3SJohn Marino 			  const struct dm_list *tags, void *handle,
7486d7f5d3SJohn Marino 			  process_single_pv_fn_t process_single);
7586d7f5d3SJohn Marino 
7686d7f5d3SJohn Marino typedef int (*process_single_lv_fn_t) (struct cmd_context *cmd,
7786d7f5d3SJohn Marino 				  struct logical_volume *lv,
7886d7f5d3SJohn Marino 				  void *handle);
7986d7f5d3SJohn Marino 
8086d7f5d3SJohn Marino int process_each_lv_in_vg(struct cmd_context *cmd,
8186d7f5d3SJohn Marino 			  const struct volume_group *vg,
8286d7f5d3SJohn Marino 			  const struct dm_list *arg_lvnames,
8386d7f5d3SJohn Marino 			  const struct dm_list *tags,
8486d7f5d3SJohn Marino 			  void *handle,
8586d7f5d3SJohn Marino 			  process_single_lv_fn_t process_single);
8686d7f5d3SJohn Marino 
8786d7f5d3SJohn Marino char *default_vgname(struct cmd_context *cmd);
8886d7f5d3SJohn Marino const char *extract_vgname(struct cmd_context *cmd, const char *lv_name);
8986d7f5d3SJohn Marino char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
9086d7f5d3SJohn Marino 		   unsigned *dev_dir_found);
9186d7f5d3SJohn Marino 
9286d7f5d3SJohn Marino /*
9386d7f5d3SJohn Marino  * Builds a list of pv's from the names in argv.  Used in
9486d7f5d3SJohn Marino  * lvcreate/extend.
9586d7f5d3SJohn Marino  */
9686d7f5d3SJohn Marino struct dm_list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int argc,
9786d7f5d3SJohn Marino 			    char **argv, int allocatable_only);
9886d7f5d3SJohn Marino 
9986d7f5d3SJohn Marino struct dm_list *clone_pv_list(struct dm_pool *mem, struct dm_list *pvs);
10086d7f5d3SJohn Marino 
10186d7f5d3SJohn Marino int apply_lvname_restrictions(const char *name);
10286d7f5d3SJohn Marino int is_reserved_lvname(const char *name);
10386d7f5d3SJohn Marino 
10486d7f5d3SJohn Marino void vgcreate_params_set_defaults(struct vgcreate_params *vp_def,
10586d7f5d3SJohn Marino 				 struct volume_group *vg);
10686d7f5d3SJohn Marino int vgcreate_params_set_from_args(struct cmd_context *cmd,
10786d7f5d3SJohn Marino 				  struct vgcreate_params *vp_new,
10886d7f5d3SJohn Marino 				  struct vgcreate_params *vp_def);
10986d7f5d3SJohn Marino int lv_refresh(struct cmd_context *cmd, struct logical_volume *lv);
11086d7f5d3SJohn Marino int vg_refresh_visible(struct cmd_context *cmd, struct volume_group *vg);
11186d7f5d3SJohn Marino void lv_spawn_background_polling(struct cmd_context *cmd,
11286d7f5d3SJohn Marino 				 struct logical_volume *lv);
11386d7f5d3SJohn Marino int pvcreate_params_validate(struct cmd_context *cmd,
11486d7f5d3SJohn Marino 			     int argc, char **argv,
11586d7f5d3SJohn Marino 			     struct pvcreate_params *pp);
11686d7f5d3SJohn Marino 
11786d7f5d3SJohn Marino #endif
118