2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
5 * This file is part of LVM2.
7 * This copyrighted material is made available to anyone wishing to use,
8 * modify, copy, or redistribute it subject to the terms and conditions
9 * of the GNU Lesser General Public License v.2.1.
11 * You should have received a copy of the GNU Lesser General Public License
12 * along with this program; if not, write to the Free Software Foundation,
13 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #ifndef _LVM_TOOLCONTEXT_H
17 #define _LVM_TOOLCONTEXT_H
19 #include "dev-cache.h"
25 * Config options that can be changed while commands are processed
34 int archive; /* should we archive ? */
35 int backup; /* should we backup ? */
36 int read_ahead; /* DM_READ_AHEAD_NONE or _AUTO */
40 const char *msg_prefix;
43 int cmd_name; /* Show command name? */
50 struct archive_params;
54 /* FIXME Split into tool & library contexts */
55 /* command-instance-related variables needed by library */
57 struct dm_pool *libmem; /* For permanent config data */
58 struct dm_pool *mem; /* Transient: Cleared between each command */
60 const struct format_type *fmt; /* Current format to use by default */
61 struct format_type *fmt_backup; /* Format to use for backups */
63 struct dm_list formats; /* Available formats */
64 struct dm_list segtypes; /* Available segment types */
66 const char *kernel_vsn;
70 struct command *command;
72 struct arg_values *arg_values;
73 struct dm_list arg_value_groups;
74 unsigned is_long_lived:1; /* Optimises persistent_filter handling */
75 unsigned handles_missing_pvs:1;
76 unsigned handles_unknown_segments:1;
77 unsigned partial_activation:1;
78 unsigned si_unit_consistency:1;
79 unsigned metadata_read_only:1;
81 unsigned independent_metadata_areas:1; /* Active formats have MDAs outside PVs */
83 struct dev_filter *filter;
84 int dump_filter; /* Dump filter when exiting? */
86 struct dm_list config_files;
88 struct config_tree *cft;
89 struct config_tree *cft_override;
90 struct config_info default_settings;
91 struct config_info current_settings;
93 struct archive_params *archive_params;
94 struct backup_params *backup_params;
95 const char *stripe_filler;
97 /* List of defined tags */
101 char system_dir[PATH_MAX];
102 char dev_dir[PATH_MAX];
103 char proc_dir[PATH_MAX];
104 char sysfs_dir[PATH_MAX]; /* FIXME Use global value instead. */
108 * system_dir may be NULL to use the default value.
109 * The environment variable LVM_SYSTEM_DIR always takes precedence.
111 struct cmd_context *create_toolcontext(unsigned is_long_lived,
112 const char *system_dir);
113 void destroy_toolcontext(struct cmd_context *cmd);
114 int refresh_toolcontext(struct cmd_context *cmd);
115 int refresh_filters(struct cmd_context *cmd);
116 int config_files_changed(struct cmd_context *cmd);
117 int init_lvmcache_orphans(struct cmd_context *cmd);
119 struct format_type *get_format_by_name(struct cmd_context *cmd, const char *format);