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
This commit is contained in:
parent
d79b4cb475
commit
aeb7e92577
@ -32,7 +32,7 @@
|
||||
.\" @(#)du.1 8.2 (Berkeley) 4/1/94
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd June 2, 2004
|
||||
.Dd May 6, 2006
|
||||
.Dt DU 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -44,6 +44,7 @@
|
||||
.Op Fl a | s | d Ar depth
|
||||
.Op Fl c
|
||||
.Op Fl h | k | m
|
||||
.Op Fl n
|
||||
.Op Fl x
|
||||
.Op Fl I Ar mask
|
||||
.Op Ar
|
||||
@ -95,6 +96,8 @@ Display a grand total.
|
||||
Display block counts in 1024-byte (1-Kbyte) blocks.
|
||||
.It Fl m
|
||||
Display block counts in 1048576-byte (1-Mbyte) blocks.
|
||||
.It Fl n
|
||||
Ignore files and directories with user "nodump" flag (UF_NODUMP) set.
|
||||
.It Fl x
|
||||
File system mount points are not traversed.
|
||||
.El
|
||||
@ -135,6 +138,7 @@ option is not specified, the block counts will be displayed in 512-byte blocks.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr df 1 ,
|
||||
.Xr chflags 2 ,
|
||||
.Xr fts 3 ,
|
||||
.Xr symlink 7 ,
|
||||
.Xr quot 8
|
||||
|
@ -78,6 +78,8 @@ void ignoreadd(const char *);
|
||||
void ignoreclean(void);
|
||||
int ignorep(FTSENT *);
|
||||
|
||||
int nodumpflag = 0;
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
@ -101,7 +103,7 @@ main(int argc, char *argv[])
|
||||
depth = INT_MAX;
|
||||
SLIST_INIT(&ignores);
|
||||
|
||||
while ((ch = getopt(argc, argv, "HI:LPasd:chkmrx")) != -1)
|
||||
while ((ch = getopt(argc, argv, "HI:LPasd:chkmnrx")) != -1)
|
||||
switch (ch) {
|
||||
case 'H':
|
||||
Hflag = 1;
|
||||
@ -149,6 +151,9 @@ main(int argc, char *argv[])
|
||||
hflag = 0;
|
||||
putenv("BLOCKSIZE=1048576");
|
||||
break;
|
||||
case 'n':
|
||||
nodumpflag = 1;
|
||||
break;
|
||||
case 'r': /* Compatibility. */
|
||||
break;
|
||||
case 'x':
|
||||
@ -438,7 +443,7 @@ static void
|
||||
usage(void)
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k | -m] [-x] [-I mask] [file ...]\n");
|
||||
"usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k | -m] [-n] [-x] [-I mask] [file ...]\n");
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
|
||||
@ -474,6 +479,8 @@ ignorep(FTSENT *ent)
|
||||
{
|
||||
struct ignentry *ign;
|
||||
|
||||
if (nodumpflag && (ent->fts_statp->st_flags & UF_NODUMP))
|
||||
return 1;
|
||||
SLIST_FOREACH(ign, &ignores, next)
|
||||
if (fnmatch(ign->mask, ent->fts_name, 0) != FNM_NOMATCH)
|
||||
return 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user