Project

General

Profile

Submit #2600 » 0002-df-hi-prints-inodes-count-human-readable.patch

rolinh, 10/25/2013 12:02 AM

View differences:

bin/df/df.1
.\" $FreeBSD: src/bin/df/df.1,v 1.18.2.9 2003/05/07 23:56:14 trhodes Exp $
.\" $DragonFly: src/bin/df/df.1,v 1.3 2006/02/17 19:33:30 swildner Exp $
.\"
.Dd June 10, 2009
.Dd October 25, 2013
.Dt DF 1
.Os
.Sh NAME
......
Gigabyte, Terabyte and Petabyte in order to reduce the number of
digits to four or fewer using base 2 for sizes.
.It Fl i
Include statistics on the number of free inodes.
Include statistics on the number of free and used inodes.
In conjunction with the
.Fl h
or
.Fl H
options, the number of inodes is scaled by powers of 1000.
.It Fl k
Use 1024-byte (1-Kbyte) blocks rather than the default. Note that
this overrides the
bin/df/df.c
}
/*
* 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);
printf(" %5s", buf);
}
/*
* Convert statfs returned filesystem size into BLOCKSIZE units.
* Attempts to avoid overflow for large filesystems.
*/
......
if (iflag) {
inodes = vsfsp->f_files;
used = inodes - vsfsp->f_ffree;
printf(" %*jd %*jd %4.0f%% ", mwp->iused, (intmax_t)used,
mwp->ifree, (intmax_t)vsfsp->f_ffree, inodes == 0 ? 100.0 :
if (hflag) {
printf(" ");
prthumanvalinode(used);
prthumanvalinode(vsfsp->f_ffree);
} else {
printf(" %*jd %*jd", mwp->iused, (intmax_t)used,
mwp->ifree, (intmax_t)vsfsp->f_ffree);
}
printf(" %4.0f%% ", inodes == 0 ? 100.0 :
(double)used / (double)inodes * 100.0);
} else
printf(" ");
(2-2/4)