mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
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.
This commit is contained in:
parent
ecccb75904
commit
ff9d27a1c7
@ -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, struct
|
||||
struct 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;
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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))
|
||||
|
@ -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)) ||
|
||||
|
Loading…
Reference in New Issue
Block a user