Commit Graph

65 Commits

Author SHA1 Message Date
bdrewery
7b51af1e74 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
2020-12-08 23:38:26 +00:00
pfg
872b698bd4 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.
2017-11-20 19:49:47 +00:00
kevans
c8e2bceb13 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
2017-08-09 01:19:19 +00:00
ngie
0e2dcbb326 du(1): trivial whitespace cleanup
MFC after:	1 month
2017-06-12 02:42:39 +00:00
imp
7e6cabd06e 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
2017-02-28 23:42:47 +00:00
bdrewery
30f99dbeef Fix improper use of "its".
Sponsored by:	Dell EMC Isilon
2016-11-08 23:59:41 +00:00
pfg
41e0db3469 du(1): replace malloc + memset with calloc. 2015-02-17 21:12:45 +00:00
pluknet
f52de12ecb Document -g option in the usage string. 2012-07-26 20:41:36 +00:00
des
385988dde5 Add -g (gigabyte) flag to complement -k (kilobyte) and -m (megabyte).
MFC after:	1 week
2012-07-18 19:28:22 +00:00
jilles
8698d2b7e1 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
2011-12-17 23:18:14 +00:00
gjb
d9807d7f63 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
2011-12-09 02:30:56 +00:00
ed
c2950f3c9c 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)
2011-11-08 11:36:46 +00:00
ed
c9f8997dfe Add missing static keywords to du(1) 2011-11-06 08:15:17 +00:00
joel
29af67e52c 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
2010-12-11 08:32:16 +00:00
brian
5b3161617d 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
2010-06-20 08:27:03 +00:00
imp
4f6e2a4607 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
mlaier
df30d890f6 Restore (intmax_t) casts I lost during the last change & unbreak the build. 2008-11-06 23:55:28 +00:00
mlaier
1d778ddbeb 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
mlaier
ce3123c324 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
mlaier
da7287b624 style(9): mostly avoiding line wrap by not indenting cases. No obj change. 2008-11-04 19:17:32 +00:00
keramida
67638f8d86 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
kevlo
cb1577dadc setenv(3) sets errno on failure, use warn() instead
Pointed out by: ru
2007-11-08 01:24:31 +00:00
kevlo
80e691eb7f Check return value for setenv() 2007-11-06 10:35:50 +00:00
scf
196b6346ba 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
ache
6ccaf050cc 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
ache
a1cdcb2c5b 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
maxim
aeb7e92577 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
stefanf
60b910d7c2 Remove unused variables. 2005-04-09 14:31:41 +00:00
pjd
4e634c9b50 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
stefanf
7cdc27d942 Use the length modifier 'll' instead of 'q' to print long longs. 2004-07-28 16:03:13 +00:00
tjr
c63c3a56b8 Respect locale settings from the environment. 2004-07-15 08:54:41 +00:00
phk
d88857d680 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
pjd
72e7aa908c Use humanize_number(3) to format sizes into a human readable form. 2004-05-24 22:22:29 +00:00
kientzle
83908c5c8b More style fixes, per bde. 2004-05-02 17:54:57 +00:00
kientzle
568c9e1d05 Style fixes, most suggested by bde. 2004-05-01 21:47:31 +00:00
kientzle
5aa078d988 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
obrien
f1f15d7a3f -{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
329cb09712 Back out rev 1.27; getbsize(3)'s original interface has been restored.
Approved by:	markm
2002-12-30 18:13:07 +00:00
markm
fba4a6dd09 Change the type of an unused variable to appease a warning. 2002-10-23 19:10:15 +00:00
dwmalone
391a69a94d ANSIify function definitions to avoid a warning. 2002-07-28 15:50:38 +00:00
obrien
bc61fc95d8 Consistently use FBSDID 2002-06-30 05:25:07 +00:00
imp
74d826c7a6 remove __P 2002-03-22 01:22:50 +00:00
peter
a0f58ee853 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
markm
11e67a9342 WARNS=2 fixup 2001-12-02 13:48:40 +00:00
robert
67c0b42424 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
roam
eaaabb7358 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
charnier
f717c07c8a Use warnx(), -Wall cleaning and remove unused #include
Better use of .Nm and .Ar
2000-03-26 14:21:57 +00:00
mharo
fea136fdfe fix bug with du -hd
Submitted by: dcs
2000-03-24 06:25:32 +00:00
mharo
3d620c4532 Add human-readable output flag, -h
Reviewed by: obrien
2000-01-25 17:46:59 +00:00
archie
167c036e91 Tweaks to allow compiling -Wall (mostly adding "const" to char rcsid[]). 1998-12-06 22:58:23 +00:00