forked from freebsd/freebsd-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MFV r325013,r325034: 640 number_to_scaled_string is duplicated in sev…
…eral commands illumos/illumos-gate@0a05512 illumos/illumos-gate@0a05512 https://www.illumos.org/issues/640 du(1), df(1m), ls(1), and swap(1m) all include a copy (it appears literally copied) of the 'number_to_scaled_string' function in their source. This should be moved to a shared library and all 4 commands should use this instead. FreeBSD note: of all libcmdutils functionality ZFS (and other illumos contrib code) currently uses only nicenum() function (which is similar to humanize_number but has some formatting differences). For this reason I decided to not port the whole library. As a result, nicenum.c from libcmdutils is compiled into libzfs and libzpool. This is a bit ugly, but works. If one day we are forced to create libillumos, then the file should be moved to that library. Reviewed by: Sebastian Wiedenroth <[email protected]> Reviewed by: Robert Mustacchi <[email protected]> Reviewed by: Yuri Pankov <[email protected]> Approved by: Dan McDonald <[email protected]> Author: Jason King <[email protected]> MFC after: 2 weeks
- Loading branch information
Showing
11 changed files
with
502 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
* Copyright (c) 2012 Martin Matuska <[email protected]>. All rights reserved. | ||
* Copyright (c) 2013 Steven Hartland. All rights reserved. | ||
* Copyright (c) 2014 Integros [integros.com] | ||
* Copyright 2017 Joyent, Inc. | ||
*/ | ||
|
||
/* | ||
|
@@ -125,6 +126,7 @@ | |
#include <errno.h> | ||
#include <sys/fs/zfs.h> | ||
#include <libnvpair.h> | ||
#include <libcmdutils.h> | ||
|
||
static int ztest_fd_data = -1; | ||
static int ztest_fd_rand = -1; | ||
|
@@ -556,12 +558,13 @@ usage(boolean_t requested) | |
{ | ||
const ztest_shared_opts_t *zo = &ztest_opts_defaults; | ||
|
||
char nice_vdev_size[10]; | ||
char nice_gang_bang[10]; | ||
char nice_vdev_size[NN_NUMBUF_SZ]; | ||
char nice_gang_bang[NN_NUMBUF_SZ]; | ||
FILE *fp = requested ? stdout : stderr; | ||
|
||
nicenum(zo->zo_vdev_size, nice_vdev_size); | ||
nicenum(zo->zo_metaslab_gang_bang, nice_gang_bang); | ||
nicenum(zo->zo_vdev_size, nice_vdev_size, sizeof (nice_vdev_size)); | ||
nicenum(zo->zo_metaslab_gang_bang, nice_gang_bang, | ||
sizeof (nice_gang_bang)); | ||
|
||
(void) fprintf(fp, "Usage: %s\n" | ||
"\t[-v vdevs (default: %llu)]\n" | ||
|
@@ -3158,10 +3161,10 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id) | |
old_class_space, new_class_space); | ||
|
||
if (ztest_opts.zo_verbose >= 5) { | ||
char oldnumbuf[6], newnumbuf[6]; | ||
char oldnumbuf[NN_NUMBUF_SZ], newnumbuf[NN_NUMBUF_SZ]; | ||
|
||
nicenum(old_class_space, oldnumbuf); | ||
nicenum(new_class_space, newnumbuf); | ||
nicenum(old_class_space, oldnumbuf, sizeof (oldnumbuf)); | ||
nicenum(new_class_space, newnumbuf, sizeof (newnumbuf)); | ||
(void) printf("%s grew from %s to %s\n", | ||
spa->spa_name, oldnumbuf, newnumbuf); | ||
} | ||
|
@@ -6204,7 +6207,7 @@ main(int argc, char **argv) | |
ztest_info_t *zi; | ||
ztest_shared_callstate_t *zc; | ||
char timebuf[100]; | ||
char numbuf[6]; | ||
char numbuf[NN_NUMBUF_SZ]; | ||
spa_t *spa; | ||
char *cmd; | ||
boolean_t hasalt; | ||
|
@@ -6341,7 +6344,7 @@ main(int argc, char **argv) | |
|
||
now = MIN(now, zs->zs_proc_stop); | ||
print_time(zs->zs_proc_stop - now, timebuf); | ||
nicenum(zs->zs_space, numbuf); | ||
nicenum(zs->zs_space, numbuf, sizeof (numbuf)); | ||
|
||
(void) printf("Pass %3d, %8s, %3llu ENOSPC, " | ||
"%4.1f%% of %5s used, %3.0f%% done, %8s to go\n", | ||
|
Oops, something went wrong.