History log of /freebsd-current/usr.bin/du/du.c
Revision Date Author Comments
# b2b8fa1a 28-Apr-2024 Nathan Huff <nhuff@acm.org>

Add libxo support to du

Convert du to use libxo enabling structured output.

[[ minor style fixes by imp ]]

Signed-off-by: Nathan Huff <nhuff@acm.org>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1145


# 0b8224d1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

Remove copyright strings ifdef'd out

We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).

Sponsored by: Netflix


# bdcbfde3 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.bin: Remove ancient SCCS tags.

Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 2dfa4b66 08-Dec-2020 Bryan Drewery <bdrewery@FreeBSD.org>

fts_read: Handle error from a NULL return better.

This is addressing cases such as fts_read(3) encountering an [EIO]
from fchdir(2) when FTS_NOCHDIR is not set. That would otherwise be
seen as a successful traversal in some of these cases while silently
discarding expected work.

As noted in r264201, fts_read() does not set errno to 0 on a successful
EOF so it needs to be set before calling it. Otherwise we might see
a random error from one of the iterations.

gzip is ignoring most errors and could be improved separately.

Reviewed by: vangyzen
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D27184


# 8a16b7a1 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

General further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.


# 476c601b 08-Aug-2017 Kyle Evans <kevans@FreeBSD.org>

du(1): Add --si option to display in terms of powers of 1000

Reviewed by: cem (earlier version), emaste
Approved by: emaste (mentor)
Differential Revision: https://reviews.freebsd.org/D11748


# 9bd154b8 11-Jun-2017 Enji Cooper <ngie@FreeBSD.org>

du(1): trivial whitespace cleanup

MFC after: 1 month


# fbbd9655 28-Feb-2017 Warner Losh <imp@FreeBSD.org>

Renumber copyright clause 4

Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96


# 28323add 08-Nov-2016 Bryan Drewery <bdrewery@FreeBSD.org>

Fix improper use of "its".

Sponsored by: Dell EMC Isilon


# 8c5a59ee 17-Feb-2015 Pedro F. Giffuni <pfg@FreeBSD.org>

du(1): replace malloc + memset with calloc.


# 0fafb093 26-Jul-2012 Sergey Kandaurov <pluknet@FreeBSD.org>

Document -g option in the usage string.


# 69739e8d 18-Jul-2012 Dag-Erling Smørgrav <des@FreeBSD.org>

Add -g (gigabyte) flag to complement -k (kilobyte) and -m (megabyte).

MFC after: 1 week


# 6530d2f2 17-Dec-2011 Jilles Tjoelker <jilles@FreeBSD.org>

du: Allow multiple -HLP options, the last one wins.

This matches 4.4BSD tradition and other utilities with these options and is
required by POSIX (POSIX does not specify -P, only -HL).

MFC after: 2 weeks


# 653fa521 08-Dec-2011 Glen Barber <gjb@FreeBSD.org>

Update du(1):

- Sort arguments alphabetically where appropriate
- '-B blocksize' is not mutually exclusive of '-h|-k|-m'
- Mention '-t' in synopsis
- Other wording improvements
- Update usage() output to reflect the new synopsis [1]
- Other miscellaneous improvements

PR: 162438
Submitted by: arundel
Reviewed by: Benjamin Kaduk (kaduk ! mit.edu), jhb[1] (original version)
MFC after: 1 week


# 66c5875a 08-Nov-2011 Ed Schouten <ed@FreeBSD.org>

Simplify getopt switch parsing.

Only one of these flags can be set. Just add them together and check the
value. Also, get rid of the listall variable. The code is already filled
with direct *flag-comparisons.

Obtained from: Alexander Best (though modified)


# d2aa301d 06-Nov-2011 Ed Schouten <ed@FreeBSD.org>

Add missing static keywords to du(1)


# da52b4ca 11-Dec-2010 Joel Dahl <joel@FreeBSD.org>

Remove the advertising clause from UCB copyrighted files in usr.bin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change

Also add $FreeBSD$ to a few files to keep svn happy.

