master - config: add CONFIG_FILE_SPECIAL config source id
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ff9d27a1c71785abd6aa71eddc7018dd56807517 Commit: ff9d27a1c71785abd6aa71eddc7018dd56807517 Parent: ecccb759048c143a4e9e2e1b96afb6b6178a9325 Author: Peter Rajnoha <[email protected]> AuthorDate: Mon May 19 10:58:28 2014 +0200 Committer: Peter Rajnoha <[email protected]> CommitterDate: Mon May 19 15:37:41 2014 +0200
config: add CONFIG_FILE_SPECIAL config source id
Add CONFIG_FILE_SPECIAL config source id to make a difference between real configuration tree (like lvm.conf and tag configs) and special purpose configuration tree (like LVM metadata, persistent filter).
This makes it easier to attach correct customized data to the config tree that is created out of the source then.
--- lib/config/config.c | 29 ++++++++++++++++++++--------- lib/config/config.h | 3 ++- lib/filters/filter-persistent.c | 2 +- lib/format_text/import.c | 4 ++-- 4 files changed, 25 insertions(+), 13 deletions(-)
lib/config/config.c +20 -9
@@ -38,7 +38,8 @@ static const char *_config_source_names[] = { [CONFIG_FILE] = "file", [CONFIG_MERGED_FILES] = "merged files", [CONFIG_STRING] = "string", - [CONFIG_PROFILE ] ="profile" + [CONFIG_PROFILE] = "profile", + [CONFIG_FILE_SPECIAL ] ="special purpose" };struct config_file {
@@ -100,7 +101,9 @@ struct dm_config_tree *config_open(config_source_t source, goto fail; } -if ((source ==CONFIG_FILE ) || (source ==CONFIG_PROFILE )) { +if ((source ==CONFIG_FILE ) || + (source ==CONFIG_FILE_SPECIAL ) || + (source ==CONFIG_PROFILE )) {if (!(cf =dm_pool_zalloc (cft->mem,sizeof (struct config_file )))) {log_error ("Failed to allocate config file." ); goto fail;
@@ -133,9 +136,12 @@ int config_file_check(struct dm_config_tree *cft, const char **filename, structstruct config_file *cf;struct stat _info; -if ((cs->type !=CONFIG_FILE ) && (cs->type !=CONFIG_PROFILE )) { -log_error (INTERNAL_ERROR "config_file_check: expected file or profile config source, " -"found %s config source." , _config_source_names[cs->type]); +if ((cs->type !=CONFIG_FILE ) && + (cs->type !=CONFIG_PROFILE ) && + (cs->type !=CONFIG_FILE_SPECIAL )) { +log_error (INTERNAL_ERROR "config_file_check: expected file, special file or " +"profile config source, found %s config source." , + _config_source_names[cs->type]);return 0 ; }
@@ -227,7 +233,9 @@ void config_destroy(struct dm_config_tree *cft) cs =dm_config_get_custom (cft); -if ((cs->type ==CONFIG_FILE ) || (cs->type ==CONFIG_PROFILE )) { +if ((cs->type ==CONFIG_FILE ) || + (cs->type ==CONFIG_PROFILE ) || + (cs->type ==CONFIG_FILE_SPECIAL )) { cf = cs->source.file;if (cf && cf->dev)if (!dev_close (cf->dev))
@@ -377,9 +385,12 @@ int config_file_read_fd(struct dm_config_tree *cft, struct device *dev,char *buf =NULL ;struct config_source *cs =dm_config_get_custom (cft); -if ((cs->type !=CONFIG_FILE ) && (cs->type !=CONFIG_PROFILE )) { -log_error (INTERNAL_ERROR "config_file_read_fd: expected file or profile config source, " -"found %s config source." , _config_source_names[cs->type]); +if ((cs->type !=CONFIG_FILE ) && + (cs->type !=CONFIG_PROFILE ) && + (cs->type !=CONFIG_FILE_SPECIAL )) { +log_error (INTERNAL_ERROR "config_file_read_fd: expected file, special file " +"or profile config source, found %s config source." , + _config_source_names[cs->type]);return 0 ; }
lib/config/config.h +2 -1
@@ -30,7 +30,8 @@ typedef enum {CONFIG_FILE ,/* one file config */ CONFIG_MERGED_FILES ,/* config that is a result of merging more config files */ CONFIG_STRING ,/* config string typed on cmdline using '--config' arg */ - CONFIG_PROFILE /* profile config */ +CONFIG_PROFILE ,/* profile config */ + CONFIG_FILE_SPECIAL /* special purpose file config (e.g. metadata, persistent filter...) */ } config_source_t;struct profile {
lib/filters/filter-persistent.c +1 -1
@@ -114,7 +114,7 @@ int persistent_filter_load(struct dev_filter *f, struct dm_config_tree **cft_out return_0; } -if (!(cft =config_open (CONFIG_FILE , pf->file,1 ))) +if (!(cft =config_open (CONFIG_FILE_SPECIAL , pf->file,1 ))) return_0;if (!config_file_read (cft))
lib/format_text/import.c +2 -2
@@ -46,7 +46,7 @@ const char *text_vgname_import(const struct format_type *fmt,_init_text_import (); -if (!(cft =config_open (CONFIG_FILE ,NULL ,0 ))) +if (!(cft =config_open (CONFIG_FILE_SPECIAL ,NULL ,0 ))) return_NULL; if ((!dev && !config_file_read(cft)) ||
@@ -92,7 +92,7 @@ struct volume_group *text_vg_import_fd(struct format_instance *fid, *desc =NULL ; *when =0 ; -if (!(cft =config_open (CONFIG_FILE , file,0 ))) +if (!(cft =config_open (CONFIG_FILE_SPECIAL , file,0 ))) return_NULL; if ((!dev && !config_file_read(cft)) ||