xref: /dflybsd-src/contrib/lvm2/dist/lib/commands/toolcontext.h (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
1*86d7f5d3SJohn Marino /*	$NetBSD: toolcontext.h,v 1.1.1.3 2009/12/02 00:26:26 haad Exp $	*/
2*86d7f5d3SJohn Marino 
3*86d7f5d3SJohn Marino /*
4*86d7f5d3SJohn Marino  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
5*86d7f5d3SJohn Marino  * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
6*86d7f5d3SJohn Marino  *
7*86d7f5d3SJohn Marino  * This file is part of LVM2.
8*86d7f5d3SJohn Marino  *
9*86d7f5d3SJohn Marino  * This copyrighted material is made available to anyone wishing to use,
10*86d7f5d3SJohn Marino  * modify, copy, or redistribute it subject to the terms and conditions
11*86d7f5d3SJohn Marino  * of the GNU Lesser General Public License v.2.1.
12*86d7f5d3SJohn Marino  *
13*86d7f5d3SJohn Marino  * You should have received a copy of the GNU Lesser General Public License
14*86d7f5d3SJohn Marino  * along with this program; if not, write to the Free Software Foundation,
15*86d7f5d3SJohn Marino  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16*86d7f5d3SJohn Marino  */
17*86d7f5d3SJohn Marino 
18*86d7f5d3SJohn Marino #ifndef _LVM_TOOLCONTEXT_H
19*86d7f5d3SJohn Marino #define _LVM_TOOLCONTEXT_H
20*86d7f5d3SJohn Marino 
21*86d7f5d3SJohn Marino #include "dev-cache.h"
22*86d7f5d3SJohn Marino 
23*86d7f5d3SJohn Marino #include <stdio.h>
24*86d7f5d3SJohn Marino #include <limits.h>
25*86d7f5d3SJohn Marino 
26*86d7f5d3SJohn Marino /*
27*86d7f5d3SJohn Marino  * Config options that can be changed while commands are processed
28*86d7f5d3SJohn Marino  */
29*86d7f5d3SJohn Marino struct config_info {
30*86d7f5d3SJohn Marino 	int debug;
31*86d7f5d3SJohn Marino 	int verbose;
32*86d7f5d3SJohn Marino 	int test;
33*86d7f5d3SJohn Marino 	int syslog;
34*86d7f5d3SJohn Marino 	int activation;
35*86d7f5d3SJohn Marino 	int suffix;
36*86d7f5d3SJohn Marino 	int archive;		/* should we archive ? */
37*86d7f5d3SJohn Marino 	int backup;		/* should we backup ? */
38*86d7f5d3SJohn Marino 	int read_ahead;		/* DM_READ_AHEAD_NONE or _AUTO */
39*86d7f5d3SJohn Marino 	int udev_sync;
40*86d7f5d3SJohn Marino 	int cache_vgmetadata;
41*86d7f5d3SJohn Marino 	const char *msg_prefix;
42*86d7f5d3SJohn Marino 	struct format_type *fmt;
43*86d7f5d3SJohn Marino 	uint64_t unit_factor;
44*86d7f5d3SJohn Marino 	int cmd_name;		/* Show command name? */
45*86d7f5d3SJohn Marino 	mode_t umask;
46*86d7f5d3SJohn Marino 	char unit_type;
47*86d7f5d3SJohn Marino 	char _padding[1];
48*86d7f5d3SJohn Marino };
49*86d7f5d3SJohn Marino 
50*86d7f5d3SJohn Marino struct config_tree;
51*86d7f5d3SJohn Marino struct archive_params;
52*86d7f5d3SJohn Marino struct backup_params;
53*86d7f5d3SJohn Marino 
54*86d7f5d3SJohn Marino /* FIXME Split into tool & library contexts */
55*86d7f5d3SJohn Marino /* command-instance-related variables needed by library */
56*86d7f5d3SJohn Marino struct cmd_context {
57*86d7f5d3SJohn Marino 	struct dm_pool *libmem;	/* For permanent config data */
58*86d7f5d3SJohn Marino 	struct dm_pool *mem;	/* Transient: Cleared between each command */
59*86d7f5d3SJohn Marino 
60*86d7f5d3SJohn Marino 	const struct format_type *fmt;	/* Current format to use by default */
61*86d7f5d3SJohn Marino 	struct format_type *fmt_backup;	/* Format to use for backups */
62*86d7f5d3SJohn Marino 
63*86d7f5d3SJohn Marino 	struct dm_list formats;	/* Available formats */
64*86d7f5d3SJohn Marino 	struct dm_list segtypes;	/* Available segment types */
65*86d7f5d3SJohn Marino 	const char *hostname;
66*86d7f5d3SJohn Marino 	const char *kernel_vsn;
67*86d7f5d3SJohn Marino 
68*86d7f5d3SJohn Marino 	unsigned rand_seed;
69*86d7f5d3SJohn Marino 	const char *cmd_line;
70*86d7f5d3SJohn Marino 	struct command *command;
71*86d7f5d3SJohn Marino 	char **argv;
72*86d7f5d3SJohn Marino 	unsigned is_long_lived:1;	/* Optimises persistent_filter handling */
73*86d7f5d3SJohn Marino 	unsigned handles_missing_pvs:1;
74*86d7f5d3SJohn Marino 	unsigned handles_unknown_segments:1;
75*86d7f5d3SJohn Marino 	unsigned partial_activation:1;
76*86d7f5d3SJohn Marino 	unsigned si_unit_consistency:1;
77*86d7f5d3SJohn Marino 
78*86d7f5d3SJohn Marino 	struct dev_filter *filter;
79*86d7f5d3SJohn Marino 	int dump_filter;	/* Dump filter when exiting? */
80*86d7f5d3SJohn Marino 
81*86d7f5d3SJohn Marino 	struct dm_list config_files;
82*86d7f5d3SJohn Marino 	int config_valid;
83*86d7f5d3SJohn Marino 	struct config_tree *cft;
84*86d7f5d3SJohn Marino 	struct config_tree *cft_override;
85*86d7f5d3SJohn Marino 	struct config_info default_settings;
86*86d7f5d3SJohn Marino 	struct config_info current_settings;
87*86d7f5d3SJohn Marino 
88*86d7f5d3SJohn Marino 	struct archive_params *archive_params;
89*86d7f5d3SJohn Marino 	struct backup_params *backup_params;
90*86d7f5d3SJohn Marino 	const char *stripe_filler;
91*86d7f5d3SJohn Marino 
92*86d7f5d3SJohn Marino 	/* List of defined tags */
93*86d7f5d3SJohn Marino 	struct dm_list tags;
94*86d7f5d3SJohn Marino 	int hosttags;
95*86d7f5d3SJohn Marino 
96*86d7f5d3SJohn Marino 	char system_dir[PATH_MAX];
97*86d7f5d3SJohn Marino 	char dev_dir[PATH_MAX];
98*86d7f5d3SJohn Marino 	char proc_dir[PATH_MAX];
99*86d7f5d3SJohn Marino 	char sysfs_dir[PATH_MAX];
100*86d7f5d3SJohn Marino };
101*86d7f5d3SJohn Marino 
102*86d7f5d3SJohn Marino /*
103*86d7f5d3SJohn Marino  * system_dir may be NULL to use the default value.
104*86d7f5d3SJohn Marino  * The environment variable LVM_SYSTEM_DIR always takes precedence.
105*86d7f5d3SJohn Marino  */
106*86d7f5d3SJohn Marino struct cmd_context *create_toolcontext(unsigned is_long_lived,
107*86d7f5d3SJohn Marino 				       const char *system_dir);
108*86d7f5d3SJohn Marino void destroy_toolcontext(struct cmd_context *cmd);
109*86d7f5d3SJohn Marino int refresh_toolcontext(struct cmd_context *cmd);
110*86d7f5d3SJohn Marino int refresh_filters(struct cmd_context *cmd);
111*86d7f5d3SJohn Marino int config_files_changed(struct cmd_context *cmd);
112*86d7f5d3SJohn Marino int init_lvmcache_orphans(struct cmd_context *cmd);
113*86d7f5d3SJohn Marino 
114*86d7f5d3SJohn Marino #endif
115