master - config: add profile arg to find_config_tree_str
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=06dd66af546dfc18a80b6ee574ce91e5d512d2f2 Commit: 06dd66af546dfc18a80b6ee574ce91e5d512d2f2 Parent: eeb7b0f7faeced4dbaa664b4857275e7c7a9e2a8 Author: Peter Rajnoha <[email protected]> AuthorDate: Tue Jun 25 12:29:54 2013 +0200 Committer: Peter Rajnoha <[email protected]> CommitterDate: Tue Jul 2 15:19:09 2013 +0200
config: add profile arg to find_config_tree_str
--- daemons/clvmd/lvm-functions.c | 2 +- lib/activate/activate.c | 2 +- lib/commands/toolcontext.c | 28 ++++++++++++++-------------- lib/config/config.c | 14 ++++++++++++-- lib/config/config.h | 2 +- lib/locking/external_locking.c | 2 +- lib/locking/file_locking.c | 2 +- lib/mirror/mirrored.c | 2 +- lib/misc/sharedlib.c | 2 +- lib/raid/raid.c | 2 +- lib/snapshot/snapshot.c | 2 +- lib/thin/thin.c | 2 +- tools/lvconvert.c | 11 ++++++----- tools/lvcreate.c | 4 ++-- tools/reporter.c | 32 ++++++++++++++++---------------- tools/toollib.c | 2 +- 16 files changed, 61 insertions(+), 50 deletions(-)
daemons/clvmd/lvm-functions.c +1 -1
@@ -811,7 +811,7 @@ static void check_config(void)if (locking_type ==2 ) {/* External library, check name */ const char *libname; - libname =find_config_tree_str (cmd, global_locking_library_CFG); + libname =find_config_tree_str (cmd, global_locking_library_CFG,NULL );if (libname &&strstr (libname,"liblvm2clusterlock.so" ))return ;
lib/activate/activate.c +1 -1
@@ -1286,7 +1286,7 @@ static struct dm_event_handler *_create_dm_event_handler(struct cmd_context *cmdif (!(dmevh =dm_event_handler_create ())) return_NULL; -if (dm_event_handler_set_dmeventd_path (dmevh,find_config_tree_str (cmd, dmeventd_executable_CFG))) +if (dm_event_handler_set_dmeventd_path (dmevh,find_config_tree_str (cmd, dmeventd_executable_CFG,NULL ))) goto_bad;if (dm_event_handler_set_dso (dmevh, dso))
lib/commands/toolcontext.c +14 -14
@@ -217,7 +217,7 @@ static void _init_logging(struct cmd_context *cmd)if (find_config_tree_bool (cmd, log_overwrite_CFG)) append =0 ; - log_file =find_config_tree_str (cmd, log_file_CFG); + log_file =find_config_tree_str (cmd, log_file_CFG,NULL );if (log_file) {release_log_memory ();
@@ -225,7 +225,7 @@ static void _init_logging(struct cmd_context *cmd)init_log_file (log_file, append); } - log_file =find_config_tree_str (cmd, log_activate_file_CFG); + log_file =find_config_tree_str (cmd, log_activate_file_CFG,NULL );if (log_file)init_log_direct (log_file, append);
@@ -290,7 +290,7 @@ static int _process_config(struct cmd_context *cmd)/* dev dir */ if (dm_snprintf (cmd->dev_dir,sizeof (cmd->dev_dir),"%s/" , -find_config_tree_str (cmd, devices_dir_CFG)) <0 ) { +find_config_tree_str (cmd, devices_dir_CFG,NULL )) <0 ) {log_error ("Device directory given in config file too long" );return 0 ; }
@@ -303,7 +303,7 @@ static int _process_config(struct cmd_context *cmd)/* proc dir */ if (dm_snprintf (cmd->proc_dir,sizeof (cmd->proc_dir),"%s" , -find_config_tree_str (cmd, global_proc_CFG)) <0 ) { +find_config_tree_str (cmd, global_proc_CFG,NULL )) <0 ) {log_error ("Device directory given in config file too long" );return 0 ; }
@@ -324,13 +324,13 @@ static int _process_config(struct cmd_context *cmd) cmd->default_settings.suffix =find_config_tree_bool (cmd, global_suffix_CFG);if (!(cmd->default_settings.unit_factor = -units_to_bytes (find_config_tree_str (cmd, global_units_CFG), +units_to_bytes (find_config_tree_str (cmd, global_units_CFG,NULL ), &cmd->default_settings.unit_type))) {log_error ("Invalid units specification" );return 0 ; } - read_ahead =find_config_tree_str (cmd, activation_readahead_CFG); + read_ahead =find_config_tree_str (cmd, activation_readahead_CFG,NULL );if (!strcasecmp (read_ahead,"auto" )) cmd->default_settings.read_ahead =DM_READ_AHEAD_AUTO ;else if (!strcasecmp (read_ahead,"none" ))
@@ -369,7 +369,7 @@ static int _process_config(struct cmd_context *cmd) cmd->use_linear_target =find_config_tree_bool (cmd, activation_use_linear_target_CFG); - cmd->stripe_filler =find_config_tree_str (cmd, activation_missing_stripe_filler_CFG); + cmd->stripe_filler =find_config_tree_str (cmd, activation_missing_stripe_filler_CFG,NULL );/* FIXME Missing error code checks from the stats, not log_warn?, notify if setting overridden, delay message/check till it is actually used (eg consider if lvm shell - file could appear later after this check)? */ if (!strcmp(cmd->stripe_filler, "/dev/ioerror") &&
@@ -606,7 +606,7 @@ static int _init_profiles(struct cmd_context *cmd)return 0 ; } -if (!(dir =find_config_tree_str (cmd, config_profile_dir_CFG))) { +if (!(dir =find_config_tree_str (cmd, config_profile_dir_CFG,NULL ))) {if (dm_snprintf (default_dir,sizeof (default_dir),"%s/%s" , cmd->system_dir,DEFAULT_PROFILE_SUBDIR ) ==-1 ) { log_error("Couldn't create default profile path '%s/%s'.",
@@ -890,8 +890,8 @@ static int _init_filters(struct cmd_context *cmd, unsigned load_persistent_cache/* * If 'cache_dir' or 'cache_file_prefix' is set, ignore 'cache'. */ - cache_dir =find_config_tree_str (cmd, devices_cache_dir_CFG); - cache_file_prefix =find_config_tree_str (cmd, devices_cache_file_prefix_CFG); + cache_dir =find_config_tree_str (cmd, devices_cache_dir_CFG,NULL ); + cache_file_prefix =find_config_tree_str (cmd, devices_cache_file_prefix_CFG,NULL );if (cache_dir || cache_file_prefix) { if (dm_snprintf(cache_file, sizeof(cache_file),
@@ -903,7 +903,7 @@ static int _init_filters(struct cmd_context *cmd, unsigned load_persistent_cachelog_error ("Persistent cache filename too long." ); goto bad; } - } else if (!(dev_cache = find_config_tree_str(cmd, devices_cache_CFG)) && + } else if (!(dev_cache = find_config_tree_str(cmd, devices_cache_CFG, NULL)) && (dm_snprintf(cache_file, sizeof(cache_file), "%s/%s/%s.cache", cmd->system_dir, DEFAULT_CACHE_SUBDIR,
@@ -1044,7 +1044,7 @@ static int _init_formats(struct cmd_context *cmd) cmd->fmt_backup = fmt; - format =find_config_tree_str (cmd, global_format_CFG); + format =find_config_tree_str (cmd, global_format_CFG,NULL ); dm_list_iterate_items(fmt, &cmd->formats) { if (!strcasecmp(fmt->name, format) ||
@@ -1267,7 +1267,7 @@ static int _init_backup(struct cmd_context *cmd)return 0 ; } -if (!(dir =find_config_tree_str (cmd, backup_archive_dir_CFG))) +if (!(dir =find_config_tree_str (cmd, backup_archive_dir_CFG,NULL ))) dir = default_dir; if (!archive_init(cmd, dir, days, min,
@@ -1287,7 +1287,7 @@ static int _init_backup(struct cmd_context *cmd)return 0 ; } -if (!(dir =find_config_tree_str (cmd, backup_backup_dir_CFG))) +if (!(dir =find_config_tree_str (cmd, backup_backup_dir_CFG,NULL ))) dir = default_dir;if (!backup_init (cmd, dir, cmd->default_settings.backup)) {
lib/config/config.c +12 -2
@@ -800,15 +800,25 @@ const struct dm_config_node *find_config_tree_node(struct cmd_context *cmd, intreturn cn; } -const char *find_config_tree_str (struct cmd_context *cmd,int id) +const char *find_config_tree_str (struct cmd_context *cmd,int id,struct profile *profile) {cfg_def_item_t *item =cfg_def_get_item_p (id);const char *path =cfg_def_get_path (item); +int profile_applied =0 ; +const char *str;if (item->type !=CFG_TYPE_STRING )log_error (INTERNAL_ERROR "%s cfg tree element not declared as string." , path); -return dm_config_tree_find_str (cmd->cft, path,cfg_def_get_default_value (item,CFG_TYPE_STRING )); +if (profile && !cmd->profile_params->global_profile) + profile_applied =override_config_tree_from_profile (cmd, profile); + + str =dm_config_tree_find_str (cmd->cft, path,cfg_def_get_default_value (item,CFG_TYPE_STRING )); + +if (profile_applied) +remove_config_tree_by_source (cmd,CONFIG_PROFILE ); + +return str; }const char *find_config_tree_str_allow_empty (struct cmd_context *cmd,int id)
lib/config/config.h +1 -1
@@ -165,7 +165,7 @@ int merge_config_tree(struct cmd_context *cmd, struct dm_config_tree *cft,* These versions check an override tree, if present, first. */ const struct dm_config_node *find_config_tree_node (struct cmd_context *cmd,int id,struct profile *profile); -const char *find_config_tree_str (struct cmd_context *cmd,int id); +const char *find_config_tree_str (struct cmd_context *cmd,int id,struct profile *profile);const char *find_config_tree_str_allow_empty (struct cmd_context *cmd,int id);int find_config_tree_int (struct cmd_context *cmd,int id);int64_t find_config_tree_int64 (struct cmd_context *cmd,int id);
lib/locking/external_locking.c +1 -1
@@ -80,7 +80,7 @@ int init_external_locking(struct locking_type *locking, struct cmd_context *cmd, locking->reset_locking = _reset_external_locking; locking->flags =0 ; -if (!(libname =find_config_tree_str (cmd, global_locking_library_CFG))) +if (!(libname =find_config_tree_str (cmd, global_locking_library_CFG,NULL ))) libname =DEFAULT_LOCKING_LIB ;if (!(_locking_lib =load_shared_library (cmd, libname,"locking" ,1 )))
lib/locking/file_locking.c +1 -1
@@ -346,7 +346,7 @@ int init_file_locking(struct locking_type *locking, struct cmd_context *cmd, locking->flags =0 ;/* Get lockfile directory from config file */ - locking_dir =find_config_tree_str (cmd, global_locking_dir_CFG); + locking_dir =find_config_tree_str (cmd, global_locking_dir_CFG,NULL );if (strlen (locking_dir) >=sizeof (_lock_dir)) {log_error ("Path for locking_dir %s is invalid." , locking_dir);return 0 ;
lib/mirror/mirrored.c +1 -1
@@ -540,7 +540,7 @@ static int _mirrored_target_present(struct cmd_context *cmd,#ifdef DMEVENTD static const char *_get_mirror_dso_path (struct cmd_context *cmd) { -return get_monitor_dso_path (cmd,find_config_tree_str (cmd, dmeventd_mirror_library_CFG)); +return get_monitor_dso_path (cmd,find_config_tree_str (cmd, dmeventd_mirror_library_CFG,NULL )); }/* FIXME Cache this */
lib/misc/sharedlib.c +1 -1
@@ -30,7 +30,7 @@ void get_shared_library_path(struct cmd_context *cmd, const char *libname,/* If libname doesn't begin with '/' then use lib_dir/libname, * if present */ if (libname[0 ] =='/' || - !(lib_dir =find_config_tree_str (cmd, global_library_dir_CFG)) || + !(lib_dir =find_config_tree_str (cmd, global_library_dir_CFG,NULL )) || (dm_snprintf (path, path_len,"%s/%s" , lib_dir, libname) ==-1 ) ||stat (path, &info) ==-1 ) {strncpy (path, libname, path_len -1 );
lib/raid/raid.c +1 -1
@@ -343,7 +343,7 @@ static void _raid_destroy(struct segment_type *segtype)#ifdef DMEVENTD static const char *_get_raid_dso_path (struct cmd_context *cmd) { -const char *config_str =find_config_tree_str (cmd, dmeventd_raid_library_CFG); +const char *config_str =find_config_tree_str (cmd, dmeventd_raid_library_CFG,NULL );return get_monitor_dso_path (cmd, config_str); }
lib/snapshot/snapshot.c +1 -1
@@ -171,7 +171,7 @@ static int _snap_target_present(struct cmd_context *cmd,static const char *_get_snapshot_dso_path (struct cmd_context *cmd) { -return get_monitor_dso_path (cmd,find_config_tree_str (cmd, dmeventd_snapshot_library_CFG)); +return get_monitor_dso_path (cmd,find_config_tree_str (cmd, dmeventd_snapshot_library_CFG,NULL )); }/* FIXME Cache this */
lib/thin/thin.c +1 -1
@@ -379,7 +379,7 @@ static int _thin_pool_target_percent(void **target_state __attribute__((unused))# ifdef DMEVENTD static const char *_get_thin_dso_path (struct cmd_context *cmd) { -return get_monitor_dso_path (cmd,find_config_tree_str (cmd, dmeventd_thin_library_CFG)); +return get_monitor_dso_path (cmd,find_config_tree_str (cmd, dmeventd_thin_library_CFG,NULL )); }/* FIXME Cache this */
tools/lvconvert.c +6 -5
@@ -488,7 +488,8 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,if (!get_stripe_params (cmd, &lp->stripes, &lp->stripe_size)) return_0; - lp->segtype =get_segtype_from_string (cmd,arg_str_value (cmd, type_ARG,find_config_tree_str (cmd, global_mirror_segtype_default_CFG))); + lp->segtype =get_segtype_from_string (cmd,arg_str_value (cmd, type_ARG, +find_config_tree_str (cmd, global_mirror_segtype_default_CFG,NULL )));if (!lp->segtype) return_0; }
@@ -859,10 +860,10 @@ static void _lvconvert_mirrors_repair_ask(struct cmd_context *cmd, *replace_log = *replace_mirrors =1 ;if (arg_count (cmd, use_policies_ARG)) { - leg_policy =find_config_tree_str (cmd, activation_mirror_image_fault_policy_CFG); + leg_policy =find_config_tree_str (cmd, activation_mirror_image_fault_policy_CFG,NULL );if (!leg_policy) - leg_policy =find_config_tree_str (cmd, activation_mirror_device_fault_policy_CFG); - log_policy =find_config_tree_str (cmd, activation_mirror_log_fault_policy_CFG); + leg_policy =find_config_tree_str (cmd, activation_mirror_device_fault_policy_CFG,NULL ); + log_policy =find_config_tree_str (cmd, activation_mirror_log_fault_policy_CFG,NULL ); *replace_mirrors =strcmp (leg_policy,"remove" ); *replace_log =strcmp (log_policy,"remove" );return ;
@@ -1585,7 +1586,7 @@ static void _lvconvert_raid_repair_ask(struct cmd_context *cmd, int *replace_dev *replace_dev =1 ;if (arg_count (cmd, use_policies_ARG)) { - dev_policy =find_config_tree_str (cmd, activation_raid_fault_policy_CFG); + dev_policy =find_config_tree_str (cmd, activation_raid_fault_policy_CFG,NULL );if (!strcmp (dev_policy,"allocate" ) || !strcmp (dev_policy,"replace" ))
tools/lvcreate.c +2 -2
@@ -724,9 +724,9 @@ static int _lvcreate_params(struct lvcreate_params *lp,if (arg_count (cmd, mirrors_ARG))if (arg_uint_value (cmd,arg_count (cmd, stripes_long_ARG) ? stripes_long_ARG : stripes_ARG,1 ) >1 ) { - segtype_str =find_config_tree_str (cmd, global_raid10_segtype_default_CFG);; + segtype_str =find_config_tree_str (cmd, global_raid10_segtype_default_CFG,NULL );; }else { - segtype_str =find_config_tree_str (cmd, global_mirror_segtype_default_CFG); + segtype_str =find_config_tree_str (cmd, global_mirror_segtype_default_CFG,NULL ); }else if (arg_count (cmd, thin_ARG) ||arg_count (cmd, thinpool_ARG)) segtype_str ="thin" ;
tools/reporter.c +16 -16
@@ -225,7 +225,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, aligned =find_config_tree_bool (cmd, report_aligned_CFG); buffered =find_config_tree_bool (cmd, report_buffered_CFG); headings =find_config_tree_bool (cmd, report_headings_CFG); - separator =find_config_tree_str (cmd, report_separator_CFG); + separator =find_config_tree_str (cmd, report_separator_CFG,NULL ); field_prefixes =find_config_tree_bool (cmd, report_prefixes_CFG); quoted =find_config_tree_bool (cmd, report_quoted_CFG); columns_as_rows =find_config_tree_bool (cmd, report_colums_as_rows_CFG);
@@ -236,40 +236,40 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,switch (report_type) {case LVS : - keys =find_config_tree_str (cmd, report_lvs_sort_CFG); + keys =find_config_tree_str (cmd, report_lvs_sort_CFG,NULL );if (!arg_count (cmd, verbose_ARG)) - options =find_config_tree_str (cmd, report_lvs_cols_CFG); + options =find_config_tree_str (cmd, report_lvs_cols_CFG,NULL );else - options =find_config_tree_str (cmd, report_lvs_cols_verbose_CFG); + options =find_config_tree_str (cmd, report_lvs_cols_verbose_CFG,NULL );break ;case VGS : - keys =find_config_tree_str (cmd, report_vgs_sort_CFG); + keys =find_config_tree_str (cmd, report_vgs_sort_CFG,NULL );if (!arg_count (cmd, verbose_ARG)) - options =find_config_tree_str (cmd, report_vgs_cols_CFG); + options =find_config_tree_str (cmd, report_vgs_cols_CFG,NULL );else - options =find_config_tree_str (cmd, report_vgs_cols_verbose_CFG); + options =find_config_tree_str (cmd, report_vgs_cols_verbose_CFG,NULL );break ;case LABEL :case PVS : - keys =find_config_tree_str (cmd, report_pvs_sort_CFG); + keys =find_config_tree_str (cmd, report_pvs_sort_CFG,NULL );if (!arg_count (cmd, verbose_ARG)) - options =find_config_tree_str (cmd, report_pvs_cols_CFG); + options =find_config_tree_str (cmd, report_pvs_cols_CFG,NULL );else - options =find_config_tree_str (cmd, report_pvs_cols_verbose_CFG); + options =find_config_tree_str (cmd, report_pvs_cols_verbose_CFG,NULL );break ;case SEGS : - keys =find_config_tree_str (cmd, report_segs_sort_CFG); + keys =find_config_tree_str (cmd, report_segs_sort_CFG,NULL );if (!arg_count (cmd, verbose_ARG)) - options =find_config_tree_str (cmd, report_segs_cols_CFG); + options =find_config_tree_str (cmd, report_segs_cols_CFG,NULL );else - options =find_config_tree_str (cmd, report_segs_cols_verbose_CFG); + options =find_config_tree_str (cmd, report_segs_cols_verbose_CFG,NULL );break ;case PVSEGS : - keys =find_config_tree_str (cmd, report_pvsegs_sort_CFG); + keys =find_config_tree_str (cmd, report_pvsegs_sort_CFG,NULL );if (!arg_count (cmd, verbose_ARG)) - options =find_config_tree_str (cmd, report_pvsegs_cols_CFG); + options =find_config_tree_str (cmd, report_pvsegs_cols_CFG,NULL );else - options =find_config_tree_str (cmd, report_pvsegs_cols_verbose_CFG); + options =find_config_tree_str (cmd, report_pvsegs_cols_verbose_CFG,NULL );break ;default :log_error (INTERNAL_ERROR "Unknown report type." );
tools/toollib.c +1 -1
@@ -1559,7 +1559,7 @@ int get_pool_params(struct cmd_context *cmd, int *passed_args,log_very_verbose ("Setting pool discards: %s" ,get_pool_discards_name (*discards)); }else { - dstr =find_config_tree_str (cmd, allocation_thin_pool_discards_CFG); + dstr =find_config_tree_str (cmd, allocation_thin_pool_discards_CFG,NULL );if (!get_pool_discards (dstr, discards)) return_0; }