summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Morozovsky <marck@FreeBSD.org>2013-07-05 08:16:40 +0000
committerDmitry Morozovsky <marck@FreeBSD.org>2013-07-05 08:16:40 +0000
commita7f61995c371539837d33405956db1ddab42e5ba (patch)
tree069ab3e55efcd0c441763423c7cdf1744dec0931
parentb9b25059efebf1257c5c8a77d0e7bab18ccbc913 (diff)
downloadsrc-test2-a7f61995c371539837d33405956db1ddab42e5ba.tar.gz
src-test2-a7f61995c371539837d33405956db1ddab42e5ba.zip
Notes
-rw-r--r--UPDATING4
-rw-r--r--sbin/hastctl/hastctl.816
-rw-r--r--sbin/hastctl/hastctl.c41
3 files changed, 48 insertions, 13 deletions
diff --git a/UPDATING b/UPDATING
index 33c33b96b39f..9fab40eb7f62 100644
--- a/UPDATING
+++ b/UPDATING
@@ -11,6 +11,10 @@ handbook:
Items affecting the ports and packages system can be found in
/usr/ports/UPDATING. Please read that file before running portupgrade.
+20130705:
+ hastctl(8)'s `status' command output changed to terse one-liner format.
+ Scripts using this should switch to `list' command or be rewritten.
+
20130618:
Fix a bug that allowed a tracing process (e.g. gdb) to write
to a memory-mapped file in the traced process's address space
diff --git a/sbin/hastctl/hastctl.8 b/sbin/hastctl/hastctl.8
index a457f2f3edde..986230573eb8 100644
--- a/sbin/hastctl/hastctl.8
+++ b/sbin/hastctl/hastctl.8
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 24, 2013
+.Dd July 5, 2013
.Dt HASTCTL 8
.Os
.Sh NAME
@@ -145,18 +145,10 @@ GEOM provider
will not be created on secondary node.
.El
.It Cm list
-.It Cm status
Present verbose status of the configured resources.
-For now, list and status commands are equivalent.
-In the near future the output of
-.Nm
-status command will change to more terse format.
-If you use `
-.Nm
-status' for parsing in your scripts, switch to `
-.Nm
-list'.
-
+.It Cm status
+Present terse (and more easy machine-parseable) status of the configured
+resources.
.It Cm dump
Dump metadata stored on local component for the configured resources.
.El
diff --git a/sbin/hastctl/hastctl.c b/sbin/hastctl/hastctl.c
index f48c8cf7affe..6fe55fa8411a 100644
--- a/sbin/hastctl/hastctl.c
+++ b/sbin/hastctl/hastctl.c
@@ -291,7 +291,7 @@ control_set_role(struct nv *nv, const char *newrole)
}
static int
-control_status(struct nv *nv)
+control_list(struct nv *nv)
{
unsigned int ii;
const char *str;
@@ -355,6 +355,43 @@ control_status(struct nv *nv)
return (ret);
}
+static int
+control_status(struct nv *nv)
+{
+ unsigned int ii;
+ const char *str;
+ int error, hprinted, ret;
+
+ hprinted = 0;
+ ret = 0;
+
+ for (ii = 0; ; ii++) {
+ str = nv_get_string(nv, "resource%u", ii);
+ if (str == NULL)
+ break;
+ if (!hprinted) {
+ printf("Name\tStatus\t Role\t\tComponents\n");
+ hprinted = 1;
+ }
+ printf("%s\t", str);
+ error = nv_get_int16(nv, "error%u", ii);
+ if (error != 0) {
+ if (ret == 0)
+ ret = error;
+ printf("ERR%d\n", error);
+ continue;
+ }
+ str = nv_get_string(nv, "status%u", ii);
+ printf("%-9s", (str != NULL) ? str : "-");
+ printf("%-15s", nv_get_string(nv, "role%u", ii));
+ printf("%s\t",
+ nv_get_string(nv, "localpath%u", ii));
+ printf("%s\n",
+ nv_get_string(nv, "remoteaddr%u", ii));
+ }
+ return (ret);
+}
+
int
main(int argc, char *argv[])
{
@@ -523,6 +560,8 @@ main(int argc, char *argv[])
error = control_set_role(nv, argv[0]);
break;
case CMD_LIST:
+ error = control_list(nv);
+ break;
case CMD_STATUS:
error = control_status(nv);
break;