Commit graph

126 commits

Author SHA1 Message Date
Warner Losh d1588599c0 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...
2009-04-30 01:24:53 +00:00
Max Laier 246b6a6d70 Restore (intmax_t) casts I lost during the last change & unbreak the build. 2008-11-06 23:55:28 +00:00
Max Laier fd543f2759 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@
2008-11-06 16:30:38 +00:00
Max Laier 0551897af2 Declare functions and variables static and save a few byte. This is a
style(9)-change, too.  Separate commit as it changes the object.
2008-11-04 19:23:48 +00:00
Max Laier 40850176c9 style(9): mostly avoiding line wrap by not indenting cases. No obj change. 2008-11-04 19:17:32 +00:00
Giorgos Keramidas fe5628d3c1 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
2008-02-25 19:06:43 +00:00
Kevin Lo d4c16fe37d setenv(3) sets errno on failure, use warn() instead
Pointed out by: ru
2007-11-08 01:24:31 +00:00
Kevin Lo ee8f97394e Check return value for setenv() 2007-11-06 10:35:50 +00:00
Sean Farley 2966d28c32 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)
2007-07-04 00:00:41 +00:00
Andrey A. Chernov ba174a5e38 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.
2007-05-01 16:02:44 +00:00
Andrey A. Chernov 97e49dd4b5 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.
2007-04-30 05:14:29 +00:00
Ruslan Ermilov cb29445a92 Markup fixes. 2006-09-29 15:20:48 +00:00
Maxim Konovalov fadc7151b7 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
2006-05-06 22:04:59 +00:00
Ruslan Ermilov f682f10c76 Sync program's usage() with manpage's SYNOPSIS. 2005-05-21 09:55:10 +00:00
Stefan Farfeleder 6c97c3d1d3 Remove unused variables. 2005-04-09 14:31:41 +00:00
Pawel Jakub Dawidek dc347bc474 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
2005-01-07 00:12:24 +00:00
Giorgos Keramidas d2c50f8bab Add a missing full-stop to match the rest of the items in a list. 2004-10-24 00:26:35 +00:00
Stefan Farfeleder 14cc87e479 Use the length modifier 'll' instead of 'q' to print long longs. 2004-07-28 16:03:13 +00:00
Tim J. Robbins e781c653dd Respect locale settings from the environment. 2004-07-15 08:54:41 +00:00
Ruslan Ermilov 6a3e8b0adc Mechanically kill hard sentence breaks. 2004-07-02 22:22:35 +00:00
Poul-Henning Kamp cd4dc87a34 typos.
Pointed out by:	ru
2004-06-02 07:31:11 +00:00
Poul-Henning Kamp b933ee5464 Give du(1) a -m option to report in megabytes.
Submitted by:	Vasily Korytov <deskpot@msk.yell.ru>
PR:	66976
2004-06-02 07:09:34 +00:00
Pawel Jakub Dawidek 7d3940bb67 Use humanize_number(3) to format sizes into a human readable form. 2004-05-24 22:22:29 +00:00
Pawel Jakub Dawidek 8cab54e9a8 Mark du(1) as WARNS6 clean.
Tested on:	alpha, amd64, i386, ia64, sparc64
2004-05-24 21:31:30 +00:00
Tim Kientzle aef39ef75f More style fixes, per bde. 2004-05-02 17:54:57 +00:00
Tim Kientzle 2622aab4ae Style fixes, most suggested by bde. 2004-05-01 21:47:31 +00:00
Tim Kientzle 231a973125 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
2004-04-30 18:17:51 +00:00
David E. O'Brien d84f9f6c14 -{h,k} are mutually exclisive. So only pay attention to the last of the
two when both are given.
2003-03-30 21:25:16 +00:00
Mike Barcroft ed857b5741 Back out rev 1.27; getbsize(3)'s original interface has been restored.
Approved by:	markm
2002-12-30 18:13:07 +00:00
Ruslan Ermilov 8d5d039f80 Uniformly refer to a file system as "file system".
Approved by:	re
2002-12-12 17:26:04 +00:00
Mark Murray 3c284de5a5 Change the type of an unused variable to appease a warning. 2002-10-23 19:10:15 +00:00
David Malone c10b37bf7a ANSIify function definitions to avoid a warning. 2002-07-28 15:50:38 +00:00
David E. O'Brien e026a48c34 Consistently use FBSDID 2002-06-30 05:25:07 +00:00
Tom Rhodes 46c2a2cfa4 More consistancy. file system > filesystem 2002-05-16 02:19:14 +00:00
Philippe Charnier 3898680cf7 Use `The .Nm utility' 2002-04-19 23:44:58 +00:00
Warner Losh f1bb2cd2aa remove __P 2002-03-22 01:22:50 +00:00
Mark Murray 91bd71d206 Remove leaf node WARNS?=2 (that mainly I added). This should
help the GCC3 transition and CURRENT in general.
2002-02-08 22:31:43 +00:00
Peter Wemm cf467a82df 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
2002-02-08 07:49:13 +00:00
Mark Murray ef0ea716d2 WARNS=2 fixup 2001-12-02 13:48:40 +00:00
Robert Drehmel c146250ee2 Use the correct blocksize when invoked with both -h and -k
options.

PR:		30275
Reviewed by:	jake
2001-09-04 09:43:31 +00:00
Ruslan Ermilov 94ba280c59 mdoc(7) police: join split punctuation to macro calls. 2001-08-10 17:35:21 +00:00
Dima Dorfman f247324df7 Remove whitespace at EOL. 2001-07-15 08:06:20 +00:00
Peter Pentchev 4bb69e3542 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
2001-06-13 06:38:58 +00:00
Ruslan Ermilov 95a09b0557 Make it clear that -P is the default.
PR:		docs/27629
2001-05-25 07:32:58 +00:00
Ruslan Ermilov 8fe908ef0c mdoc(7) police: use the new features of the Nm macro. 2000-11-20 19:21:22 +00:00
Ruslan Ermilov cb22e4fad5 Backed out part of the revision 1.10.
BLOCKSIZE could specify arbitrary block sizes, not exactly 1K blocks.
2000-10-16 10:00:50 +00:00
Bruce Evans 1f82591eba Fixed LDADD. Using ${LIBM} instead of -lm gave the wrong libm in most
cases and broke the world in some cases.

Fixed style bugs for DPADD and LDADD (don't use += for variables defined
only once).
2000-03-27 15:02:59 +00:00
Philippe Charnier 884bd44c59 Use warnx(), -Wall cleaning and remove unused #include
Better use of .Nm and .Ar
2000-03-26 14:21:57 +00:00
Michael Haro b4448bd5d2 fix bug with du -hd
Submitted by: dcs
2000-03-24 06:25:32 +00:00
Sheldon Hearn 4e86fcacf6 Remove more single-space hard sentence breaks. 2000-03-02 14:54:02 +00:00
Sheldon Hearn 87faa07bec Remove single-space hard sentence breaks. These degrade the quality
of the typeset output, tend to make diffs harder to read and provide
bad examples for new-comers to mdoc.
2000-03-01 12:20:22 +00:00
Michael Haro d3e00c127b cleanup using suggestions from bde 2000-01-27 20:55:09 +00:00
Michael Haro 54aa177193 Add human-readable output flag, -h
Reviewed by: obrien
2000-01-25 17:46:59 +00:00
Peter Wemm c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Archie Cobbs fa146c5335 Tweaks to allow compiling -Wall (mostly adding "const" to char rcsid[]). 1998-12-06 22:58:23 +00:00
Robert Nordier dd2461309f Add missing '\n'; remove redundant 'h' case in getopt switch. 1998-11-05 07:24:21 +00:00
Robert Nordier 57037d27d5 Add -c option to usage string.
PR:           8568
Submitted by: Ryan Younce <ryany@pobox.com>
1998-11-05 07:18:41 +00:00
Dag-Erling Smørgrav e06cf7dbca 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>
1998-09-11 15:53:08 +00:00
Dag-Erling Smørgrav 1f89173a8c Don't try to dereference a pointer to freed memory.
PR:		bin/7393
1998-07-29 17:50:06 +00:00
Poul-Henning Kamp 84717b42e8 .Sh ENVIRONMENT VARIABLES -> .Sh ENVIRONMENT
PR:		6599
Reviewed by:	phk
Submitted by:	Josh Gilliam <josh@quick.net>
1998-05-13 07:57:49 +00:00
Jordan K. Hubbard 1aa8a0a95b * 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>
1997-12-29 20:56:21 +00:00
Wolfram Schneider 5d7128668c du(1) always exit with value zero.
$ du /foobar
du: /foobar: No such file or directory
$ echo $?
0
1997-08-29 11:40:00 +00:00
Philippe Charnier 1aa67f6900 Document -k flag. 1997-06-30 06:50:07 +00:00
Warner Losh 1c8af87873 compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
1997-03-29 04:34:07 +00:00
Peter Wemm df3f5d9dd5 Merge from Lite2 1997-03-11 13:43:33 +00:00
Peter Wemm c115df18cd Revert $FreeBSD$ to $Id$ 1997-02-22 19:58:13 +00:00
Jordan K. Hubbard 1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00
Marc G. Fournier 0282769e2d Add a 'depth (-d#)' flag to du
patched (context diff), compiled (w/ -Wall) and tested

Submitted by:	John-Mark Gurney <jmg@nike.efn.org>
1996-10-23 06:53:57 +00:00
Wolfram Schneider b8923d4cc0 [HISTORY] command appeared in Version 1 AT&T UNIX
Obtained from: A Quarter Century of UNIX, Peter H. Salus, page 41
1996-08-29 18:06:19 +00:00
Mike Pritchard c4b4d74391 Restore the reference to quot(8). 1995-08-13 09:39:23 +00:00
Andreas Schulz 1f4b92cffb Submitted by: careilly@tcd.ie Colman Reilly
replace the reference of quot(8) with a reference to quota(1).
Colman Reilly noticed the missing quot, GNATS bin/671.
1995-08-12 13:52:26 +00:00
Rodney W. Grimes 7799f52a32 Remove trailing whitespace. 1995-05-30 06:41:30 +00:00
David Greenman 2150dea8de The last commit was bogus...the putenv doesn't affect the parent process,
so the BLOCKSIZE doesn't need to be preserved.
1994-08-12 10:19:05 +00:00
David Greenman ebf93438bf Implemented the -k flag more properly...don't destroy the user's setting
of the BLOCKSIZE environment variable.
1994-08-12 07:26:52 +00:00
Garrett Wollman abb5479a19 Gimme my `-k' option back! 1994-08-10 19:25:34 +00:00
Rodney W. Grimes 9b50d90275 BSD 4.4 Lite Usr.bin Sources 1994-05-27 12:33:43 +00:00