Discussed with: imp, rwatson


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# f0cc075c 20-Jun-2010 Brian Somers <brian@FreeBSD.org>

Add a -t switch for masking output that's above or below certain thresholds.
This switch makes it a lot easier to locate problem areas when a process
is threatening to consume all of your disk space.

PR: 144192
Submitted by: gk
MFC after: 3 weeks


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# d1588599 29-Apr-2009 Warner Losh <imp@FreeBSD.org>

Report the next directory being scanned when a ^T is pressed (or any
SIGINFO). Provides some progress report for the impatient. This
won't report that we're blocking in our walk due to disk/network
problems, however. There's no really good way to report that
condition that I'm aware of...


# 246b6a6d 06-Nov-2008 Max Laier <mlaier@FreeBSD.org>

Restore (intmax_t) casts I lost during the last change & unbreak the build.


# fd543f27 06-Nov-2008 Max Laier <mlaier@FreeBSD.org>

Add two new options to du(1):
-A Display the apparent size instead of the disk usage. This can be
helpful when operating on compressed volumes or sparse files.

-B blocksize
Calculate block counts in blocksize byte blocks. This is differ-
ent from the -k, -m options or setting BLOCKSIZE and gives an
estimate of how much space the examined file hierachy would
require on a filesystem with the given blocksize. Unless in -A
mode, blocksize is rounded up to the next multiple of 512.

The former is similar to GNU's du(1) --apparent-size. The latter is
different from what GNU's du(1) -B does, which is equivalent to setting
BLOCKSIZE in our implementation and is rather pointless as it doesn't add
any real value (i.e. you can achieve the same with a simple awk-script).

No change in the normal output or processing.

Reviewed by: keramida@, Peter French
Otherwise silience from: freebsd-hackers@


# 0551897a 04-Nov-2008 Max Laier <mlaier@FreeBSD.org>

Declare functions and variables static and save a few byte. This is a
style(9)-change, too. Separate commit as it changes the object.


# 40850176 04-Nov-2008 Max Laier <mlaier@FreeBSD.org>

style(9): mostly avoiding line wrap by not indenting cases. No obj change.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# fe5628d3c 25-Feb-2008 Giorgos Keramidas <keramida@FreeBSD.org>

