Home | History | Annotate | Download | only in df
History log of /src/bin/df/df.c
RevisionDateAuthorComments
 1.104  06-Oct-2024  christos PR/58718: Christof Meerwald: "total files" and "free files" values swapped
in df -G output
 1.103  03-Aug-2024  kre Add -M and -q options to df(1).

-q suppresses warning output (rather than redirecting stderr, which
also buries error messages, which -q does not).

-M requires each arg given to be the name of a mount point, and
issues a warning, and ignores the arg, if it is not. This allows
scripts (etc) to have a whole list of places for which to produce df
output, while only listing the ones that are actually mounted (rather
than simply listing the filesystem containing the mount point instead -
perhaps several times). (If there are no args, -M is a no-op).

If the options aren't given, nothing alters.
 1.102  18-Dec-2023  kre Correctly compute the "Filesystem" column with when using -W
(that added "NAME=" occupies space!)

XXX pullup -10
 1.101  09-Aug-2022  wiz branches: 1.101.2;
Sync usage with man page.
 1.100  08-Aug-2022  kre Add 4 new flags:
-b (from FreeBSD) - set blocksize to blocks (512 bytes)
(overrides a contrary setting in BLOCKSIZE)
-H (from FreeBSD and Linux): -h using SI units (powers of 10). Ugh.
-N suppress the header line (except with -P which requires it).
-f show only free space (or inodes) in a minimal format (implies -N)
(that is, with one file[system] specified, print 1 number only)
With -c, show only the total.
Intended to be useful for scripting (aka, I needed it.)

