[DRBD-cvs] svn commit by phil - r2931 - branches/drbd-8.0/user -
Dave Jiang <djiang@mvista.com> sent a patch to make drb
drbd-cvs at lists.linbit.com
drbd-cvs at lists.linbit.com
Mon Jun 25 16:04:13 CEST 2007
Author: phil
Date: 2007-06-25 16:04:12 +0200 (Mon, 25 Jun 2007)
New Revision: 2931
Modified:
branches/drbd-8.0/user/drbdadm.h
branches/drbd-8.0/user/drbdadm_adjust.c
branches/drbd-8.0/user/drbdadm_parser.c
Log:
Dave Jiang <djiang at mvista.com> sent a patch to make drbdadm not
crash when it gets a configfile without an "on" section for
the local host.
The propper fix is to rejest such configfiles beforehand.
Modified: branches/drbd-8.0/user/drbdadm.h
===================================================================
--- branches/drbd-8.0/user/drbdadm.h 2007-06-25 10:27:42 UTC (rev 2930)
+++ branches/drbd-8.0/user/drbdadm.h 2007-06-25 14:04:12 UTC (rev 2931)
@@ -120,6 +120,14 @@
extern void convert_discard_opt(struct d_resource* res);
extern void convert_after_option(struct d_resource* res);
+enum pr_flags {
+ ThisHRequired = 1,
+ PeerHRequired = 2,
+ BothHRequired = ThisHRequired | PeerHRequired,
+ NoneHAllowed = 4,
+};
+extern struct d_resource* parse_resource(char*, enum pr_flags);
+
extern char* config_file;
extern int config_valid;
extern struct d_resource* config;
Modified: branches/drbd-8.0/user/drbdadm_adjust.c
===================================================================
--- branches/drbd-8.0/user/drbdadm_adjust.c 2007-06-25 10:27:42 UTC (rev 2930)
+++ branches/drbd-8.0/user/drbdadm_adjust.c 2007-06-25 14:04:12 UTC (rev 2931)
@@ -39,7 +39,6 @@
#include "drbdtool_common.h"
extern FILE* yyin;
-extern struct d_resource* parse_resource(char*);
static FILE *m_popen(int *pid,char** argv)
{
@@ -184,7 +183,7 @@
line = 1;
sprintf(config_file_dummy,"drbdsetup %s show", res->me->device);
config_file = config_file_dummy;
- running = parse_resource(config_file_dummy);
+ running = parse_resource(config_file_dummy, 0);
fclose(yyin);
waitpid(pid,0,0);
Modified: branches/drbd-8.0/user/drbdadm_parser.c
===================================================================
--- branches/drbd-8.0/user/drbdadm_parser.c 2007-06-25 10:27:42 UTC (rev 2930)
+++ branches/drbd-8.0/user/drbdadm_parser.c 2007-06-25 14:04:12 UTC (rev 2931)
@@ -504,7 +504,7 @@
parse_host_body(host,res,0);
}
-struct d_resource* parse_resource(char* res_name)
+struct d_resource* parse_resource(char* res_name, enum pr_flags flags)
{
struct d_resource* res;
int token;
@@ -558,12 +558,43 @@
break;
case '}':
case 0:
- return res;
+ goto exit_loop;
default:
pe_expected_got("protocol | on | disk | net | syncer |"
" startup | handler",token);
}
}
+
+ exit_loop:
+ if(flags & ThisHRequired && !res->me) {
+ config_valid = 0;
+
+ fprintf(stderr,
+ "%s:%d: in resource %s, there is no host section"
+ " for this host.\n"
+ "\tMissing 'on %s {...}' ?\n",
+ config_file, c_section_start, res->name,
+ nodeinfo.nodename);
+ }
+ if(flags & PeerHRequired && !res->peer) {
+ config_valid = 0;
+
+ fprintf(stderr,
+ "%s:%d: in resource %s, there is no host section"
+ " for the peer host.\n"
+ "\tMissing 'on <peer-name> {...}' ?\n",
+ config_file, c_section_start, res->name);
+ }
+ if(flags == NoneHAllowed && ( res->me || res->peer ) ) {
+ config_valid = 0;
+
+ fprintf(stderr,
+ "%s:%d: in the %s section, there are no host sections"
+ " allowed.\n",
+ config_file, c_section_start, res->name);
+ }
+
+ return res;
}
void my_parse(void)
@@ -578,12 +609,13 @@
break;
case TK_COMMON:
EXP('{');
- common = parse_resource("common");
+ common = parse_resource("common",NoneHAllowed);
break;
case TK_RESOURCE:
EXP(TK_STRING);
EXP('{');
- config = APPEND(config, parse_resource(yylval.txt));
+ config=APPEND(config,
+ parse_resource(yylval.txt,BothHRequired));
break;
case TK_SKIP:
parse_skip();
More information about the drbd-cvs
mailing list