From owner-svn-src-projects@freebsd.org Sun Aug 5 20:03:06 2018 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6E218105C590 for ; Sun, 5 Aug 2018 20:03:06 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2473B757A2; Sun, 5 Aug 2018 20:03:06 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E1B1A22DEB; Sun, 5 Aug 2018 20:03:05 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w75K35E0038503; Sun, 5 Aug 2018 20:03:05 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w75K35ex038502; Sun, 5 Aug 2018 20:03:05 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201808052003.w75K35ex038502@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 5 Aug 2018 20:03:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r337359 - projects/bectl/sbin/bectl X-SVN-Group: projects X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: projects/bectl/sbin/bectl X-SVN-Commit-Revision: 337359 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Aug 2018 20:03:06 -0000 Author: kevans Date: Sun Aug 5 20:03:05 2018 New Revision: 337359 URL: https://svnweb.freebsd.org/changeset/base/337359 Log: bectl(8): Some light cleanup and commenting Modified: projects/bectl/sbin/bectl/bectl.c Modified: projects/bectl/sbin/bectl/bectl.c ============================================================================== --- projects/bectl/sbin/bectl/bectl.c Sun Aug 5 19:38:56 2018 (r337358) +++ projects/bectl/sbin/bectl/bectl.c Sun Aug 5 20:03:05 2018 (r337359) @@ -462,6 +462,7 @@ static void print_padding(const char *fval, int colsz, struct printc *pc) { + /* -H flag handling; all delimiters/padding are a single tab */ if (pc->script_fmt) { printf("\t"); return; @@ -484,6 +485,7 @@ dataset_space(const char *oname) if (dsname == NULL) return (0); + /* Truncate snapshot to dataset name, as needed */ if ((sep = strchr(dsname, '@')) != NULL) *sep = '\0'; @@ -552,6 +554,12 @@ print_info(const char *name, nvlist_t *dsprops, struct if (dsname == NULL) /* XXX TODO: Error? */ return; + /* + * Whether we're dealing with -a or -s, we'll always print the + * dataset name/information followed by its origin. For -s, we + * additionally iterate through all snapshots of this boot + * environment and also print their information. + */ pc->current_indent += INDENT_INCREMENT; print_info(dsname, dsprops, pc); pc->current_indent += INDENT_INCREMENT; @@ -594,16 +602,23 @@ print_info(const char *name, nvlist_t *dsprops, struct } oname = get_origin_props(dsprops, &originprops); - if (nvlist_lookup_string(dsprops, "used", &propstr) == 0) { + /* + * The space used column is some composition of: + * - The "used" property of the dataset + * - The "used" property of the origin snapshot (not -a or -s) + * - The "used" property of the origin dataset (-D flag only) + * + * The -D flag is ignored if -a or -s are specified. + */ space = strtoull(propstr, NULL, 10); - if (!pc->show_all_datasets && originprops != NULL && + if (!pc->show_all_datasets && !pc->show_snaps && + originprops != NULL && nvlist_lookup_string(originprops, "used", &propstr) == 0) space += strtoull(propstr, NULL, 10); - if (!pc->show_all_datasets && pc->show_space && oname != NULL) - /* Get the used space of the origin's dataset, too. */ + if (pc->show_space && oname != NULL) space += dataset_space(oname); /* Alas, there's more to it,. */ @@ -611,7 +626,7 @@ print_info(const char *name, nvlist_t *dsprops, struct printf("%s", buf); print_padding(buf, pc->space_colsz, pc); } else { - printf("%s", "-"); + printf("-"); print_padding("-", pc->space_colsz, pc); } @@ -723,6 +738,9 @@ bectl_cmd_list(int argc, char *argv[]) return (1); } + /* Force -D off if either -a or -s are specified */ + if (pc.show_all_datasets || pc.show_snaps) + pc.show_space = false; if (!pc.script_fmt) print_headers(props, &pc); /* Do a first pass to print active and next active first */