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