summaryrefslogtreecommitdiff
path: root/usr.bin/du
diff options
context:
space:
mode:
authorGiorgos Keramidas <keramida@FreeBSD.org>2008-02-25 19:06:43 +0000
committerGiorgos Keramidas <keramida@FreeBSD.org>2008-02-25 19:06:43 +0000
commitfe5628d3c11e28dab82e662c2ff4142d2b672707 (patch)
treebe80ec6ff9c0843d2cb2004c39dfbfd2c3d204c0 /usr.bin/du
parent5b62538f7f88b37a7f7b7514f511ea55f9cfcde7 (diff)
downloadsrc-test2-fe5628d3c11e28dab82e662c2ff4142d2b672707.tar.gz
src-test2-fe5628d3c11e28dab82e662c2ff4142d2b672707.zip
Notes
Diffstat (limited to 'usr.bin/du')
-rw-r--r--usr.bin/du/du.117
-rw-r--r--usr.bin/du/du.c17
2 files changed, 23 insertions, 11 deletions
diff --git a/usr.bin/du/du.1 b/usr.bin/du/du.1
index 8594ba7269d3..60264cdb8ef2 100644
--- a/usr.bin/du/du.1
+++ b/usr.bin/du/du.1
@@ -32,7 +32,7 @@
.\" @(#)du.1 8.2 (Berkeley) 4/1/94
.\" $FreeBSD$
.\"
-.Dd May 6, 2006
+.Dd February 25, 2008
.Dt DU 1
.Os
.Sh NAME
@@ -43,6 +43,7 @@
.Op Fl H | L | P
.Op Fl a | s | d Ar depth
.Op Fl c
+.Op Fl l
.Op Fl h | k | m
.Op Fl n
.Op Fl x
@@ -94,6 +95,15 @@ directories deep.
Display a grand total.
.It Fl k
Display block counts in 1024-byte (1-Kbyte) blocks.
+.It Fl l
+If a file has multiple hard links, count its size many times.
+The default behavior of
+.Nm
+is to count files with multiple hard links only once.
+When the
+.Fl l
+option is specified, the hard link checks are disabled, and these files
+are counted (and displayed) as many times as they are found.
.It Fl m
Display block counts in 1048576-byte (1-Mbyte) blocks.
.It Fl n
@@ -120,11 +130,6 @@ or
.Fl L
options are specified, storage used by any symbolic links which are
followed is not counted or displayed.
-.Pp
-Files having multiple hard links are counted (and displayed) a single
-time per
-.Nm
-execution.
.Sh ENVIRONMENT
.Bl -tag -width BLOCKSIZE
.It Ev BLOCKSIZE
diff --git a/usr.bin/du/du.c b/usr.bin/du/du.c
index ba369f953bc3..895929301e59 100644
--- a/usr.bin/du/du.c
+++ b/usr.bin/du/du.c
@@ -90,20 +90,22 @@ main(int argc, char *argv[])
int ftsoptions;
int listall;
int depth;
- int Hflag, Lflag, Pflag, aflag, sflag, dflag, cflag, hflag, ch, notused, rval;
+ int Hflag, Lflag, Pflag, aflag, sflag, dflag, cflag;
+ int hflag, lflag, ch, notused, rval;
char **save;
static char dot[] = ".";
setlocale(LC_ALL, "");
- Hflag = Lflag = Pflag = aflag = sflag = dflag = cflag = hflag = 0;
+ Hflag = Lflag = Pflag = aflag = sflag = dflag = cflag = hflag =
+ lflag = 0;
save = argv;
ftsoptions = 0;
depth = INT_MAX;
SLIST_INIT(&ignores);
- while ((ch = getopt(argc, argv, "HI:LPasd:chkmnrx")) != -1)
+ while ((ch = getopt(argc, argv, "HI:LPasd:chklmnrx")) != -1)
switch (ch) {
case 'H':
Hflag = 1;
@@ -150,6 +152,9 @@ main(int argc, char *argv[])
if (setenv("BLOCKSIZE", "1024", 1) == -1)
warn("setenv: cannot set BLOCKSIZE=1024");
break;
+ case 'l':
+ lflag = 1;
+ break;
case 'm':
hflag = 0;
if (setenv("BLOCKSIZE", "1048576", 1) == -1)
@@ -261,7 +266,8 @@ main(int argc, char *argv[])
if (ignorep(p))
break;
- if (p->fts_statp->st_nlink > 1 && linkchk(p))
+ if (lflag == 0 &&
+ p->fts_statp->st_nlink > 1 && linkchk(p))
break;
if (listall || p->fts_level == 0) {
@@ -447,7 +453,8 @@ static void
usage(void)
{
(void)fprintf(stderr,
- "usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k | -m] [-n] [-x] [-I mask] [file ...]\n");
+ "usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] "
+ "[-l] [-h | -k | -m] [-n] [-x] [-I mask] [file ...]\n");
exit(EX_USAGE);
}