While here, improve the usage message (group options where they apply,
there is no reason, for example, that -g should be shown differently
to -k -m ..., and those options aren't at all useful with -G)

Update the man page to match.
 1.99  29-Nov-2021  simonb Set totals.f_frsize to DEV_BSIZE instead of totals.f_bsize so that
addstat() uses an initialised value for total size calculations.
Fixes core dump for "df -c".
 1.98  03-Jan-2021  ginsbach df: add grand total option

Add a grand total option, -c, similar to the du(1) -c option. Adapted from
the same option (-c) in FreeBSD df(1).
 1.97  21-Aug-2020  ryo - Bump Size/Used/Avail from 10 to 12, and iUsed/iAvail from 8 to 10 for double-digit terabyte storage.
- set the field width to the optimal, if "-h" is specified.
- if blocksize is greater than M or G, reduce the size field width.
 1.96  21-Aug-2020  ryo field width of blocksize and inode can be changed by #define
 1.95  22-Sep-2019  christos Add a new member to struct vfsstat and grow the unused members
The new member is caled f_mntfromlabel and it is the dkw_wname
of the corresponding wedge. This is now used by df -W to display
the mountpoint name as NAME=
 1.94  18-Sep-2019  christos Print the wedge name with -W instead of mntfrom
 1.93  26-Aug-2018  sevan -G cannot be specified alongside -i or -P.

Heads up by <leot>
 1.92  05-Mar-2016  kamil branches: 1.92.8; 1.92.14; 1.92.16;
Correct display of df(1) with the -i parameter

Now the "Mounted on" column should be aligned with /entries.

Patch by Michal Mazurek.
 1.91  12-Nov-2015  christos PR/50422: Robert Elz: df -G prints the wrong value for fragsize (+FIX)
For df -G, print the block and fragment size instead of the iosize
and the blocksize. If we need to print the iosize, it should be done
in a different field. Nevertheless printing the blocksize in the fragment
size field is just wrong.
XXX: pullup-6, pullup-7
 1.90  07-Jan-2012  christos use strspct.
 1.89  29-Aug-2011  gson branches: 1.89.2;
Use the same column spacing for the -h output as with the normal output,
as the same header line format is used in both cases and it can't line
up correctly with both of them otherwise.
 1.88  29-Aug-2011  enami No need to print internal state once debug is done.
 1.87  28-Aug-2011  christos - static/__dead
- use strpct from libutil
- fix off by one in format
 1.86  06-Jun-2009  mlelstv block numbers are measured in f_frsize units. Make -P option
use this instead of f_bsize. Also account for reserved blocks
like normal non-P output.
Fixes PR bin/41541.
 1.85  25-Jan-2009  lukem sign-compare fix for amd64
 1.84  18-Jan-2009  lukem fix -Wsign-compare issues
 1.83  20-Jul-2008  lukem branches: 1.83.4; 1.83.8;
Remove the \n and tabs from the __COPYRIGHT() strings.
 1.82  26-May-2008  christos PR/38755: murray armfield: /bin posix programs missing setprogname and/or
setlocale
 1.81  04-Mar-2008  christos branches: 1.81.2; 1.81.4;
do the -g -G swap for real.
 1.80  04-Mar-2008  christos PR/36817: Zafer Aydogan: Don't use -g to implement the same named option
in solaris to display statvfs output, use -G instead. I researched this
and all other implementations except Solaris (OS/X, FreeBSD, us before June
24, 2007) use -g to signify gigabytes. So revert to that.
PR/38154: YAMAMOTO Takashi: df -P doesn't work without -k. Fix from Anon Ymous
together with passing lint, and exiting with the right values.
 1.79  04-Mar-2008  yamt restore whitespace between 'Filesystem' and 'blocks'.
 1.78  22-Dec-2007  yamt branches: 1.78.2;
prtstat: PRIdMAX -> jd as suggested by Joerg Sonnenberger.
 1.77  21-Dec-2007  yamt don't cast 64bit values to u_long.
 1.76  17-Jul-2007  christos branches: 1.76.4;
kill MFSNAMELEN
 1.75  16-Jul-2007  christos Fix '-Ph' segfault; from Greg Woods
 1.74  03-Jul-2007  christos spacing fixes from Geoff Wing
 1.73  24-Jun-2007  christos PR/36541: Greg A. Woods: fix -P option, and add solaris -g option.
 1.72  04-Sep-2006  christos fix formatting of df -h; from Zafer.
 1.71  21-Aug-2006  christos -h and -[mgk] are mutually exclusive. Only use the last specified. [from zafer]
Use one variable instead of 3 flags to hold the scale, so that we don't have
to reset each flag.
 1.70  17-Mar-2006  rumble branches: 1.70.2;
Handle malloc returning NULL.
 1.69  13-Jan-2006  elad PR/23688: don't say we're printing in 1k-blocks if -h was also specified.
 1.68  26-Jun-2005  christos sprinkle a little const, and now everything compiles with WARNS=3
 1.67  31-Dec-2004  augustss Use the same width (9) for both the Used and Avail columns.
 1.66  17-Jul-2004  enami Drop LSBs when denominator is big.
 1.65  07-Jul-2004  enami Remove now unnecesary/incorrect cast.
 1.64  07-Jul-2004  enami - Remove unnecessary empty line.
- Wrap long line.
 1.63  04-Jul-2004  martin Available block count may be negative - so make the calculation signed.
This avoids output like:
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/wd1a 11799 11276 9223372036854775741 100% /boot
 1.62  21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.61  26-Mar-2004  enami Combine two printf()s back to one. There was a reason to split in my
old patch but no reason to do so in the final version.
 1.60  26-Mar-2004  enami Prevent sign extension for positive value, and f_bavail if it is considered
as positive value.
 1.59  26-Mar-2004  enami Fix an output of df -h when the value is negative; we need to provide
space for minus sign.
 1.58  26-Mar-2004  enami No need to reference through a pointer; just refer the array of
character directly.
 1.57  26-Mar-2004  enami Don't put space before close paren.
 1.56  07-Mar-2004  enami Use signed 64bit integer type instead of unsigned long long
since f_bavail may be negative.
 1.55  02-Mar-2004  enami Backout recent undocumented change to keep an output same as before.
 1.54  02-Mar-2004  christos fix compilation on LP64 systems.
 1.53  02-Mar-2004  itojun cast to unsigned long long before computing to avoid overflow
 1.52  02-Mar-2004  itojun use unsigned long long to print block count.
 1.51  05-Jan-2004  jmmv Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.
 1.50  07-Dec-2003  perry Some file systems, like FAT, have no inodes in the ffs sense and don't
run out of inodes. df -i was saying, however, that such file systems
had 100% of their inodes in use, which would do things like trigger
alarms in scripts looking for file systems that have run out.

Instead, say 0% are in use, which although not strictly true is at
least less wrong, fixes scripts and is less worrying in nightly reports.
 1.49  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22249, verified by myself.
 1.48  12-Jul-2003  simonb Bump ifree/iused field width.
 1.47  18-Apr-2003  grant change -G arg to -g.

-G was chosen as SuSv2 specified -g was already used in ls(1), but ls
has no blocksize options like df/du, so this was redundant.

bump date in man page.
 1.46  16-Apr-2003  grant add -G argument for output in gigabytes.

ok'd by perry@, mrg@
 1.45  16-Apr-2003  grant sync usage args with reality.
 1.44  26-Sep-2002  provos human-readable output via -h flag. output matches Linux and other BSDs.
partly from kstailey@openbsd.org. approved itojun and perry.
 1.43  02-Aug-2002  soren Following FreeBSD's example, remove the old pre-statfs(2) code for
examining FFS filesystems directly. This also gets rid of df(1)'s
setgid operator bit.
 1.42  11-Oct-2001  christos branches: 1.42.2;
if -a is not given, we need to walk the filesystem list to check the
flags in order to get the correct count (from enami)
 1.41  11-Oct-2001  enami KNF.
 1.40  20-Feb-2001  cgd use getprogname()
 1.39  01-Feb-2001  tsutsui Adjust output column in printf().
 1.38  07-Jan-2001  christos eliminate nested extern
 1.37  04-Jan-2001  lukem use more standard %ll_ in favour of %q_
 1.36  30-Dec-2000  hubertf Add -m option, similar to -k, but display output in 1024*1024 byte units.

Patch submitted by Chris Pinnock <C.J.E.Pinnock@qmw.ac.uk> in PR 11849,
adjusted for NetBSD-current by me.
 1.35  15-Oct-2000  kleink Support the 1003.2-92 -P flag for a `portable output format'; based on
Ben Harris' patch in standards/11208 but extended about output alignment
and documentation.
 1.34  26-Jun-2000  christos Add -a flag now that we have support for MNT_IGNORE
 1.33  24-Sep-1999  hubertf Fix overflow in df on big partitions' raw device.
Supplied by Greg Oster, problem noted in OpenBSD PR#924.
 1.32  27-Jul-1999  sommerfeld branches: 1.32.2;
Fix PR3474: df -t/df -l confused by stacked local mounts.
(Ross's patch in the PR appears to Just Work).
 1.31  08-Oct-1998  wsanchez branches: 1.31.2;
Cast args to strpct() u_long, as in the prototype, not ulong.
 1.30  28-Jul-1998  mycroft Delint.
 1.29  28-Jul-1998  mycroft Delint.
 1.28  27-Jul-1998  mycroft Use mkdtemp(3).
 1.27  04-Jul-1998  mrg minor KNF.
 1.26  08-Apr-1998  fair Fix PR#3590 - remove floating point calculation from df to avoid faulting
on machines that don't yet have complete FP support (e.g. MC68LC040)
 1.25  01-Mar-1998  fvdl Merge with Lite2 + local changes
 1.24  20-Jul-1997  thorpej - Use __COPYRIGHT() and __RCSID().
- Fix compiler warnings.
 1.23  11-Dec-1996  thorpej Make df(1) more liberal (and intelligent) about what it accepts
as arguments (for -t and -l flags, specifically).
From Hubert Feyrer <feyrer@rfhs8002.fh-regensburg.de>, PR #2869.
 1.22  28-Nov-1995  jtc merge in changes from 1.1 release branch
 1.21  11-Aug-1995  jtc branches: 1.21.2;
lose unused variable; PR #1297
 1.20  18-Jun-1995  cgd don't assume f_fstypename is larger than MFSNAMELEN or is nul-terminated
 1.19  21-Mar-1995  cgd convert to new RCS id conventions.
 1.18  30-Jan-1995  mycroft Use S_IS*().
 1.17  30-Jan-1995  mycroft Various:
* Redo `-t' handling like mount(8) and umount(8).
* Don't force a stat of every fs unless we need it.
* When using an explicit list, stat everything before printing anything, and
minimize the column width.
 1.16  13-Jan-1995  mycroft Add `-t' option from Matthew Green, hacked a bit by me.
 1.15  16-Sep-1994  mycroft Deal with large file systems, and clean up a bit.
 1.14  12-Jul-1994  glass fix typo
 1.13  13-Jun-1994  chopps branches: 1.13.2;
fixup for new fs code.
 1.12  17-May-1994  cgd copyright foo
 1.11  21-Apr-1994  cgd queue/struct changes
 1.10  14-Apr-1994  cgd fs type names will soon be strings
 1.9  11-Apr-1994  glass check return code. noticed while discovering a already fixed bug
 1.8  07-Apr-1994  cgd when you move a fn. call to another function, you shouldn't depend
on the locals' values it used to set...
 1.7  11-Mar-1994  mycroft Add `-l' option.
 1.6  25-Jan-1994  cgd new definition of getbsize
 1.5  06-Aug-1993  mycroft Incorporate new version using getbsize(), with -k flag added.
 1.4  01-Aug-1993  mycroft Add RCS identifiers.
 1.3  23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2  22-Mar-1993  cgd added rcs ids to all files
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3  09-Jan-1997  tls Import from 4.4BSD-Lite
 1.1.1.2  07-Sep-1995  jtc imported from 44lite2
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.13.2.1  16-Sep-1994  cgd From trunk, per mycroft.
 1.21.2.1  01-Nov-1995  jtc complete ufs -> ffs change (From John Kohl; PR #1403)
 1.31.2.1  26-Sep-1999  cgd pull up rev 1.32 from trunk (requested by hubertf):
Fix overflow on big partition's raw device.
 1.32.2.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.42.2.1  31-Aug-2003  tron Pull up revision 1.48 (requested by simonb in ticket #1378):
Bump ifree/iused field width.
 1.70.2.1  27-Aug-2006  riz Pull up following revision(s) (requested by christos in ticket #53):
bin/df/df.c: revision 1.71
bin/mv/mv.c: revision 1.36
bin/ls/ls.1: revision 1.61
bin/ls/ls.c: revision 1.60
-h and -[mgk] are mutually exclusive. Only use the last specified. [from zafer]
Use one variable instead of 3 flags to hold the scale, so that we don't have
to reset each flag.
from zafer: you can have either -k or -h but not both since it does not make
sense.
- detect buffer overflow.
- if we have a trailing slash, don't add another one.
 1.76.4.2  23-Mar-2008  matt sync with HEAD
 1.76.4.1  09-Jan-2008  matt sync with HEAD
 1.78.2.1  24-Mar-2008  keiichi sync with head.
 1.81.4.2  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.81.4.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.81.2.1  04-Jun-2008  yamt sync with head
 1.83.8.1  21-Apr-2010  matt sync to netbsd-5
 1.83.4.1  09-Jun-2009  snj Pull up following revision(s) (requested by mlelstv in ticket #797):
bin/df/df.c: revision 1.86
block numbers are measured in f_frsize units. Make -P option
use this instead of f_bsize. Also account for reserved blocks
like normal non-P output.
Fixes PR bin/41541.
 1.89.2.1  17-Apr-2012  yamt sync with head
 1.92.16.4  21-Apr-2020  martin Ooops, restore accidently removed files from merge mishap
 1.92.16.3  21-Apr-2020  martin Sync with HEAD
 1.92.16.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.92.16.1  10-Jun-2019  christos Sync with HEAD
 1.92.14.1  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.92.8.1  28-Aug-2018  martin Pull up following revision(s) (requested by sevan in ticket #992):

external/bsd/top/dist/top.1.in: revision 1.11
sbin/gpt/main.c: revision 1.12
sbin/amrctl/amrctl.c: revision 1.11
bin/df/df.c: revision 1.93
sbin/fsck_ext2fs/fsck_ext2fs.8: revision 1.21
sbin/fsck_ext2fs/main.c: revision 1.38
bin/ksh/ksh.Man: revision 1.26
bin/ln/ln.c: revision 1.40
bin/df/df.1: revision 1.48
bin/df/df.1: revision 1.49

Document the WCPU field.

Match SYNOPSIS with usage()

-G cannot be specified alongside -i or -P.
Heads up by <leot>

Add -l to SYNOPSIS

Update usage to include -w

Match sequence as per SYNOPSIS in manual

Remove reference to -c flag which was never implemented.

Remove references to -c flag which was never included.

Add the -T flag to usage()
 1.101.2.1  18-Dec-2023  martin Pull up following revision(s) (requested by kre in ticket #506):

bin/df/df.c: revision 1.102

Correctly compute the "Filesystem" column with when using -W
(that added "NAME=" occupies space!)

RSS XML Feed