summaryrefslogtreecommitdiffstats
path: root/bin/df
diff options
context:
space:
mode:
authorgrog <grog@FreeBSD.org>2012-11-16 03:33:34 +0000
committergrog <grog@FreeBSD.org>2012-11-16 03:33:34 +0000
commit5de282f23da3bf379edbf238f017a8d0682cc278 (patch)
treef4d2e82722242289392cb7b3e93430d388b6cb9f /bin/df
parent2a4b9075dfd29011c27d8771d1fc86677c04e9fd (diff)
downloadFreeBSD-src-5de282f23da3bf379edbf238f017a8d0682cc278.zip
FreeBSD-src-5de282f23da3bf379edbf238f017a8d0682cc278.tar.gz
Update man pages and clarify a number of options.
Rework block count calculations to work correctly with small "block" sizes. MFC after: 14 days
Diffstat (limited to 'bin/df')
-rw-r--r--bin/df/df.187
-rw-r--r--bin/df/df.c13
2 files changed, 65 insertions, 35 deletions
diff --git a/bin/df/df.1 b/bin/df/df.1
index 02a4f421..f107ad3 100644
--- a/bin/df/df.1
+++ b/bin/df/df.1
@@ -29,7 +29,7 @@
.\" @(#)df.1 8.3 (Berkeley) 5/8/95
.\" $FreeBSD$
.\"
-.Dd March 3, 2012
+.Dd November 16, 2012
.Dt DF 1
.Os
.Sh NAME
@@ -50,7 +50,8 @@ displays statistics about the amount of free disk space on the specified
or on the file system of which
.Ar file
is a part.
-Values are displayed in 512-byte per block counts.
+By default block counts are displayed with an assumed block size of
+512 bytes.
If neither a file or a file system operand is specified,
statistics for all mounted file systems are displayed
(subject to the
@@ -65,46 +66,54 @@ Show all mount points, including those that were mounted with the
flag.
This is implied for file systems specified on the command line.
.It Fl b
-Use 512-byte blocks rather than the default.
-This overrides the
+Explicitly use 512 byte blocks, overriding any
.Ev BLOCKSIZE
specification from the environment.
+This is the same as the
+.Fl P
+option.
+The
+.Fl k
+option overrides this option.
.It Fl c
Display a grand total.
.It Fl g
-Use 1073741824-byte (1-Gbyte) blocks rather than the default.
-This overrides the
+Use 1073741824 byte (1 Gibibyte) blocks rather than the default.
+This overrides any
.Ev BLOCKSIZE
specification from the environment.
.It Fl H
.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.
+Use unit suffixes: Byte, Kibibyte, Mebibyte, Gibibyte, Tebibyte and
+Pebibyte (based on powers of 1024) in order to reduce the number of
+digits to four or fewer.
.It Fl h
.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.
+Gigabyte, Terabyte and Petabyte (based on powers of 1000) in order to
+reduce the number of
+digits to four or fewer.
.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.
+Use 1024 byte (1 Kibibyte) blocks rather than the default.
This overrides the
-.Ev BLOCKSIZE
-specification from the environment and the
.Fl P
-option.
+option and any
+.Ev BLOCKSIZE
+specification from the environment.
.It Fl l
Only display information about locally-mounted file systems.
.It Fl m
-Use 1048576-byte (1-Mbyte) blocks rather than the default.
-This overrides the
+Use 1048576 byte (1 Mebibyte) blocks rather than the default.
+This overrides any
.Ev BLOCKSIZE
specification from the environment.
.It Fl n
@@ -117,10 +126,12 @@ When this option is specified,
will not request new statistics from the file systems, but will respond
with the possibly stale statistics that were previously obtained.
.It Fl P
-Use POSIX compliant output of 512-byte blocks rather than the default.
-This overrides the
+Explicitly use 512 byte blocks, overriding any
.Ev BLOCKSIZE
specification from the environment.
+This is the same as the
+.Fl b
+option.
The
.Fl k
option overrides this option.
@@ -160,9 +171,18 @@ option has no effect.
.Sh ENVIRONMENT
.Bl -tag -width BLOCKSIZE
.It Ev BLOCKSIZE
-If the environment variable
-.Ev BLOCKSIZE
-is set, the block counts will be displayed in units of that size block.
+Specifies the units in which to report block counts.
+This uses
+.Xr getbsize 3 ,
+which allows units of bytes or numbers scaled with the letters
+.Em k
+(for multiples of 1024 bytes),
+.Em m
+(for multiples of 1048576 bytes) or
+.Em g
+(for gibibytes).
+The allowed range is 512 bytes to 1 GB.
+If the value is outside, it will be set to the appropriate limit.
.El
.Sh SEE ALSO
.Xr lsvfs 1 ,
@@ -170,13 +190,12 @@ is set, the block counts will be displayed in units of that size block.
.Xr fstatfs 2 ,
.Xr getfsstat 2 ,
.Xr statfs 2 ,
+.Xr getbsize 3 ,
.Xr getmntinfo 3 ,
.Xr localeconv 3 ,
.Xr fstab 5 ,
.Xr mount 8 ,
-.Xr pstat 8 ,
-.Xr quot 8 ,
-.Xr swapinfo 8
+.Xr quot 8 .
.Sh STANDARDS
With the exception of most options,
the
@@ -200,3 +219,13 @@ flag is ignored if a file or file system is specified.
Also, if a mount
point is not accessible by the user, it is possible that the file system
information could be stale.
+.Pp
+The
+.Fl b
+and
+.Fl P
+options are identical.
+The former comes from the BSD tradition, and the latter is required
+for
+.St -p1003.1-2004
+conformity.
diff --git a/bin/df/df.c b/bin/df/df.c
index 851c758..3058da0 100644
--- a/bin/df/df.c
+++ b/bin/df/df.c
@@ -393,16 +393,11 @@ prthumanvalinode(int64_t bytes)
/*
* Convert statfs returned file system size into BLOCKSIZE units.
- * Attempts to avoid overflow for large file systems.
*/
static intmax_t
fsbtoblk(int64_t num, uint64_t fsbs, u_long bs)
{
-
- if (fsbs != 0 && fsbs < bs)
- return (num / (intmax_t)(bs / fsbs));
- else
- return (num * (intmax_t)(fsbs / bs));
+ return (num * (intmax_t) fsbs / bs);
}
/*
@@ -453,6 +448,12 @@ prtstat(struct statfs *sfsp, struct maxwidths *mwp)
}
(void)printf(" Mounted on\n");
}
+ /* Check for 0 block size. Can this happen? */
+ if (sfsp->f_bsize == 0) {
+ warnx ("File system %s does not have a block size, assuming 512.",
+ sfsp->f_mntonname);
+ sfsp->f_bsize = 512;
+ }
(void)printf("%-*s", mwp->mntfrom, sfsp->f_mntfromname);
if (Tflag)
(void)printf(" %-*s", mwp->fstype, sfsp->f_fstypename);
OpenPOWER on IntegriCloud