xref: /netbsd-src/external/gpl2/lvm2/dist/tools/toollib.h (revision 7c604eea85b4f330dc75ffe65e947f4d73758aa0)
1*7c604eeaShaad /*	$NetBSD: toollib.h,v 1.1.1.3 2009/12/02 00:25:56 haad Exp $	*/
256a34939Shaad 
356a34939Shaad /*
456a34939Shaad  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
5*7c604eeaShaad  * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
656a34939Shaad  *
756a34939Shaad  * This file is part of LVM2.
856a34939Shaad  *
956a34939Shaad  * This copyrighted material is made available to anyone wishing to use,
1056a34939Shaad  * modify, copy, or redistribute it subject to the terms and conditions
1156a34939Shaad  * of the GNU Lesser General Public License v.2.1.
1256a34939Shaad  *
1356a34939Shaad  * You should have received a copy of the GNU Lesser General Public License
1456a34939Shaad  * along with this program; if not, write to the Free Software Foundation,
1556a34939Shaad  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1656a34939Shaad  */
1756a34939Shaad 
1856a34939Shaad #ifndef _LVM_TOOLLIB_H
1956a34939Shaad #define _LVM_TOOLLIB_H
2056a34939Shaad 
2156a34939Shaad #include "metadata-exported.h"
2256a34939Shaad 
2356a34939Shaad int autobackup_set(void);
2456a34939Shaad int autobackup_init(const char *backup_dir, int keep_days, int keep_number,
2556a34939Shaad 		    int autobackup);
2656a34939Shaad int autobackup(struct volume_group *vg);
2756a34939Shaad 
2856a34939Shaad struct volume_group *recover_vg(struct cmd_context *cmd, const char *vgname,
2956a34939Shaad 				uint32_t lock_type);
3056a34939Shaad 
3156a34939Shaad int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
32*7c604eeaShaad 		    uint32_t flags, void *handle,
3356a34939Shaad 		    int (*process_single) (struct cmd_context * cmd,
3456a34939Shaad 					   const char *vg_name,
3556a34939Shaad 					   struct volume_group * vg,
36*7c604eeaShaad 					   void *handle));
3756a34939Shaad 
3856a34939Shaad int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
39*7c604eeaShaad 		    struct volume_group *vg, uint32_t lock_type,
40*7c604eeaShaad 		    int scan_label_only, void *handle,
4156a34939Shaad 		    int (*process_single) (struct cmd_context * cmd,
4256a34939Shaad 					   struct volume_group * vg,
4356a34939Shaad 					   struct physical_volume * pv,
4456a34939Shaad 					   void *handle));
45*7c604eeaShaad 
4656a34939Shaad int process_each_segment_in_pv(struct cmd_context *cmd,
4756a34939Shaad 			       struct volume_group *vg,
4856a34939Shaad 			       struct physical_volume *pv,
4956a34939Shaad 			       void *handle,
5056a34939Shaad 			       int (*process_single) (struct cmd_context * cmd,
5156a34939Shaad 						      struct volume_group * vg,
5256a34939Shaad 						      struct pv_segment * pvseg,
5356a34939Shaad 						      void *handle));
5456a34939Shaad 
5556a34939Shaad int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
56*7c604eeaShaad 		    uint32_t flags, void *handle,
5756a34939Shaad 		    int (*process_single) (struct cmd_context * cmd,
5856a34939Shaad 					   struct logical_volume * lv,
5956a34939Shaad 					   void *handle));
6056a34939Shaad 
6156a34939Shaad int process_each_segment_in_lv(struct cmd_context *cmd,
6256a34939Shaad 			       struct logical_volume *lv, void *handle,
6356a34939Shaad 			       int (*process_single) (struct cmd_context * cmd,
6456a34939Shaad 						      struct lv_segment * seg,
6556a34939Shaad 						      void *handle));
6656a34939Shaad 
6756a34939Shaad typedef int (*process_single_pv_fn_t) (struct cmd_context *cmd,
6856a34939Shaad 				  struct volume_group *vg,
6956a34939Shaad 				  struct physical_volume *pv,
7056a34939Shaad 				  void *handle);
7156a34939Shaad 
7256a34939Shaad int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
7356a34939Shaad 			  const struct dm_list *tags, void *handle,
7456a34939Shaad 			  process_single_pv_fn_t process_single);
7556a34939Shaad 
7656a34939Shaad typedef int (*process_single_lv_fn_t) (struct cmd_context *cmd,
7756a34939Shaad 				  struct logical_volume *lv,
7856a34939Shaad 				  void *handle);
7956a34939Shaad 
8056a34939Shaad int process_each_lv_in_vg(struct cmd_context *cmd,
8156a34939Shaad 			  const struct volume_group *vg,
8256a34939Shaad 			  const struct dm_list *arg_lvnames,
8356a34939Shaad 			  const struct dm_list *tags,
8456a34939Shaad 			  void *handle,
8556a34939Shaad 			  process_single_lv_fn_t process_single);
8656a34939Shaad 
8756a34939Shaad char *default_vgname(struct cmd_context *cmd);
8856a34939Shaad const char *extract_vgname(struct cmd_context *cmd, const char *lv_name);
8956a34939Shaad char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
9056a34939Shaad 		   unsigned *dev_dir_found);
9156a34939Shaad 
9256a34939Shaad /*
9356a34939Shaad  * Builds a list of pv's from the names in argv.  Used in
9456a34939Shaad  * lvcreate/extend.
9556a34939Shaad  */
9656a34939Shaad struct dm_list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int argc,
9756a34939Shaad 			    char **argv, int allocatable_only);
9856a34939Shaad 
9956a34939Shaad struct dm_list *clone_pv_list(struct dm_pool *mem, struct dm_list *pvs);
10056a34939Shaad 
10156a34939Shaad int apply_lvname_restrictions(const char *name);
10256a34939Shaad int is_reserved_lvname(const char *name);
10356a34939Shaad 
104*7c604eeaShaad void vgcreate_params_set_defaults(struct vgcreate_params *vp_def,
105*7c604eeaShaad 				 struct volume_group *vg);
106*7c604eeaShaad int vgcreate_params_set_from_args(struct cmd_context *cmd,
107*7c604eeaShaad 				  struct vgcreate_params *vp_new,
10856a34939Shaad 				  struct vgcreate_params *vp_def);
109bec4d750Shaad int lv_refresh(struct cmd_context *cmd, struct logical_volume *lv);
110bec4d750Shaad int vg_refresh_visible(struct cmd_context *cmd, struct volume_group *vg);
111*7c604eeaShaad void lv_spawn_background_polling(struct cmd_context *cmd,
112*7c604eeaShaad 				 struct logical_volume *lv);
113*7c604eeaShaad int pvcreate_params_validate(struct cmd_context *cmd,
114*7c604eeaShaad 			     int argc, char **argv,
115*7c604eeaShaad 			     struct pvcreate_params *pp);
116*7c604eeaShaad 
11756a34939Shaad #endif
118