1 /* $NetBSD: toolcontext.h,v 1.1.1.1 2008/12/22 00:17:53 haad Exp $ */ 2 3 /* 4 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. 5 * Copyright (C) 2004-2007 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 cache_vgmetadata; 40 const char *msg_prefix; 41 struct format_type *fmt; 42 uint64_t unit_factor; 43 int cmd_name; /* Show command name? */ 44 mode_t umask; 45 char unit_type; 46 char _padding[1]; 47 }; 48 49 struct config_tree; 50 struct archive_params; 51 struct backup_params; 52 53 /* FIXME Split into tool & library contexts */ 54 /* command-instance-related variables needed by library */ 55 struct cmd_context { 56 struct dm_pool *libmem; /* For permanent config data */ 57 struct dm_pool *mem; /* Transient: Cleared between each command */ 58 59 const struct format_type *fmt; /* Current format to use by default */ 60 struct format_type *fmt_backup; /* Format to use for backups */ 61 62 struct dm_list formats; /* Available formats */ 63 struct dm_list segtypes; /* Available segment types */ 64 const char *hostname; 65 const char *kernel_vsn; 66 67 char *cmd_line; 68 struct command *command; 69 struct arg *args; 70 char **argv; 71 unsigned is_static:1; /* Static binary? */ 72 unsigned is_long_lived:1; /* Optimises persistent_filter handling */ 73 unsigned handles_missing_pvs:1; 74 unsigned partial_activation:1; 75 76 struct dev_filter *filter; 77 int dump_filter; /* Dump filter when exiting? */ 78 79 struct dm_list config_files; 80 int config_valid; 81 struct config_tree *cft; 82 struct config_tree *cft_override; 83 struct config_info default_settings; 84 struct config_info current_settings; 85 86 struct archive_params *archive_params; 87 struct backup_params *backup_params; 88 const char *stripe_filler; 89 90 /* List of defined tags */ 91 struct dm_list tags; 92 int hosttags; 93 94 char sys_dir[PATH_MAX]; 95 char dev_dir[PATH_MAX]; 96 char proc_dir[PATH_MAX]; 97 char sysfs_dir[PATH_MAX]; 98 }; 99 100 struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static, unsigned is_long_lived); 101 void destroy_toolcontext(struct cmd_context *cmd); 102 int refresh_toolcontext(struct cmd_context *cmd); 103 int config_files_changed(struct cmd_context *cmd); 104 int init_lvmcache_orphans(struct cmd_context *cmd); 105 106 #endif 107