master - systemid: Allow empty systemid with warnings.
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ac6a4cd7079fa97f866cde5ba3adedbf7fd61cba Commit: ac6a4cd7079fa97f866cde5ba3adedbf7fd61cba Parent: 7d615a3fe58e76af4d3b192298d55a60de9b0d5d Author: Alasdair G Kergon <[email protected]> AuthorDate: Wed Feb 25 14:12:24 2015 +0000 Committer: Alasdair G Kergon <[email protected]> CommitterDate: Wed Feb 25 14:12:24 2015 +0000
systemid: Allow empty systemid with warnings.
Add warning messages when empty system ID is set.
--- lib/commands/toolcontext.c | 13 +++++++++-- tools/toollib.c | 10 ++++++-- tools/vgchange.c | 46 +++++++++++++++++++++++++------------------ 3 files changed, 44 insertions(+), 25 deletions(-)
lib/commands/toolcontext.c +10 -3
@@ -62,6 +62,11 @@ const char *system_id_from_string(struct cmd_context *cmd, const char *str) {char *system_id; +if (!str || !*str) { +log_warn ("WARNING: Empty system ID supplied." ); +return "" ; + } +if (!(system_id =dm_pool_zalloc (cmd->mem,strlen (str) +1 ))) {log_warn ("WARNING: Failed to allocate system ID." );return NULL ;
@@ -109,13 +114,13 @@ static const char *_read_system_id_from_file(struct cmd_context *cmd, const charif (!*start || *start =='#' )continue ; -if (system_id) { +if (system_id && *system_id) {log_warn ("WARNING: Ignoring extra line(s) in system ID file %s." , file);break ; }/* Remove any comments from end of line */ -for (end = start; *end; start++) +for (end = start; *end; end++)if (*end =='#' ) { *end ='\0' ;break ;
@@ -445,8 +450,10 @@ static int _init_system_id(struct cmd_context *cmd)if (!strcmp (source,"none" ))return 1 ; -if ((cmd->system_id =_system_id_from_source (cmd, source))) +if ((system_id =_system_id_from_source (cmd, source)) && *system_id) { + cmd->system_id = system_id;return 1 ; + }/* * The source failed to resolve a system_id. In this case allow
tools/toollib.c +7 -3
@@ -770,9 +770,13 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,/* FIXME Take local/extra_system_ids into account */ if (vp_new->system_id && cmd->system_id && -strcmp (vp_new->system_id, cmd->system_id)) -log_warn ("VG with system ID \"%s\" might become inaccessible as local system ID is \"%s\"" , - vp_new->system_id, cmd->system_id); +strcmp (vp_new->system_id, cmd->system_id)) { +if (*vp_new->system_id) +log_warn ("VG with system ID \"%s\" might become inaccessible as local system ID is \"%s\"" , + vp_new->system_id, cmd->system_id); +else +log_warn ("WARNING: A VG without a system ID allows concurrent access from other hosts." ); + } }return 1 ;
tools/vgchange.c +27 -19
63 lines not on this page · raw message