From owner-svn-src-stable-8@FreeBSD.ORG Fri Jul 5 08:17:49 2013 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 6B11A4CE; Fri, 5 Jul 2013 08:17:49 +0000 (UTC) (envelope-from marck@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 5D38A1A1F; Fri, 5 Jul 2013 08:17:49 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r658HnAk048160; Fri, 5 Jul 2013 08:17:49 GMT (envelope-from marck@svn.freebsd.org) Received: (from marck@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r658Hm0c048157; Fri, 5 Jul 2013 08:17:48 GMT (envelope-from marck@svn.freebsd.org) Message-Id: <201307050817.r658Hm0c048157@svn.freebsd.org> From: Dmitry Morozovsky Date: Fri, 5 Jul 2013 08:17:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r252777 - in stable/8: . sbin/hastctl X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jul 2013 08:17:49 -0000 Author: marck (doc committer) Date: Fri Jul 5 08:17:48 2013 New Revision: 252777 URL: http://svnweb.freebsd.org/changeset/base/252777 Log: Finish MFC of r248291,249741: Change 'status' command to produce one-line easy-parseable output. Approved by: trociny Modified: stable/8/UPDATING stable/8/sbin/hastctl/hastctl.8 stable/8/sbin/hastctl/hastctl.c Directory Properties: stable/8/sbin/hastctl/ (props changed) Modified: stable/8/UPDATING ============================================================================== --- stable/8/UPDATING Fri Jul 5 08:16:40 2013 (r252776) +++ stable/8/UPDATING Fri Jul 5 08:17:48 2013 (r252777) @@ -15,6 +15,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8. debugging tools present in HEAD were left in place because sun4v support still needs work to become production ready. +20130705: + hastctl(8)'s `status' command output changed to terse one-liner format. + Scripts using this should switch to `list' command or be rewritten. + 20130624: Added ZFS TRIM support which is enabled by default. To disable ZFS TRIM support set vfs.zfs.trim.enabled=0 in loader.conf. Modified: stable/8/sbin/hastctl/hastctl.8 ============================================================================== --- stable/8/sbin/hastctl/hastctl.8 Fri Jul 5 08:16:40 2013 (r252776) +++ stable/8/sbin/hastctl/hastctl.8 Fri Jul 5 08:17:48 2013 (r252777) @@ -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 Modified: stable/8/sbin/hastctl/hastctl.c ============================================================================== --- stable/8/sbin/hastctl/hastctl.c Fri Jul 5 08:16:40 2013 (r252776) +++ stable/8/sbin/hastctl/hastctl.c Fri Jul 5 08:17:48 2013 (r252777) @@ -291,7 +291,7 @@ control_set_role(struct nv *nv, const ch } 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;