aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorSimon L. B. Nielsen <simon@FreeBSD.org>2009-08-19 21:33:09 +0000
committerSimon L. B. Nielsen <simon@FreeBSD.org>2009-08-19 21:33:09 +0000
commit1d93ce165c3e84bbe1f542f1bef8447760e89961 (patch)
tree861fc0c9af829074bfe0fd43897aaf4f4ddd75a5 /bin
parent49626c44e58de0ed7d949f454f9fff2779a4c6a7 (diff)
Notes
Diffstat (limited to 'bin')
-rw-r--r--bin/df/df.19
-rw-r--r--bin/df/df.c34
2 files changed, 37 insertions, 6 deletions
diff --git a/bin/df/df.1 b/bin/df/df.1
index 8cdff7d9a888..c2a9a9f48b59 100644
--- a/bin/df/df.1
+++ b/bin/df/df.1
@@ -78,15 +78,20 @@ this overrides the
.Ev BLOCKSIZE
specification from the environment.
.It Fl H
-"Human-readable" output.
+.Dq Human-readable
+output.
Use unit suffixes: Byte, Kilobyte, Megabyte,
Gigabyte, Terabyte and Petabyte in order to reduce the number of
digits to four or fewer using base 10 for sizes.
.It Fl h
-"Human-readable" output.
+.Dq Human-readable
+output.
Use unit suffixes: Byte, Kilobyte, Megabyte,
Gigabyte, Terabyte and Petabyte in order to reduce the number of
digits to four or fewer using base 2 for sizes.
+Inodes statistics, if enabled with
+.Fl i ,
+are always printed in base 10.
.It Fl i
Include statistics on the number of free inodes.
.It Fl k
diff --git a/bin/df/df.c b/bin/df/df.c
index f48c8c95e841..ad880dba83fb 100644
--- a/bin/df/df.c
+++ b/bin/df/df.c
@@ -365,6 +365,23 @@ prthumanval(int64_t bytes)
}
/*
+ * Print an inode count in "human-readable" format.
+ */
+static void
+prthumanvalinode(int64_t bytes)
+{
+ char buf[6];
+ int flags;
+
+ flags = HN_NOSPACE | HN_DECIMAL | HN_DIVISOR_1000;
+
+ humanize_number(buf, sizeof(buf) - (bytes < 0 ? 0 : 1),
+ bytes, "", HN_AUTOSCALE, flags);
+
+ (void)printf(" %5s", buf);
+}
+
+/*
* Convert statfs returned file system size into BLOCKSIZE units.
* Attempts to avoid overflow for large file systems.
*/
@@ -406,8 +423,10 @@ prtstat(struct statfs *sfsp, struct maxwidths *mwp)
mwp->mntfrom, "Filesystem", mwp->total, header,
mwp->used, "Used", mwp->avail, "Avail");
if (iflag) {
- mwp->iused = imax(mwp->iused, (int)strlen(" iused"));
- mwp->ifree = imax(mwp->ifree, (int)strlen("ifree"));
+ mwp->iused = imax(hflag ? 0 : mwp->iused,
+ (int)strlen(" iused"));
+ mwp->ifree = imax(hflag ? 0 : mwp->ifree,
+ (int)strlen("ifree"));
(void)printf(" %*s %*s %%iused",
mwp->iused - 2, "iused", mwp->ifree, "ifree");
}
@@ -431,8 +450,15 @@ prtstat(struct statfs *sfsp, struct maxwidths *mwp)
if (iflag) {
inodes = sfsp->f_files;
used = inodes - sfsp->f_ffree;
- (void)printf(" %*jd %*jd %4.0f%% ", mwp->iused, (intmax_t)used,
- mwp->ifree, (intmax_t)sfsp->f_ffree, inodes == 0 ? 100.0 :
+ if (hflag) {
+ (void)printf(" ");
+ prthumanvalinode(used);
+ prthumanvalinode(sfsp->f_ffree);
+ } else {
+ (void)printf(" %*jd %*jd", mwp->iused, (intmax_t)used,
+ mwp->ifree, (intmax_t)sfsp->f_ffree);
+ }
+ (void)printf(" %4.0f%% ", inodes == 0 ? 100.0 :
(double)used / (double)inodes * 100.0);
} else
(void)printf(" ");