[DRBD-cvs] svn commit by phil - r2214 - in trunk: scripts user - Fixed two small issues: * Do not crash in the the devic

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Wed May 24 20:42:54 CEST 2006


Author: phil
Date: 2006-05-24 20:42:52 +0200 (Wed, 24 May 2006)
New Revision: 2214

Modified:
   trunk/scripts/drbd.conf
   trunk/user/drbdadm_adjust.c
   trunk/user/drbdadm_main.c
Log:
Fixed two small issues:
 * Do not crash in the the device is not configured at all.
 * Verify that the resource specified with the after directive exists at all.


Modified: trunk/scripts/drbd.conf
===================================================================
--- trunk/scripts/drbd.conf	2006-05-24 12:05:16 UTC (rev 2213)
+++ trunk/scripts/drbd.conf	2006-05-24 18:42:52 UTC (rev 2214)
@@ -65,7 +65,7 @@
 # At most ONE global section is allowed.
 # It must precede any resource section.
 #
-# global {
+global {
     # use this if you want to define more resources later
     # without reloading the module.
     # by default we load the module with exactly as many devices
@@ -89,7 +89,7 @@
     # possilbe options: ask, yes, no. Default is ask. In case you do not
     # know, set it to ask, and follow the on screen instructions later.
     usage-count yes;
-# }
+}
 
 
 #

Modified: trunk/user/drbdadm_adjust.c
===================================================================
--- trunk/user/drbdadm_adjust.c	2006-05-24 12:05:16 UTC (rev 2213)
+++ trunk/user/drbdadm_adjust.c	2006-05-24 18:42:52 UTC (rev 2214)
@@ -195,8 +195,10 @@
 	convert_after_option(res);
 
 	do_attach  = !opts_equal(res->disk_options, running->disk_options);
-	do_attach |= strcmp(res->me->device, running->me->device);
-	do_attach |= !disk_equal(res->me, running->me);
+	if(running->me) {
+		do_attach |= strcmp(res->me->device, running->me->device);
+		do_attach |= !disk_equal(res->me, running->me);
+	} else  do_attach |= 1;
 
 	do_connect  = !opts_equal(res->net_options, running->net_options);
 	do_connect |= !addr_equal(res,running);

Modified: trunk/user/drbdadm_main.c
===================================================================
--- trunk/user/drbdadm_main.c	2006-05-24 12:05:16 UTC (rev 2213)
+++ trunk/user/drbdadm_main.c	2006-05-24 18:42:52 UTC (rev 2214)
@@ -473,6 +473,7 @@
     expand_opts(common->sync_options,    &res->sync_options);
     expand_opts(common->startup_options, &res->startup_options);
     expand_opts(common->handlers,        &res->handlers);
+    validate_resource(res);
   }
 }
 
@@ -747,6 +748,8 @@
 {
   struct d_option* opt;
 
+  if (res==NULL) return;
+
   if ( (opt = find_opt(res->net_options, "after-sb-0pri")) ) {
     if(!strncmp(opt->value,"discard-node-",13)) {
       if(!strcmp(nodeinfo.nodename,opt->value+13)) {
@@ -795,6 +798,8 @@
 {
   struct d_option* opt;
 
+  if (res==NULL) return;
+
   if ( (opt = find_opt(res->sync_options, "after")) ) {
     char *ptr;
     ssprintf(ptr,"%d",dt_minor_of_dev(res_by_name(opt->value)->me->device));
@@ -1374,6 +1379,8 @@
 
 void validate_resource(struct d_resource * res)
 {
+  struct d_option* opt;
+
   if (!res->protocol) {
     fprintf(stderr,
 	    "%s:%d: in resource %s:\n\tprotocol definition missing.\n",
@@ -1395,6 +1402,13 @@
 	    config_file, c_resource_start, res->name);
     config_valid = 0;
   }
+  if ( (opt = find_opt(res->sync_options, "after")) ) {
+    if (res_by_name(opt->value) == NULL) {
+      fprintf(stderr,"In resource %s:\n\tresource '%s' mentioned in "
+	      "'after' option is not known.\n",res->name,opt->value);
+      config_valid=0;
+    }
+  }
   if (res->me && res->peer) {
     verify_ips(res);
   }



More information about the drbd-cvs mailing list