LVM2 tools/lvmcmdline.c lib/commands/toolconte ...
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk at sourceware.org 2011-09-02 01:32:09
Modified files:
tools : lvmcmdline.c lib/commands : toolcontext.c toolcontext.h lib/config : config.c config.h libdm : libdevmapper.h libdm-config.c
Log message:
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.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.146&r2=1.147
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.132&r2=1.133
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.h.diff?cvsroot=lvm2&r1=1.45&r2=1.46
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/config.c.diff?cvsroot=lvm2&r1=1.104&r2=1.105
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/config.h.diff?cvsroot=lvm2&r1=1.36&r2=1.37
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.148&r2=1.149
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.5&r2=1.6
tools/lvmcmdline.c +7 -9
@@ -996,6 +996,7 @@ {int ret =0 ;int locking_type; +struct dm_config_tree *old_cft;init_error_message_produced (0 );
@@ -1020,8 +1021,7 @@set_cmd_name (cmd->command->name);if (arg_count (cmd, config_ARG)) -if (override_config_tree_from_string (cmd, -arg_str_value (cmd, config_ARG,"" ))) { +if (override_config_tree_from_string (cmd,arg_str_value (cmd, config_ARG,"" ))) { ret =EINVALID_CMD_LINE ; goto_out; }
@@ -1029,10 +1029,9 @@if (arg_count (cmd, config_ARG) || !cmd->config_valid ||config_files_changed (cmd)) {/* Reinitialise various settings inc. logging, filters */ if (!refresh_toolcontext (cmd)) { -if (cmd->cft_override) { -destroy_config_tree (cmd->cft_override); - cmd->cft_override =NULL ; - } + old_cft =remove_overridden_config_tree (cmd); +if (old_cft) +dm_config_destroy (old_cft);log_error ("Updated config file invalid. Aborting." );return ECMD_FAILED ; }
@@ -1081,9 +1080,8 @@lvmcache_destroy (cmd,1 ); } -if (cmd->cft_override) { -destroy_config_tree (cmd->cft_override); - cmd->cft_override =NULL ; +if ((old_cft =remove_overridden_config_tree (cmd))) { +dm_config_destroy (old_cft);/* Move this? */ if (!refresh_toolcontext (cmd)) stack;
lib/commands/toolcontext.c +42 -11
131 lines not on this page · raw message
lib/commands/toolcontext.h +0 -1
@@ -93,7 +93,6 @@struct dm_list config_files;int config_valid;struct dm_config_tree *cft; -struct dm_config_tree *cft_override;struct config_info default_settings;struct config_info current_settings;
lib/config/config.c +32 -21
110 lines not on this page · raw message
lib/config/config.h +1 -0
@@ -24,6 +24,7 @@int override_config_tree_from_string (struct cmd_context *cmd,const char *config_settings);void destroy_config_tree (struct dm_config_tree *cft); +struct dm_config_tree *remove_overridden_config_tree (struct cmd_context *cmd);typedef uint32_t (*checksum_fn_t ) (uint32_t initial,const uint8_t *buf,uint32_t size);
libdm/libdevmapper.h +12 -0
@@ -1248,6 +1248,7 @@struct dm_config_value *v; }; +/* FIXME Move cascade to dm_config_node and remove this struct */ struct dm_config_tree {struct dm_config_node *root;struct dm_config_tree *cascade;
@@ -1263,6 +1264,17 @@void dm_config_set_custom (struct dm_config_tree *cft,void *custom); +/* +* If there's a cascaded dm_config_tree, remove the top layer +* and return the layer below. Otherwise return NULL. +*/ +struct dm_config_tree *dm_config_remove_cascaded_tree (struct dm_config_tree *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); +void dm_config_destroy (struct dm_config_tree *cft); int dm_config_write(struct dm_config_tree *cft, const char *file,
libdm/libdm-config.c +31 -5
@@ -159,6 +159,29 @@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 @@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 @@ } 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 ; }