diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2015-07-22 14:19:07 +0200 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2015-07-22 14:25:42 +0200 |
commit | 8bfcefe11a2ce594d1f6e8ef5a1b17e80786ceab (patch) | |
tree | af93985aec0f81895fe8e0b98224eb4e3c0c387c | |
parent | 00d24511bc5e1ae446867f65b5adfe3e7d404398 (diff) | |
download | lvm2-8bfcefe11a2ce594d1f6e8ef5a1b17e80786ceab.tar.gz |
config: add CFG_SECTION_NO_CHECK flag
The CFG_SECTION_NO_CHECK flag can be used to mark a section
and its whole subtree as containing settings where checks
won't be made (lvmconfig --validate).
These are setting where we don't know the names and and type
in advance and they're recognized in runtime. As we don't know
the type and name in advance, we can't do any checks here
of course.
Use this flag with great care as it disables config checks
for the whole config subtree found under such section.
This flag is going to be used by subsequent patches from
Zdenek to support some cache settings...
-rw-r--r-- | lib/config/config.c | 12 | ||||
-rw-r--r-- | lib/config/config.h | 2 | ||||
-rw-r--r-- | lib/config/config_settings.h | 1 |
3 files changed, 9 insertions, 6 deletions
diff --git a/lib/config/config.c b/lib/config/config.c index 35ee3ac5b..eb8880ee3 100644 --- a/lib/config/config.c +++ b/lib/config/config.c @@ -1040,9 +1040,14 @@ static int _config_def_check_tree(struct cft_check_handle *handle, size_t buf_size, struct dm_config_node *root) { struct dm_config_node *cn; + cfg_def_item_t *def; int valid, r = 1; size_t len; + def = cfg_def_get_item_p(root->id); + if (def->flags & CFG_SECTION_NO_CHECK) + return 1; + for (cn = root->child; cn; cn = cn->sib) { if ((valid = _config_def_check_node(handle, vp, pvp, rp, prp, buf_size, cn)) && !cn->v) { @@ -1662,14 +1667,9 @@ static int _out_prefix_fn(const struct dm_config_node *cn, const char *line, voi char path[CFG_PATH_MAX_LEN]; char commentline[MAX_COMMENT_LINE+1]; - if (cn->id < 0) + if (cn->id <= 0) return 1; - if (!cn->id) { - log_error(INTERNAL_ERROR "Configuration node %s has invalid id.", cn->key); - return 0; - } - if (out->tree_spec->type == CFG_DEF_TREE_LIST) return 1; diff --git a/lib/config/config.h b/lib/config/config.h index 03319bfcd..7520fc074 100644 --- a/lib/config/config.h +++ b/lib/config/config.h @@ -121,6 +121,8 @@ typedef union { #define CFG_DISABLED 0x200 /* whether to print integers in octal form (prefixed by "0") */ #define CFG_FORMAT_INT_OCTAL 0x400 +/* whether to disable checks for the whole config section subtree */ +#define CFG_SECTION_NO_CHECK 0x800 /* configuration definition item structure */ typedef struct cfg_def_item { diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h index ce03b36be..520953148 100644 --- a/lib/config/config_settings.h +++ b/lib/config/config_settings.h @@ -51,6 +51,7 @@ * CFG_DEFAULT_COMMENTED - node's default value is commented out on output * CFG_DISABLED - configuration is disabled (defaults always used) * CFG_FORMAT_INT_OCTAL - print integer number in octal form (also prefixed by "0") + * CFG_SECTION_NO_CHECK - do not check content of the section at all - use with care!!! * * type: Allowed type for the value of simple configuation setting, one of: * CFG_TYPE_BOOL |