[DRBD-cvs] svn commit by phil - r2946 - branches/drbd-8.0/user - Simon's improvements to the events command: * when call

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Tue Jun 26 12:00:43 CEST 2007


Author: phil
Date: 2007-06-26 12:00:42 +0200 (Tue, 26 Jun 2007)
New Revision: 2946

Modified:
   branches/drbd-8.0/user/drbdsetup.c
Log:
Simon's improvements to the events command:
  * when called with the "-a" switch (for all devices), it
    should output the initial state for all devies as well.


Modified: branches/drbd-8.0/user/drbdsetup.c
===================================================================
--- branches/drbd-8.0/user/drbdsetup.c	2007-06-25 17:05:00 UTC (rev 2945)
+++ branches/drbd-8.0/user/drbdsetup.c	2007-06-26 10:00:42 UTC (rev 2946)
@@ -1184,6 +1184,10 @@
 	char* str;
 	int synced = 0;
 
+	/* Ignore error replies */
+	if (reply->ret_code != NoError)
+		return 1;
+
 	switch (reply->packet_type) {
 	case P_get_state:
 		if(consume_tag_int(T_state_i,reply->tag_list,(int*)&state.i)) {
@@ -1220,6 +1224,8 @@
 		break;
 	}
 
+	fflush(stdout);
+
 	return 1;
 }
 
@@ -1259,7 +1265,7 @@
 	struct drbd_tag_list *tl;
 	struct option *lo;
 	unsigned int seq=0;
-	int sk_nl,c,cont=1,rr;
+	int sk_nl,c,cont=1,rr,i,last;
 	int unfiltered=0, all_devices=0;
 	int wfc_timeout=0, degr_wfc_timeout=0,timeout_ms;
 	struct timeval before,after;
@@ -1318,11 +1324,22 @@
 	timeout_ms= 1000 * (  rr ? degr_wfc_timeout : wfc_timeout) - 1;
 
 	// ask for the current state before waiting for state updates...
-	tl->drbd_p_header->packet_type = P_get_state;
-	tl->drbd_p_header->drbd_minor = minor;
-	tl->drbd_p_header->flags = 0;
-	send_cn(sk_nl,tl->nl_header,(char*)tl->tag_list_cpos-(char*)tl->nl_header);
+	if (all_devices) {
+		i = 0;
+		last = 255;
+	}
+	else {
+		i = last = minor;
+	}
 
+	while (i <= last) {
+		tl->drbd_p_header->packet_type = P_get_state;
+		tl->drbd_p_header->drbd_minor = i;
+		tl->drbd_p_header->flags = 0;
+		send_cn(sk_nl,tl->nl_header,(char*)tl->tag_list_cpos-(char*)tl->nl_header);
+		i++;
+	}
+
 	dt_unlock_drbd(lock_fd);
 	lock_fd=-1;
 



More information about the drbd-cvs mailing list