[DRBD-cvs] r1506 - in trunk: documentation user
svn at svn.drbd.org
svn at svn.drbd.org
Thu Aug 26 15:22:25 CEST 2004
Author: phil
Date: 2004-08-26 15:22:23 +0200 (Thu, 26 Aug 2004)
New Revision: 1506
Modified:
trunk/documentation/drbdadm.sgml
trunk/documentation/drbdsetup.sgml
trunk/user/drbdadm_main.c
trunk/user/drbdsetup.c
Log:
Added the cstate command to drbdsetup and drbdadm
Modified: trunk/documentation/drbdadm.sgml
===================================================================
--- trunk/documentation/drbdadm.sgml 2004-08-26 11:31:17 UTC (rev 1505)
+++ trunk/documentation/drbdadm.sgml 2004-08-26 13:22:23 UTC (rev 1506)
@@ -16,12 +16,12 @@
<cmdsynopsis>
<command>drbdadm</command>
<arg>-d</arg>
- <arg>-c<arg choice=req><replaceable>file</replaceable></arg></arg>
- <arg>-s<arg choice=req><replaceable>cmd</replaceable></arg></arg>
- <arg choice=req><replaceable>command</replaceable></arg>
+ <arg>-c<arg choice="req"><replaceable>file</replaceable></arg></arg>
+ <arg>-s<arg choice="req"><replaceable>cmd</replaceable></arg></arg>
+ <arg choice="req"><replaceable>command</replaceable></arg>
<group>
- <arg choice=plain>all</arg>
- <arg choice=plain rep=repeat><replaceable>resource</replaceable></arg>
+ <arg choice="plain">all</arg>
+ <arg choice="plain" rep="repeat"><replaceable>resource</replaceable></arg>
</group>
</cmdsynopsis>
</refsynopsisdiv>
@@ -175,6 +175,12 @@
</para></listitem>
</varlistentry>
<varlistentry>
+ <term>cstate</term>
+ <listitem><para>
+ Shows the current connection status of the devices.
+ </para></listitem>
+ </varlistentry>
+ <varlistentry>
<term>dump</term>
<listitem><para>
Just parse the configuration file and dump it to stdout. Might
Modified: trunk/documentation/drbdsetup.sgml
===================================================================
--- trunk/documentation/drbdsetup.sgml 2004-08-26 11:31:17 UTC (rev 1505)
+++ trunk/documentation/drbdsetup.sgml 2004-08-26 13:22:23 UTC (rev 1506)
@@ -109,6 +109,16 @@
<cmdsynopsis>
<command>drbdsetup</command>
<arg choice="req"><replaceable>device</replaceable></arg>
+ <arg choice="req">state</arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>drbdsetup</command>
+ <arg choice="req"><replaceable>device</replaceable></arg>
+ <arg choice="req">cstate</arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>drbdsetup</command>
+ <arg choice="req"><replaceable>device</replaceable></arg>
<arg choice="req">resize</arg>
<arg>-d<arg choice="req"><replaceable>size</replaceable></arg></arg>
</cmdsynopsis>
@@ -557,6 +567,13 @@
</para>
</refsect2>
<refsect2>
+ <title>cstate</title>
+ <para>
+ Shows the current connection states of the
+ <replaceable>device</replaceable>.
+ </para>
+ </refsect2>
+ <refsect2>
<title>resize</title>
<para>
This causes DRBD to reexamine the size of the
Modified: trunk/user/drbdadm_main.c
===================================================================
--- trunk/user/drbdadm_main.c 2004-08-26 11:31:17 UTC (rev 1505)
+++ trunk/user/drbdadm_main.c 2004-08-26 13:22:23 UTC (rev 1506)
@@ -128,6 +128,7 @@
{ "adjust", adm_adjust, 0 ,1,1 },
{ "wait_connect", adm_wait_c, 0 ,1,1 },
{ "state", adm_generic_s,"state" ,1,1 },
+ { "cstate", adm_generic_s,"cstate" ,1,1 },
{ "dump", adm_dump, 0 ,1,1 },
{ "wait_con_int", adm_wait_ci, 0 ,1,0 },
{ "sh-resources", sh_resources,0 ,0,0 },
Modified: trunk/user/drbdsetup.c
===================================================================
--- trunk/user/drbdsetup.c 2004-08-26 11:31:17 UTC (rev 1505)
+++ trunk/user/drbdsetup.c 2004-08-26 13:22:23 UTC (rev 1506)
@@ -113,6 +113,7 @@
int cmd_syncer(int drbd_fd,char** argv,int argc,struct option *options);
int cmd_detach(int drbd_fd,char** argv,int argc,struct option *options);
int cmd_state(int drbd_fd,char** argv,int argc,struct option *options);
+int cmd_cstate(int drbd_fd,char** argv,int argc,struct option *options);
struct drbd_cmd commands[] = {
{"primary", cmd_primary, 0,
@@ -171,6 +172,7 @@
{ 0, 0, 0, 0 } } },
{"disconnect", cmd_disconnect, 0, 0, },
{"state", cmd_state, 0, 0, },
+ {"cstate", cmd_cstate, 0, 0, },
{"show", cmd_show, 0, 0, }
};
@@ -1272,6 +1274,49 @@
return 0;
}
+int cmd_cstate(int drbd_fd,char** argv,int argc,struct option *options)
+{
+ static const char *cstate_names[] = {
+ [Unconfigured] = "Unconfigured",
+ [StandAlone] = "StandAlone",
+ [Unconnected] = "Unconnected",
+ [Timeout] = "Timeout",
+ [BrokenPipe] = "BrokenPipe",
+ [NetworkFailure] = "NetworkFailure",
+ [WFConnection] = "WFConnection",
+ [WFReportParams] = "WFReportParams",
+ [Connected] = "Connected",
+ [SkippedSyncS] = "SkippedSyncS",
+ [SkippedSyncT] = "SkippedSyncT",
+ [WFBitMapS] = "WFBitMapS",
+ [WFBitMapT] = "WFBitMapT",
+ [SyncSource] = "SyncSource",
+ [SyncTarget] = "SyncTarget",
+ [PausedSyncS] = "PausedSyncS",
+ [PausedSyncT] = "PausedSyncT"
+ };
+
+ struct ioctl_get_config cn;
+ int err;
+
+ err=ioctl(drbd_fd,DRBD_IOCTL_GET_CONFIG,&cn);
+ if(err)
+ {
+ PERROR("ioctl(,GET_CONFIG,) failed");
+ return 20;
+ }
+
+ if( cn.cstate < StandAlone )
+ {
+ printf("Not configured\n");
+ return 0;
+ }
+
+ printf("%s\n",cstate_names[cn.cstate]);
+
+ return 0;
+}
+
int main(int argc, char** argv)
{
int drbd_fd,i;
More information about the drbd-cvs
mailing list