From nobody@FreeBSD.org  Sat May  6 14:04:56 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 7386216A400
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  6 May 2006 14:04:56 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 7BBDC43D62
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  6 May 2006 14:04:51 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k46E4nJ0027039
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 6 May 2006 14:04:49 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k46E4nVa027013;
	Sat, 6 May 2006 14:04:49 GMT
	(envelope-from nobody)
Message-Id: <200605061404.k46E4nVa027013@www.freebsd.org>
Date: Sat, 6 May 2006 14:04:49 GMT
From: Dmitry Kazarov <kazarov@mcm.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: nodump parameter for du
X-Send-Pr-Version: www-2.3

>Number:         96864
>Category:       bin
>Synopsis:       nodump parameter for du
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    maxim
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat May 06 14:10:13 GMT 2006
>Closed-Date:    Sun Jun 04 10:25:36 GMT 2006
>Last-Modified:  Sun Jun 04 10:25:36 GMT 2006
>Originator:     Dmitry Kazarov
>Release:        FreeBSD 6.1-RC
>Organization:
Telecom Service T
>Environment:
FreeBSD CE.multicom.ru 6.1-RC FreeBSD 6.1-RC #0: Fri May  5 12:18:36 MSD 2006     root@CE.multicom.ru:/var/tmp/obj/usr/src/sys/CE  i386

>Description:
It's very hard to estimate dump size if some files or dirs are marked with NODUMP flag. I've added flag to du to omit such files.
>How-To-Repeat:

>Fix:
--- du.1.orig	Sat May  6 17:56:02 2006
+++ du.1	Sat May  6 17:55:02 2006
@@ -43,6 +43,7 @@
 .Op Fl H | L | P
 .Op Fl a | s | d Ar depth
 .Op Fl c
+.Op Fl n
 .Op Fl h | k | m
 .Op Fl x
 .Op Fl I Ar mask
@@ -91,6 +92,8 @@
 directories deep.
 .It Fl c
 Display a grand total.
+.It Fl n
+Omit files and directories with nodump flag set.
 .It Fl k
 Display block counts in 1024-byte (1-Kbyte) blocks.
 .It Fl m

--- du.c.orig	Sat May  6 17:52:33 2006
+++ du.c	Sat May  6 17:53:10 2006
@@ -71,6 +71,8 @@
 	SLIST_ENTRY(ignentry)	next;
 };
 
+int		nodumpflag = 0;
+
 static int	linkchk(FTSENT *);
 static void	usage(void);
 void		prthumanval(int64_t);
@@ -101,7 +103,7 @@
 	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 @@
 				hflag = 0;
 				putenv("BLOCKSIZE=1048576");
 				break;
+			case 'n':
+				nodumpflag = 1;
+				break;
 			case 'r':		 /* Compatibility. */
 				break;
 			case 'x':
@@ -438,7 +443,7 @@
 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] [-n] [-c] [-h | -k | -m] [-x] [-I mask] [file ...]\n");
 	exit(EX_USAGE);
 }
 
@@ -473,6 +478,9 @@
 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)

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: maxim 
State-Changed-When: Sat May 6 22:05:49 UTC 2006 
State-Changed-Why:  
Committed to HEAD.  I decided to take NetBSD man page variant. 
Thanks for the contribution! 


Responsible-Changed-From-To: freebsd-bugs->maxim 
Responsible-Changed-By: maxim 
Responsible-Changed-When: Sat May 6 22:05:49 UTC 2006 
Responsible-Changed-Why:  
Feedbacks are mine. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=96864 
State-Changed-From-To: patched->closed 
State-Changed-By: maxim 
State-Changed-When: Sun Jun 4 10:25:12 UTC 2006 
State-Changed-Why:  
Merged to RELENG_6. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=96864 
>Unformatted:
