Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Aug 2020 00:09:40 +0000 (UTC)
From:      Robert Wing <rew@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r364369 - head/sbin/bectl
Message-ID:  <202008190009.07J09eQM061647@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rew
Date: Wed Aug 19 00:09:39 2020
New Revision: 364369
URL: https://svnweb.freebsd.org/changeset/base/364369

Log:
  bectl(8): Fix output of `bectl list` for the 'Mountpoint' column.
  
  Currently, the output of `bectl list` doesn't align the 'Mountpoint' column
  correctly when the 'mounted' property of a boot environment dataset is longer
  than the default column width.
  
  Set the 'Mountpoint' column width to the boot environment dataset with the
  longest 'mounted' property or to the default width, whichever is greater.
  
  PR:             241064
  Reported by:	vermaden@interia.pl
  Reviewed by:    kevans (mentor)
  Approved by:    kevans (mentor)
  MFC after:      1 week
  Differential Revision:	https://reviews.freebsd.org/D26048

Modified:
  head/sbin/bectl/bectl_list.c

Modified: head/sbin/bectl/bectl_list.c
==============================================================================
--- head/sbin/bectl/bectl_list.c	Tue Aug 18 22:46:46 2020	(r364368)
+++ head/sbin/bectl/bectl_list.c	Wed Aug 19 00:09:39 2020	(r364369)
@@ -292,19 +292,23 @@ print_headers(nvlist_t *props, struct printc *pc)
 	nvpair_t *cur;
 	nvlist_t *dsprops;
 	char *propstr;
-	size_t be_maxcol;
+	size_t be_maxcol, mount_colsz;
 
 	if (pc->show_all_datasets || pc->show_snaps)
 		chosen_be_header = HEADER_BEPLUS;
 	else
 		chosen_be_header = HEADER_BE;
 	be_maxcol = strlen(chosen_be_header);
+	mount_colsz = strlen(HEADER_MOUNT);
 	for (cur = nvlist_next_nvpair(props, NULL); cur != NULL;
 	    cur = nvlist_next_nvpair(props, cur)) {
 		be_maxcol = MAX(be_maxcol, strlen(nvpair_name(cur)));
+		nvpair_value_nvlist(cur, &dsprops);
+
+		if (nvlist_lookup_string(dsprops, "mounted", &propstr) == 0)
+			mount_colsz = MAX(mount_colsz, strlen(propstr));
 		if (!pc->show_all_datasets && !pc->show_snaps)
 			continue;
-		nvpair_value_nvlist(cur, &dsprops);
 		if (nvlist_lookup_string(dsprops, "dataset", &propstr) != 0)
 			continue;
 		be_maxcol = MAX(be_maxcol, strlen(propstr) + INDENT_INCREMENT);
@@ -316,10 +320,10 @@ print_headers(nvlist_t *props, struct printc *pc)
 
 	pc->be_colsz = be_maxcol;
 	pc->active_colsz_def = strlen(HEADER_ACTIVE);
-	pc->mount_colsz = strlen(HEADER_MOUNT);
+	pc->mount_colsz = mount_colsz;
 	pc->space_colsz = strlen(HEADER_SPACE);
-	printf("%*s %s %s %s %s\n", -pc->be_colsz, chosen_be_header,
-	    HEADER_ACTIVE, HEADER_MOUNT, HEADER_SPACE, HEADER_CREATED);
+	printf("%*s %s %*s %s %s\n", -pc->be_colsz, chosen_be_header,
+	    HEADER_ACTIVE, -pc->mount_colsz, HEADER_MOUNT, HEADER_SPACE, HEADER_CREATED);
 
 	/*
 	 * All other invocations in which we aren't using the default header



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008190009.07J09eQM061647>