1*7c604eeaShaad /*	$NetBSD: toolcontext.h,v 1.1.1.3 2009/12/02 00:25:44 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_TOOLCONTEXT_H
1956a34939Shaad #define _LVM_TOOLCONTEXT_H
2056a34939Shaad 
2156a34939Shaad #include "dev-cache.h"
2256a34939Shaad 
2356a34939Shaad #include <stdio.h>
2456a34939Shaad #include <limits.h>
2556a34939Shaad 
2656a34939Shaad /*
2756a34939Shaad  * Config options that can be changed while commands are processed
2856a34939Shaad  */
2956a34939Shaad struct config_info {
3056a34939Shaad 	int debug;
3156a34939Shaad 	int verbose;
3256a34939Shaad 	int test;
3356a34939Shaad 	int syslog;
3456a34939Shaad 	int activation;
3556a34939Shaad 	int suffix;
3656a34939Shaad 	int archive;		/* should we archive ? */
3756a34939Shaad 	int backup;		/* should we backup ? */
3856a34939Shaad 	int read_ahead;		/* DM_READ_AHEAD_NONE or _AUTO */
39*7c604eeaShaad 	int udev_sync;
4056a34939Shaad 	int cache_vgmetadata;
4156a34939Shaad 	const char *msg_prefix;
4256a34939Shaad 	struct format_type *fmt;
4356a34939Shaad 	uint64_t unit_factor;
4456a34939Shaad 	int cmd_name;		/* Show command name? */
4556a34939Shaad 	mode_t umask;
4656a34939Shaad 	char unit_type;
4756a34939Shaad 	char _padding[1];
4856a34939Shaad };
4956a34939Shaad 
5056a34939Shaad struct config_tree;
5156a34939Shaad struct archive_params;
5256a34939Shaad struct backup_params;
5356a34939Shaad 
5456a34939Shaad /* FIXME Split into tool & library contexts */
5556a34939Shaad /* command-instance-related variables needed by library */
5656a34939Shaad struct cmd_context {
5756a34939Shaad 	struct dm_pool *libmem;	/* For permanent config data */
5856a34939Shaad 	struct dm_pool *mem;	/* Transient: Cleared between each command */
5956a34939Shaad 
6056a34939Shaad 	const struct format_type *fmt;	/* Current format to use by default */
6156a34939Shaad 	struct format_type *fmt_backup;	/* Format to use for backups */
6256a34939Shaad 
6356a34939Shaad 	struct dm_list formats;	/* Available formats */
6456a34939Shaad 	struct dm_list segtypes;	/* Available segment types */
6556a34939Shaad 	const char *hostname;
6656a34939Shaad 	const char *kernel_vsn;
6756a34939Shaad 
68bec4d750Shaad 	unsigned rand_seed;
69*7c604eeaShaad 	const char *cmd_line;
7056a34939Shaad 	struct command *command;
7156a34939Shaad 	char **argv;
7256a34939Shaad 	unsigned is_long_lived:1;	/* Optimises persistent_filter handling */
7356a34939Shaad 	unsigned handles_missing_pvs:1;
74*7c604eeaShaad 	unsigned handles_unknown_segments:1;
7556a34939Shaad 	unsigned partial_activation:1;
76*7c604eeaShaad 	unsigned si_unit_consistency:1;
7756a34939Shaad 
7856a34939Shaad 	struct dev_filter *filter;
7956a34939Shaad 	int dump_filter;	/* Dump filter when exiting? */
8056a34939Shaad 
8156a34939Shaad 	struct dm_list config_files;
8256a34939Shaad 	int config_valid;
8356a34939Shaad 	struct config_tree *cft;
8456a34939Shaad 	struct config_tree *cft_override;
8556a34939Shaad 	struct config_info default_settings;
8656a34939Shaad 	struct config_info current_settings;
8756a34939Shaad 
8856a34939Shaad 	struct archive_params *archive_params;
8956a34939Shaad 	struct backup_params *backup_params;
9056a34939Shaad 	const char *stripe_filler;
9156a34939Shaad 
9256a34939Shaad 	/* List of defined tags */
9356a34939Shaad 	struct dm_list tags;
9456a34939Shaad 	int hosttags;
9556a34939Shaad 
96*7c604eeaShaad 	char system_dir[PATH_MAX];
9756a34939Shaad 	char dev_dir[PATH_MAX];
9856a34939Shaad 	char proc_dir[PATH_MAX];
9956a34939Shaad 	char sysfs_dir[PATH_MAX];
10056a34939Shaad };
10156a34939Shaad 
102*7c604eeaShaad /*
103*7c604eeaShaad  * system_dir may be NULL to use the default value.
104*7c604eeaShaad  * The environment variable LVM_SYSTEM_DIR always takes precedence.
105*7c604eeaShaad  */
106*7c604eeaShaad struct cmd_context *create_toolcontext(unsigned is_long_lived,
107*7c604eeaShaad 				       const char *system_dir);
10856a34939Shaad void destroy_toolcontext(struct cmd_context *cmd);
10956a34939Shaad int refresh_toolcontext(struct cmd_context *cmd);
110*7c604eeaShaad int refresh_filters(struct cmd_context *cmd);
11156a34939Shaad int config_files_changed(struct cmd_context *cmd);
11256a34939Shaad int init_lvmcache_orphans(struct cmd_context *cmd);
11356a34939Shaad 
11456a34939Shaad #endif
115