diff options
author | Alasdair Kergon <agk@redhat.com> | 2011-09-02 01:32:08 +0000 |
---|---|---|
committer | Alasdair Kergon <agk@redhat.com> | 2011-09-02 01:32:08 +0000 |
commit | c82c2bebed8958456145a3f7ce8a95991e1878c3 (patch) | |
tree | 79fbd3285e05930e7c2751408de8929cff315851 /libdm/libdm-config.c | |
parent | fe8f5dbeb7044ef462c13b3e51329dcec5e2ea05 (diff) | |
download | lvm2-c82c2bebed8958456145a3f7ce8a95991e1878c3.tar.gz lvm2-c82c2bebed8958456145a3f7ce8a95991e1878c3.tar.xz lvm2-c82c2bebed8958456145a3f7ce8a95991e1878c3.zip |
Move cascade inside libdm etc.
Makes dumpconfig whole-section output wrong in a different way from before,
but we should be able to merge cft_cmdline properly into cmd->cft now and
remove cascade.
Diffstat (limited to 'libdm/libdm-config.c')
-rw-r--r-- | libdm/libdm-config.c | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/libdm/libdm-config.c b/libdm/libdm-config.c index af1aec18..c9291e9c 100644 --- a/libdm/libdm-config.c +++ b/libdm/libdm-config.c @@ -159,6 +159,29 @@ void dm_config_destroy(struct dm_config_tree *cft) dm_pool_destroy(c->mem); } +/* + * If there's a cascaded dm_config_tree, remove and return it, otherwise + * return NULL. + */ +struct dm_config_tree *dm_config_remove_cascaded_tree(struct dm_config_tree *cft) +{ + struct dm_config_tree *second_cft = cft->cascade; + + cft->cascade = NULL; + + return second_cft; +} + +/* + * When searching, first_cft is checked before second_cft. + */ +struct dm_config_tree *dm_config_insert_cascaded_tree(struct dm_config_tree *first_cft, struct dm_config_tree *second_cft) +{ + first_cft->cascade = second_cft; + + return first_cft; +} + int dm_config_parse(struct dm_config_tree *cft, const char *start, const char *end) { /* TODO? if (start == end) return 1; */ @@ -196,14 +219,16 @@ struct dm_config_tree *dm_config_from_string(const char *config_settings) return cft; } +/* + * Doesn't populate filename if the file is empty. + */ int dm_config_check_file(struct dm_config_tree *cft, const char **filename, struct stat *info) { struct cs *c = (struct cs *) cft; struct stat _info; + if (!info) info = &_info; - if (filename) - *filename = c->filename; if (stat(c->filename, info)) { log_sys_error("stat", c->filename); @@ -218,12 +243,13 @@ int dm_config_check_file(struct dm_config_tree *cft, const char **filename, stru } c->exists = 1; + c->timestamp = info->st_ctime; + c->st_size = info->st_size; if (info->st_size == 0) log_verbose("%s is empty", c->filename); - - c->timestamp = info->st_ctime; - c->st_size = info->st_size; + else if (filename) + *filename = c->filename; return 1; } |