Implement from scratch a -l option for du(1), to match the same option
of the GNU utility. The default behavior of our original `du' is to
count hardlinked files only once for each invocation of the utility.
With the new -l option they count towards the final size every time
they are found.

PR: bin/117944
Submitted by: keramida
Reviewed by: des, obrien
MFC after: 2 weeks


# d4c16fe3 07-Nov-2007 Kevin Lo <kevlo@FreeBSD.org>

setenv(3) sets errno on failure, use warn() instead

Pointed out by: ru


# ee8f9739 06-Nov-2007 Kevin Lo <kevlo@FreeBSD.org>

Check return value for setenv()


# 2966d28c 03-Jul-2007 Sean Farley <scf@FreeBSD.org>

Significantly reduce the memory leak as noted in BUGS section for
setenv(3) by tracking the size of the memory allocated instead of using
strlen() on the current value.

Convert all calls to POSIX from historic BSD API:
- unsetenv returns an int.
- putenv takes a char * instead of const char *.
- putenv no longer makes a copy of the input string.
- errno is set appropriately for POSIX. Exceptions involve bad environ
variable and internal initialization code. These both set errno to
EFAULT.

Several patches to base utilities to handle the POSIX changes from
Andrey Chernov's previous commit. A few I re-wrote to use setenv()
instead of putenv().

New regression module for tools/regression/environ to test these
functions. It also can be used to test the performance.

Bump __FreeBSD_version to 700050 due to API change.

PR: kern/99826
Approved by: wes
Approved by: re (kensmith)


# ba174a5e 01-May-2007 Andrey A. Chernov <ache@FreeBSD.org>

Back out all POSIXified *env() changes.

Not because I admit they are technically wrong and not because of bug
reports (I receive nothing). But because I surprisingly meets so
strong opposition and resistance so lost any desire to continue that.

Anyone who interested in POSIX can dig out what changes and how
through cvs diffs.


# 97e49dd4 29-Apr-2007 Andrey A. Chernov <ache@FreeBSD.org>

Eliminate error with -W* strict flags and make putenv() calls conforming to
standard and portable in the same way as f.e. gcc internal portable code does.


# fadc7151 06-May-2006 Maxim Konovalov <maxim@FreeBSD.org>

o Implement "-n" flag: ignore files and directories with user "nodump"
flag set. Useful for calculation dump -h dump size.

PR: bin/96864
Submitted by: Dmitry Kazarov
Obtained from: NetBSD (man page)
MFC after: 1 month


# 6c97c3d1 09-Apr-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Remove unused variables.


# dc347bc4 06-Jan-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>

Use 64bit 'fts_bignum' field instead of 32bit (on 32bit archs) field
'fts_number' to remember number of blocks.
This makes du(1) 64bit-clean.

This work is part of the BigDisk project:

http://www.FreeBSD.org/projects/bigdisk/

Discussed on: arch@
MFC after: 5 days


# 14cc87e4 28-Jul-2004 Stefan Farfeleder <stefanf@FreeBSD.org>

Use the length modifier 'll' instead of 'q' to print long longs.


# e781c653 15-Jul-2004 Tim J. Robbins <tjr@FreeBSD.org>

Respect locale settings from the environment.


# b933ee54 02-Jun-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Give du(1) a -m option to report in megabytes.

Submitted by: Vasily Korytov <deskpot@msk.yell.ru>
PR: 66976


# 7d3940bb 24-May-2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>

Use humanize_number(3) to format sizes into a human readable form.


# aef39ef7 02-May-2004 Tim Kientzle <kientzle@FreeBSD.org>

More style fixes, per bde.


# 2622aab4 01-May-2004 Tim Kientzle <kientzle@FreeBSD.org>

Style fixes, most suggested by bde.


# 231a9731 30-Apr-2004 Tim Kientzle <kientzle@FreeBSD.org>

Speed up hardlink detection by using a self-sizing hash
table rather than the old linear list search.

On my "hardlink detection torture test", this reduced
user time from 4700 seconds down to 4.2 seconds
and wallclock time from 1:24:48 down to 1:08.
(Yes, that's over one THOUSAND times reduction in user time. ;-)
In the worst case, the new code doubles peak memory usage,
though it could actually reduce memory usage in many cases.

MFC after: 1 week
PR: misc/42167, bin/51151


# d84f9f6c 30-Mar-2003 David E. O'Brien <obrien@FreeBSD.org>

-{h,k} are mutually exclisive. So only pay attention to the last of the
two when both are given.


# ed857b57 30-Dec-2002 Mike Barcroft <mike@FreeBSD.org>

Back out rev 1.27; getbsize(3)'s original interface has been restored.

Approved by: markm


# 3c284de5 23-Oct-2002 Mark Murray <markm@FreeBSD.org>

Change the type of an unused variable to appease a warning.


# c10b37bf 28-Jul-2002 David Malone <dwmalone@FreeBSD.org>

ANSIify function definitions to avoid a warning.


# e026a48c 29-Jun-2002 David E. O'Brien <obrien@FreeBSD.org>

Consistently use FBSDID


# f1bb2cd2 21-Mar-2002 Warner Losh <imp@FreeBSD.org>

remove __P


# cf467a82 08-Feb-2002 Peter Wemm <peter@FreeBSD.org>

GRR. This was not WARNS=2 clean. You cannot printf a 'long' with
'%qd'.

usr.bin/du/du.c:288: warning: long long int format, long int arg (arg 2)

Pointy hat to: markm


# ef0ea716 02-Dec-2001 Mark Murray <markm@FreeBSD.org>

WARNS=2 fixup


# c146250e 04-Sep-2001 Robert Drehmel <robert@FreeBSD.org>

Use the correct blocksize when invoked with both -h and -k
options.

PR: 30275
Reviewed by: jake


# 4bb69e35 13-Jun-2001 Peter Pentchev <roam@FreeBSD.org>

Add '-I mask' cmdline flag to ignore/skip files and subdirectories
matching a specified shell-glob mask.

Reviewed by: no serious objections on -arch and -audit over
the last few months
MFC after: 1 month


# 884bd44c 26-Mar-2000 Philippe Charnier <charnier@FreeBSD.org>

Use warnx(), -Wall cleaning and remove unused #include
Better use of .Nm and .Ar


# b4448bd5 23-Mar-2000 Michael Haro <mharo@FreeBSD.org>

fix bug with du -hd

Submitted by: dcs


# 54aa1771 25-Jan-2000 Michael Haro <mharo@FreeBSD.org>

Add human-readable output flag, -h

Reviewed by: obrien


# fa146c53 06-Dec-1998 Archie Cobbs <archie@FreeBSD.org>

Tweaks to allow compiling -Wall (mostly adding "const" to char rcsid[]).


# dd246130 05-Nov-1998 Robert Nordier <rnordier@FreeBSD.org>

Add missing '\n'; remove redundant 'h' case in getopt switch.


# 57037d27 05-Nov-1998 Robert Nordier <rnordier@FreeBSD.org>

Add -c option to usage string.

PR: 8568
Submitted by: Ryan Younce <ryany@pobox.com>


# e06cf7db 11-Sep-1998 Dag-Erling Smørgrav <des@FreeBSD.org>

Print correct total for -c option (previously, the total for the last
directory scanned was printed instead of the real total)

PR: bin/7896
Submitted by: Zach Heilig <zach@gaffaneys.com>


# 1f89173a 29-Jul-1998 Dag-Erling Smørgrav <des@FreeBSD.org>

Don't try to dereference a pointer to freed memory.

PR: bin/7393


# 1aa8a0a9 29-Dec-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

* add a -c option which displays the grand total of all files
counted.

* re-word parts of the man page which I felt were badly worded
or ambiguous.

* change the behaviour of argument processing so that when more
than one of the -P, -H and -L options are specified it will
print an error message, rather than choosing the last option
specified, this behaviour is more logical and consistent with
other utilities.

* change the behaviour of argument processing so that negative
arguments to the -d option are not allowed.

PR: 5388
Submitted by: Niall Smart <rotel@indigo.ie>


# 5d712866 29-Aug-1997 Wolfram Schneider <wosch@FreeBSD.org>

du(1) always exit with value zero.

$ du /foobar
du: /foobar: No such file or directory
$ echo $?
0


# 1aa67f69 30-Jun-1997 Philippe Charnier <charnier@FreeBSD.org>

Document -k flag.


# 1c8af878 28-Mar-1997 Warner Losh <imp@FreeBSD.org>

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# df3f5d9d 11-Mar-1997 Peter Wemm <peter@FreeBSD.org>

Merge from Lite2


# 0da30e9a 11-Mar-1997 Peter Wemm <peter@FreeBSD.org>

Import some parts of CSRG 4.4BSD-Lite2 usr.bin sources to fix tree build.


# 0282769e 23-Oct-1996 Marc G. Fournier <scrappy@FreeBSD.org>

Add a 'depth (-d#)' flag to du

patched (context diff), compiled (w/ -Wall) and tested

Submitted by: John-Mark Gurney <jmg@nike.efn.org>


# 7799f52a 30-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.


# 2150dea8 12-Aug-1994 David Greenman <dg@FreeBSD.org>

The last commit was bogus...the putenv doesn't affect the parent process,
so the BLOCKSIZE doesn't need to be preserved.


# ebf93438 12-Aug-1994 David Greenman <dg@FreeBSD.org>

Implemented the -k flag more properly...don't destroy the user's setting
of the BLOCKSIZE environment variable.


# abb5479a 10-Aug-1994 Garrett Wollman <wollman@FreeBSD.org>

Gimme my `-k' option back!


# 9b50d902 26-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite Usr.bin Sources