diff options
author | maxim <maxim@FreeBSD.org> | 2006-05-06 22:04:59 +0000 |
---|---|---|
committer | maxim <maxim@FreeBSD.org> | 2006-05-06 22:04:59 +0000 |
commit | aeb7e925771d9b3f32a63fbabf3ffdaea8e905a9 (patch) | |
tree | df4bbdb30c27f70189a40e46f24734fa8b196316 /usr.bin/du | |
parent | d79b4cb4753523aa7f2394b74deffe49e0f0eff4 (diff) | |
download | FreeBSD-src-aeb7e925771d9b3f32a63fbabf3ffdaea8e905a9.zip FreeBSD-src-aeb7e925771d9b3f32a63fbabf3ffdaea8e905a9.tar.gz |
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
Diffstat (limited to 'usr.bin/du')
-rw-r--r-- | usr.bin/du/du.1 | 6 | ||||
-rw-r--r-- | usr.bin/du/du.c | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/usr.bin/du/du.1 b/usr.bin/du/du.1 index 81e7d49..cb4d458 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 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 diff --git a/usr.bin/du/du.c b/usr.bin/du/du.c index 8af4c46..00c1f5e 100644 --- a/usr.bin/du/du.c +++ b/usr.bin/du/du.c @@ -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; |