Add a "-n" flag that will ignore files/directories with the "nodump"
flag set. Useful when used in conjunction with "dump -h" to size dumps.
This commit is contained in:
parent
e2c312b8ed
commit
ef7c5f2d47
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: du.1,v 1.17 2003/08/07 11:13:34 agc Exp $
|
||||
.\" $NetBSD: du.1,v 1.18 2004/05/17 01:56:19 simonb Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -29,7 +29,7 @@
|
||||
.\"
|
||||
.\" @(#)du.1 8.2 (Berkeley) 4/1/94
|
||||
.\"
|
||||
.Dd April 18, 2003
|
||||
.Dd May 17, 2004
|
||||
.Dt DU 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -39,7 +39,7 @@
|
||||
.Nm
|
||||
.Op Fl H | Fl L | Fl P
|
||||
.Op Fl a | Fl s
|
||||
.Op Fl cghkmrx
|
||||
.Op Fl cghkmnrx
|
||||
.Op Ar file ...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
@ -91,6 +91,8 @@ If the
|
||||
.Fl m
|
||||
flag is specified, the number displayed is the number of megabyte
|
||||
(1024*1024 bytes) blocks.
|
||||
.It Fl n
|
||||
Ignore files and directories with user "nodump" flag (UF_NODUMP) set.
|
||||
.It Fl r
|
||||
Generate warning messages about directories that cannot be read.
|
||||
This is the default behaviour.
|
||||
@ -141,6 +143,7 @@ size block.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr df 1 ,
|
||||
.Xr chflags 2 ,
|
||||
.Xr fts 3 ,
|
||||
.Xr getbsize 3 ,
|
||||
.Xr symlink 7 ,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: du.c,v 1.23 2003/08/07 11:13:34 agc Exp $ */
|
||||
/* $NetBSD: du.c,v 1.24 2004/05/17 01:56:19 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993, 1994
|
||||
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993, 1994\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)du.c 8.5 (Berkeley) 5/4/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: du.c,v 1.23 2003/08/07 11:13:34 agc Exp $");
|
||||
__RCSID("$NetBSD: du.c,v 1.24 2004/05/17 01:56:19 simonb Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -76,13 +76,13 @@ main(argc, argv)
|
||||
FTSENT *p;
|
||||
int64_t totalblocks;
|
||||
int ftsoptions, listdirs, listfiles;
|
||||
int Hflag, Lflag, Pflag, aflag, ch, cflag, gkmflag, rval, sflag;
|
||||
int Hflag, Lflag, Pflag, aflag, ch, cflag, gkmflag, nflag, rval, sflag;
|
||||
char *noargv[2];
|
||||
|
||||
Hflag = Lflag = Pflag = aflag = cflag = gkmflag = sflag = 0;
|
||||
Hflag = Lflag = Pflag = aflag = cflag = gkmflag = nflag = sflag = 0;
|
||||
totalblocks = 0;
|
||||
ftsoptions = FTS_PHYSICAL;
|
||||
while ((ch = getopt(argc, argv, "HLPacghkmrsx")) != -1)
|
||||
while ((ch = getopt(argc, argv, "HLPacghkmnrsx")) != -1)
|
||||
switch (ch) {
|
||||
case 'H':
|
||||
Hflag = 1;
|
||||
@ -117,6 +117,9 @@ main(argc, argv)
|
||||
blocksize = 1024 * 1024;
|
||||
gkmflag = 1;
|
||||
break;
|
||||
case 'n':
|
||||
nflag = 1;
|
||||
break;
|
||||
case 'r':
|
||||
break;
|
||||
case 's':
|
||||
@ -175,7 +178,20 @@ main(argc, argv)
|
||||
if ((fts = fts_open(argv, ftsoptions, NULL)) == NULL)
|
||||
err(1, "fts_open `%s'", *argv);
|
||||
|
||||
for (rval = 0; (p = fts_read(fts)) != NULL;)
|
||||
for (rval = 0; (p = fts_read(fts)) != NULL;) {
|
||||
if (nflag) {
|
||||
switch (p->fts_info) {
|
||||
case FTS_NS:
|
||||
case FTS_SLNONE:
|
||||
/* nothing */
|
||||
break;
|
||||
default:
|
||||
if (p->fts_statp->st_flags & UF_NODUMP) {
|
||||
fts_set(fts, p, FTS_SKIP);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (p->fts_info) {
|
||||
case FTS_D: /* Ignore. */
|
||||
break;
|
||||
@ -213,6 +229,7 @@ main(argc, argv)
|
||||
if (cflag)
|
||||
totalblocks += p->fts_statp->st_blocks;
|
||||
}
|
||||
}
|
||||
if (errno)
|
||||
err(1, "fts_read");
|
||||
if (cflag)
|
||||
|
Loading…
Reference in New Issue
Block a user