1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
lvm2/lib
Peter Rajnoha e29cd366a2 config: add support for enhanced config node output
There's a possibility to interconnect the dm_config_node with an
ID, which in our case is used to reference the configuration
definition ID from config_settings.h. So simply interconnecting
struct dm_config_node with struct cfg_def_item.

This patch also adds support for enhanced config node output besides
existing "output line by line". This patch adds a possibility to
register a callback that gets called *before* the config node is
processed line by line (for example to include any headers on output)
and *after* the config node is processed line by line (to include any
footers on output). Also, it adds the config node reference itself
as the callback arg in addition to have a possibility to extract more
information from the config node itself if needed when processing the
output callback (e.g. the key name, the id, or whether this is a
section or a value etc...).

If the config node from lvm.conf/--config tree is recognized and valid,
it's always coupled with the config node definition ID from
config_settings.h:

 struct dm_config_node {
   int id;
   const char *key;
   struct dm_config_node *parent, *sib, *child;
   struct dm_config_value *v;
 }

For example if the dm_config_node *cn holds "devices/dev" configuration,
then the cn->id holds "devices_dev_CFG" ID from config_settings.h, -1 if
not found in config_settings.h and 0 if matching has not yet been done.

To support the enhanced config node output, a new structure has been
defined in libdevmapper to register it:

  struct dm_config_node_out_spec {
    dm_config_node_out_fn prefix_fn; /* called before processing config node lines */
    dm_config_node_out_fn line_fn; /* called for each config node line */
    dm_config_node_out_fn suffix_fn; /* called after processing config node lines */
  };

Where dm_config_node_out_fn is:

  typedef int (*dm_config_node_out_fn)(const struct dm_config_node *cn, const char *line, void *baton);

(so in comparison to existing callbacks for config node output, it has
an extra dm_config_node *cn arg in addition)

This patch also adds these functions to libdevmapper:
  - dm_config_write_node_out
  - dm_config_write_one_node_out

...which have exactly the same functionality as their counterparts
without the "out" suffix. The "*_out" functions adds the extra hooks
for enhanced config output (prefix_fn and suffix_fn mentioned above).

One can still use the old interface for config node output, this is
just an enhancement for those who'd like to modify the output more
extensively.
2013-03-06 10:46:36 +01:00
..
activate config: refer to config nodes using assigned IDs 2013-03-06 10:14:33 +01:00
cache lvmetad: fix to properly process embedding area 2013-02-27 10:36:49 +01:00
commands config: use config checks and add support for creating trees from config definition (config_def_create_tree fn) 2013-03-06 10:46:35 +01:00
config config: add support for enhanced config node output 2013-03-06 10:46:36 +01:00
datastruct Switch to return void 2012-02-08 12:52:58 +00:00
device config: refer to config nodes using assigned IDs 2013-03-06 10:14:33 +01:00
display config: refer to config nodes using assigned IDs 2013-03-06 10:14:33 +01:00
error cleanup: drop unneeded included header files 2012-08-23 14:37:20 +02:00
filters filters: add scm devices 2013-01-11 09:24:07 +01:00
format1 pv_header_extension: add support for writing PV header extension (flags & Embedding Area) 2013-02-26 11:28:00 +01:00
format_pool cleanup: use struct pvcreate_restorable_params throughout 2013-02-26 11:25:11 +01:00
format_text config: refer to config nodes using assigned IDs 2013-03-06 10:14:33 +01:00
freeseg cleanup: drop unneeded included header files 2012-08-23 14:37:20 +02:00
label logging: classify log_debug messages 2013-01-07 22:30:29 +00:00
locking config: refer to config nodes using assigned IDs 2013-03-06 10:14:33 +01:00
log logging: add debug classes 2013-01-07 22:25:19 +00:00
metadata config: refer to config nodes using assigned IDs 2013-03-06 10:14:33 +01:00
mirror config: refer to config nodes using assigned IDs 2013-03-06 10:14:33 +01:00
misc config: refer to config nodes using assigned IDs 2013-03-06 10:14:33 +01:00
mm config: refer to config nodes using assigned IDs 2013-03-06 10:14:33 +01:00
raid config: refer to config nodes using assigned IDs 2013-03-06 10:14:33 +01:00
replicator cleanup: drop unneeded included header files 2012-08-23 14:37:20 +02:00
report report: add reporting fields for Embedding Area start and size 2013-02-26 14:46:42 +01:00
snapshot config: refer to config nodes using assigned IDs 2013-03-06 10:14:33 +01:00
striped Add activation/use_linear_target enabled by default. (prajnoha) 2011-11-28 20:37:51 +00:00
thin config: refer to config nodes using assigned IDs 2013-03-06 10:14:33 +01:00
unknown cleanup: drop unneeded included header files 2012-08-23 14:37:20 +02:00
uuid Revert the #include changes. Need to fix this at the #include site for now, and 2011-07-18 14:34:33 +00:00
zero cleanup: drop unneeded included header files 2012-08-23 14:37:20 +02:00
Makefile.in cleanup: drop unneeded included header files 2012-08-23 14:37:20 +02:00