Improve the mt(1) rblim display.

The granularity reported by READ BLOCK LIMITS is an exponent, not a
byte value.  So a granularity of 0 means 2^0, or 1 byte.  A
granularity of 1 means 2^1, or 2 bytes.

Print out the individual block limits on separate lines to improve
readability and avoid exceeding 80 columns.

usr.bin/mt/mt.c:
	Fix and improve the 'mt rblim' output.  Add a MT_PLURAL()
	macro so we can print "byte" or "bytes" as appropriate.

Sponsored by:	Spectra Logic
MFC after:	4 days
This commit is contained in:
Kenneth D. Merry 2015-03-18 20:54:54 +00:00
parent 74a177ac50
commit d788649d0c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=280231

View File

@ -119,6 +119,7 @@ __FBSDID("$FreeBSD$");
#ifndef MAX
#define MAX(a, b) (a > b) ? a : b
#endif
#define MT_PLURAL(a) (a == 1) ? "" : "s"
typedef enum {
MT_CMD_NONE = MTLOAD + 1,
@ -384,10 +385,16 @@ main(int argc, char *argv[])
if (ioctl(mtfd, MTIOCRBLIM, (caddr_t)&rblim) < 0)
err(2, "%s", tape);
(void)printf("%s: min blocksize %u bytes, "
"max blocksize %u bytes, granularity %u bytes\n",
(void)printf("%s:\n"
" min blocksize %u byte%s\n"
" max blocksize %u byte%s\n"
" granularity %u byte%s\n",
tape, rblim.min_block_length,
rblim.max_block_length, rblim.granularity);
MT_PLURAL(rblim.min_block_length),
rblim.max_block_length,
MT_PLURAL(rblim.max_block_length),
(1 << rblim.granularity),
MT_PLURAL((1 << rblim.granularity)));
exit(0);
/* NOTREACHED */
}