mirror_zfs/cmd/zpool
Pawel Jakub Dawidek 5137c132a5
zpool import output is not formated properly.
The 'zpool status' output assumes that the longest prefix is six
character long plus colon plus space, eg. 'status: ', 'action: '
or 'config: ' (so eight in total). This works well even when we have
messages that requires more than one line, as '\t' is exactly eight
characters, just like the longest prefix.

The 'zpool import' output is a bit different, as it may display the
comment pool property, then the longest prefix is 'comment: ', which is
nine characters long, not eight.
All the prefixes were given an extra space in front, but:
- 'status: ' did not get an extra space.
- Messages that require more than one line should use nine spaces of
  indentation, not eight.
- The extra space in front looks redundant if there is no comment
  property set on the given pool.

Fix it by adding an extra space to all prefixes, but only if the comment
property is defined. Also, when we need to continue the message in a new
line, use '\t ' for indentation.

While here, apply small corrections to a couple messages.

Before:

   pool: tank
     id: 7412636063178848859
  state: ONLINE
status: Some supported features are not enabled on the pool.
	(Note that they may be intentionally disabled if the
	'compatibility' property is set.)
 action: The pool can be imported using its name or numeric identif[...]
	some features will not be available without an explicit 'zp[...]
comment: Example comment.
 config:

	bclone      ONLINE
	  ada0      ONLINE

After:

  pool: tank
    id: 10180960571062436759
 state: ONLINE
status: Some supported features are not enabled on the pool.
	(Note that they may be intentionally disabled if the
	'compatibility' property is set.)
action: The pool can be imported using its name or numeric identifi[...]
	some features will not be available without an explicit 'zp[...]
config:

	tank        ONLINE
	  ada3      ONLINE

   pool: dozer
     id: 11028319538368222579
  state: ONLINE
 status: Some supported features are not enabled on the pool.
	 (Note that they may be intentionally disabled if the
	 'compatibility' property is set.)
 action: The pool can be imported using its name or numeric identif[...]
	 some features will not be available without an explicit 'z[...]
comment: Example comment.
 config:

	dozer       ONLINE
	  ada1      ONLINE

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Pawel Dawidek <pawel@dawidek.net>
Closes #16128
2024-05-29 13:34:59 -07:00
..
compatibility.d ZTS: Test for all known zpool feature sets 2023-11-09 10:58:23 -08:00
os GCC: Fixes for gcc 14 on Fedora 40 2024-04-29 11:31:50 -07:00
zpool.d zed: misc vdev_enc_sysfs_path fixes 2023-11-07 09:09:24 -08:00
Makefile.am Add compatibility symlinks for FreeBSD 12.{3,4} and 13.{0,1,2} 2023-05-26 15:37:15 -07:00
zpool_iter.c zpool: Add slot power control, print power status 2023-12-21 10:53:16 -08:00
zpool_main.c zpool import output is not formated properly. 2024-05-29 13:34:59 -07:00
zpool_util.c Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
zpool_util.h zpool: Add slot power control, print power status 2023-12-21 10:53:16 -08:00
zpool_vdev.c zed: misc vdev_enc_sysfs_path fixes 2023-11-07 09:09:24 -08:00